smart_engine 0.5.0 → 0.10.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: 2487e6e6a99daf3e716d8a1d81a95ffb87c8461e510ce833e74ade673e56548c
4
- data.tar.gz: 7e66e448b6bb8a13b6720ca5d37ba673ac7e493f14460547c7dd3699d4aca90c
3
+ metadata.gz: 443ea1ba136017a41b8468a0f266bfe9c061acf1f18edff4feafc12cfd362fce
4
+ data.tar.gz: ab2383e7cc554912b6f1e6b17686760e016f22887d19c9c883b4223302d3f354
5
5
  SHA512:
6
- metadata.gz: 02a66ff6646a62f27f3c3d8416faa09a3d5dd32a35a8b47beb5f21b9914c09234a48d1500b126bb5c21903df7cbeb7ef79eab5533c586625c71778a2a9e5b0b1
7
- data.tar.gz: 74e2dd28fb809bd6f4d129c82350704e998a2ffc556f1ba1643d872f5bda3e0fdec596718e95ee812486ceb3139f951a06e61ea1b647740e34af8568c6a96241
6
+ metadata.gz: ba16d175ec535c9fc17cfea114fd1251e0d61cd0218dfeb0e6e940f7aa38a646523c27bdeff4ab88f5e8926c1ec703524a5ffa9736ddd7ed4b4b3284ea7d6866
7
+ data.tar.gz: 7862ff86af8da43fa843beb4c9613eff3e06f463ac5e99f4255333af566fd30cae833bf772e402259a533a08999f5d1c97113f3df45759db7405b4febb1059a6
@@ -5,7 +5,8 @@ inherit_gem:
5
5
  - lib/rubocop.rspec.yml
6
6
 
7
7
  AllCops:
8
- TargetRubyVersion: 2.4.9
8
+ TargetRubyVersion: 2.7.2
9
+ NewCops: enable
9
10
  Include:
10
11
  - lib/**/*.rb
11
12
  - spec/**/*.rb
@@ -13,3 +14,7 @@ AllCops:
13
14
  - Rakefile
14
15
  - smart_engine.gemspec
15
16
  - bin/console
17
+
18
+ # NOTE: for better representativeness of test examples
19
+ RSpec/DescribedClass:
20
+ Enabled: false
@@ -1,18 +1,18 @@
1
1
  ---
2
2
  language: ruby
3
3
  cache: bundler
4
- before_install: gem install bundler -v 2.1.2
5
4
  os: linux
5
+ dist: xenial
6
+ before_install: gem install bundler
6
7
  script:
7
8
  - bundle exec rake rubocop
8
9
  - bundle exec rake rspec
9
10
  jobs:
10
11
  fast_finish: true
11
12
  include:
12
- - rvm: 2.4.9
13
- - rvm: 2.5.7
14
- - rvm: 2.6.5
15
- - rvm: 2.7.0
13
+ - rvm: 2.5.8
14
+ - rvm: 2.6.6
15
+ - rvm: 2.7.2
16
16
  - rvm: ruby-head
17
17
  - rvm: jruby-head
18
18
  allow_failures:
