table_of_truth 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50bb9868581d6c991ac2f8e69fdfcd26971f7ea512470d95e237e9e3c8b85fc1
4
- data.tar.gz: f37b31b1c28366d72b5df453ff7337f38750a5a48ee6496a3779d0a0089cbd5f
3
+ metadata.gz: 3d217b4de1a5f95db664a8abaab646dc348427bd0491a52839f175512eed057a
4
+ data.tar.gz: 5329311eb7d66c072d4c467da8c8207e44ee9131f9204f3ba31986d6f018e61f
5
5
  SHA512:
6
- metadata.gz: d99d102d9498a035ca8dc7a8d182a0915f1d3244fe6d4eb6371cf79a2ab3acb14528766807603cccafbf96f308e8382343a823b16dc7a6133fb9ca27d160bc2b
7
- data.tar.gz: 45ac8bf7e63b557f40ba0ddeca77e069558c97c57bb0e16aaf7dac3ad8ec9b3f45b61e991a9a07059cfe796d5837db4698eb74d694ce18d31e33280f60ebb036
6
+ metadata.gz: b72fc0d02fd88c64c80e2dd99216f563a572cde2a2965e96ed0d63087123efa553b43c77ce39045832348cf4ec9bc899f4b06bb563745294ac9b79b3d71d1cdc
7
+ data.tar.gz: 2027afbcbffcd6f0f2c6dc347544783bef18f9a71cac8d94581877a3177b3feb32fb206dab415db89dd72bb294327324d4860452e967779f5942f2537d1cc063
@@ -1,7 +1,7 @@
1
1
  require_relative 'table_of_truth/table'
2
2
 
3
3
  module TableOfTruth
4
- def self.new(colorize: true, &block)
5
- Table.new(colorize: colorize, &block)
4
+ def self.new(&block)
5
+ Table.new(&block)
6
6
  end
7
7
  end
@@ -0,0 +1,9 @@
1
+ module TableOfTruth
2
+ class Inputs
3
+ # @param inputs [Hash<(String or Symbol)->Boolean>]
4
+ def initialize(inputs)
5
+ @inputs = inputs
6
+ @inputs.each { |key, value| define_singleton_method(key) { value } }
7
+ end
8
+ end
9
+ end
@@ -1,7 +1,7 @@
1
1
  require 'colorize'
2
2
  require 'stringio'
3
3
  require_relative 'dsl'
4
- require_relative 'input'
4
+ require_relative 'inputs'
5
5
 
6
6
  module TableOfTruth
7
7
  class Table
@@ -14,9 +14,7 @@ module TableOfTruth
14
14
  # @return [Array<String or Symbol>]
15
15
  attr_reader :expression_names
16
16
 
17
- def initialize(colorize: true, &block)
18
- String.disable_colorization = !colorize
19
-
17
+ def initialize(&block)
20
18
  dsl = DSL.new
21
19
  dsl.instance_eval(&block)
22
20
 
@@ -30,14 +28,16 @@ module TableOfTruth
30
28
  def results
31
29
  @results ||= input_table.map do |inputs|
32
30
  result = inputs.dup
33
- expressions.each { |name, expression| result[name] = expression.call(Input.new(inputs)) }
31
+ expressions.each { |name, expression| result[name] = Inputs.new(inputs).instance_eval(&expression) }
34
32
 
35
33
  result
36
34
  end
37
35
  end
38
36
 
39
37
  # @return [void]
40
- def print!
38
+ def print!(colorize: true)
39
+ String.disable_colorization = !colorize
40
+
41
41
  builder = StringIO.new
42
42
 
43
43
  # Header
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_of_truth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Booth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-15 00:00:00.000000000 Z
11
+ date: 2020-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: spud
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.18
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.18
55
69
  description:
56
70
  email: andrew@andrewbooth.xyz
57
71
  executables: []
@@ -60,7 +74,7 @@ extra_rdoc_files: []
60
74
  files:
61
75
  - lib/table_of_truth.rb
62
76
  - lib/table_of_truth/dsl.rb
63
- - lib/table_of_truth/input.rb
77
+ - lib/table_of_truth/inputs.rb
64
78
  - lib/table_of_truth/table.rb
65
79
  homepage: https://github.com/broothie/table_of_truth#readme
66
80
  licenses:
@@ -1,21 +0,0 @@
1
- module TableOfTruth
2
- class Input
3
- # @param inputs [Hash<(String or Symbol)->Boolean>]
4
- def initialize(inputs)
5
- @inputs = inputs
6
- @inputs.each { |key, value| define_singleton_method(key) { value } }
7
- end
8
-
9
- # @param key [String or Symbol]
10
- # @return [Boolean]
11
- def [](key)
12
- if @inputs.key?(key.to_s)
13
- @inputs[key.to_s]
14
- elsif @inputs.key?(key.to_sym)
15
- @inputs[key.to_sym]
16
- else
17
- raise KeyError, "key not found: #{key}"
18
- end
19
- end
20
- end
21
- end