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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71ec85575cece4defb4fb57ca8521494d4c350aef99730269747872e17aa66c1
4
- data.tar.gz: 8c15a9cfd8f219140efec5a0d0b82ca6d92dd89020898f065f29ef1ed9ce7365
3
+ metadata.gz: 775ab09abd887ecb445430e67b88c84cb466bcb7f3c427c3b21b24700661d67a
4
+ data.tar.gz: 2bb759c10b91d54a85ba38682ca3d036d334abd91d31d2ab6b6230d7d0bdec15
5
5
  SHA512:
6
- metadata.gz: '085d2028e4f104d642cda0490d94b6d91d100bd02f1f179fb9124592529a426c593b200d144c945bea4bb7c109b2650e6e822f486bbb5f75d9c78af37472876b'
7
- data.tar.gz: bd7c1d695f8f63cd5db1b1e7e586bdc35f56a9fa6983448ab8b67669e8ae33b1201fa1ac4a778fc1843ffc201c065c76b99488980ca5ab91a9bc29722ebeb221
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.0)
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
- actionpack (6.0.2.1)
15
- actionview (= 6.0.2.1)
16
- activesupport (= 6.0.2.1)
17
- rack (~> 2.0, >= 2.0.8)
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
- actionview (6.0.2.1)
22
- activesupport (= 6.0.2.1)
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
- activemodel (6.0.2.1)
28
- activesupport (= 6.0.2.1)
29
- activesupport (6.0.2.1)
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 (>= 0.7, < 2)
32
- minitest (~> 5.1)
33
- tzinfo (~> 1.1)
34
- zeitwerk (~> 2.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.0)
75
+ ast (2.4.2)
37
76
  builder (3.2.4)
38
- concurrent-ruby (1.1.6)
77
+ concurrent-ruby (1.1.8)
39
78
  crass (1.0.6)
40
- dry-configurable (0.11.3)
79
+ dry-configurable (0.13.0)
41
80
  concurrent-ruby (~> 1.0)
42
- dry-core (~> 0.4, >= 0.4.7)
43
- dry-equalizer (~> 0.2)
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.1, >= 0.1.3)
47
- dry-core (0.4.9)
84
+ dry-configurable (~> 0.13, >= 0.13.0)
85
+ dry-core (0.7.1)
48
86
  concurrent-ruby (~> 1.0)
49
- dry-equalizer (0.3.0)
50
- dry-inflector (0.2.0)
51
- dry-initializer (3.0.3)
52
- dry-logic (1.0.6)
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.2)
55
- dry-equalizer (~> 0.2)
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.4, >= 0.4.4)
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.9.0)
64
- i18n (1.8.2)
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
- jaro_winkler (1.5.4)
67
- loofah (2.4.0)
106
+ loofah (2.12.0)
68
107
  crass (~> 1.0.2)
69
108
  nokogiri (>= 1.5.9)
70
- method_source (0.9.2)
71
- mini_portile2 (2.4.0)
72
- minitest (5.14.0)
73
- minitest-focus (1.1.2)
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.2)
118
+ minitest-reporters (1.4.3)
76
119
  ansi
77
120
  builder
78
121
  minitest (>= 5.0)
79
122
  ruby-progressbar
80
- mocha (1.11.2)
81
- nokogiri (1.10.8)
82
- mini_portile2 (~> 2.4.0)
83
- parallel (1.19.1)
84
- parser (2.7.0.2)
85
- ast (~> 2.4.0)
86
- rack (2.2.2)
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.3.0)
153
+ rails-html-sanitizer (1.4.2)
93
154
  loofah (~> 2.3)
94
- railties (6.0.2.1)
95
- actionpack (= 6.0.2.1)
96
- activesupport (= 6.0.2.1)
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 (>= 0.20.3, < 2.0)
160
+ thor (~> 1.0)
100
161
  rainbow (3.0.0)
101
- rake (13.0.1)
102
- responders (3.0.0)
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.4)
106
- rubocop (0.80.0)
107
- jaro_winkler (~> 1.5.1)
167
+ rexml (3.2.5)
168
+ rubocop (1.12.1)
108
169
  parallel (~> 1.10)
109
- parser (>= 2.7.0.1)
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, < 1.7)
114
- rubocop-performance (1.5.2)
115
- rubocop (>= 0.71.0)
116
- ruby-progressbar (1.10.1)
117
- thor (1.0.1)
118
- thread_safe (0.3.6)
119
- tzinfo (1.2.6)
120
- thread_safe (~> 0.1)
121
- unicode-display_width (1.6.1)
122
- zeitwerk (2.2.2)
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.1.4
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
- def perform
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 or Rails'
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
- new(*context).perform
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Creed
4
- VERSION = '0.2.0'
4
+ VERSION = '0.4.2'
5
5
  end
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.0
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: 2020-03-18 00:00:00.000000000 Z
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.1.2
131
- signing_key:
144
+ rubygems_version: 3.2.32
145
+ signing_key:
132
146
  specification_version: 4
133
- summary: Command pattern or Rails
147
+ summary: Command pattern for Rails
134
148
  test_files: []