@@ -1,6 +1,40 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.10.0] - 2020-12-22
5
+ ### Added
6
+ - Support for `#hash` and `#instance_of?` for `SmartCore::Ext::BasicObjectAsObject` refinement;
7
+
8
+ ## [0.9.0] - 2020-12-20
9
+ ### Added
10
+ - New type of utilities: *Extensions* (`SmartCore::Ext`);
11
+ - New extension: `SmartCore::Ext::BasicObjectAsObject` refinement:
12
+ - `using SmartCore::Ext::BasicObjectAsObject` provides native support for:
13
+ - `BasicObject#is_a?`;
14
+ - `BasicObject#kind_of?`;
15
+ - `BasicObject#freeze`;
16
+ - `BasicObject#frozen?`;
17
+
18
+ ### Changed
19
+ - Updated development dependencies;
20
+ - Support for *Ruby@2.4* has ended;
21
+
22
+ ### Fixed
23
+ - `SmartCore::Engine::Frozener` can not be used with rubies lower than `@2.7`;
24
+
25
+ ## [0.8.0] - 2020-07-25
26
+ ### Added
27
+ - Any object frozener (`SmartCore::Engine::Frozener`, `SmartCore::Engine::Frozener::Mixin`);
28
+
29
+ ## [0.7.0] - 2020-07-03
30
+ ### Added
31
+ - Atomic threadsafe value container (`SmartCore::Engine::Atom`);
32
+
33
+ ## [0.6.0] - 2020-05-03
34
+ ### Added
35
+ - Inline rescue pipe (`SmartCore::Engine::RescueExt.inline_rescue_pipe`);
36
+ - Actualized development dependencies and test environment;
37
+
4
38
  ## [0.5.0] - 2020-01-22
5
39
  ### Added
6
40
  - Global error type `SmartCore::TypeError` inherited from `::TypeError`;
@@ -1,81 +1,102 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_engine (0.3.0)
4
+ smart_engine (0.10.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- armitage-rubocop (0.79.0)
10
- rubocop (= 0.79.0)
11
- rubocop-performance (= 1.5.2)
12
- rubocop-rails (= 2.4.1)
13
- rubocop-rake (= 0.5.0)
14
- rubocop-rspec (= 1.37.1)
15
- ast (2.4.0)
16
- coderay (1.1.2)
17
- diff-lcs (1.3)
18
- docile (1.3.2)
19
- jaro_winkler (1.5.4)
20
- json (2.3.0)
21
- method_source (0.9.2)
22
- parallel (1.19.1)
23
- parser (2.7.0.2)
24
- ast (~> 2.4.0)
25
- pry (0.12.2)
26
- coderay (~> 1.1.0)
27
- method_source (~> 0.9.0)
28
- rack (2.1.1)
9
+ activesupport (6.1.0)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
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
+ rubocop-rake (= 0.5.1)
20
+ rubocop-rspec (= 2.0.1)
21
+ ast (2.4.1)
22
+ coderay (1.1.3)
23
+ concurrent-ruby (1.1.7)
24
+ diff-lcs (1.4.4)
25
+ docile (1.3.3)
26
+ i18n (1.8.5)
27
+ concurrent-ruby (~> 1.0)
28
+ method_source (1.0.0)
29
+ minitest (5.14.2)
30
+ parallel (1.20.1)
31
+ parser (2.7.2.0)
32
+ ast (~> 2.4.1)
33
+ pry (0.13.1)
34
+ coderay (~> 1.1)
35
+ method_source (~> 1.0)
36
+ rack (2.2.3)
29
37
  rainbow (3.0.0)
30
- rake (13.0.1)
31
- rspec (3.9.0)
32
- rspec-core (~> 3.9.0)
33
- rspec-expectations (~> 3.9.0)
34
- rspec-mocks (~> 3.9.0)
35
- rspec-core (3.9.1)
36
- rspec-support (~> 3.9.1)
37
- rspec-expectations (3.9.0)
38
+ rake (13.0.2)
39
+ regexp_parser (2.0.0)
40
+ rexml (3.2.4)
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)
38
48
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.9.0)
40
- rspec-mocks (3.9.1)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-mocks (3.10.0)
41
51
  diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.9.0)
43
- rspec-support (3.9.2)
44
- rubocop (0.79.0)
45
- jaro_winkler (~> 1.5.1)
52
+ rspec-support (~> 3.10.0)
53
+ rspec-support (3.10.0)
54
+ rubocop (1.6.1)
46
55
  parallel (~> 1.10)
47
- parser (>= 2.7.0.1)
56
+ parser (>= 2.7.1.5)
48
57
  rainbow (>= 2.2.2, < 4.0)
58
+ regexp_parser (>= 1.8, < 3.0)
59
+ rexml
60
+ rubocop-ast (>= 1.2.0, < 2.0)
49
61
  ruby-progressbar (~> 1.7)
50
- unicode-display_width (>= 1.4.0, < 1.7)
51
- rubocop-performance (1.5.2)
52
- rubocop (>= 0.71.0)
53
- rubocop-rails (2.4.1)
62
+ unicode-display_width (>= 1.4.0, < 2.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)
69
+ activesupport (>= 4.2.0)
54
70
  rack (>= 1.1)
55
- rubocop (>= 0.72.0)
56
- rubocop-rake (0.5.0)
71
+ rubocop (>= 0.90.0, < 2.0)
72
+ rubocop-rake (0.5.1)
57
73
  rubocop
58
- rubocop-rspec (1.37.1)
59
- rubocop (>= 0.68.1)
74
+ rubocop-rspec (2.0.1)
75
+ rubocop (~> 1.0)
76
+ rubocop-ast (>= 1.1.0)
60
77
  ruby-progressbar (1.10.1)
61
- simplecov (0.17.1)
78
+ simplecov (0.20.0)
62
79
  docile (~> 1.1)
63
- json (>= 1.8, < 3)
64
- simplecov-html (~> 0.10.0)
65
- simplecov-html (0.10.2)
66
- unicode-display_width (1.6.1)
80
+ simplecov-html (~> 0.11)
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)
86
+ unicode-display_width (1.7.0)
87
+ zeitwerk (2.4.2)
67
88
 
68
89
  PLATFORMS
69
90
  ruby
70
91
 
71
92
  DEPENDENCIES
72
- armitage-rubocop (~> 0.79)
93
+ armitage-rubocop (~> 1.6)
73
94
  bundler (~> 2.1)
74
- pry (~> 0.12)
95
+ pry (~> 0.13)
75
96
  rake (~> 13.0)
76
- rspec (~> 3.9)
77
- simplecov (~> 0.17)
97
+ rspec (~> 3.10)
98
+ simplecov (~> 0.20)
78
99
  smart_engine!
79
100
 
80
101
  BUNDLED WITH
81
- 2.1.2
102
+ 2.1.4
data/README.md CHANGED
@@ -23,7 +23,11 @@ require 'smart_core'
23
23
  ## Technologies
24
24
 
