lite-command 1.0.6 → 1.0.7

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: d87e7d29724662cbe21a43b565e0452d97acbd9556bbf4b55689c773e91b73d4
4
- data.tar.gz: 3eeca99338dfcdb01d82946c24dc1477c712af81f1400b02bc6758a114cae68f
3
+ metadata.gz: 42b4977d98dc150661c9d6a3115d5fbcad3ec460215d0f245cc2ea1c9518df0e
4
+ data.tar.gz: 211efe41137b268674613a5b5781a77009620cb5a89376d096ded8c36bc091e7
5
5
  SHA512:
6
- metadata.gz: '092dde4f9c34f13e7f5df9fd848f8e77363636ba8ca7ac11cf90e1b86762f6730828d1243f6d32aa08422094c614463f1f5a8dd3e8d2fc34d77374ea3f7df0ae'
7
- data.tar.gz: 21506fbf38db972e141b3bd638c883818304703e8d049ea571227bde7580e341fbaa73bd5b62eb02a17c17c2488258536b5eb40bd9f00a18b17989a299d6c361
6
+ metadata.gz: 0c479936fe1d59c0af7d2ccce418009e29b2b390d3c8ad47925c6059a37540ca1b3c5d7119b9c2486435b9e7af0e2f6dc36708ddb8e9d16ca563f7258a692ba8
7
+ data.tar.gz: ba335e1b2175413b589e91a4d9ed96e18123739397b1b192abeded0f635ffd8f92604ad9788b25d98d69a3695c6b026794b90c125afc724f21042dec99f9b437
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.0.7] - 2019-09-12
10
+ ### Added
11
+ - Add propagation mixin
12
+
9
13
  ## [1.0.6] - 2019-09-07
10
14
  ### Added
11
15
  - Raise error when class `call` if class doesn't respond_to `execute`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-command (1.0.6)
4
+ lite-command (1.0.7)
5
5
  lite-errors
6
6
  lite-memoize
7
7
 
@@ -21,6 +21,11 @@ GEM
21
21
  erubi (~> 1.4)
22
22
  rails-dom-testing (~> 2.0)
23
23
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
+ activemodel (6.0.0)
25
+ activesupport (= 6.0.0)
26
+ activerecord (6.0.0)
27
+ activemodel (= 6.0.0)
28
+ activesupport (= 6.0.0)
24
29
  activesupport (6.0.0)
25
30
  concurrent-ruby (~> 1.0, >= 1.0.2)
26
31
  i18n (>= 0.7, < 2)
@@ -32,6 +37,7 @@ GEM
32
37
  colorize (0.8.1)
33
38
  concurrent-ruby (1.1.5)
34
39
  crass (1.0.4)
40
+ database_cleaner (1.7.0)
35
41
  diff-lcs (1.3)
36
42
  erubi (1.8.0)
37
43
  fasterer (0.6.0)
@@ -54,7 +60,7 @@ GEM
54
60
  nokogiri (1.10.4)
55
61
  mini_portile2 (~> 2.4.0)
56
62
  parallel (1.17.0)
57
- parser (2.6.4.0)
63
+ parser (2.6.4.1)
58
64
  ast (~> 2.4.0)
59
65
  rack (2.0.7)
60
66
  rack-test (1.1.0)
@@ -100,6 +106,7 @@ GEM
100
106
  ruby_parser (3.13.1)
101
107
  sexp_processor (~> 4.9)
102
108
  sexp_processor (4.12.1)
109
+ sqlite3 (1.4.1)
103
110
  thor (0.20.3)
104
111
  thread_safe (0.3.6)
105
112
  tzinfo (1.2.5)
@@ -111,7 +118,9 @@ PLATFORMS
111
118
  ruby
112
119
 
113
120
  DEPENDENCIES
121
+ activerecord
114
122
  bundler
123
+ database_cleaner
115
124
  fasterer
116
125
  generator_spec
117
126
  lite-command!
@@ -120,6 +129,7 @@ DEPENDENCIES
120
129
  rubocop
121
130
  rubocop-performance
122
131
  rubocop-rspec
