Sha256: 6050bb6f2ff3a777010644f41bd5d0cd7dc12e2f9ce082b9f9e7d706fdaf249d

Contents?: true

Size: 659 Bytes

Versions: 11

Compression:

Stored size: 659 Bytes

Contents

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

            pp_obj.group do
              pp_obj.pp k
              pp_obj.text '=>'
              pp_obj.group(1) do
                pp_obj.breakable ''
                pp_obj.pp v
              end
            end
          end
        end
      end

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

        obj
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ridgepole-0.8.0.rc1 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.7 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.6 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.5 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.5.beta3 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.5.beta2 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.5.beta lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.4 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.3 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.3.beta3 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.7.3.beta2 lib/ridgepole/ext/pp_sort_hash.rb