25
25
  - [Global set of error types](#global-set-of-error-types)
26
- - [Simple reenternant lock](#simple-reenternant-lock)
26
+ - [Simple reentrant lock](#simple-reentrant-lock)
27
+ - [Atomic thread-safe value container](#atomic-thread-safe-value-container)
28
+ - [Any Object Frozener](#any-object-frozener) (classic c-level `frozen?`/`freeze`)
29
+ - [Basic Object Refinements](#basic-object-refinements) (`SmartCore::Ext::BasicObjectAsObject`)
30
+ - [Inline rescue pipe](#inline-rescue-pipe)
27
31
 
28
32
  ---
29
33
 
@@ -37,7 +41,7 @@ require 'smart_core'
37
41
 
38
42
  ---
39
43
 
40
- ### Simple reenternant lock
44
+ ### Simple reentrant lock
41
45
 
42
46
  ```ruby
43
47
  lock = SmartCore::Engine::Lock.new
@@ -46,6 +50,142 @@ lock.synchronize { your_code }
46
50
 
47
51
  ---
48
52
 
53
+ ### Atomic thread-safe value container
54
+
55
+ ```ruby
56
+ atom = SmartCore::Engine::Atom.new # initial value - nil
57
+ atom.value # => nil
58
+ # --- or ---
59
+ atom = SmartCore::Engine::Atom.new(7) # initial value - 7
60
+ atom.value # => 7
61
+
62
+ # set new value (thread-safely)
63
+ atom.swap { |original_value| original_value * 2 }
64
+ atom.value # => 14
65
+ ```
66
+
67
+ ---
68
+
69
+ ### Any Object Frozener
70
+
71
+ - works with any type of ruby objects (event with `BasicObject`);
72
+ - uses classic Ruby C-level `frozen?`/`freeze` functionality;
73
+
74
+ ```ruby
75
+ # as a singleton
76
+
77
+ object = BasicObject.new
78
+ SmartCore::Engine::Frozener.frozen?(object) # => false
79
+
80
+ SmartCore::Engine::Frozener.freeze(object)
81
+ SmartCore::Engine::Frozener.frozen?(object) # => true
82
+ ```
83
+
84
+ ```ruby
85
+ # as a mixin
86
+
87
+ class EmptyObject < BasicObject
88
+ include SmartCore::Engine::Frozener::Mixin
89
+ end
90
+
91
+ object = EmptyObject.new
92
+
93
+ object.frozen? # => false
94
+ object.freeze
95
+ object.frozen? # => true
96
+ ```
97
+
98
+ ---
99
+
100
+ ### Basic Object Refinements
101
+
102
+ Ruby's `BasicObject` class does not have some fundamental (extremely important for instrumenting) methods:
103
+
104
+ - `is_a?` / `kind_of?`
105
+ - `instance_of?`
106
+ - `freeze` / `frozen?`
107
+ - `hash`
108
+ - `nil?`
109
+
110
+ `SmartCore::Ext::BasicObjectAsObject` refinement solves this problem (by Ruby's internal API without any manualy-emulated behavior).
111
+
112
+ ```ruby
113
+ # without refinement:
114
+ basic_obj = ::BasicObject.new
115
+
116
+ basic_obj.is_a?(::BasicObject) # raises ::NoMethodError
117
+ basic_obj.kind_of?(::BasicObject) # raises ::NoMethodError
118
+ basic_obj.instance_of?(::BasicObject) # rasies ::NoMethodError
119
+ basic_obj.freeze # raises ::NoMethodError
120
+ basic_obj.frozen? # raises ::NoMethodError
121
+ ```
122
+
123
+ ```ruby
124
+ # with refinement:
125
+ using SmartCore::Ext::BasicObjectAsObject
126
+
127
+ basic_obj = ::BasicObject.new
128
+
129
+ basic_obj.is_a?(::BasicObject) # => true
130
+ basic_obj.kind_of?(::BasicObject) # => true
131
+ basic_obj.instance_of?(::BasicObject) # => true
132
+ basic_obj.instance_of?(::Object) # => false
133
+ basic_obj.is_a?(::Integer) # => false
134
+ basic_obj.kind_of?(::Integer) # => false
135
+
136
+ basic_obj.frozen? # => false
137
+ basic_obj.freeze # => self
138
+ basic_obj.frozen? # => true
139
+ ```
140
+
141
+ ---
142
+
143
+ ### Inline rescue pipe
144
+
145
+ - works with an array of proc objects;
146
+ - returns the result of the first non-failed proc;
147
+ - provides an error interception interface (a block argument);
148
+ - fails with the last failed proc exception (if all procs were failed and interceptor was not passed);
149
+
150
+ #### Return the result of the first non-failed proc
151
+
152
+ ```ruby
153
+ SmartCore::Engine::RescueExt.inline_rescue_pipe(
154
+ -> { raise },
155
+ -> { raise },
156
+ -> { 123 },
157
+ -> { 567 },
158
+ -> { raise },
159
+ )
160
+ # => output: 123
161
+ ```
162
+
163
+ #### Fail with the last failed proc exception
164
+
165
+ ```ruby
166
+ SmartCore::Engine::RescueExt.inline_rescue_pipe(
167
+ -> { raise(::ArgumentError) },
168
+ -> { raise(::TypeError) },
169
+ -> { raise(::ZeroDivisionError) }
170
+ )
171
+ # => fails with ZeroDivisionError
172
+ ```
173
+
174
+ #### Error interception
175
+
176
+ ```ruby
177
+ SmartCore::Engine::RescueExt.inline_rescue_pipe(
178
+ -> { raise(::ArgumentError) },
179
+ -> { raise(::TypeError) },
180
+ -> { raise(::ZeroDivisionError, 'Intercepted exception') }
181
+ ) do |error|
182
+ error.message
183
+ end
184
+ # => output: "Intercepted exception"
185
+ ```
186
+
187
+ ---
188
+
49
189
  ## Contributing
50
190
 
51
191
  - Fork it ( https://github.com/smart-rb/smart_engine )
data/Rakefile CHANGED
@@ -4,6 +4,7 @@ require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
5
  require 'rubocop'
6
6
  require 'rubocop/rake_task'
7
+ require 'rubocop-rails'
7
8
  require 'rubocop-performance'
8
9
  require 'rubocop-rspec'
9
10
  require 'rubocop-rake'
@@ -11,8 +12,8 @@ require 'rubocop-rake'
11
12
  RuboCop::RakeTask.new(:rubocop) do |t|
12
13
  config_path = File.expand_path(File.join('.rubocop.yml'), __dir__)
13
14
  t.options = ['--config', config_path]
14
- t.requires << 'rubocop-performance'
15
15
  t.requires << 'rubocop-rspec'
16
+ t.requires << 'rubocop-performance'
16
17
  t.requires << 'rubocop-rake'
17
18
  end
18
19
 
@@ -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
@@ -5,4 +5,7 @@
5
5
  module SmartCore::Engine
6
6
  require_relative 'engine/version'
7
7
  require_relative 'engine/lock'
8
+ require_relative 'engine/rescue_ext'
9
+ require_relative 'engine/atom'
10
+ require_relative 'engine/frozener'
8
11
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api public
4
+ # @since 0.7.0
5
+ class SmartCore::Engine::Atom
6
+ # @param initial_value [Any]
7
+ # @return [void]
8
+ #
9
+ # @api private
10
+ # @since 0.7.0
11
+ def initialize(initial_value = nil)
12
+ @value = initial_value
13
+ @barrier = SmartCore::Engine::Lock.new
14
+ end
15
+
16
+ # @return [Any]
17
+ #
18
+ # @api public
19
+ # @since 0.7.0
20
+ def value
21
+ with_barrier { @value }
22
+ end
23
+
24
+ # @param block [Block]
25
+ # @return [Any]
26
+ #
27
+ # @api public
28
+ # @since 0.7.0
29
+ def swap(&block)
30
+ with_barrier { @value = yield(@value) }
31
+ end
32
+
33
+ private
34
+
35
+ # @param block [Block]
36
+ # @return [Any]
37
+ #
38
+ # @api private
39
+ # @since 0.1.0
40
+ def with_barrier(&block)
41
+ @barrier.synchronize(&block)
42
+ end
43
+ 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
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api public
4
+ # @since 0.8.0
5
+ # @version 0.9.0
6
+ module SmartCore::Engine::Frozener
7
+ # @api public
8
+ # @since 0.8.0
9
+ module Mixin
10
+ # @return [self]
11
+ #
12
+ # @api public
13
+ # @since 0.8.0
14
+ def freeze
15
+ SmartCore::Engine::Frozener.freeze(self)
16
+ end
17
+
18
+ # @return [Boolean]
19
+ #
20
+ # @api public
21
+ # @since 0.8.0
22
+ def frozen?
23
+ SmartCore::Engine::Frozener.frozen?(self)
24
+ end
25
+ end
26
+
27
+ # @return [UnboundMethod]
28
+ #
29
+ # @api private
30
+ # @since 0.8.0
31
+ FROZENER = Object.new.method(:freeze).unbind.tap(&:freeze)
32
+
33
+ # @return [UnboundMethod]
34
+ #
35
+ # @api private
36
+ # @since 0.8.0
37
+ FROZEN_CHECK = Object.new.method(:frozen?).unbind.tap(&:freeze)
38
+
39
+ class << self
40
+ # @param object [Any]
41
+ # @return [object]
42
+ #
43
+ # @api public
44
+ # @since 0.8.0
45
+ # @version 0.9.0
46
+ def freeze(object)
47
+ FROZENER.bind(object).call
48
+ end
49
+
50
+ # @param object [Any]
51
+ # @return [Boolean]
52
+ #
53
+ # @api public
54
+ # @since 0.8.0
55
+ # @version 0.9.0
56
+ def frozen?(object)
57
+ FROZEN_CHECK.bind(object).call
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api public
4
+ # @since 0.6.0
5
+ module SmartCore::Engine::RescueExt
6
+ # REASON:
7
+ # {module_funciton} is used to be able to include/extend any module/class
8
+ # and at the same time to use without any inclusion/extending logic as a service
9
+
10
+ module_function
11
+
12
+ # @param proks [Array<Proc>]
13
+ # @param error_interceptor [Block]
14
+ # @return [Any]
15
+ #
16
+ # @api public
17
+ # @since 0.6.0
18
+ # rubocop:disable Performance/RedundantBlockCall
19
+ def inline_rescue_pipe(*proks, &error_interceptor)
20
+ unless proks.all? { |prok| prok.is_a?(::Proc) }
21
+ raise(SmartCore::ArgumentError, 'Invalid proc object')
22
+ end
23
+
24
+ interceptable_bloks = proks.to_enum
25
+ pipe_invokation_result = nil
26
+ last_exception = nil
27
+
28
+ begin
29
+ while current_block = interceptable_bloks.next
30
+ begin
31
+ pipe_invokation_result = current_block.call
32
+ break
33
+ rescue => error
34
+ last_exception = error
35
+ end
36
+ end
37
+
38
+ pipe_invokation_result
39
+ rescue ::StopIteration
40
+ error_interceptor ? error_interceptor.call(last_exception) : raise(last_exception)
41
+ end
42
+ end
43
+ # rubocop:enable Performance/RedundantBlockCall
44
+ end
@@ -6,7 +6,7 @@ module SmartCore
6
6
  #
7
7
  # @api public
8
8
  # @since 0.1.0
9
- # @version 0.5.0
10
- VERSION = '0.5.0'
9
+ # @version 0.10.0
10
+ VERSION = '0.10.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,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api public
4
+ # @since 0.9.0
5
+ # @version 0.10.0
6
+ module SmartCore::Ext::BasicObjectAsObject
7
+ refine BasicObject do
8
+ _m_obj = ::Object.new
9
+
10
+ _is_a = _m_obj.method(:is_a?).unbind.tap(&:freeze)
11
+ _freeze = _m_obj.method(:freeze).unbind.tap(&:freeze)
12
+ _frozen = _m_obj.method(:frozen?).unbind.tap(&:freeze)
13
+ _hash = _m_obj.method(:hash).unbind.tap(&:freeze)
14
+ _nil = _m_obj.method(:nil?).unbind.tap(&:freeze)
15
+ _instance_of = _m_obj.method(:instance_of?).unbind.tap(&:freeze)
16
+
17
+ # @note Object#is_a? behavior copy
18
+ # @param klass [Class]
19
+ # @return [Boolean]
20
+ #
21
+ # @api public
22
+ # @since 0.9.0
23
+ define_method(:is_a?) do |klass|
24
+ _is_a.bind(self).call(klass)
25
+ end
26
+ alias_method :kind_of?, :is_a?
27
+
28
+ # @note Object#freeze behavior copy
29
+ # @return [self]
30
+ #
31
+ # @api public
32
+ # @since 0.9.0
33
+ define_method(:freeze) do
34
+ _freeze.bind(self).call
35
+ end
36
+
37
+ # @note Object#frozen? behavior copy
38
+ # @return [Boolean]
39
+ #
40
+ # @api public
41
+ # @since 0.9.0
42
+ define_method(:frozen?) do
43
+ _frozen.bind(self).call
44
+ end
45
+
46
+ # @return [Integer]
47
+ #
48
+ # @api public
49
+ # @since 0.10.0
50
+ define_method(:hash) do
51
+ _hash.bind(self).call
52
+ end
53
+
54
+ # @return [Boolean]
55
+ #
56
+ # @api public
57
+ # @since 0.10.0
58
+ define_method(:nil?) do
59
+ _nil.bind(self).call
60
+ end
61
+
62
+ # @return [Boolean]
63
+ #
64
+ # @api public
65
+ # @since 0.1.0
66
+ define_method(:instance_of?) do |klass|
67
+ _instance_of.bind(self).call(klass)
68
+ end
69
+ end
70
+ end
@@ -3,7 +3,7 @@
3
3
  require_relative 'lib/smart_core/engine/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.required_ruby_version = Gem::Requirement.new('>= 2.4.9')
6
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.4.10')
7
7
 
8
8
  spec.name = 'smart_engine'
9
9
  spec.version = SmartCore::Engine::VERSION
@@ -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.79'
41
- spec.add_development_dependency 'simplecov', '~> 0.17'
42
- spec.add_development_dependency 'pry', '~> 0.12'
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
+ 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.5.0
4
+ version: 0.10.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-01-22 00:00:00.000000000 Z
11
+ date: 2020-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,56 +44,56 @@ 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.79'
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.79'
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.17'
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.17'
82
+ version: '0.20'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.12'
89
+ version: '0.13'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.12'
96
+ version: '0.13'
97
97
  description: 'SmartCore Engine - a set of core functionality shared beetwen a series
98
98
  of SmartCore gems.
99
99
 
@@ -119,9 +119,15 @@ files:
119
119
  - bin/setup
120
120
  - lib/smart_core.rb
121
121
  - lib/smart_core/engine.rb
122
+ - lib/smart_core/engine/atom.rb
123
+ - lib/smart_core/engine/ext.rb
124
+ - lib/smart_core/engine/frozener.rb
122
125
  - lib/smart_core/engine/lock.rb
126
+ - lib/smart_core/engine/rescue_ext.rb
123
127
  - lib/smart_core/engine/version.rb
124
128
  - lib/smart_core/errors.rb
129
+ - lib/smart_core/ext.rb
130
+ - lib/smart_core/ext/basic_object_as_object.rb
125
131
  - smart_engine.gemspec
126
132
  homepage: https://github.com/smart-rb/smart_engine
127
133
  licenses:
@@ -130,7 +136,7 @@ metadata:
130
136
  homepage_uri: https://github.com/smart-rb/smart_engine
131
137
  source_code_uri: https://github.com/smart-rb/smart_engine
132
138
  changelog_uri: https://github.com/smart-rb/smart_engine/blob/master/CHANGELOG.md
133
- post_install_message:
139
+ post_install_message:
134
140
  rdoc_options: []
135
141
  require_paths:
136
142
  - lib
@@ -138,15 +144,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
144
  requirements:
139
145
  - - ">="
140
146
  - !ruby/object:Gem::Version
141
- version: 2.4.9
147
+ version: 2.4.10
142
148
  required_rubygems_version: !ruby/object:Gem::Requirement
143
149
  requirements:
144
150
  - - ">="
145
151
  - !ruby/object:Gem::Version
146
152
  version: '0'
147
153
  requirements: []
148
- rubygems_version: 3.1.2
149
- signing_key:
154
+ rubygems_version: 3.1.4
155
+ signing_key:
150
156
  specification_version: 4
151
157
  summary: SmartCore Engine - a generic subset of SmartCore's functionality.
152
158
  test_files: []