creed 0.3.0 → 0.4.0

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: c5b081f4c1d7a95c987d474b5b2ab027fbcb7070bcbd667888fc222527d134ee
4
- data.tar.gz: 3138c7e26c47d6ed94bfa8e012322df0448cb78aabc522d6800ee9744cf83579
3
+ metadata.gz: da26cff3b225c84ec291770b543c71ecff63748becadd4247c4fbf00c96f99f5
4
+ data.tar.gz: 8225c8d2cda6cd9844bf0d29da89d70aeb6fba2ad025bcec24a2fa08a12bb47f
5
5
  SHA512:
6
- metadata.gz: 0cf0b3550fda85365c79b25c9a33be810b1d674ad81bc71980856400b4d2e8e628cd557fdf50b6025d845836e5ad3b01c10f31fbeec5118d07c3c328f6d53edb
7
- data.tar.gz: aaa1d622f442a44351e82fb7cfb12a6116e237356541c5e3754fc9307886c5080d282cc1b2260e6b220bc80d9ada0a4fb0f3afaf4918fbc7400661284d9d09e2
6
+ metadata.gz: 876bdcf8cdebc0a213c5d1e06f8438ae3a295efb190d08cb46d8b6f746415e094b331f2dfafc60af4a7a39c0055a9c2560bb186abc5e768e59f8802815ea2d1b
7
+ data.tar.gz: 80d3518948488755ad4b87d90fb35901e3889ae19c5102491b1097b2eda2966bcb0b73e34abae2a8e05e946502abe2fb7bf62dee56ad4563c5926962c04969ad
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- creed (0.2.0)
4
+ creed (0.3.0)
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,22 +12,56 @@ PATH
11
12
  GEM
12
13
  remote: https://rubygems.org/
13
14
  specs:
14
- actionpack (6.0.3.1)
15
- actionview (= 6.0.3.1)
16
- activesupport (= 6.0.3.1)
15
+ actioncable (6.0.3.2)
16
+ actionpack (= 6.0.3.2)
17
+ nio4r (~> 2.0)
18
+ websocket-driver (>= 0.6.1)
19
+ actionmailbox (6.0.3.2)
20
+ actionpack (= 6.0.3.2)
21
+ activejob (= 6.0.3.2)
22
+ activerecord (= 6.0.3.2)
23
+ activestorage (= 6.0.3.2)
24
+ activesupport (= 6.0.3.2)
25
+ mail (>= 2.7.1)
26
+ actionmailer (6.0.3.2)
27
+ actionpack (= 6.0.3.2)
28
+ actionview (= 6.0.3.2)
29
+ activejob (= 6.0.3.2)
30
+ mail (~> 2.5, >= 2.5.4)
31
+ rails-dom-testing (~> 2.0)
32
+ actionpack (6.0.3.2)
33
+ actionview (= 6.0.3.2)
34
+ activesupport (= 6.0.3.2)
17
35
  rack (~> 2.0, >= 2.0.8)
18
36
  rack-test (>= 0.6.3)
19
37
  rails-dom-testing (~> 2.0)
20
38
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
21
- actionview (6.0.3.1)
22
- activesupport (= 6.0.3.1)
39
+ actiontext (6.0.3.2)
40
+ actionpack (= 6.0.3.2)
41
+ activerecord (= 6.0.3.2)
42
+ activestorage (= 6.0.3.2)
43
+ activesupport (= 6.0.3.2)
44
+ nokogiri (>= 1.8.5)
45
+ actionview (6.0.3.2)
46
+ activesupport (= 6.0.3.2)
23
47
  builder (~> 3.1)
24
48
  erubi (~> 1.4)
25
49
  rails-dom-testing (~> 2.0)
