check_please 0.5.4 → 0.5.5
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/Gemfile.lock +1 -1
 - data/lib/check_please.rb +0 -1
 - data/lib/check_please/comparison.rb +1 -2
 - data/lib/check_please/diffs.rb +13 -2
 - data/lib/check_please/flags.rb +3 -0
 - data/lib/check_please/printers.rb +3 -2
 - data/lib/check_please/printers/long.rb +31 -0
 - data/lib/check_please/version.rb +1 -1
 - metadata +2 -2
 - data/lib/check_please/refinements.rb +0 -16
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 9c80defc851cfda5e74a5590da7be40388643084c1e06818639685bfe05e8a46
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: fe1a9a3b8be29b8e148917ed19052ae2d0195218624b0bf195421cc29c83c20b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 0b70a2c80630b51d789327c36e9b288aa2484d2b80cc888f5e8a94acf6bed1d7eef67c659f7ac17a9e7ed6c14aacc8cad9c18414881b2cfe07bf4e96aaad785e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 2cde0b422e2ae297517680f2408201b3f7c88e2e1f81da667d2c875dfddd31b544bef57864dff3ac8739be01b09676e5fd22ff1cbb54677e64f791ff606d3a05
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/lib/check_please.rb
    CHANGED
    
    
| 
         @@ -1,5 +1,4 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module CheckPlease
         
     | 
| 
       2 
     | 
    
         
            -
              using Refinements
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
3 
     | 
    
         
             
              class Comparison
         
     | 
| 
       5 
4 
     | 
    
         
             
                def self.perform(reference, candidate, flags = {})
         
     | 
| 
         @@ -7,7 +6,7 @@ module CheckPlease 
     | 
|
| 
       7 
6 
     | 
    
         
             
                end
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
       9 
8 
     | 
    
         
             
                def perform(reference, candidate, flags = {})
         
     | 
| 
       10 
     | 
    
         
            -
                  @flags = Flags(flags) 
     | 
| 
      
 9 
     | 
    
         
            +
                  @flags = Flags.reify(flags)
         
     | 
| 
       11 
10 
     | 
    
         
             
                  @diffs = Diffs.new(flags: @flags)
         
     | 
| 
       12 
11 
     | 
    
         | 
| 
       13 
12 
     | 
    
         
             
                  catch(:max_diffs_reached) do
         
     | 
    
        data/lib/check_please/diffs.rb
    CHANGED
    
    | 
         @@ -1,14 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'forwardable'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module CheckPlease
         
     | 
| 
       4 
     | 
    
         
            -
              using Refinements
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
5 
     | 
    
         
             
              # Custom collection class for Diff instances.
         
     | 
| 
       7 
6 
     | 
    
         
             
              # Can retrieve members using indexes or paths.
         
     | 
| 
       8 
7 
     | 
    
         
             
              class Diffs
         
     | 
| 
       9 
8 
     | 
    
         
             
                attr_reader :flags
         
     | 
| 
       10 
9 
     | 
    
         
             
                def initialize(diff_list = nil, flags: {})
         
     | 
| 
       11 
     | 
    
         
            -
                  @flags = Flags(flags)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @flags = Flags.reify(flags)
         
     | 
| 
       12 
11 
     | 
    
         
             
                  @list = []
         
     | 
| 
       13 
12 
     | 
    
         
             
                  @hash = {}
         
     | 
| 
       14 
13 
     | 
    
         
             
                  Array(diff_list).each do |diff|
         
     | 
| 
         @@ -56,6 +55,18 @@ module CheckPlease 
     | 
|
| 
       56 
55 
     | 
    
         
             
                  CheckPlease::Printers.render(self, flags)
         
     | 
| 
       57 
56 
     | 
    
         
             
                end
         
     | 
| 
       58 
57 
     | 
    
         | 
| 
      
 58 
     | 
    
         
            +
                def method_missing(meth, *args, &blk)
         
     | 
| 
      
 59 
     | 
    
         
            +
                  if formats.include?(meth.to_sym)
         
     | 
| 
      
 60 
     | 
    
         
            +
                    CheckPlease::Printers.render(self, format: meth)
         
     | 
| 
      
 61 
     | 
    
         
            +
                  else
         
     | 
| 
      
 62 
     | 
    
         
            +
                    super
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                def formats
         
     | 
| 
      
 67 
     | 
    
         
            +
                  CheckPlease::Printers::FORMATS
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
       59 
70 
     | 
    
         
             
                extend Forwardable
         
     | 
| 
       60 
