dry-initializer 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/dry-initializer.gemspec +1 -1
- data/lib/dry/initializer/plugins/base.rb +1 -2
- data/lib/dry/initializer/signature.rb +2 -1
- data/spec/default_values_spec.rb +32 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 703f60031e8175b459409542ce364d243e74176c
|
4
|
+
data.tar.gz: 7397c054e19e469e5d3aff41f6ee4ea2a051b28c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 230abf76b90e2f32c5435652e90990231698fce5237ff23b12b4a87091292e9fa8aa7cefa8527357cdece57c563d22c11136cc179bf3e875a39fd45a9a4ad530
|
7
|
+
data.tar.gz: 26c23b5a2ca43c0de31110d24a0253140433d6a8b4e0d21ccabb8a2fc879fff899d99e4da04c91662da5e782e321774563379d64e25626c5b0f7948979c70e09
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## v0.10.1 2016-12-27
|
2
|
+
|
3
|
+
### Fixed
|
4
|
+
|
5
|
+
* Wrong arity when there were no options and the last param had a default (@nolith)
|
6
|
+
|
7
|
+
[Compare v0.10.0...v0.10.1](https://github.com/dry-rb/dry-initializer/compare/v0.10.0...v0.10.1)
|
8
|
+
|
1
9
|
## v0.10.0 2016-11-20
|
2
10
|
|
3
11
|
### Deleted (BREAKING CHANGE!)
|
data/dry-initializer.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "dry-initializer"
|
3
|
-
gem.version = "0.10.
|
3
|
+
gem.version = "0.10.1"
|
4
4
|
gem.author = ["Vladimir Kochnev (marshall-lee)", "Andrew Kozin (nepalez)"]
|
5
5
|
gem.email = ["hashtable@yandex.ru", "andrew.kozin@gmail.com"]
|
6
6
|
gem.homepage = "https://github.com/dryrb/dry-initializer"
|
@@ -25,7 +25,8 @@ module Dry::Initializer
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def call
|
28
|
-
(
|
28
|
+
options = all?(&:param?) ? %w(__options__={}) : %w(**__options__)
|
29
|
+
(select(&:param?).map(&:call) + options).compact.join(", ")
|
29
30
|
end
|
30
31
|
|
31
32
|
private
|
data/spec/default_values_spec.rb
CHANGED
@@ -48,4 +48,36 @@ describe "default values" do
|
|
48
48
|
subject = Test::Foo.new
|
49
49
|
expect(subject.mox).to eql :MOX
|
50
50
|
end
|
51
|
+
|
52
|
+
describe "when the last param has a default and there are no options" do
|
53
|
+
before do
|
54
|
+
class Test::Bar
|
55
|
+
extend Dry::Initializer::Mixin
|
56
|
+
|
57
|
+
param :foo
|
58
|
+
param :bar, default: proc { {} }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it "instantiate arguments" do
|
63
|
+
subject = Test::Bar.new(1, 2)
|
64
|
+
|
65
|
+
expect(subject.foo).to eql 1
|
66
|
+
expect(subject.bar).to eql 2
|
67
|
+
end
|
68
|
+
|
69
|
+
it "applies default values" do
|
70
|
+
subject = Test::Bar.new(1)
|
71
|
+
|
72
|
+
expect(subject.foo).to eql 1
|
73
|
+
expect(subject.bar).to eql({})
|
74
|
+
end
|
75
|
+
|
76
|
+
it "instantiate arguments also if the last is an hash" do
|
77
|
+
subject = Test::Bar.new(1, { baz: 2, qux: 3 })
|
78
|
+
|
79
|
+
expect(subject.foo).to eql 1
|
80
|
+
expect(subject.bar).to eql({ baz: 2, qux: 3 })
|
81
|
+
end
|
82
|
+
end
|
51
83
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-initializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Kochnev (marshall-lee)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.5.2
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: DSL for declaring params and options of the initializer
|
@@ -173,4 +173,3 @@ test_files:
|
|
173
173
|
- spec/type_argument_spec.rb
|
174
174
|
- spec/type_constraint_spec.rb
|
175
175
|
- spec/value_coercion_via_dry_types_spec.rb
|
176
|
-
has_rdoc:
|