smart_initializer 0.1.0 → 0.4.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: a8963960f317fc7217bedf7a6974970a4380043edbee19061f08ff6d51505147
4
+ data.tar.gz: 9bb224a8135f877c610e9a9941e9f0101c2dd8752d34e2834a60abbe59a6ca3f
5
5
  SHA512:
6
- metadata.gz: 1c04e15b4f1896201bf08aec13c9bb2e5d770b65115960a9ca01d307088b04171f0c81beaa1b71d54fc2bf6888406d9e63ce0a49b5695baf41523f89b89ac85a
7
- data.tar.gz: 3f3ff4b2fa17bb7727abdb1d73839bc954b0e0c2dba9f19ad8a46a95cfa9df3a17549bdfc73775d6753d799052a14f4e7a9732fefbb5dafbec5f20f72b8063b4
6
+ metadata.gz: 2113967924a39041db63a8686ecbeb47c322f39a751bb7f8ceb563f34342c6db02a65db666b65962720ff93e22e34872d1df43b38ca19daa738a98d340d9efe6
7
+ data.tar.gz: a6df46968cd156ebf62bd410fedba372fab4f5319cdc7df0224343729e44ef477bf0eff2ec4bbc2d1aa3c5a39cfd532ea759ef2a71d4f41eecd95e1fae7ebbd3
@@ -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,5 +1,37 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.4.0] - 2020-01-18
5
+ ### Added
6
+ - Attribue Definition DSL
7
+ - Support for specifying the attribute accessor type (`read_only` parameter);
8
+ - Support for attribute aliasing (`as` parameter);
9
+ - Support for **Ruby 3**;
10
+
11
+ ### Changed
12
+ - Moved from `TravisCI` to nothing (todo: migrate to `GitHub Actions`).
13
+ Temporary: we must run test cases locally.
14
+ - Updated development dependencies;
15
+
16
+ ## [0.3.2] - 2020-07-12
17
+ ### Fixed
18
+ - Deeply inherited entities lose their `__initializer_settings__` entitiy;
19
+
20
+ ## [0.3.1] - 2020-07-12
21
+ ### Fixed
22
+ - Deeply inherited entities lose their class attribute definers;
23
+
24
+ ## [0.3.0] - 2020-07-11
25
+ ### Added
26
+ - `extend_initialization_flow` alias method for `SmartCore::Initializer.ext_init`;
27
+ - Access methods to the instance attribute lists (`#__params`, `#__options__`, `#__attributes__`);
28
+
29
+ ### Changed
30
+ - Updated development dependencies;
31
+
32
+ ## [0.2.0] - 2020-05-16
33
+ ### Changed
34
+ - **Constructor**: disallow unknown option attributes;
35
+
4
36
  ## [0.1.0] - 2020-05-10
5
37
  - Release :)
@@ -1,97 +1,109 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_initializer (0.1.0.alpha4)
4
+ smart_initializer (0.4.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.1)
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)
80
- tzinfo (1.2.7)
81
- 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.3.0)
90
+ smart_engine (~> 0.10)
91
+ tzinfo (2.0.4)
92
+ concurrent-ruby (~> 1.0)
82
93
  unicode-display_width (1.7.0)
83
- zeitwerk (2.3.0)
94
+ zeitwerk (2.4.2)
84
95
 
85
96
  PLATFORMS
86
- ruby
97
+ x86_64-darwin-20
87
98
 
88
99
  DEPENDENCIES
89
- armitage-rubocop (~> 0.81)
90
- bundler (~> 2.1)
100
+ armitage-rubocop (~> 1.7)
101
+ bundler (~> 2.2)
102
+ pry (~> 0.13)
91
103
  rake (~> 13.0)
92
- rspec (~> 3.9)
93
- simplecov (~> 0.18)
104
+ rspec (~> 3.10)
105
+ simplecov (~> 0.21)
94
106
  smart_initializer!
95
107
 
96
108
  BUNDLED WITH
97
- 2.1.4
109
+ 2.2.3
data/README.md CHANGED
@@ -1,6 +1,7 @@
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
- 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
 
@@ -11,11 +12,11 @@ gem 'smart_initializer'
11
12
  ```shell
12
13
  bundle install
13
14
  # --- or ---
14
- gem install smart_types
15
+ gem install smart_initializer
15
16
  ```
16
17
 
17
18
  ```ruby
18
- require 'smart_core/types'
19
+ require 'smart_core/initializer'
19
20
  ```
20
21
 
21
22
  ---
@@ -23,11 +24,14 @@ require 'smart_core/types'
23
24
  ## Table of contents
24
25
 
25
26
  - [Synopsis](#synopsis)
26
- - [Type Aliasing](#type-aliasing)
27
+ - [Access to the instance attributes](#access-to-the-instance-attributes)
28
+ - [Configuration](#configuration)
29
+ - [Type aliasing](#type-aliasing)
27
30
  - [Initialization extension](#initialization-extension)
28
31
  - [Plugins](#plugins)
29
32
  - [thy-types](#plugin-thy-types)
30
- - [How to run tests](#how-to-run-tests)
33
+ - [Roadmap](#roadmap)
34
+ - [Build](#build)
31
35
 
32
36
  ---
33
37
 
@@ -121,6 +125,31 @@ User.new(1, 'John', 'test123', role: :admin, metadata: {}, enabled: false)
121
125
 
122
126
  ---
123
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
+
124
153
  ## Configuration
125
154
 
126
155
  - based on `Qonfig` gem;
@@ -182,6 +211,7 @@ SmartCore::Initializer::TypeSystem::ThyTypes.type_aliases
182
211
  - `ext_init(&block)`:
183
212
  - you can define as many extensions as you want;
184
213
  - extensions are invoked in the order they are defined;
214
+ - alias method: `extend_initialization_flow`;
185
215
 
186
216
  ```ruby
187
217
  class User
@@ -257,7 +287,18 @@ User.new(123, 'test', { admin: true, age: 22 })
257
287
 
258
288
  ---
259
289
 
260
- ## How to run tests
290
+ ## Roadmap
291
+
292
+ - 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
261
302
 
262
303
  - with plugin tests:
263
304
 
@@ -268,7 +309,7 @@ bin/rspec -w
268
309
  - without plugin tests:
269
310
 
270
311
  ```shell
271
- bin/rspec -g
312
+ bin/rspec -n
272
313
  ```
273
314
 
274
315
  - help message:
@@ -277,6 +318,20 @@ bin/rspec -g
277
318
  bin/rspec -h
278
319
  ```
279
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
+
280
335
  ---
281
336
 
282
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.alpha4)
4
+ smart_initializer (0.4.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.1)
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)
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)
77
89
  smart_types (0.1.0)
78
90
  smart_engine (~> 0.6)
79
- thread_safe (0.3.6)
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