smart_initializer 0.2.0 → 0.5.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: 9bd642b208f012f92391fa7564b1726eced30ef64ed7bcd31a1a7a2c5ef1c5fc
4
- data.tar.gz: c1645e91c921429d8dd4314c730bd28c7be981f21f0a90fcee224c267e410fb4
3
+ metadata.gz: e7a9f30c8b223f8e66bc1ac23dfd183cd80d32c0620fd929ecdc42a534381635
4
+ data.tar.gz: eee561816ebbacf1a4f583d5038da3bb3478c10790a95e6c01ca8569a065174d
5
5
  SHA512:
6
- metadata.gz: 65b8419d5b08f2fd53044963cf0451f903d4b69a030f6ccb38a462e3055d22d6e1ed416ca7872d195b569d15cc0acc5cb087b91af6180a42305eb1e656afaded
7
- data.tar.gz: cdf0ef362116f807c603384008c9a829220879a9e27b1120d6de673779092740c12d906c0dd4923a4c4429f7ee7aac6418f248388b02d7d3a293cf9737403bbf
6
+ metadata.gz: 2e1c9e0b9f6b84cf6ad9fc5e84107fcddcc684ea80fb4c7f4fcf93f388d95cee0d7f36cae96106d19766964b79ae247f24c263ce51df81dabbef482204c04da8
7
+ data.tar.gz: 1ecac9ea5d30974515fdc8b3aac16d4b72c922f3d1c837353006200167f203ccb5ee8c94f8b6ea517dad9b86c80deb8818ae18471ad098339595b15d7aa6ee07
@@ -5,15 +5,22 @@ inherit_gem:
5
5
  - lib/rubocop.rspec.yml
6
6
 
7
7
  AllCops:
8
- TargetRubyVersion: 2.7.1
8
+ TargetRubyVersion: 3.0.0
9
+ NewCops: enable
9
10
  Include:
10
11
  - lib/**/*.rb
11
12
  - spec/**/*.rb
12
13
  - Gemfile
13
14
  - Rakefile
14
15
  - smart_initializer.gemspec
16
+ - gemfiles/*.gemfile
15
17
  - bin/console
16
18
 
17
19
  # NOTE: It is not suitable for infrastracture-level frameworks
18
20
  Metrics/ParameterLists:
19
21
  Enabled: false
22
+
23
+ # NOTE: It is ok to use empty blocks in specs (inside simple test cases)
24
+ Lint/EmptyBlock:
25
+ Exclude:
26
+ - spec/**/*.rb
@@ -1,6 +1,35 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.5.0] - 2021-01-18
5
+ ## Changed
6
+ - Updated `smart_types` dependency (`~> 0.4.0`) to guarantee **Ruby@3** compatibility;
7
+
8
+ ## [0.4.0] - 2021-01-18
9
+ ### Added
10
+ - Support for **Ruby 3**;
11
+
12
+ ### Changed
13
+ - Moved from `TravisCI` to nothing (todo: migrate to `GitHub Actions`).
14
+ Temporary: we must run test cases locally.
15
+ - Updated development dependencies;
16
+
17
+ ## [0.3.2] - 2020-07-12
18
+ ### Fixed
19
+ - Deeply inherited entities lose their `__initializer_settings__` entitiy;
20
+
21
+ ## [0.3.1] - 2020-07-12
22
+ ### Fixed
23
+ - Deeply inherited entities lose their class attribute definers;
24
+
25
+ ## [0.3.0] - 2020-07-11
26
+ ### Added
27
+ - `extend_initialization_flow` alias method for `SmartCore::Initializer.ext_init`;
28
+ - Access methods to the instance attribute lists (`#__params`, `#__options__`, `#__attributes__`);
29
+
30
+ ### Changed
31
+ - Updated development dependencies;
32
+
4
33
  ## [0.2.0] - 2020-05-16
5
34
  ### Changed
6
35
  - **Constructor**: disallow unknown option attributes;
@@ -1,95 +1,109 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_initializer (0.2.0)
4
+ smart_initializer (0.5.0)
5
5
  qonfig (~> 0.24)
6
- smart_engine (~> 0.6)
7
- smart_types (~> 0.1.0)
6
+ smart_engine (~> 0.11)
7
+ smart_types (~> 0.4)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (6.0.3)
12
+ activesupport (6.1.1)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- zeitwerk (~> 2.2, >= 2.2.2)
18
- armitage-rubocop (0.83.0)
19
- rubocop (= 0.83.0)
20
- rubocop-performance (= 1.5.2)
21
- rubocop-rails (= 2.5.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
+ armitage-rubocop (1.7.0.1)
19
+ rubocop (= 1.7.0)
20
+ rubocop-performance (= 1.9.1)
21
+ rubocop-rails (= 2.9.1)
22
22
  rubocop-rake (= 0.5.1)
23
- rubocop-rspec (= 1.39.0)
24
- ast (2.4.0)
25
- concurrent-ruby (1.1.6)
26
- diff-lcs (1.3)
27
- docile (1.3.2)
28
- i18n (1.8.2)
23
+ rubocop-rspec (= 2.1.0)
24
+ ast (2.4.1)
25
+ coderay (1.1.3)
26
+ concurrent-ruby (1.1.7)
27
+ diff-lcs (1.4.4)
28
+ docile (1.3.5)
29
+ i18n (1.8.7)
29
30
  concurrent-ruby (~> 1.0)
30
- minitest (5.14.1)
31
- parallel (1.19.1)
32
- parser (2.7.1.2)
33
- ast (~> 2.4.0)
34
- qonfig (0.24.1)
35
- rack (2.2.2)
31
+ method_source (1.0.0)
32
+ minitest (5.14.3)
33
+ parallel (1.20.1)
34
+ parser (3.0.0.0)
35
+ ast (~> 2.4.1)
36
+ pry (0.13.1)
37
+ coderay (~> 1.1)
38
+ method_source (~> 1.0)
39
+ qonfig (0.25.0)
40
+ rack (2.2.3)
36
41
  rainbow (3.0.0)
37
- rake (13.0.1)
42
+ rake (13.0.3)
43
+ regexp_parser (2.0.3)
38
44
  rexml (3.2.4)
39
- rspec (3.9.0)
40
- rspec-core (~> 3.9.0)
41
- rspec-expectations (~> 3.9.0)
42
- rspec-mocks (~> 3.9.0)
43
- rspec-core (3.9.2)
44
- rspec-support (~> 3.9.3)
45
- rspec-expectations (3.9.2)
45
+ rspec (3.10.0)
46
+ rspec-core (~> 3.10.0)
47
+ rspec-expectations (~> 3.10.0)
48
+ rspec-mocks (~> 3.10.0)
49
+ rspec-core (3.10.1)
50
+ rspec-support (~> 3.10.0)
51
+ rspec-expectations (3.10.1)
46
52
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.9.0)
48
- rspec-mocks (3.9.1)
53
+ rspec-support (~> 3.10.0)
54
+ rspec-mocks (3.10.1)
49
55
  diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.9.0)
51
- rspec-support (3.9.3)
52
- rubocop (0.83.0)
56
+ rspec-support (~> 3.10.0)
57
+ rspec-support (3.10.1)
58
+ rubocop (1.7.0)
53
59
  parallel (~> 1.10)
54
- parser (>= 2.7.0.1)
60
+ parser (>= 2.7.1.5)
55
61
  rainbow (>= 2.2.2, < 4.0)
62
+ regexp_parser (>= 1.8, < 3.0)
56
63
  rexml
64
+ rubocop-ast (>= 1.2.0, < 2.0)
57
65
  ruby-progressbar (~> 1.7)
58
66
  unicode-display_width (>= 1.4.0, < 2.0)
59
- rubocop-performance (1.5.2)
60
- rubocop (>= 0.71.0)
61
- rubocop-rails (2.5.2)
62
- activesupport
67
+ rubocop-ast (1.4.0)
68
+ parser (>= 2.7.1.5)
69
+ rubocop-performance (1.9.1)
70
+ rubocop (>= 0.90.0, < 2.0)
71
+ rubocop-ast (>= 0.4.0)
72
+ rubocop-rails (2.9.1)
73
+ activesupport (>= 4.2.0)
63
74
  rack (>= 1.1)
64
- rubocop (>= 0.72.0)
75
+ rubocop (>= 0.90.0, < 2.0)
65
76
  rubocop-rake (0.5.1)
66
77
  rubocop
67
- rubocop-rspec (1.39.0)
68
- rubocop (>= 0.68.1)
69
- ruby-progressbar (1.10.1)
70
- simplecov (0.18.5)
78
+ rubocop-rspec (2.1.0)
79
+ rubocop (~> 1.0)
80
+ rubocop-ast (>= 1.1.0)
81
+ ruby-progressbar (1.11.0)
82
+ simplecov (0.21.2)
71
83
  docile (~> 1.1)
72
84
  simplecov-html (~> 0.11)
73
- simplecov-html (0.12.2)
74
- smart_engine (0.6.0)
75
- smart_types (0.1.0)
76
- smart_engine (~> 0.6)
77
- thread_safe (0.3.6)
78
- tzinfo (1.2.7)
79
- thread_safe (~> 0.1)
85
+ simplecov_json_formatter (~> 0.1)
86
+ simplecov-html (0.12.3)
87
+ simplecov_json_formatter (0.1.2)
88
+ smart_engine (0.11.0)
89
+ smart_types (0.4.0)
90
+ smart_engine (~> 0.11)
91
+ tzinfo (2.0.4)
92
+ concurrent-ruby (~> 1.0)
80
93
  unicode-display_width (1.7.0)
81
- zeitwerk (2.3.0)
94
+ zeitwerk (2.4.2)
82
95
 
83
96
  PLATFORMS
84
- ruby
97
+ x86_64-darwin-20
85
98
 
86
99
  DEPENDENCIES
87
- armitage-rubocop (~> 0.83)
88
- bundler (~> 2.1)
100
+ armitage-rubocop (~> 1.7)
101
+ bundler (~> 2.2)
102
+ pry (~> 0.13)
89
103
  rake (~> 13.0)
90
- rspec (~> 3.9)
91
- simplecov (~> 0.18)
104
+ rspec (~> 3.10)
105
+ simplecov (~> 0.21)
92
106
  smart_initializer!
93
107
 
94
108
  BUNDLED WITH
95
- 2.1.4
109
+ 2.2.3
data/README.md CHANGED
@@ -1,4 +1,4 @@
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)
1
+ # SmartCore::Initializer &middot; [![Gem Version](https://badge.fury.io/rb/smart_initializer.svg)](https://badge.fury.io/rb/smart_initializer)
2
2
 
3
3
  A simple and convenient way to declare complex constructors with a support for various commonly used type systems.
4
4
  (**in active development**).
@@ -12,11 +12,11 @@ gem 'smart_initializer'
12
12
  ```shell
13
13
  bundle install
14
14
  # --- or ---
15
- gem install smart_types
15
+ gem install smart_initializer
16
16
  ```
17
17
 
18
18
  ```ruby
19
- require 'smart_core/types'
19
+ require 'smart_core/initializer'
20
20
  ```
21
21
 
22
22
  ---
@@ -24,11 +24,14 @@ require 'smart_core/types'
24
24
  ## Table of contents
25
25
 
26
26
  - [Synopsis](#synopsis)
27
- - [Type Aliasing](#type-aliasing)
27
+ - [Access to the instance attributes](#access-to-the-instance-attributes)
28
+ - [Configuration](#configuration)
29
+ - [Type aliasing](#type-aliasing)
28
30
  - [Initialization extension](#initialization-extension)
29
31
  - [Plugins](#plugins)
30
32
  - [thy-types](#plugin-thy-types)
31
- - [How to run tests](#how-to-run-tests)
33
+ - [Roadmap](#roadmap)
34
+ - [Build](#build)
32
35
 
33
36
  ---
34
37
 
@@ -122,6 +125,31 @@ User.new(1, 'John', 'test123', role: :admin, metadata: {}, enabled: false)
122
125
 
123
126
  ---
124
127
 
128
+ ## Access to the instance attributes
129
+
130
+ - `#__params__` - returns a list of initialized params;
131
+ - `#__options__` - returns a list of initialized options;
132
+ - `#__attributes__` - returns a list of merged params and options;
133
+
134
+ ```ruby
135
+ class User
136
+ include SmartCore::Initializer
137
+
138
+ param :first_name, 'string'
139
+ param :second_name, 'string'
140
+ option :age, 'numeric'
141
+ option :is_admin, 'boolean', default: true
142
+ end
143
+
144
+ user = User.new('Rustam', 'Ibragimov', age: 28)
145
+
146
+ user.__params__ # => { first_name: 'Rustam', second_name: 'Ibragimov' }
147
+ user.__options__ # => { age: 28, is_admin: true }
148
+ user.__attributes__ # => { first_name: 'Rustam', second_name: 'Ibragimov', age: 28, is_admin: true }
149
+ ```
150
+
151
+ ---
152
+
125
153
  ## Configuration
126
154
 
127
155
  - based on `Qonfig` gem;
@@ -183,6 +211,7 @@ SmartCore::Initializer::TypeSystem::ThyTypes.type_aliases
183
211
  - `ext_init(&block)`:
184
212
  - you can define as many extensions as you want;
185
213
  - extensions are invoked in the order they are defined;
214
+ - alias method: `extend_initialization_flow`;
186
215
 
187
216
  ```ruby
188
217
  class User
@@ -258,7 +287,18 @@ User.new(123, 'test', { admin: true, age: 22 })
258
287
 
259
288
  ---
260
289
 
261
- ## How to run tests
290
+ ## Roadmap
291
+
292
+ - (in development) Attribue Definition DSL
293
+ - Support for specifying the attribute accessor type (`read_only` parameter);
294
+ - Support for attribute aliasing (`as` parameter);
295
+ - Migrate from `TravisCI` to `GitHub Actions`;
296
+
297
+ ---
298
+
299
+ ## Build
300
+
301
+ ### Tests Running
262
302
 
263
303
  - with plugin tests:
264
304
 
@@ -269,7 +309,7 @@ bin/rspec -w
269
309
  - without plugin tests:
270
310
 
271
311
  ```shell
272
- bin/rspec -g
312
+ bin/rspec -n
273
313
  ```
274
314
 
275
315
  - help message:
@@ -278,6 +318,20 @@ bin/rspec -g
278
318
  bin/rspec -h
279
319
  ```
280
320
 
321
+ ### Code Style Checking
322
+
323
+ - without auto-correction:
324
+
325
+ ```shell
326
+ bundle exec rake rubocop
327
+ ```
328
+
329
+ - with auto-correction:
330
+
331
+ ```shell
332
+ bundle exec rake rubocop -A
333
+ ```
334
+
281
335
  ---
282
336
 
283
337
  ## Contributing
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'bundler/setup'
5
- require 'smart_core/initializer'
5
+ require 'smart_core'
6
6
 
7
- require 'irb'
8
- IRB.start(__FILE__)
7
+ require 'pry'
8
+ Pry.start
data/bin/rspec CHANGED
@@ -23,7 +23,7 @@ module SmartCoreInitializerRSpecRunner
23
23
  run_with_plugin_tests!
24
24
  end
25
25
 
26
- opts.on('-g', '--without-plugins', 'Run general tests (without plugin tests') do
26
+ opts.on('-n', '--without-plugins', 'Run general tests (without plugin tests') do
27
27
  run_without_plugin_tests!
28
28
  end
29
29
  end.parse!
@@ -1,99 +1,111 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- smart_initializer (0.1.0)
4
+ smart_initializer (0.5.0)
5
5
  qonfig (~> 0.24)
6
- smart_engine (~> 0.6)
7
- smart_types (~> 0.1.0)
6
+ smart_engine (~> 0.11)
7
+ smart_types (~> 0.4)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (6.0.3)
12
+ activesupport (6.1.1)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- zeitwerk (~> 2.2, >= 2.2.2)
18
- armitage-rubocop (0.82.0.2)
19
- rubocop (= 0.82.0)
20
- rubocop-performance (= 1.5.2)
21
- rubocop-rails (= 2.5.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
+ armitage-rubocop (1.7.0.1)
19
+ rubocop (= 1.7.0)
20
+ rubocop-performance (= 1.9.1)
21
+ rubocop-rails (= 2.9.1)
22
22
  rubocop-rake (= 0.5.1)
23
- rubocop-rspec (= 1.39.0)
24
- ast (2.4.0)
25
- concurrent-ruby (1.1.6)
26
- diff-lcs (1.3)
27
- docile (1.3.2)
28
- i18n (1.8.2)
23
+ rubocop-rspec (= 2.1.0)
24
+ ast (2.4.1)
25
+ coderay (1.1.3)
26
+ concurrent-ruby (1.1.7)
27
+ diff-lcs (1.4.4)
28
+ docile (1.3.5)
29
+ i18n (1.8.7)
29
30
  concurrent-ruby (~> 1.0)
30
- jaro_winkler (1.5.4)
31
- minitest (5.14.0)
32
- parallel (1.19.1)
33
- parser (2.7.1.2)
34
- ast (~> 2.4.0)
35
- qonfig (0.24.1)
36
- rack (2.2.2)
31
+ method_source (1.0.0)
32
+ minitest (5.14.3)
33
+ parallel (1.20.1)
34
+ parser (3.0.0.0)
35
+ ast (~> 2.4.1)
36
+ pry (0.13.1)
37
+ coderay (~> 1.1)
38
+ method_source (~> 1.0)
39
+ qonfig (0.25.0)
40
+ rack (2.2.3)
37
41
  rainbow (3.0.0)
38
- rake (13.0.1)
42
+ rake (13.0.3)
43
+ regexp_parser (2.0.3)
39
44
  rexml (3.2.4)
40
- rspec (3.9.0)
41
- rspec-core (~> 3.9.0)
42
- rspec-expectations (~> 3.9.0)
43
- rspec-mocks (~> 3.9.0)
44
- rspec-core (3.9.2)
45
- rspec-support (~> 3.9.3)
46
- rspec-expectations (3.9.2)
45
+ rspec (3.10.0)
46
+ rspec-core (~> 3.10.0)
47
+ rspec-expectations (~> 3.10.0)
48
+ rspec-mocks (~> 3.10.0)
49
+ rspec-core (3.10.1)
50
+ rspec-support (~> 3.10.0)
51
+ rspec-expectations (3.10.1)
47
52
  diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.9.0)
49
- rspec-mocks (3.9.1)
53
+ rspec-support (~> 3.10.0)
54
+ rspec-mocks (3.10.1)
50
55
  diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.9.0)
52
- rspec-support (3.9.3)
53
- rubocop (0.82.0)
54
- jaro_winkler (~> 1.5.1)
56
+ rspec-support (~> 3.10.0)
57
+ rspec-support (3.10.1)
58
+ rubocop (1.7.0)
55
59
  parallel (~> 1.10)
56
- parser (>= 2.7.0.1)
60
+ parser (>= 2.7.1.5)
57
61
  rainbow (>= 2.2.2, < 4.0)
62
+ regexp_parser (>= 1.8, < 3.0)
58
63
  rexml
64
+ rubocop-ast (>= 1.2.0, < 2.0)
59
65
  ruby-progressbar (~> 1.7)
60
66
  unicode-display_width (>= 1.4.0, < 2.0)
61
- rubocop-performance (1.5.2)
62
- rubocop (>= 0.71.0)
63
- rubocop-rails (2.5.2)
64
- activesupport
67
+ rubocop-ast (1.4.0)
68
+ parser (>= 2.7.1.5)
69
+ rubocop-performance (1.9.1)
70
+ rubocop (>= 0.90.0, < 2.0)
71
+ rubocop-ast (>= 0.4.0)
72
+ rubocop-rails (2.9.1)
73
+ activesupport (>= 4.2.0)
65
74
  rack (>= 1.1)
66
- rubocop (>= 0.72.0)
75
+ rubocop (>= 0.90.0, < 2.0)
67
76
  rubocop-rake (0.5.1)
68
77
  rubocop
69
- rubocop-rspec (1.39.0)
70
- rubocop (>= 0.68.1)
71
- ruby-progressbar (1.10.1)
72
- simplecov (0.18.5)
78
+ rubocop-rspec (2.1.0)
79
+ rubocop (~> 1.0)
80
+ rubocop-ast (>= 1.1.0)
81
+ ruby-progressbar (1.11.0)
82
+ simplecov (0.21.2)
73
83
  docile (~> 1.1)
74
84
  simplecov-html (~> 0.11)
75
- simplecov-html (0.12.2)
76
- smart_engine (0.6.0)
77
- smart_types (0.1.0)
78
- smart_engine (~> 0.6)
79
- thread_safe (0.3.6)
85
+ simplecov_json_formatter (~> 0.1)
86
+ simplecov-html (0.12.3)
87
+ simplecov_json_formatter (0.1.2)
88
+ smart_engine (0.11.0)
89
+ smart_types (0.4.0)
90
+ smart_engine (~> 0.11)
80
91
  thy (0.1.4)
81
- tzinfo (1.2.7)
82
- thread_safe (~> 0.1)
92
+ tzinfo (2.0.4)
93
+ concurrent-ruby (~> 1.0)
83
94
  unicode-display_width (1.7.0)
84
- zeitwerk (2.3.0)
95
+ zeitwerk (2.4.2)
85
96
 
86
97
  PLATFORMS
87
- ruby
98
+ x86_64-darwin-20
88
99
 
89
100
  DEPENDENCIES
90
- armitage-rubocop (~> 0.81)
91
- bundler (~> 2.1)
101
+ armitage-rubocop (~> 1.7)
102
+ bundler (~> 2.2)
103
+ pry (~> 0.13)
92
104
  rake (~> 13.0)
93
- rspec (~> 3.9)
94
- simplecov (~> 0.18)
105
+ rspec (~> 3.10)
106
+ simplecov (~> 0.21)
95
107
  smart_initializer!
96
108
  thy (~> 0.1.4)
97
109
 
98
110
  BUNDLED WITH
99
- 2.1.4
111
+ 2.2.3