brutal 1.2.1 → 1.3.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/LICENSE.md +1 -1
- data/README.md +14 -12
- data/bin/brutal +1 -1
- data/lib/brutal/file/read.rb +1 -6
- data/lib/brutal/file/write.rb +1 -6
- data/lib/brutal/file.rb +20 -0
- data/lib/brutal/scaffold.rb +3 -3
- data/lib/brutal/yaml.rb +10 -0
- data/lib/brutal.rb +15 -7
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f98c650c2e97438b0cedcebdb5b01da84af29f7cbc0c324a4b3416b3da68114
|
4
|
+
data.tar.gz: 696e8e96639a62e046f138c10f3d5181a3265c90bb10306481bc0d2b2fd9d3d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6279a503eba6120d29cd8855fab48c725f46671bd8efa7d6fd73158e68d0cf6de9fed01e4f5ae83cf04417b0551ab9598d6c615d25b164fbefec1d3b7ce262f
|
7
|
+
data.tar.gz: 8aebd74fd0a2c9bda6b418980dd627645f9b1c85f3e92e753ba2c03bd642d0dd63393dfd8923ef25e470269e3b6645fa3428a54cd7b2128ca53ee2b5c9e5de63
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Brutal 💎🔨
|
2
2
|
|
3
|
-
[](https://github.com/fixrb/brutal/
|
3
|
+
[](https://github.com/fixrb/brutal/tags)
|
4
4
|
[](https://rubydoc.info/github/fixrb/brutal/main)
|
5
|
-
[](https://github.com/fixrb/brutal/actions?query=workflow%3Aruby+branch%3Amain)
|
6
6
|
[](https://github.com/fixrb/brutal/actions?query=workflow%3Arubocop+branch%3Amain)
|
7
7
|
[](https://github.com/fixrb/brutal/raw/main/LICENSE.md)
|
8
8
|
|
@@ -59,18 +59,22 @@ Just type `brutal` in a Ruby project's folder and watch the magic happen.
|
|
59
59
|
|
60
60
|
## Usage
|
61
61
|
|
62
|
-
|
63
|
-
|
62
|
+
__Brutal__ needs a configuration file, it's a kind of manifest, or a meta-spec if you prefer.
|
63
|
+
This file is composed of 4 top-level sections:
|
64
64
|
|
65
65
|
* `header` - Specifies the code to execute before generating the test suite.
|
66
66
|
* `subject` - Specifies the template of the code to be declined across contexts.
|
67
67
|
* `contexts` - Specifies a list of variables to populate the subject's template.
|
68
68
|
* `actuals` - Specifies templates to challenge evaluated subjects & get results.
|
69
69
|
|
70
|
+
By default, this file is called `.brutal.yml`, but it would be possible to call it differently by passing it as an argument to the brutal command.
|
71
|
+
|
72
|
+
Currently, only the YAML format is supported.
|
73
|
+
|
70
74
|
### Getting started
|
71
75
|
|
72
|
-
1. Create a
|
73
|
-
The following example
|
76
|
+
1. Create a `.brutal.yml` file in your application's root directory.
|
77
|
+
The following example `.brutal.yml` defines the shape of a Hello test suite:
|
74
78
|
|
75
79
|
```yaml
|
76
80
|
---
|
@@ -145,9 +149,7 @@ The [gem](https://rubygems.org/gems/brutal) is available as open source under th
|
|
145
149
|
|
146
150
|
***
|
147
151
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
alt="Sashite" /></a>
|
153
|
-
</p>
|
152
|
+
This project is sponsored by [Sashité](https://github.com/sashite/):
|
153
|
+
|
154
|
+

|
155
|
+

|
data/bin/brutal
CHANGED
data/lib/brutal/file/read.rb
CHANGED
@@ -1,19 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Brutal
|
4
|
-
# Brutal::File
|
5
|
-
#
|
6
|
-
# @since 1.1.0
|
7
4
|
module File
|
8
5
|
# Brutal::File::Read
|
9
6
|
#
|
10
7
|
# @since 1.1.0
|
11
8
|
class Read
|
12
|
-
NAME = ".brutal.yml"
|
13
|
-
|
14
9
|
attr_reader :name
|
15
10
|
|
16
|
-
def initialize(name
|
11
|
+
def initialize(name)
|
17
12
|
@name = name
|
18
13
|
end
|
19
14
|
|
data/lib/brutal/file/write.rb
CHANGED
@@ -1,19 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Brutal
|
4
|
-
# Brutal::File
|
5
|
-
#
|
6
|
-
# @since 1.1.0
|
7
4
|
module File
|
8
5
|
# Brutal::File::Write
|
9
6
|
#
|
10
7
|
# @since 1.1.0
|
11
8
|
class Write
|
12
|
-
NAME = "test.rb"
|
13
|
-
|
14
9
|
attr_reader :name
|
15
10
|
|
16
|
-
def initialize(name
|
11
|
+
def initialize(name)
|
17
12
|
@name = name
|
18
13
|
end
|
19
14
|
|
data/lib/brutal/file.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
%w[
|
4
|
+
read
|
5
|
+
write
|
6
|
+
].each { |filename| require_relative(File.join("file", filename)) }
|
7
|
+
|
8
|
+
module Brutal
|
9
|
+
# Brutal::File
|
10
|
+
module File
|
11
|
+
DEFAULT_CONFIG_FILENAME = ".brutal.yml"
|
12
|
+
DEFAULT_GENERATED_FILENAME = "test.rb"
|
13
|
+
|
14
|
+
def self.generated_filename(filename)
|
15
|
+
return DEFAULT_GENERATED_FILENAME if filename == DEFAULT_CONFIG_FILENAME
|
16
|
+
|
17
|
+
filename.gsub(/.[^.]+\z/, ".rb")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/brutal/scaffold.rb
CHANGED
@@ -51,7 +51,7 @@ module Brutal
|
|
51
51
|
|
52
52
|
string = <<~CODE
|
53
53
|
actual = begin
|
54
|
-
#{actual_str.gsub(/^/,
|
54
|
+
#{actual_str.gsub(/^/, ' ')}
|
55
55
|
end
|
56
56
|
|
57
57
|
CODE
|
@@ -68,8 +68,8 @@ module Brutal
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def blank_line
|
71
|
-
"\n"
|
72
|
-
"# #{
|
71
|
+
"\n" \
|
72
|
+
"# #{'-' * 78}\n" \
|
73
73
|
"\n"
|
74
74
|
end
|
75
75
|
|
data/lib/brutal/yaml.rb
CHANGED
@@ -7,8 +7,18 @@ module Brutal
|
|
7
7
|
#
|
8
8
|
# @since 1.1.0
|
9
9
|
module Yaml
|
10
|
+
FILENAME_EXTENSIONS = %w[
|
11
|
+
yaml
|
12
|
+
yml
|
13
|
+
].freeze
|
14
|
+
|
10
15
|
def self.parse(yaml)
|
11
16
|
::YAML.safe_load(yaml, symbolize_names: false)
|
12
17
|
end
|
18
|
+
|
19
|
+
def self.parse?(filename)
|
20
|
+
filename_extension = filename.split(".")[1..][-1]
|
21
|
+
FILENAME_EXTENSIONS.include?(filename_extension)
|
22
|
+
end
|
13
23
|
end
|
14
24
|
end
|
data/lib/brutal.rb
CHANGED
@@ -2,17 +2,23 @@
|
|
2
2
|
|
3
3
|
%w[
|
4
4
|
configuration
|
5
|
-
file
|
6
|
-
file/write
|
5
|
+
file
|
7
6
|
scaffold
|
8
7
|
yaml
|
9
|
-
].each { |
|
8
|
+
].each { |filename| require_relative(File.join("brutal", filename)) }
|
10
9
|
|
11
10
|
# The Brutal namespace.
|
12
11
|
module Brutal
|
13
|
-
def self.generate!
|
14
|
-
|
15
|
-
|
12
|
+
def self.generate!(filename)
|
13
|
+
file = File::Read.new(filename).call
|
14
|
+
|
15
|
+
hash = if Yaml.parse?(filename)
|
16
|
+
Yaml.parse(file)
|
17
|
+
else
|
18
|
+
raise ::ArgumentError, "Unrecognized extension. " \
|
19
|
+
"Impossible to parse #{filename.inspect}."
|
20
|
+
end
|
21
|
+
|
16
22
|
conf = Configuration.load(hash)
|
17
23
|
|
18
24
|
ruby = Scaffold.new(conf.header,
|
@@ -20,6 +26,8 @@ module Brutal
|
|
20
26
|
*conf.actuals,
|
21
27
|
**conf.contexts)
|
22
28
|
|
23
|
-
File
|
29
|
+
new_filename = File.generated_filename(filename)
|
30
|
+
|
31
|
+
File::Write.new(new_filename).call(ruby)
|
24
32
|
end
|
25
33
|
end
|
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop-gitlab-security
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rubocop-md
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,6 +148,7 @@ files:
|
|
134
148
|
- bin/brutal
|
135
149
|
- lib/brutal.rb
|
136
150
|
- lib/brutal/configuration.rb
|
151
|
+
- lib/brutal/file.rb
|
137
152
|
- lib/brutal/file/read.rb
|
138
153
|
- lib/brutal/file/write.rb
|
139
154
|
- lib/brutal/scaffold.rb
|