dslh 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/dslh.rb +8 -4
- data/lib/dslh/version.rb +1 -1
- data/spec/dslh_spec.rb +52 -0
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 7390c52a2f651e8ae19478c3b499fd156bfe9ce8
         | 
| 4 | 
            +
              data.tar.gz: a417585a38c5a06e1cdfff655c60edbe5f50cb0e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9fd88853d1941b413207e4b5616e6a20f38181f805e8a9038cfefcc51f993162318d368440c8941390abec7354f5be41a5414a01eba5075928bb04b17b384ad2
         | 
| 7 | 
            +
              data.tar.gz: dae0498effdc33b5086711927e6d786433ac94dbe3febab0693f9d0cc8c70d52ad4a2f34ad60daadb38b042fe3a7dbab4666b367a284f0b04b7993ea18fc27bd
         | 
    
        data/lib/dslh.rb
    CHANGED
    
    | @@ -146,7 +146,7 @@ class Dslh | |
| 146 146 | 
             
                  if value.any? {|v| [Array, Hash].any? {|c| v.kind_of?(c) }}
         | 
| 147 147 | 
             
                    nested = true
         | 
| 148 148 |  | 
| 149 | 
            -
                    if not @options[:dump_old_hash_array_format] and value.all? {|i| i.kind_of?(Hash) }
         | 
| 149 | 
            +
                    if not @options[:dump_old_hash_array_format] and value.all? {|i| i.kind_of?(Hash) and not exclude_keys?(i.keys) }
         | 
| 150 150 | 
             
                      value_buf.puts(@options[:use_braces_instead_of_do_end] ? ' {|*|' : ' do |*|')
         | 
| 151 151 |  | 
| 152 152 | 
             
                      value.each_with_index do |v, i|
         | 
| @@ -172,9 +172,13 @@ class Dslh | |
| 172 172 | 
             
                      value.each_with_index do |v, i|
         | 
| 173 173 | 
             
                        case v
         | 
| 174 174 | 
             
                        when Hash
         | 
| 175 | 
            -
                           | 
| 176 | 
            -
             | 
| 177 | 
            -
                           | 
| 175 | 
            +
                          if exclude_keys?(v.keys)
         | 
| 176 | 
            +
                            value_buf.print(INDENT_SPACES * (depth + 1) + v.pretty_inspect.strip)
         | 
| 177 | 
            +
                          else
         | 
| 178 | 
            +
                            value_buf.puts(next_indent + '_{')
         | 
| 179 | 
            +
                            deval0(v, depth + 2, value_buf)
         | 
| 180 | 
            +
                            value_buf.print(next_indent + '}')
         | 
| 181 | 
            +
                          end
         | 
| 178 182 | 
             
                        when Array
         | 
| 179 183 | 
             
                          value_buf.print(next_indent.slice(0...-1))
         | 
| 180 184 | 
             
                          value_proc(v, depth + 1, value_buf, false)
         | 
    
        data/lib/dslh/version.rb
    CHANGED
    
    
    
        data/spec/dslh_spec.rb
    CHANGED
    
    | @@ -2680,6 +2680,58 @@ end | |
| 2680 2680 | 
             
                EOS
         | 
| 2681 2681 | 
             
              end
         | 
| 2682 2682 |  | 
| 2683 | 
            +
              it 'should convert hash to dsl (include hash array with exclude_key)' do
         | 
| 2684 | 
            +
                exclude_key = proc do |k|
         | 
| 2685 | 
            +
                  k == :title
         | 
| 2686 | 
            +
                end
         | 
| 2687 | 
            +
             | 
| 2688 | 
            +
                h = {:glossary=>[
         | 
| 2689 | 
            +
                      {:title=>"example glossary",
         | 
| 2690 | 
            +
                       :date=>Time.parse('2016/05/21 00:00 UTC').to_s},
         | 
| 2691 | 
            +
                      {:title=>"example glossary2",
         | 
| 2692 | 
            +
                       :date=>Time.parse('2016/05/21 00:01 UTC').to_s}],
         | 
| 2693 | 
            +
                     :glossary2=>[
         | 
| 2694 | 
            +
                      {:title=>"example glossary",
         | 
| 2695 | 
            +
                       :date=>Time.parse('2016/05/21 00:00 UTC').to_s}]}
         | 
| 2696 | 
            +
             | 
| 2697 | 
            +
                dsl = Dslh.deval(h, :exclude_key => exclude_key)
         | 
| 2698 | 
            +
                expect(dsl).to eq(<<-EOS)
         | 
| 2699 | 
            +
            glossary [
         | 
| 2700 | 
            +
              {:title=>"example glossary", :date=>"2016-05-21 00:00:00 UTC"},
         | 
| 2701 | 
            +
              {:title=>"example glossary2", :date=>"2016-05-21 00:01:00 UTC"}
         | 
| 2702 | 
            +
            ]
         | 
| 2703 | 
            +
            glossary2 [
         | 
| 2704 | 
            +
              {:title=>"example glossary", :date=>"2016-05-21 00:00:00 UTC"}
         | 
| 2705 | 
            +
            ]
         | 
| 2706 | 
            +
                EOS
         | 
| 2707 | 
            +
              end
         | 
| 2708 | 
            +
             | 
| 2709 | 
            +
              it 'should convert hash to dsl (include hash array with exclude_key and dump_old_hash_array_format)' do
         | 
| 2710 | 
            +
                exclude_key = proc do |k|
         | 
| 2711 | 
            +
                  k == :title
         | 
| 2712 | 
            +
                end
         | 
| 2713 | 
            +
             | 
| 2714 | 
            +
                h = {:glossary=>[
         | 
| 2715 | 
            +
                      {:title=>"example glossary",
         | 
| 2716 | 
            +
                       :date=>Time.parse('2016/05/21 00:00 UTC').to_s},
         | 
| 2717 | 
            +
                      {:title=>"example glossary2",
         | 
| 2718 | 
            +
                       :date=>Time.parse('2016/05/21 00:01 UTC').to_s}],
         | 
| 2719 | 
            +
                     :glossary2=>[
         | 
| 2720 | 
            +
                      {:title=>"example glossary",
         | 
| 2721 | 
            +
                       :date=>Time.parse('2016/05/21 00:00 UTC').to_s}]}
         | 
| 2722 | 
            +
             | 
| 2723 | 
            +
                dsl = Dslh.deval(h, :exclude_key => exclude_key)
         | 
| 2724 | 
            +
                expect(dsl).to eq(<<-EOS)
         | 
| 2725 | 
            +
            glossary [
         | 
| 2726 | 
            +
              {:title=>"example glossary", :date=>"2016-05-21 00:00:00 UTC"},
         | 
| 2727 | 
            +
              {:title=>"example glossary2", :date=>"2016-05-21 00:01:00 UTC"}
         | 
| 2728 | 
            +
            ]
         | 
| 2729 | 
            +
            glossary2 [
         | 
| 2730 | 
            +
              {:title=>"example glossary", :date=>"2016-05-21 00:00:00 UTC"}
         | 
| 2731 | 
            +
            ]
         | 
| 2732 | 
            +
                EOS
         | 
| 2733 | 
            +
              end
         | 
| 2734 | 
            +
             | 
| 2683 2735 | 
             
              it 'should convert dsl to hash (include hash array)' do
         | 
| 2684 2736 | 
             
                h = {:glossary=>[
         | 
| 2685 2737 | 
             
                      {:title=>"example glossary",
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: dslh
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.3. | 
| 4 | 
            +
              version: 0.3.7
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Genki Sugawara
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016-05- | 
| 11 | 
            +
            date: 2016-05-25 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |