smart_engine 0.8.0 → 0.9.0

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
  SHA256:
3
- metadata.gz: 228fbd594308ecee71718fe059d6d8bf57f8e79f33b0607ca4b771fc498a0ac4
4
- data.tar.gz: 809d274f771a7de133a1bc8986448ffca67bcefa2f0fd5f3a5d39cf730c448fa
3
+ metadata.gz: 72ab66864ab2ec1673cfcb6d48f0168560c9d7a843b2851f783f16d7bdb4fc63
4
+ data.tar.gz: 3c0c6273fbfce55343452efd6bcaa2726bdfaf8133a46b06ac69fb40762649cf
5
5
  SHA512:
6
- metadata.gz: 29eb3e3f8e005af66036b33c3bdb7260d8da6054dd63177b50d7a1bb0cd6b4a6ba39a61c03a77420a9d2867fbc4424a7a2718e535c0dd6afefa4f699c6c33beb
7
- data.tar.gz: 70f57850d865a3dcbfbc083f444c30a86bd24745501e1816efff41db049c294ae5844f2c2bf6856316137a20d7be7b00c32964a852f576245ab0f378d40bb06e
6
+ metadata.gz: 8636209698ee6628cdc00af681b2400ffa6e7f4c479a3b2ae7a8cb9fdd14105a5c976791eadf541e56f1c41d719dd3d9c12adae2771468e3ba8c2be25e38a431
7
+ data.tar.gz: e886baa10d5c4d81b00b35e6c27b2ad60f2cd640acc8e57d22f9903596b475d53c9dce6c25b37f9abba11e1331e8b60705a87da15b5f0b904471d38529e9fdda
@@ -5,7 +5,8 @@ inherit_gem:
5
5
  - lib/rubocop.rspec.yml
6
6
 
7
7
  AllCops:
8
- TargetRubyVersion: 2.7.1
8
+ TargetRubyVersion: 2.7.2
9
+ NewCops: enable
9
10
  Include:
10
11
  - lib/**/*.rb
11
12
  - spec/**/*.rb
@@ -1,19 +1,18 @@
1
1
  ---
2
2
  language: ruby
3
3
  cache: bundler
4
- before_install: gem install bundler
5
4
  os: linux
6
5
  dist: xenial
6
+ before_install: gem install bundler
7
7
  script:
8
8
  - bundle exec rake rubocop
9
9
  - bundle exec rake rspec
10
10
  jobs:
11
11
  fast_finish: true
12
12
  include:
13
- - rvm: 2.4.10
14
13
  - rvm: 2.5.8
15
14
  - rvm: 2.6.6
16
- - rvm: 2.7.1
15
+ - rvm: 2.7.2
17
16
  - rvm: ruby-head
18
17
  - rvm: jruby-head
19
18
  allow_failures:
@@ -1,6 +1,23 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.9.0] - 2020-12-20
5
+ ### Added
6
+ - New type of utilities: *Extensions* (`SmartCore::Ext`);
7
+ - New extension: `SmartCore::Ext::BasicObjectAsObject` refinement:
8
+ - `using SmartCore::Ext::BasicObjectAsObject` provides native support for:
9
+ - `BasicObject#is_a?`;
10
+ - `BasicObject#kind_of?`;
11
+ - `BasicObject#freeze`;
12
+ - `BasicObject#frozen?`;
13
+
14
+ ### Changed
15
+ - Updated development dependencies;
16
+ - Support for *Ruby@2.4* has ended;
17
+
18
+ ### Fixed
19
+ - `SmartCore::Engine::Frozener` can not be used with rubies lower than `@2.7`;
20
+
4
21
  ## [0.8.0] - 2020-07-25
5
22
  ### Added
6
23
  - Any object frozener (`SmartCore::Engine::Frozener`, `SmartCore::Engine::Frozener::Mixin`);
@@ -1,98 +1,101 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_engine (0.7.0)
4
+ smart_engine (0.9.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- activesupport (6.0.3.2)
9
+ activesupport (6.1.0)
10
10
  concurrent-ruby (~> 1.0, >= 1.0.2)
11
- i18n (>= 0.7, < 2)
12
- minitest (~> 5.1)
13
- tzinfo (~> 1.1)
14
- zeitwerk (~> 2.2, >= 2.2.2)
15
- armitage-rubocop (0.87.1)
16
- rubocop (= 0.87.1)
17
- rubocop-performance (= 1.7.0)
18
- rubocop-rails (= 2.6.0)
11
+ i18n (>= 1.6, < 2)
12
+ minitest (>= 5.1)
13
+ tzinfo (~> 2.0)
14
+ zeitwerk (~> 2.3)
15
+ armitage-rubocop (1.6.1)
16
+ rubocop (= 1.6.1)
17
+ rubocop-performance (= 1.9.1)
18
+ rubocop-rails (= 2.9.0)
19
19
  rubocop-rake (= 0.5.1)
20
- rubocop-rspec (= 1.41.0)
20
+ rubocop-rspec (= 2.0.1)
21
21
  ast (2.4.1)
22
- coderay (1.1.2)
23
- concurrent-ruby (1.1.6)
22
+ coderay (1.1.3)
23
+ concurrent-ruby (1.1.7)
24
24
  diff-lcs (1.4.4)
25
- docile (1.3.2)
26
- i18n (1.8.3)
25
+ docile (1.3.3)
26
+ i18n (1.8.5)
27
27
  concurrent-ruby (~> 1.0)
28
28
  method_source (1.0.0)
29
- minitest (5.14.1)
30
- parallel (1.19.2)
31
- parser (2.7.1.4)
29
+ minitest (5.14.2)
30
+ parallel (1.20.1)
31
+ parser (2.7.2.0)
32
32
  ast (~> 2.4.1)
33
33
  pry (0.13.1)
34
34
  coderay (~> 1.1)
35
35
  method_source (~> 1.0)
36
36
  rack (2.2.3)
37
37
  rainbow (3.0.0)
38
- rake (13.0.1)
39
- regexp_parser (1.7.1)
38
+ rake (13.0.2)
39
+ regexp_parser (2.0.0)
40
40
  rexml (3.2.4)
41
- rspec (3.9.0)
42
- rspec-core (~> 3.9.0)
43
- rspec-expectations (~> 3.9.0)
44
- rspec-mocks (~> 3.9.0)
45
- rspec-core (3.9.2)
46
- rspec-support (~> 3.9.3)
47
- rspec-expectations (3.9.2)
41
+ rspec (3.10.0)
42
+ rspec-core (~> 3.10.0)
43
+ rspec-expectations (~> 3.10.0)
44
+ rspec-mocks (~> 3.10.0)
45
+ rspec-core (3.10.0)
46
+ rspec-support (~> 3.10.0)
47
+ rspec-expectations (3.10.0)
48
48
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.9.0)
50
- rspec-mocks (3.9.1)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-mocks (3.10.0)
51
51
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.9.0)
53
- rspec-support (3.9.3)
54
- rubocop (0.87.1)
52
+ rspec-support (~> 3.10.0)
53
+ rspec-support (3.10.0)
54
+ rubocop (1.6.1)
55
55
  parallel (~> 1.10)
56
- parser (>= 2.7.1.1)
56
+ parser (>= 2.7.1.5)
57
57
  rainbow (>= 2.2.2, < 4.0)
58
- regexp_parser (>= 1.7)
58
+ regexp_parser (>= 1.8, < 3.0)
59
59
  rexml
60
- rubocop-ast (>= 0.1.0, < 1.0)
60
+ rubocop-ast (>= 1.2.0, < 2.0)
61
61
  ruby-progressbar (~> 1.7)
62
62
  unicode-display_width (>= 1.4.0, < 2.0)
63
- rubocop-ast (0.1.0)
64
- parser (>= 2.7.0.1)
65
- rubocop-performance (1.7.0)
66
- rubocop (>= 0.82.0)
67
- rubocop-rails (2.6.0)
63
+ rubocop-ast (1.3.0)
64
+ parser (>= 2.7.1.5)
65
+ rubocop-performance (1.9.1)
66
+ rubocop (>= 0.90.0, < 2.0)
67
+ rubocop-ast (>= 0.4.0)
68
+ rubocop-rails (2.9.0)
68
69
  activesupport (>= 4.2.0)
69
70
  rack (>= 1.1)
70
- rubocop (>= 0.82.0)
71
+ rubocop (>= 0.90.0, < 2.0)
71
72
  rubocop-rake (0.5.1)
72
73
  rubocop
73
- rubocop-rspec (1.41.0)
74
- rubocop (>= 0.68.1)
74
+ rubocop-rspec (2.0.1)
75
+ rubocop (~> 1.0)
76
+ rubocop-ast (>= 1.1.0)
75
77
  ruby-progressbar (1.10.1)
76
- simplecov (0.18.5)
78
+ simplecov (0.20.0)
77
79
  docile (~> 1.1)
78
80
  simplecov-html (~> 0.11)
79
- simplecov-html (0.12.2)
80
- thread_safe (0.3.6)
81
- tzinfo (1.2.7)
82
- thread_safe (~> 0.1)
81
+ simplecov_json_formatter (~> 0.1)
82
+ simplecov-html (0.12.3)
83
+ simplecov_json_formatter (0.1.2)
84
+ tzinfo (2.0.4)
85
+ concurrent-ruby (~> 1.0)
83
86
  unicode-display_width (1.7.0)
84
- zeitwerk (2.3.1)
87
+ zeitwerk (2.4.2)
85
88
 
86
89
  PLATFORMS
87
90
  ruby
88
91
 
89
92
  DEPENDENCIES
90
- armitage-rubocop (~> 0.87)
93
+ armitage-rubocop (~> 1.6)
91
94
  bundler (~> 2.1)
92
95
  pry (~> 0.13)
93
96
  rake (~> 13.0)
94
- rspec (~> 3.9)
95
- simplecov (~> 0.18)
97
+ rspec (~> 3.10)
98
+ simplecov (~> 0.20)
96
99
  smart_engine!
97
100
 
98
101
  BUNDLED WITH
data/README.md CHANGED
@@ -25,7 +25,8 @@ require 'smart_core'
25
25
  - [Global set of error types](#global-set-of-error-types)
26
26
  - [Simple reentrant lock](#simple-reentrant-lock)
27
27
  - [Atomic thread-safe value container](#atomic-thread-safe-value-container)
28
- - [Any Object Frozener](#any-object-frozener)
28
+ - [Any Object Frozener](#any-object-frozener) (classic c-level `frozen?`/`freeze`)
29
+ - [Basic Object Refinements](#basic-object-refinements) (`SmartCore::Ext::BasicObjectAsObject`)
29
30
  - [Inline rescue pipe](#inline-rescue-pipe)
30
31
 
31
32
  ---
@@ -68,6 +69,7 @@ atom.value # => 14
68
69
  ### Any Object Frozener
69
70
 
70
71
  - works with any type of ruby objects (event with `BasicObject`);
72
+ - uses classic Ruby C-level `frozen?`/`freeze` functionality;
71
73
 
72
74
  ```ruby
73
75
  # as a singleton
@@ -95,6 +97,43 @@ object.frozen? # => true
95
97
 
96
98
  ---
97
99
 
100
+ ### Basic Object Refinements
101
+
102
+ Ruby's `BasicObject` class does not have some fundamental (extremely important) methods:
103
+
104
+ - `is_a?` / `kind_of?`
105
+ - `freeze` / `frozen?`
106
+
107
+ `SmartCore::Ext::BasicObjectAsObject` refinement solves this problem.
108
+
109
+ ```ruby
110
+ # without refinement:
111
+ basic_obj = ::BasicObject.new
112
+
113
+ basic_obj.is_a?(::BasicObject) # raises ::NoMethodError
114
+ basic_obj.kind_of?(::BasicObject) # raises ::NoMethodError
115
+ basic_obj.freeze # raises ::NoMethodError
116
+ basic_obj.frozen? # raises ::NoMethodError
117
+ ```
118
+
119
+ ```ruby
120
+ # with refinement:
121
+ using SmartCore::Ext::BasicObjectAsObject
122
+
123
+ basic_obj = ::BasicObject.new
124
+
125
+ basic_obj.is_a?(::BasicObject) # => true
126
+ basic_obj.kind_of?(::BasicObject)
127
+ basic_obj.is_a?(::Integer) # => false
128
+ basic_obj.kind_of?(::Integer) # => false
129
+
130
+ basic_obj.frozen? # => false
131
+ basic_obj.freeze # => self
132
+ basic_obj.frozen? # => true
133
+ ```
134
+
135
+ ---
136
+
98
137
  ### Inline rescue pipe
99
138
 
100
139
  - works with an array of proc objects;
@@ -5,4 +5,5 @@
5
5
  module SmartCore
6
6
  require_relative 'smart_core/errors'
7
7
  require_relative 'smart_core/engine'
8
+ require_relative 'smart_core/ext'
8
9
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api private
4
+ # @since 0.9.0
5
+ module SmartCore::Engine::Ext
6
+ require_relative 'ext/basic_object_as_object'
7
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  # @api public
4
4
  # @since 0.8.0
5
+ # @version 0.9.0
5
6
  module SmartCore::Engine::Frozener
6
7
  # @api public
7
8
  # @since 0.8.0
@@ -41,8 +42,9 @@ module SmartCore::Engine::Frozener
41
42
  #
42
43
  # @api public
43
44
  # @since 0.8.0
45
+ # @version 0.9.0
44
46
  def freeze(object)
45
- FROZENER.bind_call(object)
47
+ FROZENER.bind(object).call
46
48
  end
47
49
 
48
50
  # @param object [Any]
@@ -50,8 +52,9 @@ module SmartCore::Engine::Frozener
50
52
  #
51
53
  # @api public
52
54
  # @since 0.8.0
55
+ # @version 0.9.0
53
56
  def frozen?(object)
54
- FROZEN_CHECK.bind_call(object)
57
+ FROZEN_CHECK.bind(object).call
55
58
  end
56
59
  end
57
60
  end
@@ -6,7 +6,7 @@ module SmartCore
6
6
  #
7
7
  # @api public
8
8
  # @since 0.1.0
9
- # @version 0.8.0
10
- VERSION = '0.8.0'
9
+ # @version 0.9.0
10
+ VERSION = '0.9.0'
11
11
  end
12
12
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api private
4
+ # @since 0.9.0
5
+ module SmartCore::Ext
6
+ require_relative 'ext/basic_object_as_object'
7
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api public
4
+ # @since 0.9.0
5
+ module SmartCore::Ext::BasicObjectAsObject
6
+ refine BasicObject do
7
+ _m_obj = ::Object.new
8
+
9
+ _is_a = _m_obj.method(:is_a?).unbind.tap(&:freeze)
10
+ _freeze = _m_obj.method(:freeze).unbind.tap(&:freeze)
11
+ _frozen = _m_obj.method(:frozen?).unbind.tap(&:freeze)
12
+
13
+ # @note Object#is_a? behavior copy
14
+ # @param klass [Class]
15
+ # @return [Boolean]
16
+ #
17
+ # @api public
18
+ # @since 0.9.0
19
+ define_method(:is_a?) do |klass|
20
+ _is_a.bind(self).call(klass)
21
+ end
22
+ alias_method :kind_of?, :is_a?
23
+
24
+ # @note Object#freeze behavior copy
25
+ # @return [self]
26
+ #
27
+ # @api public
28
+ # @since 0.9.0
29
+ define_method(:freeze) do
30
+ _freeze.bind(self).call
31
+ end
32
+
33
+ # @note Object#frozen? behavior copy
34
+ # @return [Boolean]
35
+ #
36
+ # @api public
37
+ # @since 0.9.0
38
+ define_method(:frozen?) do
39
+ _frozen.bind(self).call
40
+ end
41
+ end
42
+ end
@@ -36,8 +36,8 @@ Gem::Specification.new do |spec|
36
36
 
37
37
  spec.add_development_dependency 'bundler', '~> 2.1'
38
38
  spec.add_development_dependency 'rake', '~> 13.0'
39
- spec.add_development_dependency 'rspec', '~> 3.9'
40
- spec.add_development_dependency 'armitage-rubocop', '~> 0.87'
41
- spec.add_development_dependency 'simplecov', '~> 0.18'
39
+ spec.add_development_dependency 'rspec', '~> 3.10'
40
+ spec.add_development_dependency 'armitage-rubocop', '~> 1.6'
41
+ spec.add_development_dependency 'simplecov', '~> 0.20'
42
42
  spec.add_development_dependency 'pry', '~> 0.13'
43
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-25 00:00:00.000000000 Z
11
+ date: 2020-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,42 +44,42 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.9'
47
+ version: '3.10'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.9'
54
+ version: '3.10'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: armitage-rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.87'
61
+ version: '1.6'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.87'
68
+ version: '1.6'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.18'
75
+ version: '0.20'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.18'
82
+ version: '0.20'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -120,11 +120,14 @@ files:
120
120
  - lib/smart_core.rb
121
121
  - lib/smart_core/engine.rb
122
122
  - lib/smart_core/engine/atom.rb
123
+ - lib/smart_core/engine/ext.rb
123
124
  - lib/smart_core/engine/frozener.rb
124
125
  - lib/smart_core/engine/lock.rb
125
126
  - lib/smart_core/engine/rescue_ext.rb
126
127
  - lib/smart_core/engine/version.rb
127
128
  - lib/smart_core/errors.rb
129
+ - lib/smart_core/ext.rb
130
+ - lib/smart_core/ext/basic_object_as_object.rb
128
131
  - smart_engine.gemspec
129
132
  homepage: https://github.com/smart-rb/smart_engine
130
133
  licenses:
@@ -133,7 +136,7 @@ metadata:
133
136
  homepage_uri: https://github.com/smart-rb/smart_engine
134
137
  source_code_uri: https://github.com/smart-rb/smart_engine
135
138
  changelog_uri: https://github.com/smart-rb/smart_engine/blob/master/CHANGELOG.md
136
- post_install_message:
139
+ post_install_message:
137
140
  rdoc_options: []
138
141
  require_paths:
139
142
  - lib
@@ -148,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
151
  - !ruby/object:Gem::Version
149
152
  version: '0'
150
153
  requirements: []
151
- rubygems_version: 3.1.2
152
- signing_key:
154
+ rubygems_version: 3.1.4
155
+ signing_key:
153
156
  specification_version: 4
154
157
  summary: SmartCore Engine - a generic subset of SmartCore's functionality.
155
158
  test_files: []