table_of_truth 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/table_of_truth.rb +2 -2
- data/lib/table_of_truth/inputs.rb +9 -0
- data/lib/table_of_truth/table.rb +6 -6
- metadata +17 -3
- data/lib/table_of_truth/input.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d217b4de1a5f95db664a8abaab646dc348427bd0491a52839f175512eed057a
|
4
|
+
data.tar.gz: 5329311eb7d66c072d4c467da8c8207e44ee9131f9204f3ba31986d6f018e61f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b72fc0d02fd88c64c80e2dd99216f563a572cde2a2965e96ed0d63087123efa553b43c77ce39045832348cf4ec9bc899f4b06bb563745294ac9b79b3d71d1cdc
|
7
|
+
data.tar.gz: 2027afbcbffcd6f0f2c6dc347544783bef18f9a71cac8d94581877a3177b3feb32fb206dab415db89dd72bb294327324d4860452e967779f5942f2537d1cc063
|
data/lib/table_of_truth.rb
CHANGED
data/lib/table_of_truth/table.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'colorize'
|
2
2
|
require 'stringio'
|
3
3
|
require_relative 'dsl'
|
4
|
-
require_relative '
|
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(
|
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] =
|
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.
|
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-
|
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/
|
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:
|
data/lib/table_of_truth/input.rb
DELETED
@@ -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
|