light-service 0.8.3 → 0.8.4

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
  SHA1:
3
- metadata.gz: bd457f452026a64465b3d6da771be7ed69547580
4
- data.tar.gz: d330c6b02f86878cb314786b36fff478dfa3fa20
3
+ metadata.gz: fa927bdc5eaab0a8eed9f198bf61c28c042dc530
4
+ data.tar.gz: 6855d34240f37a93ef2ece590074eabd30ff901d
5
5
  SHA512:
6
- metadata.gz: f054267b74b35a40a6f0a9f007e2144d375c9574b593a7f116a252df196e413e2b90476222d31ae11f92fe5b08847a3956f970d16e5ca09d8fc6f15809ae8bf1
7
- data.tar.gz: '018c3672a0eaf6a526495607066ea499d3488608cd855694f5d2053583a2a62618b11f0b3b30cd50fe09e6e3ec60f5172546de7834c7f11319d4236f72c935a2'
6
+ metadata.gz: 5bb0724f04a18663620795c3f53fa048e88a6a07d441dd2250f1e0121f68f5b7f3d108aeb4ff64155ec83f6151756efc2f695df071d2f77dc14c3519380abddb
7
+ data.tar.gz: be037dc8236f1d38b860e912226e28a951db55be761c6b3f8591adf4404c1d61b367538ee4bd9c6595d546e50d206604529b71ed6ddefe59cd93e0a7a68cb5e6
data/.rubocop.yml CHANGED
@@ -18,7 +18,7 @@ Style/Encoding:
18
18
  Style/StringLiterals:
19
19
  Enabled: false
20
20
 
21
- Style/TrailingBlankLines:
21
+ Style/FormatStringToken:
22
22
  Enabled: false
23
23
 
24
24
  Style/RedundantReturn:
@@ -30,11 +30,19 @@ Style/SignalException:
30
30
  Style/HashSyntax:
31
31
  EnforcedStyle: hash_rockets
32
32
 
33
- Style/PredicateName:
34
- Enabled: false
35
-
36
33
  Style/TrivialAccessors:
37
34
  AllowPredicates: true
38
35
 
36
+ Naming/PredicateName:
37
+ Enabled: false
38
+
39
39
  Metrics/MethodLength:
40
40
  Max: 15
41
+
42
+ Metrics/BlockLength:
43
+ Max: 35
44
+ Exclude:
45
+ - 'spec/**/*.rb'
46
+
47
+ Layout/TrailingBlankLines:
48
+ Enabled: false
data/RELEASES.md CHANGED
@@ -1,5 +1,8 @@
1
1
  A brief list of new features and changes introduced with the specified version.
2
2
 
3
+ ### 0.8.4
4
+ * Only pass [default argument](https://github.com/adomokos/light-service/pull/123) to Hash#fetch in context if no block given.
5
+
3
6
  ### 0.8.3
4
7
  * Make logging more [efficient](https://github.com/adomokos/light-service/pull/120) the context.
5
8
 
data/Rakefile CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env rake
2
1
  require "bundler/gem_tasks"
3
2
 
4
3
  require "rubygems"
@@ -10,4 +9,4 @@ RuboCop::RakeTask.new
10
9
  RSpec::Core::RakeTask.new(:spec)
11
10
 
12
11
  task(:default).clear
13
- task :default => [:spec, :rubocop]
12
+ task :default => %i[spec rubocop]
@@ -19,7 +19,6 @@ module LightService
19
19
  @error_code = error_code
20
20
  @skip_remaining = false
21
21
  context.to_hash.each { |k, v| self[k] = v }
22
- self
23
22
  end
24
23
 
25
24
  def self.make(context = {})
@@ -140,8 +139,12 @@ module LightService
140
139
  return super(key)
141
140
  end
142
141
 
143
- def fetch(key, default_or_block = nil)
144
- self[key] ||= super(key, default_or_block)
142
+ def fetch(key, default = nil, &blk)
143
+ self[key] ||= if block_given?
144
+ super(key, &blk)
145
+ else
146
+ super
147
+ end
145
148
  end
146
149
 
147
150
  def inspect
@@ -10,7 +10,7 @@ module LightService
10
10
 
11
11
  def are_all_keys_in_context?(keys)
12
12
  not_found_keys = keys_not_found(keys)
13
- !not_found_keys.any?
13
+ not_found_keys.none?
14
14
  end
15
15
 
16
16
  def keys_not_found(keys)
@@ -111,7 +111,7 @@ module LightService
111
111
  end
112
112
 
113
113
  def reserved_keys
114
- [:message, :error_code, :current_action].freeze
114
+ %i[message error_code current_action].freeze
115
115
  end
116
116
  end
117
117
  end
@@ -17,7 +17,7 @@ module LightService
17
17
  # In case this module is included
18
18
  module ClassMethods
19
19
  def with(data = {})
20
- VerifyCallMethodExists.call(self, caller.first)
20
+ VerifyCallMethodExists.call(self, caller(1..1).first)
21
21
  data[:_aliases] = @aliases if @aliases
22
22
  WithReducerFactory.make(self).with(data)
23
23
  end
@@ -1,3 +1,3 @@
1
1
  module LightService
2
- VERSION = "0.8.3".freeze
2
+ VERSION = "0.8.4".freeze
3
3
  end
@@ -20,6 +20,6 @@ Gem::Specification.new do |gem|
20
20
 
21
21
  gem.add_development_dependency("rspec", "~> 3.0")
22
22
  gem.add_development_dependency("simplecov", "~> 0.14.1")
23
- gem.add_development_dependency("rubocop", "0.46")
23
+ gem.add_development_dependency("rubocop", "~> 0.51")
24
24
  gem.add_development_dependency("pry", "~> 0.10")
25
25
  end
data/spec/action_spec.rb CHANGED
@@ -74,7 +74,7 @@ describe LightService::Action do
74
74
  result = TestDoubles::AddsTwoActionWithFetch.execute(ctx)
75
75
 
76
76
  expect(result).to be_success
77
- expect(result.keys).to eq([:some_key, :number])
77
+ expect(result.keys).to eq(%i[some_key number])
78
78
  end
79
79
  end
80
80
 
data/spec/context_spec.rb CHANGED
@@ -162,6 +162,14 @@ RSpec.describe LightService::Context do
162
162
  expect(context[:foo]).to eq false
163
163
  end
164
164
 
165
+ it "allows a default value for #fetch" do
166
+ expect(context.fetch(:madeup, :default)).to eq(:default)
167
+ end
168
+
169
+ it "allows a default block value for #fetch" do
170
+ expect(context.fetch(:madeup) { :default }).to eq(:default)
171
+ end
172
+
165
173
  context "when aliases are included via .make" do
166
174
  let(:context) do
167
175
  LightService::Context.make(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: light-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Attila Domokos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-10 00:00:00.000000000 Z
11
+ date: 2017-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.46'
61
+ version: '0.51'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.46'
68
+ version: '0.51'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry
71
71
  requirement: !ruby/object:Gem::Requirement