ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:77501] [Ruby trunk Bug#12814] Pathname#each_child(false) produces unusable file paths
       [not found] <redmine.issue-12814.20161006113854@ruby-lang.org>
@ 2016-10-06 11:38 ` tao
  2016-10-06 12:56 ` [ruby-core:77503] [Ruby trunk Bug#12814][Feedback] " nobu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: tao @ 2016-10-06 11:38 UTC (permalink / raw
  To: ruby-core

Issue #12814 has been reported by Mr. Tao.

----------------------------------------
Bug #12814: Pathname#each_child(false) produces unusable file paths
https://bugs.ruby-lang.org/issues/12814

* Author: Mr. Tao
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I tried to iterate over items in a directory with *each.child* testing each item whether it is a directory or not with *directory?*. This was working just fine until I added **false** as an argument to *each_child*.

~~~ ruby
Pathname.new('.').each_child { |f| p f.realpath } # works as expected
Pathname.new('.').each_child(false) { |f| p f.realpath } # throws an error
~~~

As per Ruby doc `By default, the yielded pathnames will have enough information to access the files.`, however pathnames yielded with `with_directory=false` are completely useless as file paths.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:77503] [Ruby trunk Bug#12814][Feedback] Pathname#each_child(false) produces unusable file paths
       [not found] <redmine.issue-12814.20161006113854@ruby-lang.org>
  2016-10-06 11:38 ` [ruby-core:77501] [Ruby trunk Bug#12814] Pathname#each_child(false) produces unusable file paths tao
@ 2016-10-06 12:56 ` nobu
  2016-10-06 14:10 ` [ruby-core:77504] [Ruby trunk Bug#12814] " tao
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: nobu @ 2016-10-06 12:56 UTC (permalink / raw
  To: ruby-core

Issue #12814 has been updated by Nobuyoshi Nakada.

Description updated
Status changed from Open to Feedback

I can't reproduce it.
What exception raised exactly?

----------------------------------------
Bug #12814: Pathname#each_child(false) produces unusable file paths
https://bugs.ruby-lang.org/issues/12814#change-60767

* Author: Mr. Tao
* Status: Feedback
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I tried to iterate over items in a directory with `each_child` testing each item whether it is a directory or not with `directory?`. This was working just fine until I added **`false`** as an argument to `each_child`.

~~~ ruby
Pathname.new('.').each_child { |f| p f.realpath } # works as expected
Pathname.new('.').each_child(false) { |f| p f.realpath } # throws an error
~~~

As per Ruby doc "By default, the yielded pathnames will have enough information to access the files.", however pathnames yielded with `with_directory=false` are completely useless as file paths.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:77504] [Ruby trunk Bug#12814] Pathname#each_child(false) produces unusable file paths
       [not found] <redmine.issue-12814.20161006113854@ruby-lang.org>
  2016-10-06 11:38 ` [ruby-core:77501] [Ruby trunk Bug#12814] Pathname#each_child(false) produces unusable file paths tao
  2016-10-06 12:56 ` [ruby-core:77503] [Ruby trunk Bug#12814][Feedback] " nobu
@ 2016-10-06 14:10 ` tao
  2016-10-11  1:12 ` [ruby-core:77545] " shyouhei
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: tao @ 2016-10-06 14:10 UTC (permalink / raw
  To: ruby-core

Issue #12814 has been updated by Mr. Tao.


Sorry, I over edited my post. Argument to pathname is some existing folder, even `'..'` produces the error.

~~~ ruby
>> Pathname.new('..').each_child(false) { |f| p f.realpath }
~~~
~~~none
Errno::ENOENT: No such file or directory @ realpath_rec - <some_path_here>
	from (irb):10:in `realpath'
	from (irb):10:in `realpath'
	from (irb):10:in `block in irb_binding'
	from /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/pathname.rb:490:in `each'
	from /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/pathname.rb:490:in `each_child'
	from (irb):10
	from /usr/local/bin/irb:11:in `<main>'
~~~

----------------------------------------
Bug #12814: Pathname#each_child(false) produces unusable file paths
https://bugs.ruby-lang.org/issues/12814#change-60768

* Author: Mr. Tao
* Status: Feedback
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I tried to iterate over items in a directory with `each_child` testing each item whether it is a directory or not with `directory?`. This was working just fine until I added **`false`** as an argument to `each_child`.

~~~ ruby
Pathname.new('.').each_child { |f| p f.realpath } # works as expected
Pathname.new('.').each_child(false) { |f| p f.realpath } # throws an error
~~~

As per Ruby doc "By default, the yielded pathnames will have enough information to access the files.", however pathnames yielded with `with_directory=false` are completely useless as file paths.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:77545] [Ruby trunk Bug#12814] Pathname#each_child(false) produces unusable file paths
       [not found] <redmine.issue-12814.20161006113854@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2016-10-06 14:10 ` [ruby-core:77504] [Ruby trunk Bug#12814] " tao
@ 2016-10-11  1:12 ` shyouhei
  2016-10-15 16:30 ` [ruby-core:77636] " tao
  2016-11-05  7:25 ` [ruby-core:77958] [Ruby trunk Bug#12814][Rejected] " akr
  5 siblings, 0 replies; 6+ messages in thread
From: shyouhei @ 2016-10-11  1:12 UTC (permalink / raw
  To: ruby-core

Issue #12814 has been updated by Shyouhei Urabe.


It's true you can't infer a realpath from `with_directory=false`-yielded file paths.  Yes.  But isn't it intentional?  You requested to cut where the path was from.  Pretty natural you can no longer infer its origin.

The RDoc says it guarantees to include info enough to infer the realpath "By default", and you are requesting something not default.  I think the behavour is by design.

----------------------------------------
Bug #12814: Pathname#each_child(false) produces unusable file paths
https://bugs.ruby-lang.org/issues/12814#change-60812

* Author: Mr. Tao
* Status: Feedback
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I tried to iterate over items in a directory with `each_child` testing each item whether it is a directory or not with `directory?`. This was working just fine until I added **`false`** as an argument to `each_child`.

~~~ ruby
Pathname.new('.').each_child { |f| p f.realpath } # works as expected
Pathname.new('.').each_child(false) { |f| p f.realpath } # throws an error
~~~

As per Ruby doc "By default, the yielded pathnames will have enough information to access the files.", however pathnames yielded with `with_directory=false` are completely useless as file paths.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:77636] [Ruby trunk Bug#12814] Pathname#each_child(false) produces unusable file paths
       [not found] <redmine.issue-12814.20161006113854@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2016-10-11  1:12 ` [ruby-core:77545] " shyouhei
@ 2016-10-15 16:30 ` tao
  2016-11-05  7:25 ` [ruby-core:77958] [Ruby trunk Bug#12814][Rejected] " akr
  5 siblings, 0 replies; 6+ messages in thread
From: tao @ 2016-10-15 16:30 UTC (permalink / raw
  To: ruby-core

Issue #12814 has been updated by Mr. Tao.


I see… Still I can't decide whether it is for good or not. What is the purpose of such a path then? Shouldn't a String object instead of a Pathname be returned in such a case?

In my scenario I traverse directories and process some of them. If `each_child(false)` still contained enough information about it's relative position in directory tree it would allow me make code below somewhat simpler and more readable. Perhaps augmenting the Pathname class with this information might be beneficial.

~~~ruby
…
    user_path.each_child do |mailbox_path|
        process_mailbox mailbox_path if mailbox_path.directory?
…
def process_mailbox(mailbox_path)
…
    mailbox_path.find do |f|
          if f.directory?
            process_folder(f)
            next
…
def process_folder(folder)
    @user.mailboxes.find_or_create_by_path((folder.relative_path_from @user_path).to_s.split(File::SEPARATOR))
…
~~~

----------------------------------------
Bug #12814: Pathname#each_child(false) produces unusable file paths
https://bugs.ruby-lang.org/issues/12814#change-60909

* Author: Mr. Tao
* Status: Feedback
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I tried to iterate over items in a directory with `each_child` testing each item whether it is a directory or not with `directory?`. This was working just fine until I added **`false`** as an argument to `each_child`.

~~~ ruby
Pathname.new('.').each_child { |f| p f.realpath } # works as expected
Pathname.new('.').each_child(false) { |f| p f.realpath } # throws an error
~~~

As per Ruby doc "By default, the yielded pathnames will have enough information to access the files.", however pathnames yielded with `with_directory=false` are completely useless as file paths.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:77958] [Ruby trunk Bug#12814][Rejected] Pathname#each_child(false) produces unusable file paths
       [not found] <redmine.issue-12814.20161006113854@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2016-10-15 16:30 ` [ruby-core:77636] " tao
@ 2016-11-05  7:25 ` akr
  5 siblings, 0 replies; 6+ messages in thread
From: akr @ 2016-11-05  7:25 UTC (permalink / raw
  To: ruby-core

Issue #12814 has been updated by Akira Tanaka.

Status changed from Feedback to Rejected

Pathname#each_child is designed that easier access for child files by default (with_directory=true).
But it is also possible to obtain filenames only (with_directory=false) for applications which
remember the directory in the application (or application don't need the directory).

If you need directory in pathname, you can use with_directory=true.
If you don't want directory in pathname, you can use with_directory=false.

----------------------------------------
Bug #12814: Pathname#each_child(false) produces unusable file paths
https://bugs.ruby-lang.org/issues/12814#change-61287

* Author: Mr. Tao
* Status: Rejected
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I tried to iterate over items in a directory with `each_child` testing each item whether it is a directory or not with `directory?`. This was working just fine until I added **`false`** as an argument to `each_child`.

~~~ ruby
Pathname.new('.').each_child { |f| p f.realpath } # works as expected
Pathname.new('.').each_child(false) { |f| p f.realpath } # throws an error
~~~

As per Ruby doc "By default, the yielded pathnames will have enough information to access the files.", however pathnames yielded with `with_directory=false` are completely useless as file paths.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-11-05  6:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-12814.20161006113854@ruby-lang.org>
2016-10-06 11:38 ` [ruby-core:77501] [Ruby trunk Bug#12814] Pathname#each_child(false) produces unusable file paths tao
2016-10-06 12:56 ` [ruby-core:77503] [Ruby trunk Bug#12814][Feedback] " nobu
2016-10-06 14:10 ` [ruby-core:77504] [Ruby trunk Bug#12814] " tao
2016-10-11  1:12 ` [ruby-core:77545] " shyouhei
2016-10-15 16:30 ` [ruby-core:77636] " tao
2016-11-05  7:25 ` [ruby-core:77958] [Ruby trunk Bug#12814][Rejected] " akr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).