check_please 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bd44bf6bcc771bf5d0179fa562f5ddff80f0ed4bb2420ede197d60007d8057d
4
- data.tar.gz: 7c0725d4b8cf3d03d7c8ffd2e8df51a8e5a1616e86c4cad02695dca73921340f
3
+ metadata.gz: 9c80defc851cfda5e74a5590da7be40388643084c1e06818639685bfe05e8a46
4
+ data.tar.gz: fe1a9a3b8be29b8e148917ed19052ae2d0195218624b0bf195421cc29c83c20b
5
5
  SHA512:
6
- metadata.gz: 0add2fc010b651ae30a1309c3df9b26c1280e40fc7c45b5214ad22922fb3103c533f0f0ebbf26d46c3dbfb97b09d36ded3c9a419818039437aed2d198ced4669
7
- data.tar.gz: 88611e7acca8a803f69e48ddefddfbc208faeae359fc3417b0f0faa0aae11e853a45891919290abd062f503558f0caedc3b05fa037397f3b4142b11a3905245c
6
+ metadata.gz: 0b70a2c80630b51d789327c36e9b288aa2484d2b80cc888f5e8a94acf6bed1d7eef67c659f7ac17a9e7ed6c14aacc8cad9c18414881b2cfe07bf4e96aaad785e
7
+ data.tar.gz: 2cde0b422e2ae297517680f2408201b3f7c88e2e1f81da667d2c875dfddd31b544bef57864dff3ac8739be01b09676e5fd22ff1cbb54677e64f791ff606d3a05
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- check_please (0.5.4)
4
+ check_please (0.5.5)
5
5
  table_print
6
6
 
7
7
  GEM
data/lib/check_please.rb CHANGED
@@ -18,7 +18,6 @@ module CheckPlease
18
18
  autoload :PathSegment, "check_please/path_segment"
19
19
  autoload :PathSegmentMatcher, "check_please/path_segment_matcher"
20
20
  autoload :Printers, "check_please/printers"
21
- autoload :Refinements, "check_please/refinements"
22
21
  end
23
22
 
24
23
 
@@ -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) # whoa, it's almost like Java in here
9
+ @flags = Flags.reify(flags)
11
10
  @diffs = Diffs.new(flags: @flags)
12
11
 
13
12
  catch(:max_diffs_reached) do
@@ -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
@@ -3,6 +3,9 @@ module CheckPlease
3
3
  # NOTE: this gets all of its attributes defined (via .define) in ../check_please.rb
4
4
 
5
5
  class Flags
6
+ include CheckPlease::Reification
7
+ can_reify Hash
8
+
6
9
  BY_NAME = {} ; private_constant :BY_NAME
7
10
 
8
11
  def self.[](name)
@@ -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
+
@@ -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" # about to release? rerun `bundle lock` to update Gemfile.lock
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
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