Sha256: b164204d20bc8288ddc7c05e63d2c5ad40dd0e23e6284463c17d03831c290d6a

Contents?: true

Size: 609 Bytes

Versions: 18

Compression:

Stored size: 609 Bytes

Contents

module Ridgepole
  module Ext
    module PpSortHash
      def pretty_print(q)
        q.group(1, '{', '}') {
          q.seplist(self.sort_by {|k, _| k.to_s } , nil, :each) {|k, v|
            v = PpSortHash.extend_if_hash(v)

            q.group {
              q.pp k
              q.text '=>'
              q.group(1) {
                q.breakable ''
                q.pp v
              }
            }
          }
        }
      end

      def self.extend_if_hash(obj)
        if obj.kind_of?(Hash)
          obj = obj.dup
          obj.extend(self)
        end

        obj
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ridgepole-0.7.3.beta lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.2 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.2.beta lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.1 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.1.beta5 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.1.beta4 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.1.beta3 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.1.beta2 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.1.beta lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.0 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.0.rc1 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.0.beta22 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.0.beta21 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.0.beta20 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.0.beta19 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.0.beta18 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.0.beta17 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.0.beta16 lib/ridgepole/ext/pp_sort_hash.rb