synvert-core 0.62.1 → 0.63.0
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/CHANGELOG.md +2 -1
 - data/Gemfile +0 -2
 - data/lib/synvert/core/node_ext.rb +18 -16
 - data/lib/synvert/core/version.rb +1 -1
 - data/spec/spec_helper.rb +0 -3
 - data/spec/synvert/core/node_ext_spec.rb +28 -0
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a008b0eb8cb6152ae896c550c0b5317f7c9679f9b23f4203c270e34b04f6f76a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 38ac175aabd6f7b8f598408bcc0615905bc9ee237070d514da3bc2aee30b96be
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e4d2c687d3f1f77ef46347718eec9753d920de3cefe410add119197814a24b8cd246c9442dd5ab09e163b719b9cd326088974d2c3519aa78a14a0fef38986457
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 75dd1ce3fa81439af5667eedf08b5b071394e6f025d3f31887527393c8cfd9057d8d58e9b3306cb8b3150898b065c85c1094f015308b6091844f12f9b0aa4464
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/Gemfile
    CHANGED
    
    
| 
         @@ -487,27 +487,29 @@ module Parser::AST 
     | 
|
| 
       487 
487 
     | 
    
         
             
                # @param rules [Hash] rules to match.
         
     | 
| 
       488 
488 
     | 
    
         
             
                # @return true if matches.
         
     | 
| 
       489 
489 
     | 
    
         
             
                def match?(rules)
         
     | 
| 
      
 490 
     | 
    
         
            +
                  keywords = %i[any contain not in not_in gt gte lt lte]
         
     | 
| 
       490 
491 
     | 
    
         
             
                  flat_hash(rules).keys.all? do |multi_keys|
         
     | 
| 
       491 
     | 
    
         
            -
                     
     | 
| 
      
 492 
     | 
    
         
            +
                    last_key = multi_keys.last
         
     | 
| 
      
 493 
     | 
    
         
            +
                    actual = keywords.include?(last_key) ? actual_value(multi_keys[0...-1]) : actual_value(multi_keys)
         
     | 
| 
      
 494 
     | 
    
         
            +
                    expected = expected_value(rules, multi_keys)
         
     | 
| 
      
 495 
     | 
    
         
            +
                    case last_key
         
     | 
| 
       492 
496 
     | 
    
         
             
                    when :any, :contain
         
     | 
| 
       493 
     | 
    
         
            -
                       
     | 
| 
       494 
     | 
    
         
            -
                      expected = expected_value(rules, multi_keys)
         
     | 
| 
       495 
     | 
    
         
            -
                      actual_values.any? { |actual| match_value?(actual, expected) }
         
     | 
| 
      
 497 
     | 
    
         
            +
                      actual.any? { |actual_value| match_value?(actual_value, expected) }
         
     | 
| 
       496 
498 
     | 
    
         
             
                    when :not
         
     | 
| 
       497 
     | 
    
         
            -
                      actual = actual_value(self, multi_keys[0...-1])
         
     | 
| 
       498 
     | 
    
         
            -
                      expected = expected_value(rules, multi_keys)
         
     | 
| 
       499 
499 
     | 
    
         
             
                      !match_value?(actual, expected)
         
     | 
| 
       500 
500 
     | 
    
         
             
                    when :in
         
     | 
| 
       501 
     | 
    
         
            -
                       
     | 
| 
       502 
     | 
    
         
            -
                      expected_values = expected_value(rules, multi_keys)
         
     | 
| 
       503 
     | 
    
         
            -
                      expected_values.any? { |expected| match_value?(actual, expected) }
         
     | 
| 
      
 501 
     | 
    
         
            +
                      expected.any? { |expected_value| match_value?(actual, expected_value) }
         
     | 
| 
       504 
502 
     | 
    
         
             
                    when :not_in
         
     | 
| 
       505 
     | 
    
         
            -
                       
     | 
| 
       506 
     | 
    
         
            -
             
     | 
| 
       507 
     | 
    
         
            -
                       
     | 
| 
      
 503 
     | 
    
         
            +
                      expected.all? { |expected_value| !match_value?(actual, expected_value) }
         
     | 
| 
      
 504 
     | 
    
         
            +
                    when :gt
         
     | 
| 
      
 505 
     | 
    
         
            +
                      actual > expected
         
     | 
| 
      
 506 
     | 
    
         
            +
                    when :gte
         
     | 
| 
      
 507 
     | 
    
         
            +
                      actual >= expected
         
     | 
| 
      
 508 
     | 
    
         
            +
                    when :lt
         
     | 
| 
      
 509 
     | 
    
         
            +
                      actual < expected
         
     | 
| 
      
 510 
     | 
    
         
            +
                    when :lte
         
     | 
| 
      
 511 
     | 
    
         
            +
                      actual <= expected
         
     | 
| 
       508 
512 
     | 
    
         
             
                    else
         
     | 
| 
       509 
     | 
    
         
            -
                      actual = actual_value(self, multi_keys)
         
     | 
| 
       510 
     | 
    
         
            -
                      expected = expected_value(rules, multi_keys)
         
     | 
