smart_init 3.4.0 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smart_init/main.rb +6 -1
- data/lib/smart_init/version.rb +1 -1
- data/smart_init.gemspec +1 -1
- data/test/test_hash_api.rb +4 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51e20a618133427922cb386a3469a77420e95eaf2ad9debaf3f7684a1a0f3e35
|
4
|
+
data.tar.gz: 7441d3d6e5eec084365e041d1b33885489ffe4126ec6e16d8eefa04a28caab7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48c99e64ba5e5325b3ea9087be3eff565add93252a7a52efddd2810f6b37d255d98b475e97614d7201009636fe5a1d6070309f0cf2e761e5da8b4de72b0ee313
|
7
|
+
data.tar.gz: 2118838699bd2fcd42227041515033d01d790a1d6bcabe44437a0ce95cf0653fbc3c49d42d65a8bc65a708070302df621f79c62e7935d2d1eabd6552cb55f9ec
|
data/lib/smart_init/main.rb
CHANGED
@@ -28,7 +28,12 @@ module SmartInit
|
|
28
28
|
end
|
29
29
|
|
30
30
|
(required_attrs + default_value_attrs.keys).each do |attribute|
|
31
|
-
value = parameters.first
|
31
|
+
value = if parameters.first.has_key?(attribute)
|
32
|
+
parameters.first.fetch(attribute)
|
33
|
+
else
|
34
|
+
default_value_attrs[attribute]
|
35
|
+
end
|
36
|
+
|
32
37
|
instance_variable_set("@#{attribute}", value)
|
33
38
|
end
|
34
39
|
end
|
data/lib/smart_init/version.rb
CHANGED
data/smart_init.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.description = %q{ A smart DSL for ruby initializers boilerplate }
|
13
13
|
gem.homepage = "http://github.com/pawurb/smart_init"
|
14
14
|
gem.files = `git ls-files`.split("\n")
|
15
|
-
gem.test_files = gem.files.grep(%r{^(
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test)/})
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.license = "MIT"
|
18
18
|
gem.add_development_dependency "rake"
|
data/test/test_hash_api.rb
CHANGED
@@ -76,4 +76,8 @@ class HashApiTest < Test::Unit::TestCase
|
|
76
76
|
def test_all_defaults
|
77
77
|
assert_equal TestServiceAllDefaults.call, ["default_value_1", "default_value_2", "default_value_3"]
|
78
78
|
end
|
79
|
+
|
80
|
+
def test_falsey_values
|
81
|
+
assert_equal TestService.call(attribute_1: false, attribute_2: nil), [false, nil]
|
82
|
+
end
|
79
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_init
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,4 +80,6 @@ rubygems_version: 3.0.3
|
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: Remove Ruby initializer boilerplate code
|
83
|
-
test_files:
|
83
|
+
test_files:
|
84
|
+
- test/test_args_api.rb
|
85
|
+
- test/test_hash_api.rb
|