lite-command 1.2.0 → 1.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: 8276865933176a07427bd4a80d4d3bcdf256feb6eaccb7826853f66a5dabc3a0
4
- data.tar.gz: 623626a014811b47eddc3a2adbe757444083c0d0ec98a5aad30b50a5b5b9e606
3
+ metadata.gz: 282197a645e710c42a8f5dc270014479fa140448bdda36763f50ae752a06c929
4
+ data.tar.gz: 2cb030c21fe0ee8c8fefe4e4d1d7d401721119ccc242d85ce79ccff1556134bc
5
5
  SHA512:
6
- metadata.gz: b215647faddd4a9ffe954f4a439cfcc6cf59c60d5719541abe2b74c544e0eaee9a425833009eefc31c664e5c38f9d972e0e0e8490328d0612f2f357d7f21e81a
7
- data.tar.gz: ce6049235be9c026c1ce070e22bb3dd5ca740bed64a15f5fc5f25f007b398aefa17de2e6118376bf6a437326735ee0ec384615b725e774f055818f2aa7d128fe
6
+ metadata.gz: cfa99cd28ccf17132d77902bffdf0874202148e49a32d5d59656949cbcaf06191f4adda461e9d23eaaca65d6497ffc14e0d67cac98b7d8748d6465cd066bcc6c
7
+ data.tar.gz: 5466138b9894de3a53f95e999f752d41ba965ccd9bd171d8da43cdff234b51fdfbfdaa42db9a507c7f0242b5505d7f45ed78b5b6cf93e2ee36b614e885b2688f
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ require:
3
3
  - rubocop-rake
4
4
  - rubocop-rspec
5
5
  AllCops:
6
- TargetRubyVersion: 2.7
6
+ TargetRubyVersion: 3.0
7
7
  NewCops: enable
8
8
  DisplayCopNames: true
9
9
  DisplayStyleGuide: true
@@ -36,6 +36,8 @@ RSpec/ExampleLength:
36
36
  Enabled: false
37
37
  RSpec/MultipleExpectations:
38
38
  Enabled: false
39
+ Style/ArgumentsForwarding:
40
+ Enabled: false
39
41
  Style/Documentation:
40
42
  Enabled: false
41
43
  Style/ExpandPathArguments:
data/CHANGELOG.md CHANGED
@@ -6,6 +6,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.4.0] - 2021-09-04
10
+ ### Added
11
+ - Added `assign_and_return!` to propagation extension
12
+
13
+ ## [1.3.2] - 2021-07-21
14
+ ### Changed
15
+ - Improved setup
16
+
17
+ ## [1.3.1] - 2021-07-21
18
+ ### Changed
19
+ - Improved Railtie support
20
+
21
+ ## [1.3.0] - 2021-07-19
22
+ ### Added
23
+ - Added Ruby 3.0 support
24
+
9
25
  ## [1.2.0] - 2021-02-04
10
26
  ### Changed
11
27
  - Add failed_steps to procedure
data/Gemfile.lock CHANGED
@@ -1,32 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-command (1.2.0)
4
+ lite-command (1.4.0)
5
5
  lite-errors
6
6
  lite-memoize
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (6.1.1)
12
- actionview (= 6.1.1)
13
- activesupport (= 6.1.1)
11
+ actionpack (6.1.4.1)
12
+ actionview (= 6.1.4.1)
13
+ activesupport (= 6.1.4.1)
14
14
  rack (~> 2.0, >= 2.0.9)
15
15
  rack-test (>= 0.6.3)
16
16
  rails-dom-testing (~> 2.0)
