smart_engine 0.7.0 → 0.8.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: fb49309ce61e395a7073af81c275aabdb9adbcf8d8b7d953da30aa87bafa7f20
4
- data.tar.gz: 3e08590d5bce668b39ee3ea8893de436154dab189a6b528d1ca68156abbcb5b5
3
+ metadata.gz: 228fbd594308ecee71718fe059d6d8bf57f8e79f33b0607ca4b771fc498a0ac4
4
+ data.tar.gz: 809d274f771a7de133a1bc8986448ffca67bcefa2f0fd5f3a5d39cf730c448fa
5
5
  SHA512:
6
- metadata.gz: fe721dc23e1d34a4fac5a37e49e9909758d80605f6e8bdff145e3bf532439a26d192941638896c1d7da4fdec0c8dc9f879fadab4dae4b1a341a5ded4999cba26
7
- data.tar.gz: f99856596971bb98fa521e1ee77a777f17bc7c7a6541477aa243f625e58e8f21d7f9a6d5bbadd51e38241cd05cb37b0e67a229bc3a3fe2459a3e2ae30a23ed85
6
+ metadata.gz: 29eb3e3f8e005af66036b33c3bdb7260d8da6054dd63177b50d7a1bb0cd6b4a6ba39a61c03a77420a9d2867fbc4424a7a2718e535c0dd6afefa4f699c6c33beb
7
+ data.tar.gz: 70f57850d865a3dcbfbc083f444c30a86bd24745501e1816efff41db049c294ae5844f2c2bf6856316137a20d7be7b00c32964a852f576245ab0f378d40bb06e
@@ -13,3 +13,7 @@ AllCops:
13
13
  - Rakefile
14
14
  - smart_engine.gemspec
15
15
  - bin/console
16
+
17
+ # NOTE: for better representativeness of test examples
18
+ RSpec/DescribedClass:
19
+ Enabled: false
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.8.0] - 2020-07-25
5
+ ### Added
6
+ - Any object frozener (`SmartCore::Engine::Frozener`, `SmartCore::Engine::Frozener::Mixin`);
7
+
4
8
  ## [0.7.0] - 2020-07-03
5
9
  ### Added
6
10
  - Atomic threadsafe value container (`SmartCore::Engine::Atom`);
@@ -12,12 +12,12 @@ GEM
12
12
  minitest (~> 5.1)
13
13
  tzinfo (~> 1.1)
14
14
  zeitwerk (~> 2.2, >= 2.2.2)
15
- armitage-rubocop (0.85.1)
16
- rubocop (= 0.85.1)
17
- rubocop-performance (= 1.6.1)
15
+ armitage-rubocop (0.87.1)
16
+ rubocop (= 0.87.1)
17
+ rubocop-performance (= 1.7.0)
18
18
  rubocop-rails (= 2.6.0)
19
19
  rubocop-rake (= 0.5.1)
20
- rubocop-rspec (= 1.40.0)
20
+ rubocop-rspec (= 1.41.0)
21
21
  ast (2.4.1)
22
22
  coderay (1.1.2)
23
23
  concurrent-ruby (1.1.6)
@@ -51,26 +51,26 @@ GEM
51
51
  diff-lcs (>= 1.2.0, < 2.0)
52
52
  rspec-support (~> 3.9.0)
53
53
  rspec-support (3.9.3)
54
- rubocop (0.85.1)
54
+ rubocop (0.87.1)
55
55
  parallel (~> 1.10)
56
- parser (>= 2.7.0.1)
56
+ parser (>= 2.7.1.1)
57
57
  rainbow (>= 2.2.2, < 4.0)
58
58
  regexp_parser (>= 1.7)
59
59
  rexml
60
- rubocop-ast (>= 0.0.3)
60
+ rubocop-ast (>= 0.1.0, < 1.0)
61
61
  ruby-progressbar (~> 1.7)
62
62
  unicode-display_width (>= 1.4.0, < 2.0)
63
63
  rubocop-ast (0.1.0)
64
64
  parser (>= 2.7.0.1)
65
- rubocop-performance (1.6.1)
66
- rubocop (>= 0.71.0)
65
+ rubocop-performance (1.7.0)
66
+ rubocop (>= 0.82.0)
67
67
  rubocop-rails (2.6.0)
68
68
  activesupport (>= 4.2.0)
69
69
  rack (>= 1.1)
70
70
  rubocop (>= 0.82.0)
71
71
  rubocop-rake (0.5.1)
72
72
  rubocop
73
- rubocop-rspec (1.40.0)
73
+ rubocop-rspec (1.41.0)
74
74
  rubocop (>= 0.68.1)
75
75
  ruby-progressbar (1.10.1)
76
76
  simplecov (0.18.5)
@@ -87,7 +87,7 @@ PLATFORMS
87
87
  ruby
88
88
 
89
89
  DEPENDENCIES
90
- armitage-rubocop (~> 0.85)
90
+ armitage-rubocop (~> 0.87)
91
91
  bundler (~> 2.1)
92
92
  pry (~> 0.13)
93
93
  rake (~> 13.0)
data/README.md CHANGED
@@ -25,6 +25,7 @@ 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
29
  - [Inline rescue pipe](#inline-rescue-pipe)
29
30
 
30
31
  ---
@@ -64,6 +65,36 @@ atom.value # => 14
64
65
 
65
66
  ---
66
67
 
68
+ ### Any Object Frozener
69
+
70
+ - works with any type of ruby objects (event with `BasicObject`);
71
+
72
+ ```ruby
73
+ # as a singleton
74
+
75
+ object = BasicObject.new
76
+ SmartCore::Engine::Frozener.frozen?(object) # => false
77
+
78
+ SmartCore::Engine::Frozener.freeze(object)
79
+ SmartCore::Engine::Frozener.frozen?(object) # => true
80
+ ```
81
+
82
+ ```ruby
83
+ # as a mixin
84
+
85
+ class EmptyObject < BasicObject
86
+ include SmartCore::Engine::Frozener::Mixin
87
+ end
88
+
89
+ object = EmptyObject.new
90
+
91
+ object.frozen? # => false
92
+ object.freeze
93
+ object.frozen? # => true
94
+ ```
95
+
96
+ ---
97
+
67
98
  ### Inline rescue pipe
68
99
 
69
100
  - works with an array of proc objects;
@@ -7,4 +7,5 @@ module SmartCore::Engine
7
7
  require_relative 'engine/lock'
8
8
  require_relative 'engine/rescue_ext'
9
9
  require_relative 'engine/atom'
10
+ require_relative 'engine/frozener'
10
11
  end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api public
4
+ # @since 0.8.0
5
+ module SmartCore::Engine::Frozener
6
+ # @api public
7
+ # @since 0.8.0
8
+ module Mixin
9
+ # @return [self]
10
+ #
11
+ # @api public
12
+ # @since 0.8.0
13
+ def freeze
14
+ SmartCore::Engine::Frozener.freeze(self)
15
+ end
16
+
17
+ # @return [Boolean]
18
+ #
19
+ # @api public
20
+ # @since 0.8.0
21
+ def frozen?
22
+ SmartCore::Engine::Frozener.frozen?(self)
23
+ end
24
+ end
25
+
26
+ # @return [UnboundMethod]
27
+ #
28
+ # @api private
29
+ # @since 0.8.0
30
+ FROZENER = Object.new.method(:freeze).unbind.tap(&:freeze)
31
+
32
+ # @return [UnboundMethod]
33
+ #
34
+ # @api private
35
+ # @since 0.8.0
36
+ FROZEN_CHECK = Object.new.method(:frozen?).unbind.tap(&:freeze)
37
+
38
+ class << self
39
+ # @param object [Any]
40
+ # @return [object]
41
+ #
42
+ # @api public
43
+ # @since 0.8.0
44
+ def freeze(object)
45
+ FROZENER.bind_call(object)
46
+ end
47
+
48
+ # @param object [Any]
49
+ # @return [Boolean]
50
+ #
51
+ # @api public
52
+ # @since 0.8.0
53
+ def frozen?(object)
54
+ FROZEN_CHECK.bind_call(object)
55
+ end
56
+ end
57
+ end
@@ -6,7 +6,7 @@ module SmartCore
6
6
  #
7
7
  # @api public
8
8
  # @since 0.1.0
9
- # @version 0.7.0
10
- VERSION = '0.7.0'
9
+ # @version 0.8.0
10
+ VERSION = '0.8.0'
11
11
  end
12
12
  end
@@ -37,7 +37,7 @@ 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.85'
40
+ spec.add_development_dependency 'armitage-rubocop', '~> 0.87'
41
41
  spec.add_development_dependency 'simplecov', '~> 0.18'
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.7.0
4
+ version: 0.8.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-07-03 00:00:00.000000000 Z
11
+ date: 2020-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.85'
61
+ version: '0.87'
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.85'
68
+ version: '0.87'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -120,6 +120,7 @@ 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/frozener.rb
123
124
  - lib/smart_core/engine/lock.rb
124
125
  - lib/smart_core/engine/rescue_ext.rb
125
126
  - lib/smart_core/engine/version.rb