https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112018-01-26T19:07:24ZRuby Issue Tracking SystemRuby master - Feature #14405: Add base option to Pathname.glob alsohttps://redmine.ruby-lang.org/issues/14405?journal_id=698602018-01-26T19:07:24Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>Probably makes sense so people can use either variant by default<br>
depending on their personal preferences.</p>
<p>I personally love "Dir"-related methods; I think Dir[] is probably<br>
the method I use the most in general when I need to find/obtain<br>
files and directory. For me, Pathname was too lengthy. :)</p> Ruby master - Feature #14405: Add base option to Pathname.glob alsohttps://redmine.ruby-lang.org/issues/14405?journal_id=698872018-01-27T05:59:02Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p><code>Pathname</code> has <code>glob</code> instance method.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">p</span> <span class="no">Pathname</span><span class="p">(</span><span class="s1">'lib'</span><span class="p">).</span><span class="nf">glob</span><span class="p">(</span><span class="s1">'i*.rb'</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">=></span> <span class="p">[</span><span class="c1">#<Pathname:lib/ipaddr.rb>, #<Pathname:lib/irb.rb>]</span>
</code></pre>
<p>This looks brief enough.</p> Ruby master - Feature #14405: Add base option to Pathname.glob alsohttps://redmine.ruby-lang.org/issues/14405?journal_id=699572018-01-29T05:54:01Zpocke (Masataka Kuwabara)
<ul></ul><p>nobu (Nobuyoshi Nakada) wrote:</p>
<blockquote>
<p><code>Pathname</code> has <code>glob</code> instance method.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">p</span> <span class="no">Pathname</span><span class="p">(</span><span class="s1">'lib'</span><span class="p">).</span><span class="nf">glob</span><span class="p">(</span><span class="s1">'i*.rb'</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">=></span> <span class="p">[</span><span class="c1">#<Pathname:lib/ipaddr.rb>, #<Pathname:lib/irb.rb>]</span>
</code></pre>
<p>This looks brief enough.</p>
</blockquote>
<p>Definitely. I also noticed it after created this ticket.</p>
<p>However I think <code>Pathname.glob</code> makes sense for two reasons.<br>
Firstly, I think <code>Pathname.glob</code> should have same interface as <code>Dir.glob</code>. For example, if they have the same interface, we can replace <code>Dir.glob</code> with <code>Pathname.glob</code> more easily.</p>
<pre><code># before
Dir.glob('*', base: 'path/to/dir')
# When I'd like to get pathnames:
# If they don't have the same interface, I should rewrite the whole code.
Pathname('path/to/dir').glob('*')
# If they have the same interface, I'll just replace `Dir` with `Pathname` only. I think it is more easily.
Pathname.glob('*', base: 'path/to/dir')
</code></pre>
<p>Secondly, I feel the <code>Pathname('path/to/dir')</code> is a subject in <code>Pathname('path/to/dir').glob('*')</code>, and <code>base: 'path/to/dir'</code> is not a subject in <code>Pathname.glob('*', base: 'path/to/dir')</code>.<br>
I guess a base directory is not a subject of the <code>glob</code> methods in many cases, so I'd like to use the keyword argument style in many cases.<br>
(ここの英語でちゃんと伝えきれているかわからないので、日本語で補足させてください。<br>
<code>Pathname('path/to/dir').glob('*')</code>では、<code>Pathname('path/to/dir')</code>がこのコードの主役のように感じます。一方<code>Pathname.glob('*', base: 'path/to/dir')</code>の方では<code>base: 'path/to/dir'</code>はコードの主役ではないように感じます。<br>
多くのケースにおいて、baseディレクトリと言うのは<code>glob</code>の主役ではない(パターンがこのメソッドの主役)と思うので、その関係をより色濃く反映したkeyword引数のスタイルの方を使いたいです。)</p>
<p>What do you think?</p> Ruby master - Feature #14405: Add base option to Pathname.glob alsohttps://redmine.ruby-lang.org/issues/14405?journal_id=699982018-01-30T05:31:22Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>akr (Akira Tanaka)</i></li></ul> Ruby master - Feature #14405: Add base option to Pathname.glob alsohttps://redmine.ruby-lang.org/issues/14405?journal_id=793912019-07-14T08:43:18Zakr (Akira Tanaka)akr@fsij.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>Applied in changeset <a class="changeset" title="Delegates 3 arguments for Pathname.glob. Thanks for the patch by pocke (Masataka Kuwabara) [Feat..." href="https://redmine.ruby-lang.org/projects/ruby-master/repository/git/revisions/4d9504fe13c6470d9da74540f92a247e8c1d9b99">git|4d9504fe13c6470d9da74540f92a247e8c1d9b99</a>.</p>
<hr>
<p>Delegates 3 arguments for Pathname.glob.</p>
<p>Thanks for the patch by pocke (Masataka Kuwabara) [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Add base option to Pathname.glob also (Closed)" href="https://redmine.ruby-lang.org/issues/14405">#14405</a>].</p>