71 
     | 
    
         
             
                def_delegators :@list, *%i[
         
     | 
| 
       61 
72 
     | 
    
         
             
                  each
         
     | 
    
        data/lib/check_please/flags.rb
    CHANGED
    
    
| 
         @@ -1,20 +1,21 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module CheckPlease
         
     | 
| 
       2 
     | 
    
         
            -
              using Refinements
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
3 
     | 
    
         
             
              module Printers
         
     | 
| 
       5 
4 
     | 
    
         
             
                autoload :Base,       "check_please/printers/base"
         
     | 
| 
       6 
5 
     | 
    
         
             
                autoload :JSON,       "check_please/printers/json"
         
     | 
| 
      
 6 
     | 
    
         
            +
                autoload :Long,       "check_please/printers/long"
         
     | 
| 
       7 
7 
     | 
    
         
             
                autoload :TablePrint, "check_please/printers/table_print"
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                PRINTERS_BY_FORMAT = {
         
     | 
| 
       10 
10 
     | 
    
         
             
                  table: Printers::TablePrint,
         
     | 
| 
       11 
11 
     | 
    
         
             
                  json:  Printers::JSON,
         
     | 
| 
      
 12 
     | 
    
         
            +
                  long:  Printers::Long,
         
     | 
| 
       12 
13 
     | 
    
         
             
                }
         
     | 
| 
       13 
14 
     | 
    
         
             
                FORMATS = PRINTERS_BY_FORMAT.keys.sort
         
     | 
| 
       14 
15 
     | 
    
         
             
                DEFAULT_FORMAT = :table
         
     | 
| 
       15 
16 
     | 
    
         | 
| 
       16 
17 
     | 
    
         
             
                def self.render(diffs, flags = {})
         
     | 
| 
       17 
     | 
    
         
            -
                  flags = Flags(flags)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  flags = Flags.reify(flags)
         
     | 
| 
       18 
19 
     | 
    
         
             
                  printer = PRINTERS_BY_FORMAT[flags.format]
         
     | 
| 
       19 
20 
     | 
    
         
             
                  printer.render(diffs)
         
     | 
| 
       20 
21 
     | 
    
         
             
                end
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module CheckPlease
         
     | 
| 
      
 2 
     | 
    
         
            +
            module Printers
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              class Long < Base
         
     | 
| 
      
 5 
     | 
    
         
            +
                def to_s
         
     | 
| 
      
 6 
     | 
    
         
            +
                  return "" if diffs.empty?
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                  out = build_string do |io|
         
     | 
| 
      
 9 
     | 
    
         
            +
                    diffs.each do |diff|
         
     | 
| 
      
 10 
     | 
    
         
            +
                      t = diff.type.to_sym
         
     | 
| 
      
 11 
     | 
    
         
            +
                      ref, can = *[ diff.reference, diff.candidate ].map(&:inspect)
         
     | 
| 
      
 12 
     | 
    
         
            +
                      diff_string = <<~EOF.strip
         
     | 
| 
      
 13 
     | 
    
         
            +
                        #{diff.path} [#{diff.type}]
         
     | 
| 
      
 14 
     | 
    
         
            +
                          reference: #{( t == :extra   ) ? "[no value]" : ref}
         
     | 
| 
      
 15 
     | 
    
         
            +
                          candidate: #{( t == :missing ) ? "[no value]" : can}
         
     | 
| 
      
 16 
     | 
    
         
            +
                      EOF
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                      io.puts diff_string
         
     | 
| 
      
 19 
     | 
    
         
            +
                      io.puts
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  out.strip
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                private
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
    
        data/lib/check_please/version.rb
    CHANGED
    
    | 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module CheckPlease
         
     | 
| 
       2 
2 
     | 
    
         
             
              # NOTE: 'check_please_rspec_matcher' depends on this,
         
     | 
| 
       3 
3 
     | 
    
         
             
              #       so try to keep them roughly in sync
         
     | 
| 
       4 
     | 
    
         
            -
              VERSION = "0.5. 
     | 
| 
      
 4 
     | 
    
         
            +
              VERSION = "0.5.5" # about to release? rerun `bundle lock` to update Gemfile.lock
         
     | 
| 
       5 
5 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: check_please
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.5. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.5.5
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Sam Livingston-Gray
         
     | 
| 
         @@ -91,8 +91,8 @@ files: 
     | 
|
| 
       91 
91 
     | 
    
         
             
            - lib/check_please/printers.rb
         
     | 
| 
       92 
92 
     | 
    
         
             
            - lib/check_please/printers/base.rb
         
     | 
| 
       93 
93 
     | 
    
         
             
            - lib/check_please/printers/json.rb
         
     | 
| 
      
 94 
     | 
    
         
            +
            - lib/check_please/printers/long.rb
         
     | 
| 
       94 
95 
     | 
    
         
             
            - lib/check_please/printers/table_print.rb
         
     | 
| 
       95 
     | 
    
         
            -
            - lib/check_please/refinements.rb
         
     | 
| 
       96 
96 
     | 
    
         
             
            - lib/check_please/reification.rb
         
     | 
| 
       97 
97 
     | 
    
         
             
            - lib/check_please/version.rb
         
     | 
| 
       98 
98 
     | 
    
         
             
            - usage_examples.rb
         
     | 
| 
         @@ -1,16 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module CheckPlease
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              module Refinements
         
     | 
| 
       4 
     | 
    
         
            -
                refine Kernel do
         
     | 
| 
       5 
     | 
    
         
            -
                  def Flags(flags_or_hash)
         
     | 
| 
       6 
     | 
    
         
            -
                    case flags_or_hash
         
     | 
| 
       7 
     | 
    
         
            -
                    when Flags ; return flags_or_hash
         
     | 
| 
       8 
     | 
    
         
            -
                    when Hash  ; return Flags.new(flags_or_hash)
         
     | 
| 
       9 
     | 
    
         
            -
                    else
         
     | 
| 
       10 
     | 
    
         
            -
                      raise ArgumentError, "Expected either a CheckPlease::Flags or a Hash; got #{flags_or_hash.inspect}"
         
     | 
| 
       11 
     | 
    
         
            -
                    end
         
     | 
| 
       12 
     | 
    
         
            -
                  end
         
     | 
| 
       13 
     | 
    
         
            -
                end
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            end
         
     |