17
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (6.1.1)
19
- activesupport (= 6.1.1)
18
+ actionview (6.1.4.1)
19
+ activesupport (= 6.1.4.1)
20
20
  builder (~> 3.1)
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.1.1)
25
- activesupport (= 6.1.1)
26
- activerecord (6.1.1)
27
- activemodel (= 6.1.1)
28
- activesupport (= 6.1.1)
29
- activesupport (6.1.1)
24
+ activemodel (6.1.4.1)
25
+ activesupport (= 6.1.4.1)
26
+ activerecord (6.1.4.1)
27
+ activemodel (= 6.1.4.1)
28
+ activesupport (= 6.1.4.1)
29
+ activesupport (6.1.4.1)
30
30
  concurrent-ruby (~> 1.0, >= 1.0.2)
31
31
  i18n (>= 1.6, < 2)
32
32
  minitest (>= 5.1)
@@ -35,37 +35,37 @@ GEM
35
35
  ast (2.4.2)
36
36
  builder (3.2.4)
37
37
  colorize (0.8.1)
38
- concurrent-ruby (1.1.8)
38
+ concurrent-ruby (1.1.9)
39
39
  crass (1.0.6)
40
40
  database_cleaner (2.0.1)
41
41
  database_cleaner-active_record (~> 2.0.0)
42
- database_cleaner-active_record (2.0.0)
42
+ database_cleaner-active_record (2.0.1)
43
43
  activerecord (>= 5.a)
44
44
  database_cleaner-core (~> 2.0.0)
45
45
  database_cleaner-core (2.0.1)
46
46
  diff-lcs (1.4.4)
47
47
  erubi (1.10.0)
48
- fasterer (0.8.3)
48
+ fasterer (0.9.0)
49
49
  colorize (~> 0.7)
50
50
  ruby_parser (>= 3.14.1)
51
51
  generator_spec (0.9.4)
52
52
  activesupport (>= 3.0.0)
53
53
  railties (>= 3.0.0)
54
- i18n (1.8.8)
54
+ i18n (1.8.10)
55
55
  concurrent-ruby (~> 1.0)
56
- lite-errors (1.0.1)
57
- lite-memoize (1.0.3)
58
- loofah (2.9.0)
56
+ lite-errors (1.2.1)
57
+ lite-memoize (1.1.1)
58
+ loofah (2.12.0)
59
59
  crass (~> 1.0.2)
60
60
  nokogiri (>= 1.5.9)
61
61
  method_source (1.0.0)
62
- mini_portile2 (2.5.0)
63
- minitest (5.14.3)
64
- nokogiri (1.11.1)
65
- mini_portile2 (~> 2.5.0)
62
+ mini_portile2 (2.6.1)
63
+ minitest (5.14.4)
64
+ nokogiri (1.12.4)
65
+ mini_portile2 (~> 2.6.1)
66
66
  racc (~> 1.4)
67
- parallel (1.20.1)
68
- parser (3.0.0.0)
67
+ parallel (1.20.2)
68
+ parser (3.0.2.0)
69
69
  ast (~> 2.4.1)
70
70
  racc (1.5.2)
71
71
  rack (2.2.3)
@@ -74,18 +74,18 @@ GEM
74
74
  rails-dom-testing (2.0.3)
75
75
  activesupport (>= 4.2.0)
76
76
  nokogiri (>= 1.6)
77
- rails-html-sanitizer (1.3.0)
77
+ rails-html-sanitizer (1.4.2)
78
78
  loofah (~> 2.3)
79
- railties (6.1.1)
80
- actionpack (= 6.1.1)
81
- activesupport (= 6.1.1)
79
+ railties (6.1.4.1)
80
+ actionpack (= 6.1.4.1)
81
+ activesupport (= 6.1.4.1)
82
82
  method_source
83
- rake (>= 0.8.7)
83
+ rake (>= 0.13)
84
84
  thor (~> 1.0)
85
85
  rainbow (3.0.0)
86
- rake (13.0.3)
87
- regexp_parser (2.0.3)
88
- rexml (3.2.4)
86
+ rake (13.0.6)
87
+ regexp_parser (2.1.1)
88
+ rexml (3.2.5)
89
89
  rspec (3.10.0)
90
90
  rspec-core (~> 3.10.0)
91
91
  rspec-expectations (~> 3.10.0)
