Sha256: 86d21e9510ee4b86e01d9d7cd8c9d2fb7cbb05f32da84c96b8f9a81f049c35dc

Contents?: true

Size: 690 Bytes

Versions: 46

Compression:

Stored size: 690 Bytes

Contents

# frozen_string_literal: true

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

46 entries across 46 versions & 1 rubygems

Version Path
ridgepole-1.0.0 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.9.6 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.9.5 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.9.4 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.9.3 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.9.2 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.9.1 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.9.0 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.8.13 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.9.0.rc1 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.9.0.beta lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.8.12 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.8.11 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.8.10 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.8.9 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.8.8 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.8.7 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.8.6 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.8.5 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-0.8.4 lib/ridgepole/ext/pp_sort_hash.rb