symbiont-ruby 0.4.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 +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +2 -1
- data/CHANGELOG.md +11 -2
- data/LICENSE.txt +1 -1
- data/lib/symbiont/private_trigger.rb +43 -2
- data/lib/symbiont/public_trigger.rb +40 -1
- data/lib/symbiont/trigger.rb +17 -4
- data/lib/symbiont/version.rb +1 -1
- data/symbiont-ruby.gemspec +2 -2
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4489ff0e80e1a0d40fd0035404c9472c2ea050c4ed49aa2927595fda63eff5df
|
4
|
+
data.tar.gz: 1990f1547ee49c472b120eee6db5712ba2f09bb874accefe992a745db6f7fab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9f1954c4aba6f0217e41e591f11e24fde1c260b0facb60e6823e60731b883e5917c96cd7a3ef93de47e5aac799647ff8f35b4088f224042d294fc15df12bc63
|
7
|
+
data.tar.gz: fcef1a29a6185fbd6e6ad3f0756a30aa4ab4452ba423d9dac1e46f5d6a524538aac77c3b9d0d8f05bd8d1c360ad86d71c2756aec63f63f16c120e2a1d208651b
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [0.5.0] 2018-03-28
|
5
|
+
### Added
|
6
|
+
- Support for method dispatching for `BasicObject` instances (which does not support `#respond_to?` method);
|
7
|
+
- Support for method extrancting for `BasicObject` instances (which does not support `#method` method);
|
8
|
+
- Updated development dependencies;
|
9
|
+
- Support for `Ruby@2.6.2`, `Ruby@2.5.5`;
|
10
|
+
|
4
11
|
## [0.4.0] 2018-10-25
|
5
|
-
###
|
6
|
-
- End of Ruby@2.2;
|
12
|
+
### Added
|
7
13
|
- Support for Ruby@2.5.3, Ruby@2.4.5, Ruby@2.3.8;
|
8
14
|
- Updated development dependencies;
|
9
15
|
|
16
|
+
### Changed
|
17
|
+
- End of Ruby@2.2;
|
18
|
+
|
10
19
|
## [0.3.0] 2018-06-15
|
11
20
|
### Added
|
12
21
|
- `Symbiont::Isolator` - proc object isolation layer for delayed invocations;
|
data/LICENSE.txt
CHANGED
@@ -17,7 +17,7 @@ module Symbiont
|
|
17
17
|
#
|
18
18
|
# @param method_name [String,Symbol] Method that a context should respond to.
|
19
19
|
# @raise NoMethodError
|
20
|
-
#
|
20
|
+
# Is raised when no one of the contexts are able to respond to the required method.
|
21
21
|
# @return [Objcet]
|
22
22
|
#
|
23
23
|
# @see Symbiont::Trigger#__actual_context__
|
@@ -26,8 +26,49 @@ module Symbiont
|
|
26
26
|
# @since 0.1.0
|
27
27
|
def __actual_context__(method_name)
|
28
28
|
__directed_contexts__.find do |context|
|
29
|
-
|
29
|
+
begin
|
30
|
+
context.respond_to?(method_name, true)
|
31
|
+
rescue ::NoMethodError
|
32
|
+
# NOTE:
|
33
|
+
# this situation is caused when the context object does not respodond to
|
34
|
+
# #resond_to? method (BasicObject instances for example)
|
35
|
+
|
36
|
+
context_singleton = __extract_singleton_object__(context)
|
37
|
+
|
38
|
+
context_singleton.private_methods(true).include?(method_name) ||
|
39
|
+
context_singleton.methods(true).include?(method_name) ||
|
40
|
+
context_singleton.superclass.private_instance_methods(true).include?(method_name) ||
|
41
|
+
context_singleton.superclass.instance_methods(true).include?(method_name)
|
42
|
+
end
|
30
43
|
end || super
|
31
44
|
end
|
45
|
+
|
46
|
+
# Returns a corresponding public/private method object of the actual context.
|
47
|
+
#
|
48
|
+
# @param method_name [String,Symbol] Method name
|
49
|
+
# @return [Method]
|
50
|
+
#
|
51
|
+
# @see [Symbiont::Trigger#method]
|
52
|
+
#
|
53
|
+
# @api private
|
54
|
+
# @since 0.5.0
|
55
|
+
def method(method_name)
|
56
|
+
__context__ = __actual_context__(method_name)
|
57
|
+
|
58
|
+
# NOTE:
|
59
|
+
# block is used cuz #__actual_context__can raise
|
60
|
+
# ::NoMethodError (ContextNoMethodError) too (and we should raise it).
|
61
|
+
begin
|
62
|
+
__context__.method(method_name)
|
63
|
+
rescue ::NoMethodError
|
64
|
+
# NOTE:
|
65
|
+
# this situation is caused when the context object does not respond
|
66
|
+
# to #method method (BasicObject instances for example). We can extract
|
67
|
+
# method objects via it's singleton class.
|
68
|
+
|
69
|
+
__context_singleton__ = __extract_singleton_object__(__context__)
|
70
|
+
__context_singleton__.superclass.instance_method(method_name).bind(__context__)
|
71
|
+
end
|
72
|
+
end
|
32
73
|
end
|
33
74
|
end
|
@@ -26,8 +26,47 @@ module Symbiont
|
|
26
26
|
# @since 0.1.0
|
27
27
|
def __actual_context__(method_name)
|
28
28
|
__directed_contexts__.find do |context|
|
29
|
-
|
29
|
+
begin
|
30
|
+
context.respond_to?(method_name, false)
|
31
|
+
rescue ::NoMethodError
|
32
|
+
# NOTE:
|
33
|
+
# this situation is caused when the context object does not respodond to
|
34
|
+
# #resond_to? method (BasicObject instances for example)
|
35
|
+
|
36
|
+
context_singleton = __extract_singleton_object__(context)
|
37
|
+
|
38
|
+
context_singleton.public_methods(false).include?(method_name) ||
|
39
|
+
context_singleton.superclass.public_instance_methods(false).include?(method_name)
|
40
|
+
end
|
30
41
|
end || super
|
31
42
|
end
|
43
|
+
|
44
|
+
# Returns a corresponding public method object of the actual context.
|
45
|
+
#
|
46
|
+
# @param method_name [String,Symbol] Method name
|
47
|
+
# @return [Method]
|
48
|
+
#
|
49
|
+
# @see [Symbiont::Trigger#method]
|
50
|
+
#
|
51
|
+
# @api private
|
52
|
+
# @since 0.5.0
|
53
|
+
def method(method_name)
|
54
|
+
__context__ = __actual_context__(method_name)
|
55
|
+
|
56
|
+
# NOTE:
|
57
|
+
# block is used cuz #__actual_context__can raise
|
58
|
+
# ::NoMethodError (ContextNoMethodError) too (and we should raise it)
|
59
|
+
begin
|
60
|
+
__context__.method(method_name)
|
61
|
+
rescue ::NoMethodError
|
62
|
+
# NOTE:
|
63
|
+
# this situation is caused when the context object does not respond
|
64
|
+
# to #method method (BasicObject instances for example). We can extract
|
65
|
+
# method objects via it's singleton class.
|
66
|
+
|
67
|
+
__context_singleton__ = __extract_singleton_object__(__context__)
|
68
|
+
__context_singleton__.superclass.public_instance_method(method_name).bind(__context__)
|
69
|
+
end
|
70
|
+
end
|
32
71
|
end
|
33
72
|
end
|
data/lib/symbiont/trigger.rb
CHANGED
@@ -233,7 +233,7 @@ class Symbiont::Trigger < BasicObject
|
|
233
233
|
# @api private
|
234
234
|
# @since 0.1.0
|
235
235
|
def method_missing(method_name, *arguments, &block)
|
236
|
-
__actual_context__(method_name).
|
236
|
+
__actual_context__(method_name).__send__(method_name, *arguments, &block)
|
237
237
|
end
|
238
238
|
|
239
239
|
# Checks that the actual context is able to respond to a required method.
|
@@ -255,7 +255,7 @@ class Symbiont::Trigger < BasicObject
|
|
255
255
|
end
|
256
256
|
# :nocov:
|
257
257
|
|
258
|
-
#
|
258
|
+
# Should return a corresponding method object of the actual context.
|
259
259
|
#
|
260
260
|
# @param method_name [String,Symbol] Method name
|
261
261
|
# @raise ContextNoMethodError
|
@@ -266,9 +266,22 @@ class Symbiont::Trigger < BasicObject
|
|
266
266
|
# @see #respond_to_missing?
|
267
267
|
# @see #__actual_context__
|
268
268
|
#
|
269
|
+
# @see [Symbiont::PrivateTrigget#method]
|
270
|
+
# @see [Symbiont::PublicTrigger#method]
|
271
|
+
#
|
269
272
|
# @api private
|
270
273
|
# @since 0.1.0
|
271
|
-
def method(method_name)
|
272
|
-
|
274
|
+
def method(method_name); end # :nocov:
|
275
|
+
|
276
|
+
# Returns an internal singleton object of the passed object.
|
277
|
+
#
|
278
|
+
# @param object [Any] Extractable object
|
279
|
+
# @return [Class] Singleton class of the passed object
|
280
|
+
#
|
281
|
+
# @api private
|
282
|
+
# @sionce 0.5.0
|
283
|
+
def __extract_singleton_object__(object)
|
284
|
+
# NOTE: `<<` approach is used cuz BasicObject does not support #singleton_class method.
|
285
|
+
class << object; self; end
|
273
286
|
end
|
274
287
|
end
|
data/lib/symbiont/version.rb
CHANGED
data/symbiont-ruby.gemspec
CHANGED
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
6
|
require 'symbiont/version'
|
7
7
|
|
8
8
|
Gem::Specification.new do |spec|
|
9
|
-
spec.required_ruby_version = '>= 2.3.
|
9
|
+
spec.required_ruby_version = '>= 2.3.8'
|
10
10
|
|
11
11
|
spec.name = 'symbiont-ruby'
|
12
12
|
spec.version = Symbiont::VERSION
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
33
33
|
spec.add_development_dependency 'simplecov', '~> 0.16'
|
34
34
|
spec.add_development_dependency 'coveralls', '~> 0.8'
|
35
|
-
spec.add_development_dependency 'armitage-rubocop', '~> 0.
|
35
|
+
spec.add_development_dependency 'armitage-rubocop', '~> 0.24'
|
36
36
|
|
37
37
|
spec.add_development_dependency 'pry'
|
38
38
|
spec.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: symbiont-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Ibragimov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.24'
|
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.
|
68
|
+
version: '0.24'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,15 +199,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
199
|
requirements:
|
200
200
|
- - ">="
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version: 2.3.
|
202
|
+
version: 2.3.8
|
203
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
204
|
requirements:
|
205
205
|
- - ">="
|
206
206
|
- !ruby/object:Gem::Version
|
207
207
|
version: '0'
|
208
208
|
requirements: []
|
209
|
-
|
210
|
-
rubygems_version: 2.7.6
|
209
|
+
rubygems_version: 3.0.2
|
211
210
|
signing_key:
|
212
211
|
specification_version: 4
|
213
212
|
summary: Evaluate proc-objects in many contexts simultaneously
|