26
50
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
27
- activemodel (6.0.3.1)
28
- activesupport (= 6.0.3.1)
29
- activesupport (6.0.3.1)
51
+ activejob (6.0.3.2)
52
+ activesupport (= 6.0.3.2)
53
+ globalid (>= 0.3.6)
54
+ activemodel (6.0.3.2)
55
+ activesupport (= 6.0.3.2)
56
+ activerecord (6.0.3.2)
57
+ activemodel (= 6.0.3.2)
58
+ activesupport (= 6.0.3.2)
59
+ activestorage (6.0.3.2)
60
+ actionpack (= 6.0.3.2)
61
+ activejob (= 6.0.3.2)
62
+ activerecord (= 6.0.3.2)
63
+ marcel (~> 0.3.1)
64
+ activesupport (6.0.3.2)
30
65
  concurrent-ruby (~> 1.0, >= 1.0.2)
31
66
  i18n (>= 0.7, < 2)
32
67
  minitest (~> 5.1)
@@ -35,9 +70,9 @@ GEM
35
70
  ansi (1.5.0)
36
71
  ast (2.4.1)
37
72
  builder (3.2.4)
38
- concurrent-ruby (1.1.6)
73
+ concurrent-ruby (1.1.7)
39
74
  crass (1.0.6)
40
- dry-configurable (0.11.5)
75
+ dry-configurable (0.11.6)
41
76
  concurrent-ruby (~> 1.0)
42
77
  dry-core (~> 0.4, >= 0.4.7)
43
78
  dry-equalizer (~> 0.2)
@@ -49,7 +84,10 @@ GEM
49
84
  dry-equalizer (0.3.0)
50
85
  dry-inflector (0.2.0)
51
86
  dry-initializer (3.0.3)
52
- dry-logic (1.0.6)
87
+ dry-initializer-rails (3.1.1)
88
+ dry-initializer (>= 2.4, < 4)
89
+ rails (> 3.0)
90
+ dry-logic (1.0.7)
53
91
  concurrent-ruby (~> 1.0)
54
92
  dry-core (~> 0.2)
55
93
  dry-equalizer (~> 0.2)
@@ -61,12 +99,20 @@ GEM
61
99
  dry-inflector (~> 0.1, >= 0.1.2)
62
100
  dry-logic (~> 1.0, >= 1.0.2)
63
101
  erubi (1.9.0)
64
- i18n (1.8.3)
102
+ globalid (0.4.2)
103
+ activesupport (>= 4.2.0)
104
+ i18n (1.8.5)
65
105
  concurrent-ruby (~> 1.0)
66
- loofah (2.5.0)
106
+ loofah (2.6.0)
67
107
  crass (~> 1.0.2)
68
108
  nokogiri (>= 1.5.9)
109
+ mail (2.7.1)
110
+ mini_mime (>= 0.1.1)
111
+ marcel (0.3.3)
112
+ mimemagic (~> 0.3.2)
69
113
  method_source (1.0.0)
114
+ mimemagic (0.3.5)
115
+ mini_mime (1.0.2)
70
116
  mini_portile2 (2.4.0)
71
117
  minitest (5.14.1)
72
118
  minitest-focus (1.2.1)
@@ -77,22 +123,38 @@ GEM
77
123
  minitest (>= 5.0)
78
124
  ruby-progressbar
79
125
  mocha (1.11.2)
80
- nokogiri (1.10.9)
126
+ nio4r (2.5.2)
127
+ nokogiri (1.10.10)
81
128
  mini_portile2 (~> 2.4.0)
82
- parallel (1.19.1)
83
- parser (2.7.1.3)
84
- ast (~> 2.4.0)
129
+ parallel (1.19.2)
130
+ parser (2.7.1.4)
131
+ ast (~> 2.4.1)
85
132
  rack (2.2.3)
86
133
  rack-test (1.1.0)
87
134
  rack (>= 1.0, < 3)
135
+ rails (6.0.3.2)
136
+ actioncable (= 6.0.3.2)
137
+ actionmailbox (= 6.0.3.2)
138
+ actionmailer (= 6.0.3.2)
139
+ actionpack (= 6.0.3.2)
140
+ actiontext (= 6.0.3.2)
141
+ actionview (= 6.0.3.2)
142
+ activejob (= 6.0.3.2)
143
+ activemodel (= 6.0.3.2)
144
+ activerecord (= 6.0.3.2)
145
+ activestorage (= 6.0.3.2)
146
+ activesupport (= 6.0.3.2)
147
+ bundler (>= 1.3.0)
148
+ railties (= 6.0.3.2)
149
+ sprockets-rails (>= 2.0.0)
88
150
  rails-dom-testing (2.0.3)
89
151
  activesupport (>= 4.2.0)
90
152
  nokogiri (>= 1.6)
91
153
  rails-html-sanitizer (1.3.0)
92
154
  loofah (~> 2.3)
93
- railties (6.0.3.1)
94
- actionpack (= 6.0.3.1)
95
- activesupport (= 6.0.3.1)
155
+ railties (6.0.3.2)
156
+ actionpack (= 6.0.3.2)
157
+ activesupport (= 6.0.3.2)
96
158
  method_source
97
159
  rake (>= 0.8.7)
98
160
  thor (>= 0.20.3, < 2.0)
@@ -103,26 +165,36 @@ GEM
103
165
  actionpack (>= 5.0)
104
166
  railties (>= 5.0)
105
167
  rexml (3.2.4)
106
- rubocop (0.85.1)
168
+ rubocop (0.89.1)
107
169
  parallel (~> 1.10)
108
- parser (>= 2.7.0.1)
170
+ parser (>= 2.7.1.1)
109
171
  rainbow (>= 2.2.2, < 4.0)
110
172
  regexp_parser (>= 1.7)
111
173
  rexml
112
- rubocop-ast (>= 0.0.3)
174
+ rubocop-ast (>= 0.3.0, < 1.0)
113
175
  ruby-progressbar (~> 1.7)
114
176
  unicode-display_width (>= 1.4.0, < 2.0)
115
- rubocop-ast (0.0.3)
116
- parser (>= 2.7.0.1)
117
- rubocop-performance (1.6.1)
118
- rubocop (>= 0.71.0)
177
+ rubocop-ast (0.3.0)
178
+ parser (>= 2.7.1.4)
179
+ rubocop-performance (1.7.1)
180
+ rubocop (>= 0.82.0)
119
181
  ruby-progressbar (1.10.1)
182
+ sprockets (4.0.2)
183
+ concurrent-ruby (~> 1.0)
184
+ rack (> 1, < 3)
185
+ sprockets-rails (3.2.1)
186
+ actionpack (>= 4.0)
187
+ activesupport (>= 4.0)
188
+ sprockets (>= 3.0.0)
120
189
  thor (1.0.1)
121
190
  thread_safe (0.3.6)
122
191
  tzinfo (1.2.7)
123
192
  thread_safe (~> 0.1)
124
193
  unicode-display_width (1.7.0)
125
- zeitwerk (2.3.0)
194
+ websocket-driver (0.7.3)
195
+ websocket-extensions (>= 0.1.0)
196
+ websocket-extensions (0.1.5)
197
+ zeitwerk (2.4.0)
126
198
 
127
199
  PLATFORMS
128
200
  ruby
data/README.md CHANGED
@@ -20,12 +20,13 @@ 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.
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
  def perform
31
32
  # Do something here...
@@ -38,7 +39,7 @@ Then in your controller (or anywhere):
38
39
  ```ruby
39
40
  class UserController < ApplicationController
40
41
  def create
41
- CreateUser.perform(user_params)
42
+ CreateUser.perform(user_params, validate: false)
42
43
  end
43
44
  end
44
45
  ```
@@ -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'
@@ -1,12 +1,27 @@
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
+
21
+ context << options
22
+ end
23
+
24
+ new(*context).perform(&block)
10
25
  end
11
26
 
12
27
  def perform
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Creed
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
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.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-15 00:00:00.000000000 Z
11
+ date: 2020-08-19 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