brutal 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brutal.rb +11 -13
- data/lib/brutal/configuration.rb +11 -32
- data/lib/brutal/file/read.rb +33 -0
- data/lib/brutal/file/write.rb +36 -0
- data/lib/brutal/yaml.rb +14 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31950aed12f6f2f8a292c6df194cbab35c832f649597df8a96f73a7852688da9
|
4
|
+
data.tar.gz: 5300bdf71607debf6de06e4ddf37e8f7c7d4104822b18784cffed24451df8f30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd76ba0d91ce4a7df5c477906970e1affb5459d2dcffa03709d6078089e95b82a0a80b372d659e6306a870b5c6f73469c6bcf95e7c8367d09f833f53941fa0de
|
7
|
+
data.tar.gz: 5cc889579792f8d836de4327eb83007c490e204016da975fdbe60792eea096d41c5906127a5210a5d2899cfc565024eede92d566ad69afe0b4f748fdbd46e8f1
|
data/lib/brutal.rb
CHANGED
@@ -2,25 +2,23 @@
|
|
2
2
|
|
3
3
|
%w[
|
4
4
|
configuration
|
5
|
+
file/read
|
6
|
+
file/write
|
5
7
|
scaffold
|
8
|
+
yaml
|
6
9
|
].each { |file_name| require_relative(File.join('brutal', file_name)) }
|
7
10
|
|
8
11
|
# The Brutal namespace
|
9
12
|
module Brutal
|
10
|
-
def self.settings
|
11
|
-
Configuration.load!
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.generate
|
15
|
-
Scaffold.new(*settings)
|
16
|
-
end
|
17
|
-
|
18
13
|
def self.generate!
|
19
|
-
|
20
|
-
|
14
|
+
yaml = File::Read.new.call
|
15
|
+
hash = Yaml.parse(yaml)
|
16
|
+
conf = Configuration.new(**hash)
|
17
|
+
ruby = Scaffold.new(conf.header,
|
18
|
+
conf.subject,
|
19
|
+
*conf.actuals,
|
20
|
+
**conf.contexts)
|
21
21
|
|
22
|
-
|
23
|
-
ensure
|
24
|
-
file.close
|
22
|
+
File::Write.new.call(ruby)
|
25
23
|
end
|
26
24
|
end
|
data/lib/brutal/configuration.rb
CHANGED
@@ -1,45 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'yaml'
|
4
|
-
|
5
3
|
module Brutal
|
6
4
|
# Brutal::Configuration
|
7
5
|
#
|
8
6
|
# @since 1.0.0
|
9
7
|
class Configuration
|
10
|
-
|
11
|
-
PATH = ::File.join(::Dir.pwd, NAME).freeze
|
12
|
-
|
13
|
-
def self.load!
|
14
|
-
new.to_a
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.file!
|
18
|
-
::YAML.load_file(PATH)
|
19
|
-
rescue ::Errno::ENOENT => _e
|
20
|
-
abort("File #{PATH} not found!")
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_reader(:header, :subject, :contexts, :actuals)
|
8
|
+
HEAD = '# Brutal test suite'
|
24
9
|
|
25
|
-
|
26
|
-
def initialize
|
27
|
-
settings = self.class.file!
|
10
|
+
attr_reader(:actuals, :contexts, :header, :subject)
|
28
11
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
raise ::TypeError, @header.inspect unless @header.is_a?(::String)
|
35
|
-
raise ::TypeError, @subject.inspect unless @subject.is_a?(::String)
|
36
|
-
raise ::TypeError, @contexts.inspect unless @contexts.is_a?(::Hash)
|
37
|
-
raise ::TypeError, @actuals.inspect unless @actuals.is_a?(::Array)
|
38
|
-
end
|
39
|
-
# rubocop:enable Metrics/AbcSize
|
12
|
+
def initialize(actuals: [], contexts: {}, header: HEAD, subject: '')
|
13
|
+
raise ::TypeError, actuals.inspect unless actuals.is_a?(::Array)
|
14
|
+
raise ::TypeError, contexts.inspect unless contexts.is_a?(::Hash)
|
15
|
+
raise ::TypeError, header.inspect unless header.is_a?(::String)
|
16
|
+
raise ::TypeError, subject.inspect unless subject.is_a?(::String)
|
40
17
|
|
41
|
-
|
42
|
-
|
18
|
+
@actuals = actuals
|
19
|
+
@contexts = contexts
|
20
|
+
@header = header
|
21
|
+
@subject = subject
|
43
22
|
end
|
44
23
|
end
|
45
24
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Brutal
|
4
|
+
# Brutal::File
|
5
|
+
#
|
6
|
+
# @since 1.1.0
|
7
|
+
module File
|
8
|
+
# Brutal::File::Read
|
9
|
+
#
|
10
|
+
# @since 1.1.0
|
11
|
+
class Read
|
12
|
+
NAME = '.brutal.yml'
|
13
|
+
|
14
|
+
attr_reader :name
|
15
|
+
|
16
|
+
def initialize(name = NAME)
|
17
|
+
@name = name
|
18
|
+
end
|
19
|
+
|
20
|
+
def call
|
21
|
+
::File.read(path)
|
22
|
+
rescue ::Errno::ENOENT => _e
|
23
|
+
abort("File #{path} not found!")
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def path
|
29
|
+
::File.join(::Dir.pwd, name)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Brutal
|
4
|
+
# Brutal::File
|
5
|
+
#
|
6
|
+
# @since 1.1.0
|
7
|
+
module File
|
8
|
+
# Brutal::File::Write
|
9
|
+
#
|
10
|
+
# @since 1.1.0
|
11
|
+
class Write
|
12
|
+
NAME = 'test.rb'
|
13
|
+
|
14
|
+
attr_reader :name
|
15
|
+
|
16
|
+
def initialize(name = NAME)
|
17
|
+
@name = name
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(scaffold)
|
21
|
+
file = ::File.open(path, 'w')
|
22
|
+
file.write(scaffold)
|
23
|
+
|
24
|
+
true
|
25
|
+
ensure
|
26
|
+
file.close
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def path
|
32
|
+
::File.join(::Dir.pwd, name)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/brutal/yaml.rb
ADDED
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.1.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: 2020-03-
|
11
|
+
date: 2020-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,7 +106,10 @@ files:
|
|
106
106
|
- bin/brutal
|
107
107
|
- lib/brutal.rb
|
108
108
|
- lib/brutal/configuration.rb
|
109
|
+
- lib/brutal/file/read.rb
|
110
|
+
- lib/brutal/file/write.rb
|
109
111
|
- lib/brutal/scaffold.rb
|
112
|
+
- lib/brutal/yaml.rb
|
110
113
|
homepage: https://github.com/fixrb/brutal
|
111
114
|
licenses:
|
112
115
|
- MIT
|
@@ -119,14 +122,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
122
|
requirements:
|
120
123
|
- - ">="
|
121
124
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
125
|
+
version: 2.6.0
|
123
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
127
|
requirements:
|
125
128
|
- - ">="
|
126
129
|
- !ruby/object:Gem::Version
|
127
130
|
version: '0'
|
128
131
|
requirements: []
|
129
|
-
rubygems_version: 3.1
|
132
|
+
rubygems_version: 3.0.1
|
130
133
|
signing_key:
|
131
134
|
specification_version: 4
|
132
135
|
summary: A code-first approach to automate the writing of unit tests.
|