@@ -99,29 +99,29 @@ GEM
99
99
  diff-lcs (>= 1.2.0, < 2.0)
100
100
  rspec-support (~> 3.10.0)
101
101
  rspec-support (3.10.2)
102
- rubocop (1.9.1)
102
+ rubocop (1.20.0)
103
103
  parallel (~> 1.10)
104
104
  parser (>= 3.0.0.0)
105
105
  rainbow (>= 2.2.2, < 4.0)
106
106
  regexp_parser (>= 1.8, < 3.0)
107
107
  rexml
108
- rubocop-ast (>= 1.2.0, < 2.0)
108
+ rubocop-ast (>= 1.9.1, < 2.0)
109
109
  ruby-progressbar (~> 1.7)
110
110
  unicode-display_width (>= 1.4.0, < 3.0)
111
- rubocop-ast (1.4.1)
112
- parser (>= 2.7.1.5)
113
- rubocop-performance (1.9.2)
114
- rubocop (>= 0.90.0, < 2.0)
111
+ rubocop-ast (1.11.0)
112
+ parser (>= 3.0.1.1)
113
+ rubocop-performance (1.11.5)
114
+ rubocop (>= 1.7.0, < 2.0)
115
115
  rubocop-ast (>= 0.4.0)
116
- rubocop-rake (0.5.1)
117
- rubocop
118
- rubocop-rspec (2.2.0)
116
+ rubocop-rake (0.6.0)
117
+ rubocop (~> 1.0)
118
+ rubocop-rspec (2.4.0)
119
119
  rubocop (~> 1.0)
120
120
  rubocop-ast (>= 1.1.0)
121
121
  ruby-progressbar (1.11.0)
122
- ruby_parser (3.15.1)
123
- sexp_processor (~> 4.9)
124
- sexp_processor (4.15.2)
122
+ ruby_parser (3.17.0)
123
+ sexp_processor (~> 4.15, >= 4.15.1)
124
+ sexp_processor (4.15.3)
125
125
  sqlite3 (1.4.2)
126
126
  thor (1.1.0)
127
127
  tzinfo (2.0.4)
@@ -148,4 +148,4 @@ DEPENDENCIES
148
148
  sqlite3
149
149
 
150
150
  BUNDLED WITH
151
- 2.2.8
151
+ 2.2.26
data/README.md CHANGED
@@ -225,8 +225,12 @@ user_model.merge_errors!(command, direction: :to)
225
225
  Propagation methods help you perform an action on an object. If successful is
226
226
  returns the result else it adds the object errors to the form object. Available
227
227
  propagation methods are:
228
- `create_and_return!(object, params)`, `update_and_return!(object, params)`,
229
- `save_and_return!(object)`, and `destroy_and_return!(object)`
228
+ - `assign_and_return!(object, params)`
229
+ - `create_and_return!(klass, params)`
230
+ - `update_and_return!(object, params)`
231
+ - `destroy_and_return!(object)`
232
+ - `archive_and_return!(object)` (if using Lite::Archive)
233
+ - `save_and_return!(object)`
230
234
 
