simple_command 0.2.0 → 1.0.1

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: 8847792f86f2c4162d832d2603abfb7f0f40208110ad339484851dfaeeb99cf4
4
- data.tar.gz: ba9e8c0e1d46fb25d8408f430ba462e14e2ca386e5cd7b4c611d7787523448a0
3
+ metadata.gz: 0bfe8377a98ac9d816954e6060c6fb39b0e0c6a8817a1f14ccc3695ff1f38711
4
+ data.tar.gz: f7ffdea8cec0b7988a8b4b71977986d1a0b2aa9ac5c2219ac9fd490c114c8b41
5
5
  SHA512:
6
- metadata.gz: d4fa95128f6e3fcd15419705bf36d56c33b8da0ced34b068940a3ee3fe066feeada465f8257f5076a87f3e237bd0adfd83b377a1d68bf9e81a09240bae5be243
7
- data.tar.gz: 8cc7cea6c22b3af310b039eee0f041f0ac5c48597d8cc13122771ffdef67a54dcf2ce8f2b77172ad3c6425e5598024d2ef48d95a7562083c94c3d1419348a7e0
6
+ metadata.gz: 11cde61466a2c6fea1c40cee0f358e3e299ea9bc3e98653fd9a8bafc414f5475a24bd3fa26537d1c7c86be8774f26d703e2aef44c6a325b441b7b9e9eb143be6
7
+ data.tar.gz: 03c2d3b58075237aa7e56d2a72dd4b7faafa5f7b7b13dd76fcc919b034e9eecd581c3099f9ce1aa4ba4efe91074699b2622f8e9be19bc1838edad7f282030c5b
@@ -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.6", "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
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Code Climate](https://codeclimate.com/github/nebulab/simple_command/badges/gpa.svg)](https://codeclimate.com/github/nebulab/simple_command)
2
- [ ![Codeship Status for nebulab/simple_command](https://app.codeship.com/projects/45ce7790-8daf-0132-1412-669677a474c3/status?branch=master)](https://app.codeship.com/projects/60741)
2
+ ![CI](https://github.com/nebulab/simple_command/actions/workflows/ci.yml/badge.svg)
3
3
 
4
4
  # SimpleCommand
5
5
 
@@ -7,7 +7,7 @@ A simple, standardized way to build and use _Service Objects_ (aka _Commands_) i
7
7
 
8
8
  ## Requirements
9
9
 
10
- * Ruby 2.0+
10
+ * Ruby 2.6+
11
11
 
12
12
  ## Installation
13
13
 
@@ -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.2.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'simple_command/version'
2
+ require 'simple_command/utils'
2
3
  require 'simple_command/errors'
3
4
 
4
5
  module SimpleCommand
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'simple_command/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.required_ruby_version = '>= 2.0'
7
+ s.required_ruby_version = '>= 2.6'
8
8
  s.name = 'simple_command'
9
9
  s.version = SimpleCommand::VERSION
10
10
  s.authors = ['Andrea Pavoni']
@@ -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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Pavoni
@@ -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
@@ -88,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
90
  requirements:
89
91
  - - ">="
90
92
  - !ruby/object:Gem::Version
91
- version: '2.0'
93
+ version: '2.6'
92
94
  required_rubygems_version: !ruby/object:Gem::Requirement
93
95
  requirements:
94
96
  - - ">="