dry-initializer 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d7b2eac100f891f9a301c572c97182eaf78db71
4
- data.tar.gz: da3d4896fcd9037b02c334f0c9fabec64dc79333
3
+ metadata.gz: 67fcba3cf78d1b854e4ff970cc130c505d5d493c
4
+ data.tar.gz: 8f8efa2a05d06ba5b4f9d0d8db8f70d4bbe1f76a
5
5
  SHA512:
6
- metadata.gz: ff805cc5d6808fbba1471b790049388c23f2c555dd7024c145e87e4e550a60310ceb8fe46858d235fc3bc55705c8df97c50ad465e80907c78e318834ce69321d
7
- data.tar.gz: ef61fe2db0a4d404c39a4b0eb00c779c31dbddb0c4a926be77b7c9f7008c7e6e97c3d877df2161ecaf08ff4bd586ea913a9b3aeb2440d081b5c6cb130bdda66f
6
+ metadata.gz: d1ded457500d4a80d184c34a8045f8c7cee0ce914c1d007d980237c1cca6eb2fd9e35f4c5e7a0a7dc55c0b1ec2bc43168d969c549d8aee6e47ba9e6525b789ed
7
+ data.tar.gz: b948cc6fce3c2b98587364945790942d095997a36b5b9c0ce30ccd53453cff6b12169fcb87c4d086a74862aed7a02ce55bb0332aeef89e513f9af5f3a432f4bf
data/CHANGELOG.md CHANGED
@@ -5,7 +5,31 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
- ## [2.0.0] To be released ASAP
8
+ ## [2.1.0] [2017-09-11]
9
+
10
+ ### Added
11
+ - Method `#options` to param/option definition (nepalez)
12
+
13
+ ```ruby
14
+ class User
15
+ extend Dry::Initializer
16
+ option :name, proc(&:to_s), optional: true
17
+ option :email, optional: true
18
+ end
19
+
20
+ User.dry_initializer.options.map do |option|
21
+ [option.source, option.options]
22
+ end
23
+ # => [
24
+ # [:name, { type: proc(&:to_s), as: :name, optional: true }],
25
+ # [:email, { as: :email, optional: true }]
26
+ # ]
27
+ ```
28
+
29
+ This method can be helpful for replicating params/options
30
+ in another class without inheritance.
31
+
32
+ ## [2.0.0] [2017-08-28]
9
33
 
10
34
  The gem has been rewritten under the hood keeping its documented
11
35
  interface about the same (see "Deleted" section below for the only
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "dry-initializer"
3
- gem.version = "2.0.0"
3
+ gem.version = "2.1.0"
4
4
  gem.author = ["Vladimir Kochnev (marshall-lee)", "Andrew Kozin (nepalez)"]
5
5
  gem.email = "andrew.kozin@gmail.com"
6
6
  gem.homepage = "https://github.com/dryrb/dry-initializer"
@@ -11,6 +11,16 @@ module Dry::Initializer
11
11
  attr_reader :option, :null, :source, :target, :ivar,
12
12
  :type, :optional, :default, :reader
13
13
 
14
+ def options
15
+ {
16
+ as: target,
17
+ type: type,
18
+ optional: optional,
19
+ default: default,
20
+ reader: reader
21
+ }.reject { |_, value| value.nil? }
22
+ end
23
+
14
24
  def name
15
25
  @name ||= (option ? "option" : "parameter") << " '#{source}'"
16
26
  end
@@ -16,6 +16,22 @@ describe "definition" do
16
16
  option :bar
17
17
  end
18
18
  end
19
+
20
+ it "preservers definition params" do
21
+ params = Test::Foo.dry_initializer.params.map do |definition|
22
+ [definition.source, definition.options]
23
+ end
24
+
25
+ expect(params).to eq [[:foo, { as: :foo, reader: :public }]]
26
+ end
27
+
28
+ it "preservers definition options" do
29
+ options = Test::Foo.dry_initializer.options.map do |definition|
30
+ [definition.source, definition.options]
31
+ end
32
+
33
+ expect(options).to eq [[:bar, { as: :bar, reader: :public }]]
34
+ end
19
35
  end
20
36
 
21
37
  it_behaves_like :initializer, "extend Dry::Initializer" do
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: 2.0.0
4
+ version: 2.1.0
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: 2017-08-28 00:00:00.000000000 Z
12
+ date: 2017-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.5.2
148
+ rubygems_version: 2.6.13
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: DSL for declaring params and options of the initializer