casegen 2.0.0 → 3.0.0
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/.rspec +1 -0
- data/.rubocop.yml +109 -0
- data/.ruby-version +1 -1
- data/Gemfile +3 -1
- data/Gemfile.lock +51 -6
- data/README.md +10 -119
- data/Rakefile +9 -7
- data/bin/casegen +2 -1
- data/casegen.gemspec +13 -9
- data/doc/bounding_box.rb +37 -0
- data/doc/cart.rb +43 -0
- data/doc/expect_only.rb +28 -0
- data/doc/pricing.rb +50 -0
- data/doc/ruby_array.rb +41 -0
- data/lib/case_gen/combination.rb +38 -0
- data/lib/case_gen/combo_matcher.rb +15 -0
- data/lib/case_gen/exclude_rule.rb +50 -0
- data/lib/case_gen/expect_rule.rb +24 -0
- data/lib/case_gen/generator.rb +40 -0
- data/lib/case_gen/output/exclude.rb +6 -0
- data/lib/case_gen/output/exclude_as_table.rb +13 -0
- data/lib/case_gen/output/exclude_as_text.rb +12 -0
- data/lib/case_gen/output/exclude_inline.rb +13 -0
- data/lib/case_gen/output/exclude_inline_footnotes.rb +20 -0
- data/lib/case_gen/output.rb +66 -0
- data/lib/case_gen/rule_description.rb +11 -0
- data/lib/case_gen/set.rb +16 -0
- data/lib/casegen.rb +15 -183
- data/spec/cart_sample_spec.rb +46 -0
- data/spec/case_gen/combination_spec.rb +11 -0
- data/spec/case_gen/exclude_rule_spec.rb +17 -0
- data/spec/exclude_as_table_spec.rb +39 -0
- data/spec/exclude_as_text_spec.rb +58 -0
- data/spec/exclude_inline_footnotes_spec.rb +58 -0
- data/spec/exclude_inline_spec.rb +50 -0
- data/spec/expect_only_spec.rb +30 -0
- data/spec/spec_helper.rb +113 -0
- metadata +101 -35
- data/.idea/encodings.xml +0 -5
- data/.idea/misc.xml +0 -5
- data/.idea/modules.xml +0 -9
- data/.idea/vcs.xml +0 -7
- data/doc/calc.sample.txt +0 -13
- data/doc/cart.sample.rb +0 -3
- data/doc/cart.sample.txt +0 -33
- data/doc/ruby_array.sample.rb +0 -26
- data/lib/agents/sets/enum/by.rb +0 -244
- data/lib/agents/sets/enum/cluster.rb +0 -164
- data/lib/agents/sets/enum/inject.rb +0 -50
- data/lib/agents/sets/enum/nest.rb +0 -117
- data/lib/agents/sets/enum/op.rb +0 -283
- data/lib/agents/sets/enum/pipe.rb +0 -160
- data/lib/agents/sets/enum/tree.rb +0 -442
- data/lib/agents/sets.rb +0 -313
- data/test/agents/console_output_test.rb +0 -27
- data/test/agents/sets.test.rb +0 -227
- data/test/agents_test.rb +0 -41
- data/test/casegen.tests.rb +0 -0
- data/test/parser_test.rb +0 -163
- data/test/test_helper.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5e215e499369c78f12bd5d6a0fec866176d1312dbeb439f7c3be80eb5e13edd
|
4
|
+
data.tar.gz: 43b213fdec1a20d90b49a6977b8901188bf148eb39ed37392f2236c116f1ce19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0f2722a36ff8497bac7c8b2b60ba7fe26d437be2af76808ea6ba9948a4d4e2f7072bfc505b7e91a612f48d0ace2dbdf2df972fa32eca8f28a118c7548004dc1
|
7
|
+
data.tar.gz: 4dc6709949e06c88e1f3d5d99bacfbe74a8f9452fb498aa299e411d011cd4f167e373fd16933ae882881319634efc98db3d23faf98bbee3d07babf4ba8a2dfe3
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rake
|
4
|
+
- rubocop-rspec
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
TargetRubyVersion: 2.5
|
8
|
+
NewCops: disable
|
9
|
+
Exclude:
|
10
|
+
- bin/*
|
11
|
+
|
12
|
+
Layout/ClassStructure:
|
13
|
+
Enabled: true
|
14
|
+
Categories:
|
15
|
+
module_inclusion:
|
16
|
+
- include
|
17
|
+
- prepend
|
18
|
+
- extend
|
19
|
+
ExpectedOrder:
|
20
|
+
- module_inclusion
|
21
|
+
- public_class_methods
|
22
|
+
- initializer
|
23
|
+
- public_methods
|
24
|
+
- protected_methods
|
25
|
+
- private_methods
|
26
|
+
|
27
|
+
Layout/DotPosition:
|
28
|
+
EnforcedStyle: trailing
|
29
|
+
|
30
|
+
Layout/LineLength:
|
31
|
+
Enabled: false
|
32
|
+
Max: 120
|
33
|
+
AllowHeredoc: true
|
34
|
+
AllowURI: true
|
35
|
+
URISchemes: http, https
|
36
|
+
|
37
|
+
Layout/MultilineMethodCallIndentation:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Layout/SpaceInsideHashLiteralBraces:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Metrics:
|
44
|
+
Enabled: true
|
45
|
+
|
46
|
+
Metrics/AbcSize:
|
47
|
+
Max: 20
|
48
|
+
|
49
|
+
Metrics/BlockLength:
|
50
|
+
Exclude:
|
51
|
+
- 'Rakefile'
|
52
|
+
- '**/*.rake'
|
53
|
+
- 'spec/**/*.rb'
|
54
|
+
- 'test/**/*.rb'
|
55
|
+
IgnoredMethods: ['included', 'namespace']
|
56
|
+
|
57
|
+
Metrics/ClassLength:
|
58
|
+
Exclude:
|
59
|
+
- 'Rakefile'
|
60
|
+
- 'spec/**/*.rb'
|
61
|
+
- 'test/**/*.rb'
|
62
|
+
|
63
|
+
Metrics/MethodLength:
|
64
|
+
CountComments: false # count full line comments?
|
65
|
+
Max: 15
|
66
|
+
|
67
|
+
Naming/MemoizedInstanceVariableName:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
RSpec/DescribeClass:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Style/BlockComments:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Style/Documentation:
|
77
|
+
Enabled: false
|
78
|
+
|
79
|
+
Style/DocumentationMethod:
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
Style/FrozenStringLiteralComment:
|
83
|
+
EnforcedStyle: always
|
84
|
+
Enabled: true
|
85
|
+
|
86
|
+
Style/GuardClause:
|
87
|
+
Enabled: false
|
88
|
+
|
89
|
+
Style/MultilineBlockChain:
|
90
|
+
Enabled: false
|
91
|
+
|
92
|
+
# Technically this performs better, and I got no problem with it.
|
93
|
+
Style/ParallelAssignment:
|
94
|
+
Enabled: false
|
95
|
+
|
96
|
+
Style/RedundantSelf:
|
97
|
+
Enabled: false
|
98
|
+
|
99
|
+
Style/TrailingCommaInArrayLiteral:
|
100
|
+
Enabled: false
|
101
|
+
|
102
|
+
Style/TrailingCommaInHashLiteral:
|
103
|
+
Enabled: false
|
104
|
+
|
105
|
+
Style/WhenThen:
|
106
|
+
Enabled: true
|
107
|
+
|
108
|
+
Style/WordArray:
|
109
|
+
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.6
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,25 +1,70 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
casegen (
|
4
|
+
casegen (3.0.0)
|
5
5
|
tablesmith
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
ast (2.4.2)
|
11
|
+
diff-lcs (1.4.4)
|
12
|
+
parallel (1.20.1)
|
13
|
+
parser (3.0.0.0)
|
14
|
+
ast (~> 2.4.1)
|
15
|
+
rainbow (3.0.0)
|
16
|
+
rake (13.0.3)
|
17
|
+
regexp_parser (2.0.3)
|
18
|
+
rexml (3.2.5)
|
19
|
+
rspec (3.10.0)
|
20
|
+
rspec-core (~> 3.10.0)
|
21
|
+
rspec-expectations (~> 3.10.0)
|
22
|
+
rspec-mocks (~> 3.10.0)
|
23
|
+
rspec-core (3.10.1)
|
24
|
+
rspec-support (~> 3.10.0)
|
25
|
+
rspec-expectations (3.10.1)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.10.0)
|
28
|
+
rspec-mocks (3.10.2)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.10.0)
|
31
|
+
rspec-support (3.10.2)
|
32
|
+
rubocop (1.9.1)
|
33
|
+
parallel (~> 1.10)
|
34
|
+
parser (>= 3.0.0.0)
|
35
|
+
rainbow (>= 2.2.2, < 4.0)
|
36
|
+
regexp_parser (>= 1.8, < 3.0)
|
37
|
+
rexml
|
38
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
39
|
+
ruby-progressbar (~> 1.7)
|
40
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
41
|
+
rubocop-ast (1.4.1)
|
42
|
+
parser (>= 2.7.1.5)
|
43
|
+
rubocop-performance (1.9.2)
|
44
|
+
rubocop (>= 0.90.0, < 2.0)
|
45
|
+
rubocop-ast (>= 0.4.0)
|
46
|
+
rubocop-rake (0.5.1)
|
47
|
+
rubocop
|
48
|
+
rubocop-rspec (2.2.0)
|
49
|
+
rubocop (~> 1.0)
|
50
|
+
rubocop-ast (>= 1.1.0)
|
51
|
+
ruby-progressbar (1.11.0)
|
52
|
+
tablesmith (0.6.2)
|
13
53
|
text-table
|
14
54
|
text-table (1.2.4)
|
55
|
+
unicode-display_width (2.0.0)
|
15
56
|
|
16
57
|
PLATFORMS
|
17
58
|
ruby
|
18
59
|
|
19
60
|
DEPENDENCIES
|
20
61
|
casegen!
|
21
|
-
minitest
|
22
62
|
rake
|
63
|
+
rspec
|
64
|
+
rubocop
|
65
|
+
rubocop-performance
|
66
|
+
rubocop-rake
|
67
|
+
rubocop-rspec
|
23
68
|
|
24
69
|
BUNDLED WITH
|
25
|
-
|
70
|
+
2.2.27
|
data/README.md
CHANGED
@@ -1,132 +1,23 @@
|
|
1
1
|
# CaseGen
|
2
2
|
|
3
|
-
CaseGen is a small Ruby
|
4
|
-
|
3
|
+
CaseGen is a small Ruby gem for generating combinations of variables, optionally
|
4
|
+
restricted by a set of rules.
|
5
5
|
|
6
6
|
## Usage
|
7
7
|
|
8
|
-
|
8
|
+
The [`doc`](/doc) folder has a few examples demonstrating how you can use this
|
9
|
+
gem. The [`specs`](/spec) also demonstrate various input and output options.
|
9
10
|
|
10
|
-
sets
|
11
|
-
------------
|
12
|
-
payment: Credit, Check, Online Bank
|
13
|
-
amount: 100, 1,000, 10,000
|
14
|
-
shipping: Ground, Air
|
15
|
-
ship to country: US, Outside US
|
16
|
-
bill to country: US, Outside US
|
17
|
-
|
18
|
-
|
19
|
-
rules(sets)
|
20
|
-
---------------------------
|
21
|
-
exclude shipping = Ground AND ship to country = Outside US
|
22
|
-
Our ground shipper will only ship things within the US.
|
23
|
-
|
24
|
-
exclude payment = Check AND bill to country == Outside US
|
25
|
-
Our bank will not accept checks written from banks outside the US.
|
26
|
-
|
27
|
-
exclude payment = Online Bank AND amount == 1,000
|
28
|
-
exclude payment = Online Bank AND amount == 10,000
|
29
|
-
While the online bank will process amounts > $1,000, we've experienced
|
30
|
-
occasional problems with their services and have had to write off some
|
31
|
-
transactions, so we no longer allow this payment option for amounts greater
|
32
|
-
than $1,000
|
33
|
-
|
34
|
-
exclude ship to country = US AND bill to country = Outside US
|
35
|
-
If we're shipping to the US, billing party cannot be outside US
|
36
|
-
|
37
|
-
|
38
|
-
console(rules)
|
39
|
-
----------
|
40
11
|
|
12
|
+
## Breaking Changes in 3.0
|
41
13
|
|
42
|
-
|
43
|
-
|
44
|
-
+-------------+--------+----------+-----------------+-----------------+
|
45
|
-
| payment | amount | shipping | ship to country | bill to country |
|
46
|
-
+-------------+--------+----------+-----------------+-----------------+
|
47
|
-
| Credit | 100 | Ground | US | US |
|
48
|
-
| Credit | 100 | Air | US | US |
|
49
|
-
| Credit | 100 | Air | Outside US | US |
|
50
|
-
| Credit | 100 | Air | Outside US | Outside US |
|
51
|
-
| Credit | 1,000 | Ground | US | US |
|
52
|
-
| Credit | 1,000 | Air | US | US |
|
53
|
-
| Credit | 1,000 | Air | Outside US | US |
|
54
|
-
| Credit | 1,000 | Air | Outside US | Outside US |
|
55
|
-
| Credit | 10,000 | Ground | US | US |
|
56
|
-
| Credit | 10,000 | Air | US | US |
|
57
|
-
| Credit | 10,000 | Air | Outside US | US |
|
58
|
-
| Credit | 10,000 | Air | Outside US | Outside US |
|
59
|
-
| Check | 100 | Ground | US | US |
|
60
|
-
| Check | 100 | Air | US | US |
|
61
|
-
| Check | 100 | Air | Outside US | US |
|
62
|
-
| Check | 1,000 | Ground | US | US |
|
63
|
-
| Check | 1,000 | Air | US | US |
|
64
|
-
| Check | 1,000 | Air | Outside US | US |
|
65
|
-
| Check | 10,000 | Ground | US | US |
|
66
|
-
| Check | 10,000 | Air | US | US |
|
67
|
-
| Check | 10,000 | Air | Outside US | US |
|
68
|
-
| Online Bank | 100 | Ground | US | US |
|
69
|
-
| Online Bank | 100 | Air | US | US |
|
70
|
-
| Online Bank | 100 | Air | Outside US | US |
|
71
|
-
| Online Bank | 100 | Air | Outside US | Outside US |
|
72
|
-
+-------------+--------+----------+-----------------+-----------------+
|
73
|
-
|
74
|
-
exclude shipping = Ground AND ship to country = Outside US
|
75
|
-
Our ground shipper will only ship things within the US.
|
76
|
-
|
77
|
-
exclude payment = Check AND bill to country == Outside US
|
78
|
-
Our bank will not accept checks written from banks outside the US.
|
79
|
-
|
80
|
-
exclude payment = Online Bank AND amount == 1,000
|
81
|
-
|
82
|
-
exclude payment = Online Bank AND amount == 10,000
|
83
|
-
While the online bank will process amounts > $1,000, we've experienced
|
84
|
-
occasional problems with their services and have had to write off some
|
85
|
-
transactions, so we no longer allow this payment option for amounts greater
|
86
|
-
than $1,000
|
87
|
-
|
88
|
-
exclude ship to country = US AND bill to country = Outside US
|
89
|
-
If we're shipping to the US, billing party cannot be outside US
|
90
|
-
|
91
|
-
If you pull the source locally, you can execute this:
|
14
|
+
Versions 1 and 2 were based on a DSL format. Version 3.0 removed the DSL
|
15
|
+
to just use plain Ruby.
|
92
16
|
|
93
|
-
casegen doc/cart.sample.txt
|
94
|
-
|
95
17
|
## FAQ
|
96
18
|
|
97
|
-
How can I use this lib inside another Ruby file, instead of having a separate
|
98
|
-
input file?
|
99
|
-
|
100
|
-
sample.rb:
|
101
|
-
|
102
|
-
require "bundler/inline"
|
103
|
-
|
104
|
-
gemfile do
|
105
|
-
source "https://rubygems.org"
|
106
|
-
gem "casegen", "~> 2.0"
|
107
|
-
end
|
108
|
-
|
109
|
-
require 'casegen'
|
110
|
-
|
111
|
-
CLabs::CaseGen::CaseGen.new(DATA.read)
|
112
|
-
|
113
|
-
__END__
|
114
|
-
|
115
|
-
sets
|
116
|
-
----
|
117
|
-
a: 1, 2
|
118
|
-
b: 3, 4
|
119
|
-
|
120
|
-
rules(sets)
|
121
|
-
-----------
|
122
|
-
exclude a = 1
|
123
|
-
|
124
|
-
console(rules)
|
125
|
-
--------------
|
126
|
-
|
127
|
-
|
128
19
|
### Are there other tools similar to CaseGen?
|
129
20
|
|
130
|
-
<a href="
|
131
|
-
Another is <a href="
|
132
|
-
Bach.
|
21
|
+
<a href="https://github.com/cornutum/tcases">tcases</a> is one to check out.
|
22
|
+
Another is <a href="https://www.satisfice.com/download/allpairs">AllPairs</a> by
|
23
|
+
James Bach.
|
data/Rakefile
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
4
|
|
3
|
-
require '
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
require 'rubocop/rake_task'
|
4
10
|
|
5
|
-
|
6
|
-
Rake::TestTask.new do |t|
|
7
|
-
t.pattern = 'test/**/*test*.rb'
|
8
|
-
# t.verbose = true
|
9
|
-
end
|
11
|
+
RuboCop::RakeTask.new
|
10
12
|
|
11
|
-
task default: :
|
13
|
+
task default: [:spec, 'rubocop:auto_correct']
|
data/bin/casegen
CHANGED
data/casegen.gemspec
CHANGED
@@ -1,26 +1,30 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/casegen'
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = 'casegen'
|
7
|
-
gem.version =
|
7
|
+
gem.version = '3.0.0'
|
8
8
|
gem.authors = ['chrismo']
|
9
9
|
gem.email = 'chrismo@clabs.org'
|
10
|
-
gem.description = 'Simple
|
11
|
-
gem.summary = 'Simple
|
10
|
+
gem.description = 'Simple tool to generate use cases restricted by sets of rules'
|
11
|
+
gem.summary = 'Simple tool to generate use cases restricted by sets of rules'
|
12
12
|
gem.homepage = 'https://github.com/chrismo/casegen'
|
13
13
|
gem.license = 'MIT'
|
14
14
|
|
15
|
-
gem.files = `git ls-files`.split(
|
15
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
16
|
gem.executables = 'casegen'
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
-
gem.required_ruby_version = '~> 2.
|
20
|
+
gem.required_ruby_version = '~> 2.5'
|
21
21
|
|
22
22
|
gem.add_dependency 'tablesmith'
|
23
23
|
|
24
|
-
gem.add_development_dependency 'minitest'
|
25
24
|
gem.add_development_dependency 'rake'
|
25
|
+
gem.add_development_dependency 'rspec'
|
26
|
+
gem.add_development_dependency 'rubocop'
|
27
|
+
gem.add_development_dependency 'rubocop-performance'
|
28
|
+
gem.add_development_dependency 'rubocop-rake'
|
29
|
+
gem.add_development_dependency 'rubocop-rspec'
|
26
30
|
end
|
data/doc/bounding_box.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/casegen'
|
4
|
+
|
5
|
+
# Presuming a 300x300 bounding box, we need images to test edge cases.
|
6
|
+
|
7
|
+
bounding_box_relation = %w[inside outside]
|
8
|
+
|
9
|
+
sets = {
|
10
|
+
width: bounding_box_relation,
|
11
|
+
height: bounding_box_relation,
|
12
|
+
aspect: %w[wide tall],
|
13
|
+
result: [:expect]
|
14
|
+
}
|
15
|
+
|
16
|
+
rules = {
|
17
|
+
exclude: [
|
18
|
+
{width: 'inside', height: 'outside', aspect: 'wide',
|
19
|
+
note: 'a narrower image cannot have a wide aspect'},
|
20
|
+
{width: 'outside', height: 'inside', aspect: 'tall',
|
21
|
+
note: 'a shorter image cannot have a tall aspect'},
|
22
|
+
],
|
23
|
+
expect: [
|
24
|
+
{width: 'inside', height: 'inside', aspect: 'wide', result: '200x100'},
|
25
|
+
{width: 'inside', height: 'inside', aspect: 'tall', result: '100x200'},
|
26
|
+
{width: 'inside', height: 'outside', aspect: 'tall', result: '100x400'},
|
27
|
+
{width: 'outside', height: 'inside', aspect: 'wide', result: '400x100'},
|
28
|
+
{width: 'outside', height: 'outside', aspect: 'wide', result: '500x400'},
|
29
|
+
{width: 'outside', height: 'outside', aspect: 'tall', result: '400x500'},
|
30
|
+
]
|
31
|
+
}
|
32
|
+
|
33
|
+
if __FILE__ == $PROGRAM_NAME
|
34
|
+
puts CaseGen.generate(sets, rules, :exclude_as_table).to_s
|
35
|
+
else
|
36
|
+
Fixtures.add(:box, sets, rules)
|
37
|
+
end
|