1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/pp.rb (PP::PPMethods#pp_hash): don't sort keys because hash is

ordered.
  (ENV.pretty_print): call pp_hash with sorted hash.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2007-10-14 02:14:16 +00:00
parent b933a5348b
commit 9d326d261e
2 changed files with 14 additions and 12 deletions

View file

@ -1,3 +1,9 @@
Sun Oct 14 11:09:09 2007 Tanaka Akira <akr@fsij.org>
* lib/pp.rb (PP::PPMethods#pp_hash): don't sort keys because hash is
ordered.
(ENV.pretty_print): call pp_hash with sorted hash.
Sun Oct 14 04:08:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun Oct 14 04:08:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (AC_SYS_LARGEFILE): keep results also in command * configure.in (AC_SYS_LARGEFILE): keep results also in command
@ -166,7 +172,7 @@ Tue Oct 9 15:40:24 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
Mon Oct 8 20:06:29 2007 GOTOU Yuuzou <gotoyuzo@notwork.org> Mon Oct 8 20:06:29 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/net/imap.rb, lib/net/smtp.rb, lib/net/pop.rb: hostname should * lib/net/imap.rb, lib/net/smtp.rb, lib/net/pop.rb: hostname should
be verified against server's indentity as persented in the server's be verified against server's identity as presented in the server's
certificate. [ruby-dev:31960] certificate. [ruby-dev:31960]
* ext/openssl/lib/net/telnets.rb, ext/openssl/lib/net/ftptls.rb: ditto. * ext/openssl/lib/net/telnets.rb, ext/openssl/lib/net/ftptls.rb: ditto.
@ -261,7 +267,7 @@ Fri Oct 5 03:25:51 2007 Akinori MUSHA <knu@iDaemons.org>
* lib/ipaddr.rb (succ): Implement IPAddr#succ. You can now create * lib/ipaddr.rb (succ): Implement IPAddr#succ. You can now create
a range between two IPAddr's, which (Range) object is a range between two IPAddr's, which (Range) object is
enumeratable. enumerable.
* lib/ipaddr.rb (to_range): A new method to create a Range object * lib/ipaddr.rb (to_range): A new method to create a Range object
for the (network) address. for the (network) address.

View file

@ -247,15 +247,7 @@ class PP < PrettyPrint
def pp_hash(obj) def pp_hash(obj)
group(1, '{', '}') { group(1, '{', '}') {
keys = obj.keys seplist(obj, nil, :each_pair) {|k, v|
if 0 < keys.length
key_class = keys[0].class
if key_class < Comparable && keys.all? {|k| k.class == key_class }
keys.sort!
end
end
seplist(keys, nil, :each) {|k|
v = obj[k]
group { group {
pp k pp k
text '=>' text '=>'
@ -359,7 +351,11 @@ end
class << ENV class << ENV
def pretty_print(q) def pretty_print(q)
q.pp_hash self h = {}
ENV.keys.sort.each {|k|
h[k] = ENV[k]
}
q.pp_hash h
end end
end end