| 
       511 
513 
     | 
    
         
             
                      match_value?(actual, expected)
         
     | 
| 
       512 
514 
     | 
    
         
             
                    end
         
     | 
| 
       513 
515 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -696,8 +698,8 @@ module Parser::AST 
     | 
|
| 
       696 
698 
     | 
    
         
             
                # @param node [Parser::AST::Node]
         
     | 
| 
       697 
699 
     | 
    
         
             
                # @param multi_keys [Array<Symbol>]
         
     | 
| 
       698 
700 
     | 
    
         
             
                # @return [Object] actual value.
         
     | 
| 
       699 
     | 
    
         
            -
                def actual_value( 
     | 
| 
       700 
     | 
    
         
            -
                  multi_keys.inject( 
     | 
| 
      
 701 
     | 
    
         
            +
                def actual_value(multi_keys)
         
     | 
| 
      
 702 
     | 
    
         
            +
                  multi_keys.inject(self) { |n, key| n.send(key) if n }
         
     | 
| 
       701 
703 
     | 
    
         
             
                end
         
     | 
| 
       702 
704 
     | 
    
         | 
| 
       703 
705 
     | 
    
         
             
                # Get expected value from rules.
         
     | 
    
        data/lib/synvert/core/version.rb
    CHANGED
    
    
    
        data/spec/spec_helper.rb
    CHANGED
    
    
| 
         @@ -567,6 +567,34 @@ describe Parser::AST::Node do 
     | 
|
| 
       567 
567 
     | 
    
         
             
                  node = parse(source)
         
     | 
| 
       568 
568 
     | 
    
         
             
                  expect(node).not_to be_match(type: 'send', message: { not_in: %i[create build] })
         
     | 
| 
       569 
569 
     | 
    
         
             
                end
         
     | 
| 
      
 570 
     | 
    
         
            +
             
     | 
| 
      
 571 
     | 
    
         
            +
                it 'matches gt' do
         
     | 
| 
      
 572 
     | 
    
         
            +
                  source = 'foobar(foo, bar)'
         
     | 
| 
      
 573 
     | 
    
         
            +
                  node = parse(source)
         
     | 
| 
      
 574 
     | 
    
         
            +
                  expect(node).to be_match(type: 'send', arguments: { size: { gt: 1 } })
         
     | 
| 
      
 575 
     | 
    
         
            +
                  expect(node).not_to be_match(type: 'send', arguments: { size: { gt: 2 } })
         
     | 
| 
      
 576 
     | 
    
         
            +
                end
         
     | 
| 
      
 577 
     | 
    
         
            +
             
     | 
| 
      
 578 
     | 
    
         
            +
                it 'matches gte' do
         
     | 
| 
      
 579 
     | 
    
         
            +
                  source = 'foobar(foo, bar)'
         
     | 
| 
      
 580 
     | 
    
         
            +
                  node = parse(source)
         
     | 
| 
      
 581 
     | 
    
         
            +
                  expect(node).to be_match(type: 'send', arguments: { size: { gte: 2 } })
         
     | 
| 
      
 582 
     | 
    
         
            +
                  expect(node).not_to be_match(type: 'send', arguments: { size: { gte: 3 } })
         
     | 
| 
      
 583 
     | 
    
         
            +
                end
         
     | 
| 
      
 584 
     | 
    
         
            +
             
     | 
| 
      
 585 
     | 
    
         
            +
                it 'matches lt' do
         
     | 
| 
      
 586 
     | 
    
         
            +
                  source = 'foobar(foo, bar)'
         
     | 
| 
      
 587 
     | 
    
         
            +
                  node = parse(source)
         
     | 
| 
      
 588 
     | 
    
         
            +
                  expect(node).to be_match(type: 'send', arguments: { size: { lt: 3 } })
         
     | 
| 
      
 589 
     | 
    
         
            +
                  expect(node).not_to be_match(type: 'send', arguments: { size: { lt: 2 } })
         
     | 
| 
      
 590 
     | 
    
         
            +
                end
         
     | 
| 
      
 591 
     | 
    
         
            +
             
     | 
| 
      
 592 
     | 
    
         
            +
                it 'matches lte' do
         
     | 
| 
      
 593 
     | 
    
         
            +
                  source = 'foobar(foo, bar)'
         
     | 
| 
      
 594 
     | 
    
         
            +
                  node = parse(source)
         
     | 
| 
      
 595 
     | 
    
         
            +
                  expect(node).to be_match(type: 'send', arguments: { size: { lte: 2 } })
         
     | 
| 
      
 596 
     | 
    
         
            +
                  expect(node).not_to be_match(type: 'send', arguments: { size: { lte: 1 } })
         
     | 
| 
      
 597 
     | 
    
         
            +
                end
         
     | 
| 
       570 
598 
     | 
    
         
             
              end
         
     | 
| 
       571 
599 
     | 
    
         | 
| 
       572 
600 
     | 
    
         
             
              describe '#child_node_by_name' do
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: synvert-core
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.63.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Richard Huang
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-02-26 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     |