creed 0.2.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +144 -69
- data/README.md +7 -4
- data/creed.gemspec +2 -1
- data/lib/creed/command.rb +15 -2
- data/lib/creed/version.rb +1 -1
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 775ab09abd887ecb445430e67b88c84cb466bcb7f3c427c3b21b24700661d67a
|
4
|
+
data.tar.gz: 2bb759c10b91d54a85ba38682ca3d036d334abd91d31d2ab6b6230d7d0bdec15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7f58b2fa021cd1b674bc0b5cff7aaf39ee1d61f6e04f2baef31348d55def3b9b5dbc6e508a6bf5f9fa9963fd5a8d485191c4b1ea14a4abd418a23709a8e69ad
|
7
|
+
data.tar.gz: 3775609dfb85c9d6f617344fc98f6e15dfb45463175c3228c999fe9cf7f7cc1c9645358ecff1c69b3719f731ad9023d5cbb95ac26965e5feacc32259d0f3e1dd
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
creed (0.1
|
4
|
+
creed (0.4.1)
|
5
5
|
actionpack (>= 6.0)
|
6
6
|
dry-initializer
|
7
|
+
dry-initializer-rails
|
7
8
|
dry-types
|
8
9
|
railties (>= 6.0)
|
9
10
|
responders
|
@@ -11,115 +12,189 @@ PATH
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
13
14
|
specs:
|
14
|
-
|
15
|
-
|
16
|
-
activesupport (= 6.
|
17
|
-
|
15
|
+
actioncable (6.1.3.1)
|
16
|
+
actionpack (= 6.1.3.1)
|
17
|
+
activesupport (= 6.1.3.1)
|
18
|
+
nio4r (~> 2.0)
|
19
|
+
websocket-driver (>= 0.6.1)
|
20
|
+
actionmailbox (6.1.3.1)
|
21
|
+
actionpack (= 6.1.3.1)
|
22
|
+
activejob (= 6.1.3.1)
|
23
|
+
activerecord (= 6.1.3.1)
|
24
|
+
activestorage (= 6.1.3.1)
|
25
|
+
activesupport (= 6.1.3.1)
|
26
|
+
mail (>= 2.7.1)
|
27
|
+
actionmailer (6.1.3.1)
|
28
|
+
actionpack (= 6.1.3.1)
|
29
|
+
actionview (= 6.1.3.1)
|
30
|
+
activejob (= 6.1.3.1)
|
31
|
+
activesupport (= 6.1.3.1)
|
32
|
+
mail (~> 2.5, >= 2.5.4)
|
33
|
+
rails-dom-testing (~> 2.0)
|
34
|
+
actionpack (6.1.3.1)
|
35
|
+
actionview (= 6.1.3.1)
|
36
|
+
activesupport (= 6.1.3.1)
|
37
|
+
rack (~> 2.0, >= 2.0.9)
|
18
38
|
rack-test (>= 0.6.3)
|
19
39
|
rails-dom-testing (~> 2.0)
|
20
40
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
21
|
-
|
22
|
-
|
41
|
+
actiontext (6.1.3.1)
|
42
|
+
actionpack (= 6.1.3.1)
|
43
|
+
activerecord (= 6.1.3.1)
|
44
|
+
activestorage (= 6.1.3.1)
|
45
|
+
activesupport (= 6.1.3.1)
|
46
|
+
nokogiri (>= 1.8.5)
|
47
|
+
actionview (6.1.3.1)
|
48
|
+
activesupport (= 6.1.3.1)
|
23
49
|
builder (~> 3.1)
|
24
50
|
erubi (~> 1.4)
|
25
51
|
rails-dom-testing (~> 2.0)
|
26
52
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
27
|
-
|
28
|
-
activesupport (= 6.
|
29
|
-
|
53
|
+
activejob (6.1.3.1)
|
54
|
+
activesupport (= 6.1.3.1)
|
55
|
+
globalid (>= 0.3.6)
|
56
|
+
activemodel (6.1.3.1)
|
57
|
+
activesupport (= 6.1.3.1)
|
58
|
+
activerecord (6.1.3.1)
|
59
|
+
activemodel (= 6.1.3.1)
|
60
|
+
activesupport (= 6.1.3.1)
|
61
|
+
activestorage (6.1.3.1)
|
62
|
+
actionpack (= 6.1.3.1)
|
63
|
+
activejob (= 6.1.3.1)
|
64
|
+
activerecord (= 6.1.3.1)
|
65
|
+
activesupport (= 6.1.3.1)
|
66
|
+
marcel (~> 1.0.0)
|
67
|
+
mini_mime (~> 1.0.2)
|
68
|
+
activesupport (6.1.3.1)
|
30
69
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
31
|
-
i18n (>=
|
32
|
-
minitest (
|
33
|
-
tzinfo (~>
|
34
|
-
zeitwerk (~> 2.
|
70
|
+
i18n (>= 1.6, < 2)
|
71
|
+
minitest (>= 5.1)
|
72
|
+
tzinfo (~> 2.0)
|
73
|
+
zeitwerk (~> 2.3)
|
35
74
|
ansi (1.5.0)
|
36
|
-
ast (2.4.
|
75
|
+
ast (2.4.2)
|
37
76
|
builder (3.2.4)
|
38
|
-
concurrent-ruby (1.1.
|
77
|
+
concurrent-ruby (1.1.8)
|
39
78
|
crass (1.0.6)
|
40
|
-
dry-configurable (0.
|
79
|
+
dry-configurable (0.13.0)
|
41
80
|
concurrent-ruby (~> 1.0)
|
42
|
-
dry-core (~> 0.
|
43
|
-
|
44
|
-
dry-container (0.7.2)
|
81
|
+
dry-core (~> 0.6)
|
82
|
+
dry-container (0.9.0)
|
45
83
|
concurrent-ruby (~> 1.0)
|
46
|
-
dry-configurable (~> 0.
|
47
|
-
dry-core (0.
|
84
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
85
|
+
dry-core (0.7.1)
|
48
86
|
concurrent-ruby (~> 1.0)
|
49
|
-
dry-
|
50
|
-
dry-
|
51
|
-
dry-initializer (3.
|
52
|
-
|
87
|
+
dry-inflector (0.2.1)
|
88
|
+
dry-initializer (3.0.4)
|
89
|
+
dry-initializer-rails (3.1.1)
|
90
|
+
dry-initializer (>= 2.4, < 4)
|
91
|
+
rails (> 3.0)
|
92
|
+
dry-logic (1.2.0)
|
53
93
|
concurrent-ruby (~> 1.0)
|
54
|
-
dry-core (~> 0.
|
55
|
-
|
56
|
-
dry-types (1.3.1)
|
94
|
+
dry-core (~> 0.5, >= 0.5)
|
95
|
+
dry-types (1.5.1)
|
57
96
|
concurrent-ruby (~> 1.0)
|
58
97
|
dry-container (~> 0.3)
|
59
|
-
dry-core (~> 0.
|
60
|
-
dry-equalizer (~> 0.3)
|
98
|
+
dry-core (~> 0.5, >= 0.5)
|
61
99
|
dry-inflector (~> 0.1, >= 0.1.2)
|
62
100
|
dry-logic (~> 1.0, >= 1.0.2)
|
63
|
-
erubi (1.
|
64
|
-
|
101
|
+
erubi (1.10.0)
|
102
|
+
globalid (0.5.2)
|
103
|
+
activesupport (>= 5.0)
|
104
|
+
i18n (1.8.10)
|
65
105
|
concurrent-ruby (~> 1.0)
|
66
|
-
|
67
|
-
loofah (2.4.0)
|
106
|
+
loofah (2.12.0)
|
68
107
|
crass (~> 1.0.2)
|
69
108
|
nokogiri (>= 1.5.9)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
109
|
+
mail (2.7.1)
|
110
|
+
mini_mime (>= 0.1.1)
|
111
|
+
marcel (1.0.2)
|
112
|
+
method_source (1.0.0)
|
113
|
+
mini_mime (1.0.3)
|
114
|
+
mini_portile2 (2.6.1)
|
115
|
+
minitest (5.14.4)
|
116
|
+
minitest-focus (1.2.1)
|
74
117
|
minitest (>= 4, < 6)
|
75
|
-
minitest-reporters (1.4.
|
118
|
+
minitest-reporters (1.4.3)
|
76
119
|
ansi
|
77
120
|
builder
|
78
121
|
minitest (>= 5.0)
|
79
122
|
ruby-progressbar
|
80
|
-
mocha (1.
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
123
|
+
mocha (1.12.0)
|
124
|
+
nio4r (2.5.8)
|
125
|
+
nokogiri (1.12.5)
|
126
|
+
mini_portile2 (~> 2.6.1)
|
127
|
+
racc (~> 1.4)
|
128
|
+
parallel (1.20.1)
|
129
|
+
parser (3.0.1.0)
|
130
|
+
ast (~> 2.4.1)
|
131
|
+
racc (1.5.2)
|
132
|
+
rack (2.2.3)
|
87
133
|
rack-test (1.1.0)
|
88
134
|
rack (>= 1.0, < 3)
|
135
|
+
rails (6.1.3.1)
|
136
|
+
actioncable (= 6.1.3.1)
|
137
|
+
actionmailbox (= 6.1.3.1)
|
138
|
+
actionmailer (= 6.1.3.1)
|
139
|
+
actionpack (= 6.1.3.1)
|
140
|
+
actiontext (= 6.1.3.1)
|
141
|
+
actionview (= 6.1.3.1)
|
142
|
+
activejob (= 6.1.3.1)
|
143
|
+
activemodel (= 6.1.3.1)
|
144
|
+
activerecord (= 6.1.3.1)
|
145
|
+
activestorage (= 6.1.3.1)
|
146
|
+
activesupport (= 6.1.3.1)
|
147
|
+
bundler (>= 1.15.0)
|
148
|
+
railties (= 6.1.3.1)
|
149
|
+
sprockets-rails (>= 2.0.0)
|
89
150
|
rails-dom-testing (2.0.3)
|
90
151
|
activesupport (>= 4.2.0)
|
91
152
|
nokogiri (>= 1.6)
|
92
|
-
rails-html-sanitizer (1.
|
153
|
+
rails-html-sanitizer (1.4.2)
|
93
154
|
loofah (~> 2.3)
|
94
|
-
railties (6.
|
95
|
-
actionpack (= 6.
|
96
|
-
activesupport (= 6.
|
155
|
+
railties (6.1.3.1)
|
156
|
+
actionpack (= 6.1.3.1)
|
157
|
+
activesupport (= 6.1.3.1)
|
97
158
|
method_source
|
98
159
|
rake (>= 0.8.7)
|
99
|
-
thor (
|
160
|
+
thor (~> 1.0)
|
100
161
|
rainbow (3.0.0)
|
101
|
-
rake (13.0.
|
102
|
-
|
162
|
+
rake (13.0.3)
|
163
|
+
regexp_parser (2.1.1)
|
164
|
+
responders (3.0.1)
|
103
165
|
actionpack (>= 5.0)
|
104
166
|
railties (>= 5.0)
|
105
|
-
rexml (3.2.
|
106
|
-
rubocop (
|
107
|
-
jaro_winkler (~> 1.5.1)
|
167
|
+
rexml (3.2.5)
|
168
|
+
rubocop (1.12.1)
|
108
169
|
parallel (~> 1.10)
|
109
|
-
parser (>=
|
170
|
+
parser (>= 3.0.0.0)
|
110
171
|
rainbow (>= 2.2.2, < 4.0)
|
172
|
+
regexp_parser (>= 1.8, < 3.0)
|
111
173
|
rexml
|
174
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
112
175
|
ruby-progressbar (~> 1.7)
|
113
|
-
unicode-display_width (>= 1.4.0, <
|
114
|
-
rubocop-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
176
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
177
|
+
rubocop-ast (1.4.1)
|
178
|
+
parser (>= 2.7.1.5)
|
179
|
+
rubocop-performance (1.10.2)
|
180
|
+
rubocop (>= 0.90.0, < 2.0)
|
181
|
+
rubocop-ast (>= 0.4.0)
|
182
|
+
ruby-progressbar (1.11.0)
|
183
|
+
sprockets (4.0.2)
|
184
|
+
concurrent-ruby (~> 1.0)
|
185
|
+
rack (> 1, < 3)
|
186
|
+
sprockets-rails (3.2.2)
|
187
|
+
actionpack (>= 4.0)
|
188
|
+
activesupport (>= 4.0)
|
189
|
+
sprockets (>= 3.0.0)
|
190
|
+
thor (1.1.0)
|
191
|
+
tzinfo (2.0.4)
|
192
|
+
concurrent-ruby (~> 1.0)
|
193
|
+
unicode-display_width (2.0.0)
|
194
|
+
websocket-driver (0.7.5)
|
195
|
+
websocket-extensions (>= 0.1.0)
|
196
|
+
websocket-extensions (0.1.5)
|
197
|
+
zeitwerk (2.4.2)
|
123
198
|
|
124
199
|
PLATFORMS
|
125
200
|
ruby
|
@@ -136,4 +211,4 @@ DEPENDENCIES
|
|
136
211
|
rubocop-performance
|
137
212
|
|
138
213
|
BUNDLED WITH
|
139
|
-
2.
|
214
|
+
2.2.25
|
data/README.md
CHANGED
@@ -20,14 +20,17 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
Create your Command classes in `app/commands`, extending `Creed::Command`, and implementing a `perform` method
|
23
|
+
Create your Command classes in `app/commands`, extending `Creed::Command`, and implementing a `perform` method. Optionally defining params and/or options that can be passed when performing the command. Unknown arguments will raise an exception.
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
class CreateUser < Creed::Command
|
27
|
-
# Define types and/or validations.
|
27
|
+
# Define types and/or validations. See https://github.com/dry-rb/dry-initializer.
|
28
28
|
param :user_params, Creed::Types.Instance(ActionController::Parameters)
|
29
|
+
option :validate, default: true
|
29
30
|
|
30
|
-
|
31
|
+
# #perform has access to all options and params and named attributes. You can also pass it a
|
32
|
+
# block.
|
33
|
+
def perform(&block)
|
31
34
|
# Do something here...
|
32
35
|
end
|
33
36
|
end
|
@@ -38,7 +41,7 @@ Then in your controller (or anywhere):
|
|
38
41
|
```ruby
|
39
42
|
class UserController < ApplicationController
|
40
43
|
def create
|
41
|
-
CreateUser.perform(user_params)
|
44
|
+
CreateUser.perform(user_params, validate: false)
|
42
45
|
end
|
43
46
|
end
|
44
47
|
```
|
data/creed.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ['Joel Moss']
|
9
9
|
spec.email = ['joel@developwithstyle.com']
|
10
10
|
|
11
|
-
spec.summary = 'Command pattern
|
11
|
+
spec.summary = 'Command pattern for Rails'
|
12
12
|
spec.homepage = 'https://github.com/joelmoss/creed'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_dependency 'actionpack', '>= 6.0'
|
32
32
|
spec.add_dependency 'dry-initializer'
|
33
|
+
spec.add_dependency 'dry-initializer-rails'
|
33
34
|
spec.add_dependency 'dry-types'
|
34
35
|
spec.add_dependency 'railties', '>= 6.0'
|
35
36
|
spec.add_dependency 'responders'
|
data/lib/creed/command.rb
CHANGED
@@ -1,12 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'dry-initializer'
|
4
|
+
require 'dry-initializer-rails'
|
4
5
|
|
5
6
|
class Creed::Command
|
6
7
|
extend Dry::Initializer[undefined: false]
|
7
8
|
|
8
|
-
def self.perform(*context)
|
9
|
-
|
9
|
+
def self.perform(*context, &block)
|
10
|
+
# Make sure that any given options have their keys symbolized, otherwise they will be ignored,
|
11
|
+
# as Dry::Initializer requires keyword arguments or symbolized keys.
|
12
|
+
options = context.extract_options!
|
13
|
+
|
14
|
+
unless options.empty?
|
15
|
+
options.symbolize_keys!
|
16
|
+
|
17
|
+
# Raise on unknown options.
|
18
|
+
unknown_keys = options.keys - dry_initializer.options.map(&:source)
|
19
|
+
raise ArgumentError, "unknown keys: `#{unknown_keys.join '`, `'}`" if unknown_keys.any?
|
20
|
+
end
|
21
|
+
|
22
|
+
(options.empty? ? new(*context) : new(*context, **options)).perform(&block)
|
10
23
|
end
|
11
24
|
|
12
25
|
def perform
|
data/lib/creed/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: creed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Moss
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-initializer-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: dry-types
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +94,7 @@ dependencies:
|
|
80
94
|
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
|
-
description:
|
97
|
+
description:
|
84
98
|
email:
|
85
99
|
- joel@developwithstyle.com
|
86
100
|
executables: []
|
@@ -112,7 +126,7 @@ metadata:
|
|
112
126
|
homepage_uri: https://github.com/joelmoss/creed
|
113
127
|
source_code_uri: https://github.com/joelmoss/creed
|
114
128
|
changelog_uri: https://github.com/joelmoss/creed/releases
|
115
|
-
post_install_message:
|
129
|
+
post_install_message:
|
116
130
|
rdoc_options: []
|
117
131
|
require_paths:
|
118
132
|
- lib
|
@@ -127,8 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
141
|
- !ruby/object:Gem::Version
|
128
142
|
version: '0'
|
129
143
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
131
|
-
signing_key:
|
144
|
+
rubygems_version: 3.2.32
|
145
|
+
signing_key:
|
132
146
|
specification_version: 4
|
133
|
-
summary: Command pattern
|
147
|
+
summary: Command pattern for Rails
|
134
148
|
test_files: []
|