smart_initializer 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: 756d03ef9a7c4f10bb075d1669bb4abe856d0dd6a68c0bd632b927a3a32662e6
4
- data.tar.gz: 7deaef19a44a8e9a813bb5548aef332df88087b62f5cf6265929875f7eb20000
3
+ metadata.gz: 9bd642b208f012f92391fa7564b1726eced30ef64ed7bcd31a1a7a2c5ef1c5fc
4
+ data.tar.gz: c1645e91c921429d8dd4314c730bd28c7be981f21f0a90fcee224c267e410fb4
5
5
  SHA512:
6
- metadata.gz: 1c04e15b4f1896201bf08aec13c9bb2e5d770b65115960a9ca01d307088b04171f0c81beaa1b71d54fc2bf6888406d9e63ce0a49b5695baf41523f89b89ac85a
7
- data.tar.gz: 3f3ff4b2fa17bb7727abdb1d73839bc954b0e0c2dba9f19ad8a46a95cfa9df3a17549bdfc73775d6753d799052a14f4e7a9732fefbb5dafbec5f20f72b8063b4
6
+ metadata.gz: 65b8419d5b08f2fd53044963cf0451f903d4b69a030f6ccb38a462e3055d22d6e1ed416ca7872d195b569d15cc0acc5cb087b91af6180a42305eb1e656afaded
7
+ data.tar.gz: cdf0ef362116f807c603384008c9a829220879a9e27b1120d6de673779092740c12d906c0dd4923a4c4429f7ee7aac6418f248388b02d7d3a293cf9737403bbf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.2.0] - 2020-05-16
5
+ ### Changed
6
+ - **Constructor**: disallow unknown option attributes;
7
+
4
8
  ## [0.1.0] - 2020-05-10
5
9
  - Release :)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_initializer (0.1.0.alpha4)
4
+ smart_initializer (0.2.0)
5
5
  qonfig (~> 0.24)
6
6
  smart_engine (~> 0.6)
7
7
  smart_types (~> 0.1.0)
@@ -15,8 +15,8 @@ GEM
15
15
  minitest (~> 5.1)
16
16
  tzinfo (~> 1.1)
17
17
  zeitwerk (~> 2.2, >= 2.2.2)
18
- armitage-rubocop (0.82.0.2)
19
- rubocop (= 0.82.0)
18
+ armitage-rubocop (0.83.0)
19
+ rubocop (= 0.83.0)
20
20
  rubocop-performance (= 1.5.2)
21
21
  rubocop-rails (= 2.5.2)
22
22
  rubocop-rake (= 0.5.1)
@@ -27,8 +27,7 @@ GEM
27
27
  docile (1.3.2)
28
28
  i18n (1.8.2)
29
29
  concurrent-ruby (~> 1.0)
30
- jaro_winkler (1.5.4)
31
- minitest (5.14.0)
30
+ minitest (5.14.1)
32
31
  parallel (1.19.1)
33
32
  parser (2.7.1.2)
34
33
  ast (~> 2.4.0)
@@ -50,8 +49,7 @@ GEM
50
49
  diff-lcs (>= 1.2.0, < 2.0)
51
50
  rspec-support (~> 3.9.0)
52
51
  rspec-support (3.9.3)
53
- rubocop (0.82.0)
54
- jaro_winkler (~> 1.5.1)
52
+ rubocop (0.83.0)
55
53
  parallel (~> 1.10)
56
54
  parser (>= 2.7.0.1)
57
55
  rainbow (>= 2.2.2, < 4.0)
@@ -86,7 +84,7 @@ PLATFORMS
86
84
  ruby
87
85
 
88
86
  DEPENDENCIES
89
- armitage-rubocop (~> 0.81)
87
+ armitage-rubocop (~> 0.83)
90
88
  bundler (~> 2.1)
91
89
  rake (~> 13.0)
92
90
  rspec (~> 3.9)
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # SmartCore::Initializer &middot; [![Gem Version](https://badge.fury.io/rb/smart_initializer.svg)](https://badge.fury.io/rb/smart_initializer) [![Build Status](https://travis-ci.org/smart-rb/smart_initializer.svg?branch=master)](https://travis-ci.org/smart-rb/smart_initializer)
2
2
 
3
- A simple and convenient way to declare complex constructors (**in active development**).
3
+ A simple and convenient way to declare complex constructors with a support for various commonly used type systems.
4
+ (**in active development**).
4
5
 
5
6
  ## Installation
6
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- smart_initializer (0.1.0.alpha4)
4
+ smart_initializer (0.1.0)
5
5
  qonfig (~> 0.24)
6
6
  smart_engine (~> 0.6)
7
7
  smart_types (~> 0.1.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- smart_initializer (0.1.0.alpha4)
4
+ smart_initializer (0.1.0)
5
5
  qonfig (~> 0.24)
6
6
  smart_engine (~> 0.6)
7
7
  smart_types (~> 0.1.0)
@@ -72,8 +72,8 @@ class SmartCore::Initializer::Constructor
72
72
  #
73
73
  # @api private
74
74
  # @since 0.1.0
75
+ # rubocop:disable Metrics/AbcSize
75
76
  def prevent_attribute_insufficiency
76
- required_options = klass.__options__.reject(&:has_default?).map(&:name)
77
77
  required_parameter_count = klass.__params__.size
78
78
 
79
79
  raise(
@@ -82,13 +82,23 @@ class SmartCore::Initializer::Constructor
82
82
  "(given #{parameters.size}, expected #{required_parameter_count})"
83
83
  ) unless parameters.size == required_parameter_count
84
84
 
85
- missing_options = required_options.reject { |option| options.key?(option) }
85
+ required_options = klass.__options__.reject(&:has_default?).map(&:name)
86
+ missing_options = required_options.reject { |option| options.key?(option) }
86
87
 
87
88
  raise(
88
89
  SmartCore::Initializer::OptionArgumentError,
89
90
  "Missing options: #{missing_options.join(', ')}"
90
91
  ) if missing_options.any?
92
+
93
+ possible_options = klass.__options__.map(&:name)
94
+ unknown_options = options.keys - possible_options
95
+
96
+ raise(
97
+ SmartCore::Initializer::OptionArgumentError,
98
+ "Unknown options: #{unknown_options.join(', ')}"
99
+ ) if unknown_options.any?
91
100
  end
101
+ # rubocop:enable Metrics/AbcSize
92
102
 
93
103
  # @return [Any]
94
104
  #
@@ -6,6 +6,6 @@ module SmartCore
6
6
  #
7
7
  # @api public
8
8
  # @since 0.1.0
9
- VERSION = '0.1.0'
9
+ VERSION = '0.2.0'
10
10
  end
11
11
  end
@@ -37,6 +37,6 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency 'bundler', '~> 2.1'
38
38
  spec.add_development_dependency 'rake', '~> 13.0'
39
39
  spec.add_development_dependency 'rspec', '~> 3.9'
40
- spec.add_development_dependency 'armitage-rubocop', '~> 0.81'
40
+ spec.add_development_dependency 'armitage-rubocop', '~> 0.83'
41
41
  spec.add_development_dependency 'simplecov', '~> 0.18'
42
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_initializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-10 00:00:00.000000000 Z
11
+ date: 2020-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_engine
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.81'
103
+ version: '0.83'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0.81'
110
+ version: '0.83'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement