pacer 2.0.18-java → 2.0.19-java
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/pacer/transform/sort_section.rb +46 -13
 - data/lib/pacer/version.rb +1 -1
 - data/spec/pacer/transform/sort_section_spec.rb +16 -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: 50f9f48f941e86e98b7155587e62f6477812edd9
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 99f7b7c8e1265d73c9bc2f9cdcebbcaedb8749a6
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: fb477cd2ffdbaca86421c856a0c5d61c79eeb581086bfca05097d30d1f0e966b820acd9aedf26206d76cdabb82c166b6ccf9b4f2fffabea61b7e29817bebc70c
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 299290b76f510049a74d8c155366d8289aa315e3a919988c26f04252d4aa704a0f6a23cbc38c71beb0519e15b4e04b141450a01a46844291fe8e76c60f7339c0
         
     | 
| 
         @@ -2,13 +2,13 @@ module Pacer 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Routes
         
     | 
| 
       3 
3 
     | 
    
         
             
                module RouteOperations
         
     | 
| 
       4 
4 
     | 
    
         
             
                  # Arity 2 uses custom sort logic. Arity 1 uses sort_by logic.
         
     | 
| 
       5 
     | 
    
         
            -
                  def sort_section(section = nil, &block)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  def sort_section(section = nil, opts = {}, &block)
         
     | 
| 
       6 
6 
     | 
    
         
             
                    if not block
         
     | 
| 
       7 
     | 
    
         
            -
                      chain_route transform: :sort_section, section: section
         
     | 
| 
      
 7 
     | 
    
         
            +
                      chain_route opts.merge(transform: :sort_section, section: section)
         
     | 
| 
       8 
8 
     | 
    
         
             
                    elsif block.arity == 2
         
     | 
| 
       9 
     | 
    
         
            -
                      chain_route transform: :sort_section, custom_sort_block: block, section: section
         
     | 
| 
      
 9 
     | 
    
         
            +
                      chain_route opts.merge(transform: :sort_section, custom_sort_block: block, section: section)
         
     | 
| 
       10 
10 
     | 
    
         
             
                    else
         
     | 
| 
       11 
     | 
    
         
            -
                      chain_route transform: :sort_section, sort_by_block: block, section: section
         
     | 
| 
      
 11 
     | 
    
         
            +
                      chain_route opts.merge(transform: :sort_section, sort_by_block: block, section: section)
         
     | 
| 
       12 
12 
     | 
    
         
             
                    end
         
     | 
| 
       13 
13 
     | 
    
         
             
                  end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
         @@ -29,6 +29,12 @@ module Pacer 
     | 
|
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
                  attr_accessor :sort_by_block
         
     | 
| 
       31 
31 
     | 
    
         
             
                  attr_accessor :custom_sort_block
         
     | 
| 
      
 32 
     | 
    
         
            +
                  attr_accessor :nil_value
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  def nil_sort_value(value)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    @nil_value = nil_value
         
     | 
| 
      
 36 
     | 
    
         
            +
                    self
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
       32 
38 
     | 
    
         | 
| 
       33 
39 
     | 
    
         
             
                  protected
         
     | 
| 
       34 
40 
     | 
    
         | 
| 
         @@ -38,23 +44,24 @@ module Pacer 
     | 
|
| 
       38 
44 
     | 
    
         
             
                      pipe = CustomSortPipe.new(self, section_visitor, custom_sort_block, graph, wrapper)
         
     | 
| 
       39 
45 
     | 
    
         
             
                    else # sort_by_block
         
     | 
| 
       40 
46 
     | 
    
         
             
                      pf = Pacer::Wrappers::WrappingPipeFunction.new self, sort_by_block if sort_by_block
         
     | 
| 
       41 
     | 
    
         
            -
                      pipe = SortBySectionPipe.new(self, section_visitor, pf)
         
     | 
| 
      
 47 
     | 
    
         
            +
                      pipe = SortBySectionPipe.new(self, section_visitor, pf, nil_value)
         
     | 
| 
       42 
48 
     | 
    
         
             
                    end
         
     | 
| 
       43 
49 
     | 
    
         
             
                    pipe.setStarts end_pipe if end_pipe
         
     | 
| 
       44 
50 
     | 
    
         
             
                    pipe
         
     | 
| 
       45 
51 
     | 
    
         
             
                  end
         
     | 
| 
       46 
52 
     | 
    
         | 
| 
       47 
53 
     | 
    
         
             
                  class SortBySectionPipe < Pacer::Pipes::RubyPipe
         
     | 
| 
       48 
     | 
    
         
            -
                    attr_reader :pf_1, :pf_2, :to_sort, :to_emit, :section, :route
         
     | 
| 
      
 54 
     | 
    
         
            +
                    attr_reader :pf_1, :pf_2, :to_sort, :to_emit, :section, :route, :nil_value
         
     | 
| 
       49 
55 
     | 
    
         
             
                    attr_reader :getPathToHere
         
     | 
| 
       50 
56 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
                    def initialize(route, visitor_pipe, pipe_function)
         
     | 
| 
      
 57 
     | 
    
         
            +
                    def initialize(route, visitor_pipe, pipe_function, nil_value)
         
     | 
| 
       52 
58 
     | 
    
         
             
                      super()
         
     | 
| 
       53 
59 
     | 
    
         
             
                      @to_emit = []
         
     | 
| 
       54 
60 
     | 
    
         
             
                      @visitor_pipe = visitor_pipe
         
     | 
| 
       55 
61 
     | 
    
         
             
                      @route = route
         
     | 
| 
       56 
62 
     | 
    
         
             
                      @to_sort = []
         
     | 
| 
       57 
63 
     | 
    
         
             
                      @paths = []
         
     | 
| 
      
 64 
     | 
    
         
            +
                      @nil_value = nil_value
         
     | 
| 
       58 
65 
     | 
    
         
             
                      if visitor_pipe
         
     | 
| 
       59 
66 
     | 
    
         
             
                        visitor_pipe.visitor = self
         
     | 
| 
       60 
67 
     | 
    
         
             
                      else
         
     | 
| 
         @@ -106,16 +113,42 @@ module Pacer 
     | 
|
| 
       106 
113 
     | 
    
         
             
                    def after_element
         
     | 
| 
       107 
114 
     | 
    
         
             
                      if to_sort.any?
         
     | 
| 
       108 
115 
     | 
    
         
             
                        if pf_1
         
     | 
| 
       109 
     | 
    
         
            -
                           
     | 
| 
       110 
     | 
    
         
            -
                             
     | 
| 
      
 116 
     | 
    
         
            +
                          if nil_value
         
     | 
| 
      
 117 
     | 
    
         
            +
                            sorted = to_sort.sort_by do |element, path|
         
     | 
| 
      
 118 
     | 
    
         
            +
                              v = pf_1.call element
         
     | 
| 
      
 119 
     | 
    
         
            +
                              if v.nil?
         
     | 
| 
      
 120 
     | 
    
         
            +
                                nil_value
         
     | 
| 
      
 121 
     | 
    
         
            +
                              else
         
     | 
| 
      
 122 
     | 
    
         
            +
                                v
         
     | 
| 
      
 123 
     | 
    
         
            +
                              end
         
     | 
| 
      
 124 
     | 
    
         
            +
                            end
         
     | 
| 
      
 125 
     | 
    
         
            +
                          else
         
     | 
| 
      
 126 
     | 
    
         
            +
                            sorted = to_sort.sort_by do |element, path|
         
     | 
| 
      
 127 
     | 
    
         
            +
                              pf_1.call element
         
     | 
| 
      
 128 
     | 
    
         
            +
                            end
         
     | 
| 
       111 
129 
     | 
    
         
             
                          end
         
     | 
| 
       112 
130 
     | 
    
         
             
                        elsif pf_2
         
     | 
| 
       113 
     | 
    
         
            -
                           
     | 
| 
       114 
     | 
    
         
            -
                             
     | 
| 
      
 131 
     | 
    
         
            +
                          if nil_value
         
     | 
| 
      
 132 
     | 
    
         
            +
                            sorted = to_sort.sort_by do |element, path|
         
     | 
| 
      
 133 
     | 
    
         
            +
                              v = pf_2.call_with_args element, @section_element, pf_2.wrap_path(path)
         
     | 
| 
      
 134 
     | 
    
         
            +
                              if v.nil?
         
     | 
| 
      
 135 
     | 
    
         
            +
                                nil_value
         
     | 
| 
      
 136 
     | 
    
         
            +
                              else
         
     | 
| 
      
 137 
     | 
    
         
            +
                                v
         
     | 
| 
      
 138 
     | 
    
         
            +
                              end
         
     | 
| 
      
 139 
     | 
    
         
            +
                            end
         
     | 
| 
      
 140 
     | 
    
         
            +
                          else
         
     | 
| 
      
 141 
     | 
    
         
            +
                            sorted = to_sort.sort_by do |element, path|
         
     | 
| 
      
 142 
     | 
    
         
            +
                              pf_2.call_with_args element, @section_element, pf_2.wrap_path(path)
         
     | 
| 
      
 143 
     | 
    
         
            +
                            end
         
     | 
| 
       115 
144 
     | 
    
         
             
                          end
         
     | 
| 
       116 
145 
     | 
    
         
             
                        else
         
     | 
| 
       117 
146 
     | 
    
         
             
                          sorted = to_sort.sort_by do |element, path|
         
     | 
| 
       118 
     | 
    
         
            -
                            element
         
     | 
| 
      
 147 
     | 
    
         
            +
                            if element.nil?
         
     | 
| 
      
 148 
     | 
    
         
            +
                              nil_value
         
     | 
| 
      
 149 
     | 
    
         
            +
                            else
         
     | 
| 
      
 150 
     | 
    
         
            +
                              element
         
     | 
| 
      
 151 
     | 
    
         
            +
                            end
         
     | 
| 
       119 
152 
     | 
    
         
             
                          end
         
     | 
| 
       120 
153 
     | 
    
         
             
                        end
         
     | 
| 
       121 
154 
     | 
    
         
             
                        to_emit.concat sorted
         
     | 
| 
         @@ -128,7 +161,7 @@ module Pacer 
     | 
|
| 
       128 
161 
     | 
    
         
             
                    attr_reader :sort_block
         
     | 
| 
       129 
162 
     | 
    
         | 
| 
       130 
163 
     | 
    
         
             
                    def initialize(route, visitor_pipe, sort_block, graph, wrapper)
         
     | 
| 
       131 
     | 
    
         
            -
                      super route, visitor_pipe, nil
         
     | 
| 
      
 164 
     | 
    
         
            +
                      super route, visitor_pipe, nil, nil
         
     | 
| 
       132 
165 
     | 
    
         
             
                      @sort_block = sort_block
         
     | 
| 
       133 
166 
     | 
    
         
             
                      @graph = graph
         
     | 
| 
       134 
167 
     | 
    
         
             
                      @wrapper = wrapper
         
     | 
    
        data/lib/pacer/version.rb
    CHANGED
    
    | 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Pacer
         
     | 
| 
       2 
     | 
    
         
            -
              VERSION = "2.0. 
     | 
| 
      
 2 
     | 
    
         
            +
              VERSION = "2.0.19"
         
     | 
| 
       3 
3 
     | 
    
         
             
              # Clients may optionally define the following constants in the Pacer namespace:
         
     | 
| 
       4 
4 
     | 
    
         
             
              # - LOAD_JARS : set to false to manage jar loading in the client. Be sure to load the jars defined in JARFILES.
         
     | 
| 
       5 
5 
     | 
    
         
             
              # - LOCKJAR_LOCK_OPTS : set some options to be passed to LockJar.lock (ie. :lockfile, :download_artifacts, :local_repo)
         
     | 
| 
         @@ -57,6 +57,22 @@ Run.tg :read_only do 
     | 
|
| 
       57 
57 
     | 
    
         
             
                end
         
     | 
| 
       58 
58 
     | 
    
         
             
              end
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
      
 60 
     | 
    
         
            +
              describe 'sort by with nil' do
         
     | 
| 
      
 61 
     | 
    
         
            +
                let(:by_name) do
         
     | 
| 
      
 62 
     | 
    
         
            +
                  graph.v.section(:x).out.out.sort_section(:x, nil_value: 'x') { |v| nil }
         
     | 
| 
      
 63 
     | 
    
         
            +
                end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                it 'should have the same elements' do
         
     | 
| 
      
 66 
     | 
    
         
            +
                  by_name.group_count.should == unsorted.group_count
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                it 'should have 3 elements in the path' do
         
     | 
| 
      
 70 
     | 
    
         
            +
                  by_name.paths.each do |path|
         
     | 
| 
      
 71 
     | 
    
         
            +
                    path.length.should == 3
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
       60 
76 
     | 
    
         
             
              describe 'sort with more info' do
         
     | 
| 
       61 
77 
     | 
    
         
             
                let(:unsorted) { graph.v.out.out }
         
     | 
| 
       62 
78 
     | 
    
         
             
                let(:with_path) do
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: pacer
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.0.19
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: java
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Darrick Wiebe
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-07-02 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: lock_jar
         
     |