brutal 1.1.0 → 1.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 +4 -4
- data/README.md +1 -1
- data/lib/brutal.rb +2 -2
- data/lib/brutal/configuration.rb +29 -3
- data/lib/brutal/scaffold.rb +15 -5
- data/lib/brutal/yaml.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98d43784db59dbf4d8263ec4730d302832e7e5edc46ebafc1a13d95935e9b697
|
4
|
+
data.tar.gz: e2d37b31d5b37387437e6ac80afb11b5b1a6d104cb677629ec3aafa9aae153af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3af04c68e89e7bdd965163066db2b99a4e3df78846ea6f33a0a89b9fe443e477376a6108a31c8b69d86d45f04459991d503f56c345b5089b7233a22b0d831bd
|
7
|
+
data.tar.gz: 55e326bf5cdcba338c63d7e57a8f75378f9869fe0f986867a86ece479850dd78745a2a568c3e0b89c8080f343e977b17d42b714e80dbbe3543b980204fd67c4d
|
data/README.md
CHANGED
@@ -133,7 +133,7 @@ __Brutal__ follows [Semantic Versioning 2.0](https://semver.org/).
|
|
133
133
|
|
134
134
|
## License
|
135
135
|
|
136
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
136
|
+
The [gem](https://rubygems.org/gems/brutal) is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
137
137
|
|
138
138
|
***
|
139
139
|
|
data/lib/brutal.rb
CHANGED
@@ -8,12 +8,12 @@
|
|
8
8
|
yaml
|
9
9
|
].each { |file_name| require_relative(File.join('brutal', file_name)) }
|
10
10
|
|
11
|
-
# The Brutal namespace
|
11
|
+
# The Brutal namespace.
|
12
12
|
module Brutal
|
13
13
|
def self.generate!
|
14
14
|
yaml = File::Read.new.call
|
15
15
|
hash = Yaml.parse(yaml)
|
16
|
-
conf = Configuration.
|
16
|
+
conf = Configuration.load(hash)
|
17
17
|
ruby = Scaffold.new(conf.header,
|
18
18
|
conf.subject,
|
19
19
|
*conf.actuals,
|
data/lib/brutal/configuration.rb
CHANGED
@@ -5,11 +5,37 @@ module Brutal
|
|
5
5
|
#
|
6
6
|
# @since 1.0.0
|
7
7
|
class Configuration
|
8
|
-
|
8
|
+
DEFAULT_ACTUALS = [].freeze
|
9
|
+
DEFAULT_CONTEXTS = {}.freeze
|
10
|
+
DEFAULT_HEAD = '# Brutal test suite'
|
11
|
+
DEFAULT_SUBJECT = ''
|
9
12
|
|
10
|
-
|
13
|
+
# Load the configuration parameters.
|
14
|
+
#
|
15
|
+
# @param params [Hash] Receive the 4 top-level section parameters.
|
16
|
+
def self.load(params)
|
17
|
+
new(
|
18
|
+
actuals: params.fetch('actuals', DEFAULT_ACTUALS),
|
19
|
+
contexts: params.fetch('contexts', DEFAULT_CONTEXTS),
|
20
|
+
header: params.fetch('header', DEFAULT_HEAD),
|
21
|
+
subject: params.fetch('subject', DEFAULT_SUBJECT)
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Specifies templates to challenge evaluated subjects & get results.
|
26
|
+
attr_reader :actuals
|
27
|
+
|
28
|
+
# Specifies a list of variables to populate the subject's template.
|
29
|
+
attr_reader :contexts
|
30
|
+
|
31
|
+
# Specifies the code to execute before generating the test suite.
|
32
|
+
attr_reader :header
|
33
|
+
|
34
|
+
# Specifies the template of the code to be declined across contexts.
|
35
|
+
attr_reader :subject
|
11
36
|
|
12
|
-
|
37
|
+
# Initialize a new configuration.
|
38
|
+
def initialize(actuals:, contexts:, header:, subject:)
|
13
39
|
raise ::TypeError, actuals.inspect unless actuals.is_a?(::Array)
|
14
40
|
raise ::TypeError, contexts.inspect unless contexts.is_a?(::Hash)
|
15
41
|
raise ::TypeError, header.inspect unless header.is_a?(::String)
|
data/lib/brutal/scaffold.rb
CHANGED
@@ -5,9 +5,19 @@ module Brutal
|
|
5
5
|
#
|
6
6
|
# @since 1.0.0
|
7
7
|
class Scaffold
|
8
|
-
|
8
|
+
# Specifies templates to challenge evaluated subjects & get results.
|
9
|
+
attr_reader :actuals
|
9
10
|
|
10
|
-
#
|
11
|
+
# Specifies a list of variables to populate the subject's template.
|
12
|
+
attr_reader :contexts
|
13
|
+
|
14
|
+
# Specifies the code to execute before generating the test suite.
|
15
|
+
attr_reader :header
|
16
|
+
|
17
|
+
# Specifies the template of the code to be declined across contexts.
|
18
|
+
attr_reader :subject
|
19
|
+
|
20
|
+
# Initialize a new scaffold generator.
|
11
21
|
def initialize(header, subject, *actuals, **contexts)
|
12
22
|
warn('Empty subject!') if subject.empty?
|
13
23
|
warn('Empty actual values!') if actuals.empty?
|
@@ -28,13 +38,13 @@ module Brutal
|
|
28
38
|
object.strip
|
29
39
|
end
|
30
40
|
|
31
|
-
# Return a string representation
|
41
|
+
# Return a string representation.
|
32
42
|
#
|
33
43
|
# @return [String]
|
34
44
|
#
|
35
45
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
36
46
|
def to_s
|
37
|
-
header.chomp
|
47
|
+
"#{header.chomp}\n#{blank_line}" + combinations_values.map do |values|
|
38
48
|
attributes = context_names.each_with_index.inject({}) do |h, (name, i)|
|
39
49
|
h.merge(name.to_sym => inspect(values.fetch(i)))
|
40
50
|
end
|
@@ -75,7 +85,7 @@ module Brutal
|
|
75
85
|
end
|
76
86
|
|
77
87
|
def combinations_values
|
78
|
-
Array(contexts_values[0]).product(*Array(contexts_values[1
|
88
|
+
Array(contexts_values[0]).product(*Array(contexts_values[1..]))
|
79
89
|
end
|
80
90
|
end
|
81
91
|
end
|
data/lib/brutal/yaml.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brutal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,14 +122,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
122
|
requirements:
|
123
123
|
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 2.
|
125
|
+
version: 2.7.0
|
126
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
|
-
rubygems_version: 3.
|
132
|
+
rubygems_version: 3.1.2
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: A code-first approach to automate the writing of unit tests.
|