dry-initializer 0.9.2 → 0.9.3

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: 18ddd83e225177df21ed6dda7229643f2a746b3e
4
- data.tar.gz: 58e21460831b91ce91438c6ba869c130f7b13f9b
3
+ metadata.gz: 92409ca11ac8b4f856593691a82b0fbeae8c48bf
4
+ data.tar.gz: f8176cbbfb30b21c3084ad5108791ff2062e094b
5
5
  SHA512:
6
- metadata.gz: 15e1f2a75cf3229433588554d3c148f24d7109196602591f3b1a834b915c247e05c5564d1b306ab188d6d3c3a5e00c8de5fabb803485d2f7c44d8d7b1b4e4062
7
- data.tar.gz: bcbfec542d6db6dd57aa16a1f5dd01583a711307fb7ed9eeec267e30881c721640944a3969646936b3a5bfa03836746438828d58bf3b6cff21212d75857832e9
6
+ metadata.gz: c8c311f7daac997e3b08f86da46b31e40c9cd87a8ec0e9de14ff4d47679be2956cd009a11396aedd03f26e0455d9df149f2eb97582c90829459e517af9c8a21b
7
+ data.tar.gz: af5e325331c0dc37d4e160f90ffa59b608c21660bf919fa30f216c918203be548c165c909d1a28e9fcbcfeac6d30a38bc53bdd0623614976972921c5837aa3c5
@@ -1,3 +1,21 @@
1
+ ## v0.9.3 2016-11-10
2
+
3
+ ### Deprecated
4
+
5
+ * After discussion in [PR #17](https://github.com/dry-rb/dry-initializer/pull/17)
6
+ (many thanks to @sahal2080 and @hrom512 for starting that issue and PR),
7
+ the method `using` is deprecated and will be removed from v0.10.0 (@nepalez)
8
+
9
+ ### Fixed
10
+
11
+ * Support of weird option names (@nepalez)
12
+
13
+ ```ruby
14
+ option :"First name", as: :first_name
15
+ ```
16
+
17
+ [Compare v0.9.2...v0.9.3](https://github.com/dry-rb/dry-initializer/compare/v0.9.2...v0.9.3)
18
+
1
19
  ## v0.9.2 2016-11-10
2
20
 
3
21
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "dry-initializer"
3
- gem.version = "0.9.2"
3
+ gem.version = "0.9.3"
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"
@@ -40,6 +40,7 @@ module Dry::Initializer
40
40
  # @return [self]
41
41
  #
42
42
  def using(**settings, &block)
43
+ warn "[DEPRECATION] The method `using` will be removed in v0.10.0"
43
44
  Scope.new(self, settings).instance_eval(&block)
44
45
  self
45
46
  end
@@ -42,7 +42,7 @@ module Dry::Initializer::Plugins
42
42
  # Returns the name for the attribute
43
43
  # @return (see .name)
44
44
  def rename
45
- @rename ||= settings[:option] ? settings[:as] || name : name
45
+ @rename ||= settings[:option] ? (settings[:as] || name) : name
46
46
  end
47
47
  end
48
48
  end
@@ -22,8 +22,9 @@ module Dry::Initializer::Plugins
22
22
 
23
23
  def call
24
24
  return "@#{name} = #{name}" if param?
25
- return "@#{rename} = __options__.fetch(:#{name})" if required?
26
- "@#{rename} = __options__.fetch(:#{name}, Dry::Initializer::UNDEFINED)"
25
+ key = ":\"#{name}\""
26
+ return "@#{rename} = __options__.fetch(#{key})" if required?
27
+ "@#{rename} = __options__.fetch(#{key}, Dry::Initializer::UNDEFINED)"
27
28
  end
28
29
  end
29
30
  end
@@ -3,11 +3,11 @@ describe "renaming options" do
3
3
  class Test::Foo
4
4
  extend Dry::Initializer::Mixin
5
5
 
6
- option :foo, as: :bar
6
+ option :"some foo", as: :bar
7
7
  end
8
8
  end
9
9
 
10
- subject { Test::Foo.new foo: :BAZ }
10
+ subject { Test::Foo.new "some foo": :BAZ }
11
11
 
12
12
  it "renames the attribute" do
13
13
  expect(subject.bar).to eq :BAZ
@@ -16,6 +16,5 @@ describe "renaming options" do
16
16
 
17
17
  it "renames the variable" do
18
18
  expect(subject.instance_variable_get(:@bar)).to eq :BAZ
19
- expect(subject.instance_variable_get(:@foo)).to be_nil
20
19
  end
21
20
  end
@@ -3,8 +3,12 @@ describe "shared definition" do
3
3
  class Test::Foo
4
4
  extend Dry::Initializer::Mixin
5
5
 
6
+ class << self
7
+ alias_method :attribute, :param
8
+ end
9
+
6
10
  using default: proc { nil } do
7
- param :foo
11
+ attribute :foo
8
12
  option :end
9
13
  option :baz, default: proc { 0 }
10
14
  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.9.2
4
+ version: 0.9.3
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-11-10 00:00:00.000000000 Z
12
+ date: 2016-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -182,3 +182,4 @@ test_files:
182
182
  - spec/type_argument_spec.rb
183
183
  - spec/type_constraint_spec.rb
184
184
  - spec/value_coercion_via_dry_types_spec.rb
185
+ has_rdoc: