lite-commands 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9952df6f6c22e9cbdaea749ace14c516a4fdbe10a317c930940b810ab575a3e9
4
- data.tar.gz: 10ef372dc0d547329ea0f05dd0f0f0e04dba9eed3536728600b28ab0d457e1c9
3
+ metadata.gz: 82235a0ddfa9ee5215ac9893ebf3f2481fbe53a5614732fbd2480208ffd86473
4
+ data.tar.gz: 2e8ec6a4f115ae7bee71381ac4f79f1908e8ea9048e175de3d3df976a69b58ac
5
5
  SHA512:
6
- metadata.gz: 847f62bfadd9aa8256a8d31e7d42d111d6055a793b33c471e314f0330cfcd73cef3d44318dda2dd1e047182931bf65429e9765b498b60a8481c816055de4bc40
7
- data.tar.gz: 181b2d0b438ed2665a9b404e8f3b36c58b67319be693a2bd63fa1fb4d7ee6d9ce6fb0f4b987b0ed7c68133b9f0dc27a6aa0b3028ab8a8301abed8a04025596a1
6
+ metadata.gz: 9fee64eb1c5df1aab5cee544a080973db262e06c9e529c0a1d56678e7a24d96e4286a17ee58c821266e3d39e90a3171604e3036bcef414a265b2ea2359fdb810
7
+ data.tar.gz: 22c2b7c08df74710d7084ecf75a711d2c9da0a7265c441a7887d2067e45e9086fded1eb0e465a6971e55b4f01f86712f08c0a28e53af3cb5675109bb47784e1f
data/.rubocop.yml CHANGED
@@ -18,6 +18,10 @@ Metrics/BlockLength:
18
18
  Exclude:
19
19
  - 'spec/**/**/*'
20
20
  - '*.gemspec'
21
+ RSpec/ExampleLength:
22
+ Enabled: false
23
+ RSpec/MultipleExpectations:
24
+ Enabled: false
21
25
  Style/Documentation:
22
26
  Enabled: false
23
27
  Style/ExpandPathArguments:
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.0.1] - 2019-07-31
10
+ ### Added
11
+ - Added perform method to errors mixin
12
+ ### Changed
13
+ - Renamed exception file to exceptions
14
+
9
15
  ## [1.0.0] - 2019-07-18
10
16
  ### Added
11
17
  - Initial project version
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-commands (1.0.0)
4
+ lite-commands (1.0.1)
5
5
  lite-errors
6
6
  lite-memoize
7
7
 
@@ -11,22 +11,22 @@ GEM
11
11
  ast (2.4.0)
12
12
  colorize (0.8.1)
13
13
  diff-lcs (1.3)
14
- fasterer (0.5.1)
14
+ fasterer (0.6.0)
15
15
  colorize (~> 0.7)
16
16
  ruby_parser (>= 3.13.0)
17
17
  jaro_winkler (1.5.3)
18
18
  lite-errors (1.0.1)
19
- lite-memoize (1.0.0)
19
+ lite-memoize (1.0.1)
20
20
  parallel (1.17.0)
21
21
  parser (2.6.3.0)
22
22
  ast (~> 2.4.0)
23
23
  rainbow (3.0.0)
24
- rake (12.3.2)
24
+ rake (12.3.3)
25
25
  rspec (3.8.0)
26
26
  rspec-core (~> 3.8.0)
27
27
  rspec-expectations (~> 3.8.0)
28
28
  rspec-mocks (~> 3.8.0)
29
- rspec-core (3.8.1)
29
+ rspec-core (3.8.2)
30
30
  rspec-support (~> 3.8.0)
31
31
  rspec-expectations (3.8.4)
32
32
  diff-lcs (>= 1.2.0, < 2.0)
@@ -35,16 +35,16 @@ GEM
35
35
  diff-lcs (>= 1.2.0, < 2.0)
36
36
  rspec-support (~> 3.8.0)
37
37
  rspec-support (3.8.2)
38
- rubocop (0.71.0)
38
+ rubocop (0.74.0)
39
39
  jaro_winkler (~> 1.5.1)
40
40
  parallel (~> 1.10)
41
41
  parser (>= 2.6)
42
42
  rainbow (>= 2.2.2, < 4.0)
43
43
  ruby-progressbar (~> 1.7)
44
44
  unicode-display_width (>= 1.4.0, < 1.7)
45
- rubocop-performance (1.4.0)
45
+ rubocop-performance (1.4.1)
46
46
  rubocop (>= 0.71.0)
47
- rubocop-rspec (1.33.0)
47
+ rubocop-rspec (1.34.1)
48
48
  rubocop (>= 0.60.0)
49
49
  ruby-progressbar (1.10.1)
50
50
  ruby_parser (3.13.1)
data/README.md CHANGED
@@ -115,6 +115,16 @@ class SearchMovies < Lite::Commands::Base
115
115
  end
116
116
  ```
117
117
 
118
+ **Caller**
119
+
120
+ ```ruby
121
+ # Useful for controllers or actions that depend on states.
122
+ SearchMovies.perform('Toy Story') do |result, success, failure|
123
+ success.call { redirect_to(movie_path, notice: "Movie can be found at: #{result}") }
124
+ failure.call { redirect_to(root_path, notice: "Movie cannot be found at: #{result}") }
125
+ end
126
+ ```
127
+
118
128
  **Methods**
119
129
 
120
130
  ```ruby
data/lib/lite/commands.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- %w[version exception errors memoize base].each do |name|
3
+ %w[version exceptions states errors memoize base].each do |name|
4
4
  require "lite/commands/#{name}"
5
5
  end
@@ -13,8 +13,8 @@ module Lite
13
13
  end
14
14
 
15
15
  def run(*args)
16
- klass = new(*args)
17
- klass.call
16
+ klass = call(*args)
17
+ klass.result
18
18
  end
19
19
 
20
20
  end
@@ -6,6 +6,28 @@ module Lite
6
6
  module Commands
7
7
  module Errors
8
8
 
9
+ module ClassMethods
10
+
11
+ def perform(*args)
12
+ klass = call(*args)
13
+
14
+ if klass.success?
15
+ yield(klass.result, Lite::Commands::Success, Lite::Commands::Failure)
16
+ else
17
+ yield(klass.result, Lite::Commands::Failure, Lite::Commands::Success)
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ class << self
24
+
25
+ def included(klass)
26
+ klass.extend(ClassMethods)
27
+ end
28
+
29
+ end
30
+
9
31
  def errors
10
32
  @errors ||= Lite::Errors::Messages.new
11
33
  end
File without changes
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lite
4
+ module Commands
5
+
6
+ class Success
7
+
8
+ class << self
9
+
10
+ def call
11
+ yield
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+
18
+ class Failure
19
+
20
+ class << self
21
+
22
+ def call
23
+ # Do nothing
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Commands
5
5
 
6
- VERSION ||= '1.0.0'
6
+ VERSION ||= '1.0.1'
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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-07-18 00:00:00.000000000 Z
11
+ date: 2019-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lite-errors
@@ -162,8 +162,9 @@ files:
162
162
  - lib/lite/commands.rb
163
163
  - lib/lite/commands/base.rb
164
164
  - lib/lite/commands/errors.rb
165
- - lib/lite/commands/exception.rb
165
+ - lib/lite/commands/exceptions.rb
166
166
  - lib/lite/commands/memoize.rb
167
+ - lib/lite/commands/states.rb
167
168
  - lib/lite/commands/version.rb
168
169
  - lite-commands.gemspec
169
170
  homepage: http://drexed.github.io/lite-commands