g2_command 0.3.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +84 -0
- data/.github/config/rubocop_linter_action.yml +17 -0
- data/.github/workflows/linters.yml +17 -0
- data/.rubocop.yml +8 -39
- data/.ruby-version +1 -0
- data/.tool-versions +1 -1
- data/Appraisals +13 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +92 -75
- data/README.md +2 -2
- data/g2_command.gemspec +2 -2
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/rails_5.1.gemfile +16 -0
- data/gemfiles/rails_5.1.gemfile.lock +201 -0
- data/gemfiles/rails_5.2.gemfile +16 -0
- data/gemfiles/rails_5.2.gemfile.lock +209 -0
- data/gemfiles/rails_6.0.gemfile +15 -0
- data/gemfiles/rails_6.0.gemfile.lock +224 -0
- data/lib/command.rb +7 -7
- data/lib/command/failure.rb +12 -0
- data/lib/command/input_middleware/symbolizer.rb +1 -1
- data/lib/command/version.rb +1 -1
- data/lib/gem_ext/active_model/errors.rb +10 -0
- metadata +25 -12
- data/.github/workflows/ruby.yml +0 -26
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal"
|
6
|
+
gem "fivemat"
|
7
|
+
gem "pry"
|
8
|
+
gem "rails", "6.0.3"
|
9
|
+
gem "rake", "~> 12.0"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "rspec_junit_formatter"
|
12
|
+
gem "rubocop-g2"
|
13
|
+
gem "simplecov", "0.16.1"
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -0,0 +1,224 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
g2_command (2.2.0)
|
5
|
+
activemodel (>= 5.0, < 7)
|
6
|
+
activesupport (>= 5.0, < 7)
|
7
|
+
dry-initializer (~> 3.0)
|
8
|
+
dry-monads (~> 1.3)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actioncable (6.0.3)
|
14
|
+
actionpack (= 6.0.3)
|
15
|
+
nio4r (~> 2.0)
|
16
|
+
websocket-driver (>= 0.6.1)
|
17
|
+
actionmailbox (6.0.3)
|
18
|
+
actionpack (= 6.0.3)
|
19
|
+
activejob (= 6.0.3)
|
20
|
+
activerecord (= 6.0.3)
|
21
|
+
activestorage (= 6.0.3)
|
22
|
+
activesupport (= 6.0.3)
|
23
|
+
mail (>= 2.7.1)
|
24
|
+
actionmailer (6.0.3)
|
25
|
+
actionpack (= 6.0.3)
|
26
|
+
actionview (= 6.0.3)
|
27
|
+
activejob (= 6.0.3)
|
28
|
+
mail (~> 2.5, >= 2.5.4)
|
29
|
+
rails-dom-testing (~> 2.0)
|
30
|
+
actionpack (6.0.3)
|
31
|
+
actionview (= 6.0.3)
|
32
|
+
activesupport (= 6.0.3)
|
33
|
+
rack (~> 2.0, >= 2.0.8)
|
34
|
+
rack-test (>= 0.6.3)
|
35
|
+
rails-dom-testing (~> 2.0)
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
37
|
+
actiontext (6.0.3)
|
38
|
+
actionpack (= 6.0.3)
|
39
|
+
activerecord (= 6.0.3)
|
40
|
+
activestorage (= 6.0.3)
|
41
|
+
activesupport (= 6.0.3)
|
42
|
+
nokogiri (>= 1.8.5)
|
43
|
+
actionview (6.0.3)
|
44
|
+
activesupport (= 6.0.3)
|
45
|
+
builder (~> 3.1)
|
46
|
+
erubi (~> 1.4)
|
47
|
+
rails-dom-testing (~> 2.0)
|
48
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
49
|
+
activejob (6.0.3)
|
50
|
+
activesupport (= 6.0.3)
|
51
|
+
globalid (>= 0.3.6)
|
52
|
+
activemodel (6.0.3)
|
53
|
+
activesupport (= 6.0.3)
|
54
|
+
activerecord (6.0.3)
|
55
|
+
activemodel (= 6.0.3)
|
56
|
+
activesupport (= 6.0.3)
|
57
|
+
activestorage (6.0.3)
|
58
|
+
actionpack (= 6.0.3)
|
59
|
+
activejob (= 6.0.3)
|
60
|
+
activerecord (= 6.0.3)
|
61
|
+
marcel (~> 0.3.1)
|
62
|
+
activesupport (6.0.3)
|
63
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
64
|
+
i18n (>= 0.7, < 2)
|
65
|
+
minitest (~> 5.1)
|
66
|
+
tzinfo (~> 1.1)
|
67
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
68
|
+
appraisal (2.3.0)
|
69
|
+
bundler
|
70
|
+
rake
|
71
|
+
thor (>= 0.14.0)
|
72
|
+
ast (2.4.1)
|
73
|
+
builder (3.2.4)
|
74
|
+
coderay (1.1.3)
|
75
|
+
concurrent-ruby (1.1.7)
|
76
|
+
crass (1.0.6)
|
77
|
+
diff-lcs (1.4.4)
|
78
|
+
docile (1.3.2)
|
79
|
+
dry-core (0.4.9)
|
80
|
+
concurrent-ruby (~> 1.0)
|
81
|
+
dry-equalizer (0.3.0)
|
82
|
+
dry-initializer (3.0.4)
|
83
|
+
dry-monads (1.3.5)
|
84
|
+
concurrent-ruby (~> 1.0)
|
85
|
+
dry-core (~> 0.4, >= 0.4.4)
|
86
|
+
dry-equalizer
|
87
|
+
erubi (1.9.0)
|
88
|
+
fivemat (1.3.7)
|
89
|
+
globalid (0.4.2)
|
90
|
+
activesupport (>= 4.2.0)
|
91
|
+
i18n (1.8.5)
|
92
|
+
concurrent-ruby (~> 1.0)
|
93
|
+
json (2.3.1)
|
94
|
+
loofah (2.7.0)
|
95
|
+
crass (~> 1.0.2)
|
96
|
+
nokogiri (>= 1.5.9)
|
97
|
+
mail (2.7.1)
|
98
|
+
mini_mime (>= 0.1.1)
|
99
|
+
marcel (0.3.3)
|
100
|
+
mimemagic (~> 0.3.2)
|
101
|
+
method_source (1.0.0)
|
102
|
+
mimemagic (0.3.5)
|
103
|
+
mini_mime (1.0.2)
|
104
|
+
mini_portile2 (2.4.0)
|
105
|
+
minitest (5.14.2)
|
106
|
+
nio4r (2.5.4)
|
107
|
+
nokogiri (1.10.10)
|
108
|
+
mini_portile2 (~> 2.4.0)
|
109
|
+
parallel (1.19.2)
|
110
|
+
parser (2.7.2.0)
|
111
|
+
ast (~> 2.4.1)
|
112
|
+
pry (0.13.1)
|
113
|
+
coderay (~> 1.1)
|
114
|
+
method_source (~> 1.0)
|
115
|
+
rack (2.2.3)
|
116
|
+
rack-test (1.1.0)
|
117
|
+
rack (>= 1.0, < 3)
|
118
|
+
rails (6.0.3)
|
119
|
+
actioncable (= 6.0.3)
|
120
|
+
actionmailbox (= 6.0.3)
|
121
|
+
actionmailer (= 6.0.3)
|
122
|
+
actionpack (= 6.0.3)
|
123
|
+
actiontext (= 6.0.3)
|
124
|
+
actionview (= 6.0.3)
|
125
|
+
activejob (= 6.0.3)
|
126
|
+
activemodel (= 6.0.3)
|
127
|
+
activerecord (= 6.0.3)
|
128
|
+
activestorage (= 6.0.3)
|
129
|
+
activesupport (= 6.0.3)
|
130
|
+
bundler (>= 1.3.0)
|
131
|
+
railties (= 6.0.3)
|
132
|
+
sprockets-rails (>= 2.0.0)
|
133
|
+
rails-dom-testing (2.0.3)
|
134
|
+
activesupport (>= 4.2.0)
|
135
|
+
nokogiri (>= 1.6)
|
136
|
+
rails-html-sanitizer (1.3.0)
|
137
|
+
loofah (~> 2.3)
|
138
|
+
railties (6.0.3)
|
139
|
+
actionpack (= 6.0.3)
|
140
|
+
activesupport (= 6.0.3)
|
141
|
+
method_source
|
142
|
+
rake (>= 0.8.7)
|
143
|
+
thor (>= 0.20.3, < 2.0)
|
144
|
+
rainbow (3.0.0)
|
145
|
+
rake (12.3.3)
|
146
|
+
regexp_parser (1.8.2)
|
147
|
+
rexml (3.2.4)
|
148
|
+
rspec (3.9.0)
|
149
|
+
rspec-core (~> 3.9.0)
|
150
|
+
rspec-expectations (~> 3.9.0)
|
151
|
+
rspec-mocks (~> 3.9.0)
|
152
|
+
rspec-core (3.9.3)
|
153
|
+
rspec-support (~> 3.9.3)
|
154
|
+
rspec-expectations (3.9.3)
|
155
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
156
|
+
rspec-support (~> 3.9.0)
|
157
|
+
rspec-mocks (3.9.1)
|
158
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
159
|
+
rspec-support (~> 3.9.0)
|
160
|
+
rspec-support (3.9.4)
|
161
|
+
rspec_junit_formatter (0.4.1)
|
162
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
163
|
+
rubocop (0.93.1)
|
164
|
+
parallel (~> 1.10)
|
165
|
+
parser (>= 2.7.1.5)
|
166
|
+
rainbow (>= 2.2.2, < 4.0)
|
167
|
+
regexp_parser (>= 1.8)
|
168
|
+
rexml
|
169
|
+
rubocop-ast (>= 0.6.0)
|
170
|
+
ruby-progressbar (~> 1.7)
|
171
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
172
|
+
rubocop-ast (1.1.0)
|
173
|
+
parser (>= 2.7.1.5)
|
174
|
+
rubocop-g2 (1.2.1)
|
175
|
+
rubocop (>= 0.82)
|
176
|
+
rubocop-rails (>= 2.5)
|
177
|
+
rubocop-rspec (>= 1.39)
|
178
|
+
rubocop-rails (2.8.1)
|
179
|
+
activesupport (>= 4.2.0)
|
180
|
+
rack (>= 1.1)
|
181
|
+
rubocop (>= 0.87.0)
|
182
|
+
rubocop-rspec (1.44.1)
|
183
|
+
rubocop (~> 0.87)
|
184
|
+
rubocop-ast (>= 0.7.1)
|
185
|
+
ruby-progressbar (1.10.1)
|
186
|
+
simplecov (0.16.1)
|
187
|
+
docile (~> 1.1)
|
188
|
+
json (>= 1.8, < 3)
|
189
|
+
simplecov-html (~> 0.10.0)
|
190
|
+
simplecov-html (0.10.2)
|
191
|
+
sprockets (4.0.2)
|
192
|
+
concurrent-ruby (~> 1.0)
|
193
|
+
rack (> 1, < 3)
|
194
|
+
sprockets-rails (3.2.2)
|
195
|
+
actionpack (>= 4.0)
|
196
|
+
activesupport (>= 4.0)
|
197
|
+
sprockets (>= 3.0.0)
|
198
|
+
thor (1.0.1)
|
199
|
+
thread_safe (0.3.6)
|
200
|
+
tzinfo (1.2.7)
|
201
|
+
thread_safe (~> 0.1)
|
202
|
+
unicode-display_width (1.7.0)
|
203
|
+
websocket-driver (0.7.3)
|
204
|
+
websocket-extensions (>= 0.1.0)
|
205
|
+
websocket-extensions (0.1.5)
|
206
|
+
zeitwerk (2.4.0)
|
207
|
+
|
208
|
+
PLATFORMS
|
209
|
+
ruby
|
210
|
+
|
211
|
+
DEPENDENCIES
|
212
|
+
appraisal
|
213
|
+
fivemat
|
214
|
+
g2_command!
|
215
|
+
pry
|
216
|
+
rails (= 6.0.3)
|
217
|
+
rake (~> 12.0)
|
218
|
+
rspec (~> 3.0)
|
219
|
+
rspec_junit_formatter
|
220
|
+
rubocop-g2
|
221
|
+
simplecov (= 0.16.1)
|
222
|
+
|
223
|
+
BUNDLED WITH
|
224
|
+
2.1.4
|
data/lib/command.rb
CHANGED
@@ -5,20 +5,21 @@ require 'active_model'
|
|
5
5
|
require 'dry-initializer'
|
6
6
|
require 'dry-monads'
|
7
7
|
|
8
|
+
require 'gem_ext/active_model/errors' if ActiveModel.version < Gem::Version.new('5.2')
|
9
|
+
require 'command/failure'
|
8
10
|
require 'command/input_middleware'
|
9
11
|
require 'command/interrupt'
|
10
12
|
|
11
13
|
module Command
|
12
14
|
extend ActiveSupport::Concern
|
13
15
|
|
14
|
-
# rubocop:disable Metrics/BlockLength
|
15
16
|
included do
|
16
17
|
extend Dry::Initializer
|
17
18
|
include Dry::Monads[:result]
|
18
19
|
include ActiveModel::Validations
|
19
20
|
|
20
21
|
def initialize(inputs = {})
|
21
|
-
super(Command::InputMiddleware.call(inputs))
|
22
|
+
super(**Command::InputMiddleware.call(inputs))
|
22
23
|
end
|
23
24
|
|
24
25
|
def execute
|
@@ -26,7 +27,7 @@ module Command
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def run
|
29
|
-
result = if valid?
|
30
|
+
result = if errors.empty? && valid?
|
30
31
|
begin
|
31
32
|
execute
|
32
33
|
rescue Command::Interrupt => e
|
@@ -34,13 +35,13 @@ module Command
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
|
-
errors.empty? ? Success(result) : Failure(errors)
|
38
|
+
errors.empty? ? Success(result) : Failure(Command::Failure.new(result, errors))
|
38
39
|
end
|
39
40
|
|
40
41
|
def compose(command, *args)
|
41
42
|
outcome = command.run(*args)
|
42
43
|
|
43
|
-
raise Command::Interrupt, outcome.failure if outcome.failure?
|
44
|
+
raise Command::Interrupt, outcome.failure.errors if outcome.failure?
|
44
45
|
|
45
46
|
outcome.value!
|
46
47
|
end
|
@@ -49,11 +50,10 @@ module Command
|
|
49
50
|
self.class.dry_initializer.attributes(self)
|
50
51
|
end
|
51
52
|
end
|
52
|
-
# rubocop:enable Metrics/BlockLength
|
53
53
|
|
54
54
|
class_methods do
|
55
55
|
def run(inputs = {})
|
56
|
-
new(inputs).run
|
56
|
+
new(**inputs).run
|
57
57
|
end
|
58
58
|
|
59
59
|
def run!(inputs = {})
|
data/lib/command/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: g2_command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hamed Asghari
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '7'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '5.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '7'
|
@@ -36,7 +36,7 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '5.0'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '7'
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '5.0'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '7'
|
@@ -78,18 +78,22 @@ dependencies:
|
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '1.3'
|
81
|
-
description:
|
81
|
+
description:
|
82
82
|
email:
|
83
83
|
- hasghari@g2.com
|
84
84
|
executables: []
|
85
85
|
extensions: []
|
86
86
|
extra_rdoc_files: []
|
87
87
|
files:
|
88
|
-
- ".
|
88
|
+
- ".circleci/config.yml"
|
89
|
+
- ".github/config/rubocop_linter_action.yml"
|
90
|
+
- ".github/workflows/linters.yml"
|
89
91
|
- ".gitignore"
|
90
92
|
- ".rspec"
|
91
93
|
- ".rubocop.yml"
|
94
|
+
- ".ruby-version"
|
92
95
|
- ".tool-versions"
|
96
|
+
- Appraisals
|
93
97
|
- CODE_OF_CONDUCT.md
|
94
98
|
- Gemfile
|
95
99
|
- Gemfile.lock
|
@@ -99,20 +103,29 @@ files:
|
|
99
103
|
- bin/console
|
100
104
|
- bin/setup
|
101
105
|
- g2_command.gemspec
|
106
|
+
- gemfiles/.bundle/config
|
107
|
+
- gemfiles/rails_5.1.gemfile
|
108
|
+
- gemfiles/rails_5.1.gemfile.lock
|
109
|
+
- gemfiles/rails_5.2.gemfile
|
110
|
+
- gemfiles/rails_5.2.gemfile.lock
|
111
|
+
- gemfiles/rails_6.0.gemfile
|
112
|
+
- gemfiles/rails_6.0.gemfile.lock
|
102
113
|
- lib/command.rb
|
114
|
+
- lib/command/failure.rb
|
103
115
|
- lib/command/input_middleware.rb
|
104
116
|
- lib/command/input_middleware/rails_params.rb
|
105
117
|
- lib/command/input_middleware/symbolizer.rb
|
106
118
|
- lib/command/interrupt.rb
|
107
119
|
- lib/command/version.rb
|
108
120
|
- lib/g2_command.rb
|
121
|
+
- lib/gem_ext/active_model/errors.rb
|
109
122
|
homepage: https://github.com/g2crowd/g2_command
|
110
123
|
licenses:
|
111
124
|
- MIT
|
112
125
|
metadata:
|
113
126
|
homepage_uri: https://github.com/g2crowd/g2_command
|
114
127
|
source_code_uri: https://github.com/g2crowd/g2_command
|
115
|
-
post_install_message:
|
128
|
+
post_install_message:
|
116
129
|
rdoc_options: []
|
117
130
|
require_paths:
|
118
131
|
- lib
|
@@ -127,8 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
140
|
- !ruby/object:Gem::Version
|
128
141
|
version: '0'
|
129
142
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
131
|
-
signing_key:
|
143
|
+
rubygems_version: 3.1.4
|
144
|
+
signing_key:
|
132
145
|
specification_version: 4
|
133
146
|
summary: An implementation of the command pattern using dry-rb
|
134
147
|
test_files: []
|