132
+ sqlite3
123
133
 
124
134
  BUNDLED WITH
125
135
  2.0.1
data/README.md CHANGED
@@ -194,6 +194,28 @@ command.merge_errors!(command_2)
194
194
  user_model.merge_errors!(command, direction: :to)
195
195
  ```
196
196
 
197
+ ### Propagation (optional)
198
+
199
+ Propagation methods help you perform an action on an object. If successful is
200
+ returns the result else it adds the object errors to the form object. Available
201
+ propagation methods are:
202
+ `create_and_return!(object, params)`, `update_and_return!(object, params)`,
203
+ `save_and_return!(object)`, and `destroy_and_return!(object)`
204
+
205
+ ```ruby
206
+ class SearchMovies < Lite::Command::Complex
207
+ include Lite::Command::Extensions::Errors
208
+ include Lite::Command::Extensions::Propagation
209
+
210
+ # ... ommited ...
211
+
212
+ def execute
213
+ create_and_return!(User, name: 'John Doe')
214
+ end
215
+
216
+ end
217
+ ```
218
+
197
219
  ### Memoize (optional)
198
220
 
199
221
  Learn more about using [Lite::Memoize](https://github.com/drexed/lite-memoize)
data/lib/lite/command.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'lite/command/version'
4
4
 
5
- %w[errors memoize].each do |name|
5
+ %w[errors memoize propagation].each do |name|
6
6
  require "lite/command/extensions/#{name}"
7
7
  end
8
8
 
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lite
4
+ module Command
5
+ module Extensions
6
+ module Propagation
7
+
8
+ private
9
+
10
+ %i[archive destroy save].each do |action|
11
+ define_method("#{action}_and_return!") do |klass|
12
+ merge_errors!(klass) unless klass.send(action)
13
+ klass
14
+ end
15
+ end
16
+
17
+ def create_and_return!(klass, params)
18
+ klass = klass.create(params)
19
+ merge_errors!(klass) unless klass.persisted?
20
+ klass
21
+ end
22
+
23
+ def update_and_return!(klass, params)
24
+ merge_errors!(klass) unless klass.update(params)
25
+ klass
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Command
5
5
 
6
- VERSION ||= '1.0.6'
6
+ VERSION ||= '1.0.7'
7
7
 
8
8
  end
9
9
  end
data/lite-command.gemspec CHANGED
@@ -40,7 +40,9 @@ Gem::Specification.new do |spec|
40
40
  spec.add_dependency 'lite-errors'
41
41
  spec.add_dependency 'lite-memoize'
42
42
 
43
+ spec.add_development_dependency 'activerecord'
43
44
  spec.add_development_dependency 'bundler'
45
+ spec.add_development_dependency 'database_cleaner'
44
46
  spec.add_development_dependency 'fasterer'
45
47
  spec.add_development_dependency 'generator_spec'
46
48
  spec.add_development_dependency 'rake'
@@ -48,4 +50,5 @@ Gem::Specification.new do |spec|
48
50
  spec.add_development_dependency 'rubocop'
49
51
  spec.add_development_dependency 'rubocop-performance'
50
52
  spec.add_development_dependency 'rubocop-rspec'
53
+ spec.add_development_dependency 'sqlite3'
51
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-07 00:00:00.000000000 Z
11
+ date: 2019-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lite-errors
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activerecord
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,20 @@ dependencies:
52
66
  - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: database_cleaner
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: fasterer
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +178,20 @@ dependencies:
150
178
  - - ">="
151
179
  - !ruby/object:Gem::Version
152
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: sqlite3
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
153
195
  description:
154
196
  email:
155
197
  - j.gomez@drexed.com
@@ -184,6 +226,7 @@ files:
184
226
  - lib/lite/command/exceptions.rb
185
227
  - lib/lite/command/extensions/errors.rb
186
228
  - lib/lite/command/extensions/memoize.rb
229
+ - lib/lite/command/extensions/propagation.rb
187
230
  - lib/lite/command/simple.rb
188
231
  - lib/lite/command/states.rb
189
232
  - lib/lite/command/version.rb