[#7476] Net::HTTP Bug in Ruby 1.8.4? — James Edward Gray II <james@...>
Can a Net::HTTP guru comment on this message:
[#7485] Bugzilla for ruby? — Hadmut Danisch <hadmut@...>
Hi,
[#7493] how to introduce reference objects into ruby — "Geert Fannes" <Geert.Fannes@...>
Hello,
[#7497] Re: how to introduce reference objects into ruby — "Geert Fannes" <Geert.Fannes@...>
Hello,
[#7500] Re: how to introduce reference objects into ruby — "Geert Fannes" <Geert.Fannes@...>
The problem with the code you sent is that you have to go through ALL
The columns store the actual values (doubles), and the rows store pointers to the corresponding doubles. This way, I can update a double directly via the columns, via the rows after dereferencing the pointers.
[#7518] Proposal: String#notempty? — Bertram Scharpf <lists@...>
Hi,
[#7524] Sefe level: bug or feature? — "Kirill A. Shutemov" <k.shutemov@...>
Why cannot do eval with $SAFE=3 and can with $SAFE=4? Is it bug or
Hi,
On Mon, 13 Mar 2006, Yukihiro Matsumoto wrote:
[#7529] Re: Proposal: String#notempty? — "Berger, Daniel" <Daniel.Berger@...>
> -----Original Message-----
[#7546] Re: how to introduce reference objects into ruby — "Geert Fannes" <Geert.Fannes@...>
In Ruby, there's the []= and [] operators which you can define together.
[#7553] "not" operator used in expression that is a method parameter can generate syntax error — noreply@...
Bugs item #3843, was opened at 2006-03-15 22:09
Hi,
Nobu, you are not answering to the question.... You have to unveil why
Hi,
Hello,
Zev Blut wrote:
On 3/16/06, Joel VanderWerf <vjoel@path.berkeley.edu> wrote:
On 3/16/06, Zev Blut <rubyzbibd@ubit.com> wrote:
Hello,
Yukihiro Matsumoto wrote:
On 3/16/06, mathew <meta@pobox.com> wrote:
Brian Mitchell wrote:
On 3/16/06, mathew <meta@pobox.com> wrote:
Dear all
What you've described is the basic predence difference between
Evan Phoenix wrote:
[#7600] ruby_script ? — "Nicolas Despr鑚" <nicolas.despres@...>
Hi list,
>>>>> "N" == Nicolas Despr=E8s?= <ISO-8859-1> writes:
On 3/25/06, ts <decoux@moulon.inra.fr> wrote:
>>>>> "N" == Nicolas Despr=E8s?= <ISO-8859-1> writes:
[#7601] to_str, to_s and StringValue — "Gerardo Santana Gez Garrido" <gerardo.santana@...>
If I understand correctly, StringValue is a way for writing duck-type
[#7614] PATCH: A subclassable Pathname — "Evan Phoenix" <evanwebb@...>
A simply change (changing all references of "Pathname.new" to
In article <92f5f81d0603262350k796fe48fp2224b9f2108ac507@mail.gmail.com>,
Quite right on the .glob and .getwd. I guess the tests don't test hit
In article <92f5f81d0603270903g2fb02244i6a395be708dfffa3@mail.gmail.com>,
In article <87fyl3x0wd.fsf@m17n.org>,
Hm, well, thats because of the shortcut behavior in Pathname#+ which
In article <92f5f81d0603271717r1ce51d30p6c28e363dc32a09b@mail.gmail.com>,
Re: PATCH: A subclassable Pathname
Here's one that fixes + and join to always return an instance of self.class.
- Evan
On 3/27/06, Evan Phoenix <evanwebb@gmail.com> wrote:
> Hm, well, thats because of the shortcut behavior in Pathname#+ which
> tests that the argument is absolute. I'll fix that and see if thats
> done other places and change them to create new instances from
> self.class.
>
>
>
> On 3/27/06, Tanaka Akira <akr@m17n.org> wrote:
> > In article <87fyl3x0wd.fsf@m17n.org>,
> > Tanaka Akira <akr@m17n.org> writes:
> >
> > > The class of an argument may be different from
> > > self.class.new.
> > >
> > > For example, if P inherits Pathname,
> > > Pathname.new("...") + P.new("...") returns an instance of
> > > Pathname.
> >
> > Oops. It was wrong. It may return an instance of P.
> >
> > % ./ruby -Ilib -rpathname -e '
> > class P1 < Pathname; end
> > class P2 < Pathname; end
> > p P1.new("a") + P2.new("b")
> > p P1.new("a") + P2.new("/b")
> > '
> > #<P1:a/b>
> > #<P2:/b>
> >
> > I think it is inconsistent.
> > --
> > Tanaka Akira
> >
> >
>
>
> --
> When I do good, I feel good; when I do bad, I feel bad,
> and that is my religion.
> -- Abraham Lincoln (1809 - 1865)
>
>
--
When I do good, I feel good; when I do bad, I feel bad,
and that is my religion.
-- Abraham Lincoln (1809 - 1865)
Attachments (1)
--- /usr/local/lib/ruby/1.8/pathname.rb 2005-07-10 08:17:35.000000000 -0700
+++ ./pathname.rb 2006-03-27 17:22:19.000000000 -0800
@@ -258,7 +258,7 @@
# cleanpath_aggressive assumes:
# * no symlink
# * all pathname prefix contained in the pathname is existing directory
- return Pathname.new('') if @path == ''
+ return self.class.new('') if @path == ''
absolute = absolute?
names = []
@path.scan(%r{[^/]+}) {|name|
@@ -275,20 +275,20 @@
end
names << name
}
- return Pathname.new(absolute ? '/' : '.') if names.empty?
+ return self.class.new(absolute ? '/' : '.') if names.empty?
path = absolute ? '/' : ''
path << names.join('/')
- Pathname.new(path)
+ self.class.new(path)
end
private :cleanpath_aggressive
def cleanpath_conservative
- return Pathname.new('') if @path == ''
+ return self.class.new('') if @path == ''
names = @path.scan(%r{[^/]+})
last_dot = names.last == '.'
names.delete('.')
names.shift while names.first == '..' if absolute?
- return Pathname.new(absolute? ? '/' : '.') if names.empty?
+ return self.class.new(absolute? ? '/' : '.') if names.empty?
path = absolute? ? '/' : ''
path << names.join('/')
if names.last != '..'
@@ -298,7 +298,7 @@
path << '/'
end
end
- Pathname.new(path)
+ self.class.new(path)
end
private :cleanpath_conservative
@@ -363,9 +363,9 @@
end
if resolved.empty?
- Pathname.new(top.empty? ? '.' : '/')
+ self.class.new(top.empty? ? '.' : '/')
else
- Pathname.new(top + resolved.join('/'))
+ self.class.new(top + resolved.join('/'))
end
end
@@ -431,9 +431,9 @@
# This method doesn't access the file system; it is pure string manipulation.
#
def +(other)
- other = Pathname.new(other) unless Pathname === other
+ other = self.class.new(other) unless Pathname === other
- return other if other.absolute?
+ return self.class.new(other.to_str) if other.absolute?
path1 = @path
path2 = other.to_s
@@ -449,13 +449,13 @@
end
end
- return Pathname.new(path2) if path1 == '.'
- return Pathname.new(path1) if path2 == '.'
+ return self.class.new(path2) if path1 == '.'
+ return self.class.new(path1) if path2 == '.'
if %r{/\z} =~ path1
- Pathname.new(path1 + path2)
+ self.class.new(path1 + path2)
else
- Pathname.new(path1 + '/' + path2)
+ self.class.new(path1 + '/' + path2)
end
end
@@ -468,10 +468,10 @@
def join(*args)
args.unshift self
result = args.pop
- result = Pathname.new(result) unless Pathname === result
- return result if result.absolute?
+ result = self.class.new(result) unless Pathname === result
+ return self.class.new(result.to_str) if result.absolute?
args.reverse_each {|arg|
- arg = Pathname.new(arg) unless Pathname === arg
+ arg = self.class.new(arg) unless Pathname === arg
result = arg + result
return result if result.absolute?
}
@@ -505,9 +505,9 @@
Dir.foreach(@path) {|e|
next if e == '.' || e == '..'
if with_directory
- result << Pathname.new(File.join(@path, e))
+ result << self.class.new(File.join(@path, e))
else
- result << Pathname.new(e)
+ result << self.class.new(e)
end
}
result
@@ -554,9 +554,9 @@
base.fill '..'
relpath = base + dest
if relpath.empty?
- Pathname.new(".")
+ self.class.new(".")
else
- Pathname.new(relpath.join('/'))
+ self.class.new(relpath.join('/'))
end
end
@@ -635,7 +635,7 @@
end
# See <tt>File.readlink</tt>. Read symbolic link.
- def readlink() Pathname.new(File.readlink(@path)) end
+ def readlink() self.class.new(File.readlink(@path)) end
# See <tt>File.rename</tt>. Rename the file.
def rename(to) File.rename(@path, to) end
@@ -656,20 +656,20 @@
def utime(atime, mtime) File.utime(atime, mtime, @path) end
# See <tt>File.basename</tt>. Returns the last component of the path.
- def basename(*args) Pathname.new(File.basename(@path, *args)) end
+ def basename(*args) self.class.new(File.basename(@path, *args)) end
# See <tt>File.dirname</tt>. Returns all but the last component of the path.
- def dirname() Pathname.new(File.dirname(@path)) end
+ def dirname() self.class.new(File.dirname(@path)) end
# See <tt>File.extname</tt>. Returns the file's extension.
def extname() File.extname(@path) end
# See <tt>File.expand_path</tt>.
- def expand_path(*args) Pathname.new(File.expand_path(@path, *args)) end
+ def expand_path(*args) self.class.new(File.expand_path(@path, *args)) end
# See <tt>File.split</tt>. Returns the #dirname and the #basename in an
# Array.
- def split() File.split(@path).map {|f| Pathname.new(f) } end
+ def split() File.split(@path).map {|f| self.class.new(f) } end
# Pathname#link is confusing and *obsoleted* because the receiver/argument
# order is inverted to corresponding system call.
@@ -761,14 +761,14 @@
# See <tt>Dir.glob</tt>. Returns or yields Pathname objects.
def Pathname.glob(*args) # :yield: p
if block_given?
- Dir.glob(*args) {|f| yield Pathname.new(f) }
+ Dir.glob(*args) {|f| yield new(f) }
else
- Dir.glob(*args).map {|f| Pathname.new(f) }
+ Dir.glob(*args).map {|f| new(f) }
end
end
# See <tt>Dir.getwd</tt>. Returns the current working directory as a Pathname.
- def Pathname.getwd() Pathname.new(Dir.getwd) end
+ def Pathname.getwd() new(Dir.getwd) end
class << self; alias pwd getwd end
# Pathname#chdir is *obsoleted* at 1.8.1.
@@ -785,14 +785,14 @@
# Return the entries (files and subdirectories) in the directory, each as a
# Pathname object.
- def entries() Dir.entries(@path).map {|f| Pathname.new(f) } end
+ def entries() Dir.entries(@path).map {|f| self.class.new(f) } end
# Iterates over the entries (files and subdirectories) in the directory. It
# yields a Pathname object for each entry.
#
# This method has existed since 1.8.1.
def each_entry(&block) # :yield: p
- Dir.foreach(@path) {|f| yield Pathname.new(f) }
+ Dir.foreach(@path) {|f| yield self.class.new(f) }
end
# Pathname#dir_foreach is *obsoleted* at 1.8.1.
@@ -828,9 +828,9 @@
def find(&block) # :yield: p
require 'find'
if @path == '.'
- Find.find(@path) {|f| yield Pathname.new(f.sub(%r{\A\./}, '')) }
+ Find.find(@path) {|f| yield self.class.new(f.sub(%r{\A\./}, '')) }
else
- Find.find(@path) {|f| yield Pathname.new(f) }
+ Find.find(@path) {|f| yield self.class.new(f) }
end
end
end
@@ -1195,5 +1195,17 @@
assert_equal(1, count)
assert_equal(2, result)
end
+
+ def test_s_glob
+ ary = []
+ Pathname.glob("*") { |f| ary << f }
+ slf = ary.find { |e| e.to_s == __FILE__ }
+ assert slf
+ end
+
+ def test_s_getwd
+ pn = Pathname.getwd
+ assert_equal Dir.getwd, pn.to_s
+ end
end
end