231
235
  ```ruby
232
236
  class SearchMovies < Lite::Command::Complex
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/generators'
4
-
5
3
  module Rails
6
4
  class CommandGenerator < Rails::Generators::NamedBase
7
5
 
@@ -6,16 +6,16 @@ module Lite
6
6
 
7
7
  class << self
8
8
 
9
- def call(*args)
10
- klass = new(*args)
9
+ def call(*args, **kwargs, &block)
10
+ klass = new(*args, **kwargs, &block)
11
11
  raise Lite::Command::NotImplementedError unless klass.respond_to?(:execute)
12
12
 
13
13
  klass.call
14
14
  klass
15
15
  end
16
16
 
17
- def execute(*args)
18
- klass = call(*args)
17
+ def execute(*args, **kwargs, &block)
18
+ klass = call(*args, **kwargs, &block)
19
19
  klass.result
20
20
  end
21
21
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lite/errors'
3
+ require 'lite/errors' unless defined?(Lite::Errors)
4
4
 
5
5
  module Lite
6
6
  module Command
@@ -9,8 +9,8 @@ module Lite
9
9
 
10
10
  module ClassMethods
11
11
 
12
- def perform(*args)
13
- klass = call(*args)
12
+ def perform(*args, **kwargs, &block)
13
+ klass = call(*args, **kwargs, &block)
14
14
 
15
15
  if klass.success?
16
16
  yield(klass.result, Lite::Command::Success, Lite::Command::Failure)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lite/memoize'
3
+ require 'lite/memoize' unless defined?(Lite::Memoize)
4
4
 
5
5
  module Lite
6
6
  module Command
@@ -7,11 +7,10 @@ module Lite
7
7
 
8
8
  private
9
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
10
+ def assign_and_return!(instance, params)
11
+ instance = instance.assign_attributes(params)
12
+ errors.merge!(instance.errors) unless instance.valid?
13
+ instance
15
14
  end
16
15
 
17
16
  def create_and_return!(klass, params)
@@ -20,9 +19,16 @@ module Lite
20
19
  klass
21
20
  end
22
21
 
23
- def update_and_return!(klass, params)
24
- merge_errors!(klass) unless klass.update(params)
25
- klass
22
+ def update_and_return!(instance, params)
23
+ merge_errors!(instance) unless instance.update(params)
24
+ instance
25
+ end
26
+
27
+ %i[archive destroy save].each do |action|
28
+ define_method("#{action}_and_return!") do |instance|
29
+ merge_errors!(instance) unless instance.send(action)
30
+ instance
31
+ end
26
32
  end
27
33
 
28
34
  end
@@ -6,10 +6,10 @@ module Lite
6
6
 
7
7
  class << self
8
8
 
9
- def call(*args)
9
+ def call(*args, **kwargs, &block)
10
10
  raise Lite::Command::NotImplementedError unless defined?(execute)
11
11
 
12
- execute(*args)
12
+ execute(*args, **kwargs, &block)
13
13
  end
14
14
 
15
15
  end
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Command
5
5
 
6
- VERSION = '1.2.0'
6
+ VERSION = '1.4.0'
7
7
 
8
8
  end
9
9
  end
data/lib/lite/command.rb CHANGED
@@ -1,13 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lite/command/version'
3
+ require 'generators/rails/command_generator' if defined?(Rails::Generators)
4
4
 
5
- %w[errors memoize propagation].each do |name|
6
- require "lite/command/extensions/#{name}"
7
- end
5
+ require 'lite/command/version'
8
6
 
9
- %w[exceptions states simple complex procedure].each do |name|
10
- require "lite/command/#{name}"
11
- end
7
+ require 'lite/command/extensions/errors'
8
+ require 'lite/command/extensions/memoize'
9
+ require 'lite/command/extensions/propagation'
12
10
 
13
- require 'generators/rails/command_generator'
11
+ require 'lite/command/exceptions'
12
+ require 'lite/command/states'
13
+ require 'lite/command/simple'
14
+ require 'lite/command/complex'
15
+ require 'lite/command/procedure'
data/lite-command.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  )
26
26
  else
27
27
  raise 'RubyGems 2.0 or newer is required to protect against ' \
28
- 'public gem pushes.'
28
+ 'public gem pushes.'
29
29
  end
30
30
 
31
31
  # Specify which files should be added to the gem when it is released.
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.2.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-04 00:00:00.000000000 Z
11
+ date: 2021-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lite-errors
@@ -262,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
262
  - !ruby/object:Gem::Version
263
263
  version: '0'
264
264
  requirements: []
265
- rubygems_version: 3.2.8
265
+ rubygems_version: 3.2.26
266
266
  signing_key:
267
267
  specification_version: 4
268
268
  summary: Ruby Command based framework (aka service objects)