g2_command 1.0.0 → 2.4.0

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.
data/lib/command.rb CHANGED
@@ -5,6 +5,7 @@ require 'active_model'
5
5
  require 'dry-initializer'
6
6
  require 'dry-monads'
7
7
 
8
+ require 'gem_ext/active_model/errors' if ActiveModel.version < Gem::Version.new('5.2')
8
9
  require 'command/failure'
9
10
  require 'command/input_middleware'
10
11
  require 'command/interrupt'
@@ -12,14 +13,13 @@ require 'command/interrupt'
12
13
  module Command
13
14
  extend ActiveSupport::Concern
14
15
 
15
- # rubocop:disable Metrics/BlockLength
16
16
  included do
17
17
  extend Dry::Initializer
18
18
  include Dry::Monads[:result]
19
19
  include ActiveModel::Validations
20
20
 
21
21
  def initialize(inputs = {})
22
- super(Command::InputMiddleware.call(inputs))
22
+ super(**Command::InputMiddleware.call(inputs))
23
23
  end
24
24
 
25
25
  def execute
@@ -38,8 +38,8 @@ module Command
38
38
  errors.empty? ? Success(result) : Failure(Command::Failure.new(result, errors))
39
39
  end
40
40
 
41
- def compose(command, *args)
42
- outcome = command.run(*args)
41
+ def compose(command, **args)
42
+ outcome = command.run(**args)
43
43
 
44
44
  raise Command::Interrupt, outcome.failure.errors if outcome.failure?
45
45
 
@@ -50,11 +50,10 @@ module Command
50
50
  self.class.dry_initializer.attributes(self)
51
51
  end
52
52
  end
53
- # rubocop:enable Metrics/BlockLength
54
53
 
55
54
  class_methods do
56
55
  def run(inputs = {})
57
- new(inputs).run
56
+ new(**Command::InputMiddleware.call(inputs)).run
58
57
  end
59
58
 
60
59
  def run!(inputs = {})
@@ -8,7 +8,7 @@ module Command
8
8
  def self.call(inputs)
9
9
  return inputs unless inputs.is_a?(Hash)
10
10
 
11
- inputs.to_h.deep_symbolize_keys
11
+ inputs.to_h.symbolize_keys
12
12
  end
13
13
  end
14
14
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Command
4
- VERSION = '1.0.0'
4
+ VERSION = '2.4.0'
5
5
  end
@@ -0,0 +1,10 @@
1
+ require 'active_model/errors'
2
+
3
+ module ActiveModel
4
+ class Errors
5
+ def merge!(other)
6
+ @messages.merge!(other.messages) { |_, ary1, ary2| ary1 + ary2 }
7
+ @details.merge!(other.details) { |_, ary1, ary2| ary1 + ary2 }
8
+ end
9
+ end
10
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: g2_command
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamed Asghari
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-26 00:00:00.000000000 Z
11
+ date: 2021-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '6.0'
19
+ version: '5.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '7'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '6.0'
29
+ version: '5.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '7'
@@ -36,7 +36,7 @@ dependencies:
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '6.0'
39
+ version: '5.0'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '7'
@@ -46,7 +46,7 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '6.0'
49
+ version: '5.0'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '7'
@@ -78,18 +78,22 @@ dependencies:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
80
  version: '1.3'
81
- description:
81
+ description:
82
82
  email:
83
83
  - hasghari@g2.com
84
84
  executables: []
85
85
  extensions: []
86
86
  extra_rdoc_files: []
87
87
  files:
88
- - ".github/workflows/ruby.yml"
88
+ - ".circleci/config.yml"
89
+ - ".github/config/rubocop_linter_action.yml"
90
+ - ".github/workflows/linters.yml"
89
91
  - ".gitignore"
90
92
  - ".rspec"
91
93
  - ".rubocop.yml"
94
+ - ".ruby-version"
92
95
  - ".tool-versions"
96
+ - Appraisals
93
97
  - CODE_OF_CONDUCT.md
94
98
  - Gemfile
95
99
  - Gemfile.lock
@@ -99,6 +103,15 @@ files:
99
103
  - bin/console
100
104
  - bin/setup
101
105
  - g2_command.gemspec
106
+ - gemfiles/.bundle/config
107
+ - gemfiles/rails_5.1.gemfile
108
+ - gemfiles/rails_5.1.gemfile.lock
109
+ - gemfiles/rails_5.2.gemfile
110
+ - gemfiles/rails_5.2.gemfile.lock
111
+ - gemfiles/rails_6.0.gemfile
112
+ - gemfiles/rails_6.0.gemfile.lock
113
+ - gemfiles/rails_6.1.gemfile
114
+ - gemfiles/rails_6.1.gemfile.lock
102
115
  - lib/command.rb
103
116
  - lib/command/failure.rb
104
117
  - lib/command/input_middleware.rb
@@ -107,13 +120,14 @@ files:
107
120
  - lib/command/interrupt.rb
108
121
  - lib/command/version.rb
109
122
  - lib/g2_command.rb
123
+ - lib/gem_ext/active_model/errors.rb
110
124
  homepage: https://github.com/g2crowd/g2_command
111
125
  licenses:
112
126
  - MIT
113
127
  metadata:
114
128
  homepage_uri: https://github.com/g2crowd/g2_command
115
129
  source_code_uri: https://github.com/g2crowd/g2_command
116
- post_install_message:
130
+ post_install_message:
117
131
  rdoc_options: []
118
132
  require_paths:
119
133
  - lib
@@ -121,15 +135,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - ">="
123
137
  - !ruby/object:Gem::Version
124
- version: 2.3.0
138
+ version: 2.4.0
125
139
  required_rubygems_version: !ruby/object:Gem::Requirement
126
140
  requirements:
127
141
  - - ">="
128
142
  - !ruby/object:Gem::Version
129
143
  version: '0'
130
144
  requirements: []
131
- rubygems_version: 3.0.3
132
- signing_key:
145
+ rubygems_version: 3.2.3
146
+ signing_key:
133
147
  specification_version: 4
134
148
  summary: An implementation of the command pattern using dry-rb
135
149
  test_files: []
@@ -1,26 +0,0 @@
1
- name: Ruby
2
-
3
- on: [push]
4
-
5
- jobs:
6
- build:
7
-
8
- runs-on: ubuntu-latest
9
-
10
- steps:
11
- - uses: actions/checkout@v2
12
- - name: Set up Ruby
13
- uses: ruby/setup-ruby@v1
14
- with:
15
- ruby-version: 2.6.6
16
- - name: Configure Bundler
17
- run: |
18
- gem install bundler:2.1.4 --no-document
19
- bundle install --jobs 4 --retry 3
20
- - name: Run tests with RSpec
21
- uses: paambaati/codeclimate-action@v2.5.4
22
- env:
23
- CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
24
- with:
25
- coverageCommand: bundle exec rspec
26
- debug: false