simple_command 0.1.0 → 1.0.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: e1f9517aa67b971a3bf9f8a44789254c5bdcc0e790abba2dd154043d7654012a
4
- data.tar.gz: d137bb78badaff5767a9dc692d685cd7d6280cf3413b0fd3df2c954922055c4a
3
+ metadata.gz: 709a8e79d062fc2df30ceb2515a4996dac770a1a06b26cfedef243b560fa86d4
4
+ data.tar.gz: 6b30945ca6b05353376bb3636f42c501d7c349ded063adc98706628ced2ecc03
5
5
  SHA512:
6
- metadata.gz: 2f1dde12a3f9d6258fd6d85fd9591aaec4c9bd1839de53b511224a924d5faba132de927c375fe56898fb87862c33c2379fcd0410e3f5ce2cd2abeb5e54378593
7
- data.tar.gz: 70b63c426ec5e29060cdb9ce0b7c7457d84564b4ba109a481eb1cfe1779c1f2069bc1f878bb3c972abd1674bc3e1d0dfcd3a285cb9fc75e498c40eabe70a8c6e
6
+ metadata.gz: 5e9a41d79fe67caa53d69c54d690958f62eae87ef54c8e966360854adb4b1716580446255ccf5767a35aaea9f45ac53c1d20b0686b5ff30cd715ac37074d5d8c
7
+ data.tar.gz: 5ac692c46307b7f034658608b8217e5a367587b91760ca7f38aebb8cca3612eae9b29f3069ddb896b6ffbadd8b12f600609ebcc6b38c2f06f395358c9dc5655b
@@ -0,0 +1,23 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby: ["2.7", "3.0", "3.1", ruby-head, jruby-9.3, jruby-head]
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ bundler-cache: true # 'bundle install' and cache gems
21
+ ruby-version: ${{ matrix.ruby }}
22
+ - name: Run tests
23
+ run: bundle exec rake
@@ -10,7 +10,7 @@ module SimpleCommand
10
10
 
11
11
  def add_multiple_errors(errors_hash)
12
12
  errors_hash.each do |key, values|
13
- values.each { |value| add key, value }
13
+ SimpleCommand::Utils.array_wrap(values).each { |value| add key, value }
14
14
  end
15
15
  end
16
16
 
@@ -0,0 +1,14 @@
1
+ module SimpleCommand
2
+ module Utils
3
+ # Borrowed from active_support/core_ext/array/wrap
4
+ def self.array_wrap(object)
5
+ if object.nil?
6
+ []
7
+ elsif object.respond_to?(:to_ary)
8
+ object.to_ary || [object]
9
+ else
10
+ [object]
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleCommand
2
- VERSION = '0.1.0'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -1,12 +1,13 @@
1
1
  require 'simple_command/version'
2
+ require 'simple_command/utils'
2
3
  require 'simple_command/errors'
3
4
 
4
5
  module SimpleCommand
5
6
  attr_reader :result
6
7
 
7
8
  module ClassMethods
8
- def call(*args)
9
- new(*args).call
9
+ def call(*args, **kwargs)
10
+ new(*args, **kwargs).call
10
11
  end
11
12
  end
12
13
 
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.test_files = s.files.grep(/^(test|spec|features)\//)
20
20
  s.require_paths = ['lib']
21
21
 
22
- s.add_development_dependency 'bundler', '~> 1.7'
23
- s.add_development_dependency 'rake', '~> 10.0'
22
+ s.add_development_dependency 'bundler'
23
+ s.add_development_dependency 'rake'
24
24
  s.add_development_dependency 'rspec', '~> 3.1'
25
25
  end
@@ -19,21 +19,33 @@ describe SimpleCommand::Errors do
19
19
  end
20
20
 
21
21
  describe '#add_multiple_errors' do
22
- let(:errors_list) do
23
- {
22
+ it 'populates itself with the added errors' do
23
+ errors_list = {
24
24
  some_error: ['some error description'],
25
25
  another_error: ['another error description']
26
26
  }
27
- end
28
27
 
29
- before do
30
28
  errors.add_multiple_errors errors_list
31
- end
32
29
 
33
- it 'populates itself with the added errors' do
34
30
  expect(errors[:some_error]).to eq(errors_list[:some_error])
35
31
  expect(errors[:another_error]).to eq(errors_list[:another_error])
36
32
  end
33
+
34
+ it 'copies errors from another SimpleCommand::Errors object' do
35
+ command_errors = SimpleCommand::Errors.new
36
+ command_errors.add :some_error, "was found"
37
+ command_errors.add :some_error, "happened again"
38
+
39
+ errors.add_multiple_errors command_errors
40
+
41
+ expect(errors[:some_error]).to eq(["was found", "happened again"])
42
+ end
43
+
44
+ it "ignores nil values" do
45
+ errors.add_multiple_errors({:foo => nil})
46
+
47
+ expect(errors[:foo]).to eq nil
48
+ end
37
49
  end
38
50
 
39
51
  describe '#each' do
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Pavoni
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-03 00:00:00.000000000 Z
11
+ date: 2022-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.7'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -59,6 +59,7 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/workflows/ci.yml"
62
63
  - ".gitignore"
63
64
  - ".rspec"
64
65
  - ".rubocop.yml"
@@ -69,6 +70,7 @@ files:
69
70
  - Rakefile
70
71
  - lib/simple_command.rb
71
72
  - lib/simple_command/errors.rb
73
+ - lib/simple_command/utils.rb
72
74
  - lib/simple_command/version.rb
73
75
  - simple_command.gemspec
74
76
  - spec/factories/missed_call_command.rb
@@ -80,7 +82,7 @@ homepage: http://github.com/nebulab/simple_command
80
82
  licenses:
81
83
  - MIT
82
84
  metadata: {}
83
- post_install_message:
85
+ post_install_message:
84
86
  rdoc_options: []
85
87
  require_paths:
86
88
  - lib
@@ -95,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
97
  - !ruby/object:Gem::Version
96
98
  version: '0'
97
99
  requirements: []
98
- rubygems_version: 3.0.6
99
- signing_key:
100
+ rubygems_version: 3.2.20
101
+ signing_key:
100
102
  specification_version: 4
101
103
  summary: Easy way to build and manage commands (service objects)
102
104
  test_files: