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-3.0.0 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-2.1.1 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-2.1.0 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-2.0.3 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-2.0.2 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-2.0.1 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-2.0.0 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-2.0.0.beta2 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-2.0.0.beta lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-1.2.1 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-1.2.0 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-1.1.0 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-1.0.7 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-1.0.6 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-1.0.5 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-1.0.4 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-1.0.3 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-1.0.2 lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-1.0.2.beta lib/ridgepole/ext/pp_sort_hash.rb
ridgepole-1.0.1 lib/ridgepole/ext/pp_sort_hash.rb