evt-invocation 1.0.0.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 +7 -0
- data/lib/invocation.rb +1 -0
- data/lib/invocation/controls.rb +7 -0
- data/lib/invocation/controls/block_parameter.rb +16 -0
- data/lib/invocation/controls/double_splat_parameter.rb +16 -0
- data/lib/invocation/controls/mixed_parameters.rb +16 -0
- data/lib/invocation/controls/named_parameters.rb +16 -0
- data/lib/invocation/controls/no_parameters.rb +16 -0
- data/lib/invocation/controls/positional_parameters.rb +16 -0
- data/lib/invocation/controls/splat_parameter.rb +16 -0
- data/lib/invocation/invocation.rb +31 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 29383106e151de1b3dcd6538a5c776c5b76c339f810b36567d8a5f9713e13dea
|
4
|
+
data.tar.gz: c4c4d5f731b1a74ca1f9ba3e7a78e29d4056986d3d1984d45be855d2f5a20e20
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 907c81041301b04981de2714280ea85ae7a729968b970a2d3fb545b96ad1ec2c1a034e924dc656c9c68b4db14fe7bc3a4ceda1dc47e7dd83ef0aaa9e7b166aec
|
7
|
+
data.tar.gz: e6cd041f136c3e3b48e344f3f821b59d1dc5f0a25a021d52085f9877bc6ccc555368d2557998784c1b6bc47d144047477f6907629567344fd6e7fbf520a83ba3
|
data/lib/invocation.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'invocation/invocation'
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'invocation/controls/no_parameters'
|
2
|
+
require 'invocation/controls/positional_parameters'
|
3
|
+
require 'invocation/controls/named_parameters'
|
4
|
+
require 'invocation/controls/block_parameter'
|
5
|
+
require 'invocation/controls/splat_parameter'
|
6
|
+
require 'invocation/controls/double_splat_parameter'
|
7
|
+
require 'invocation/controls/mixed_parameters'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Invocation
|
2
|
+
module Controls
|
3
|
+
module BlockParameter
|
4
|
+
def self.example(&blk)
|
5
|
+
subject = Example.new
|
6
|
+
subject.some_method(&blk)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Example
|
10
|
+
def some_method(&blk)
|
11
|
+
::Invocation.build(binding)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Invocation
|
2
|
+
module Controls
|
3
|
+
module DoubleSplatParameter
|
4
|
+
def self.example(**parameters)
|
5
|
+
subject = Example.new
|
6
|
+
subject.some_method(**parameters)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Example
|
10
|
+
def some_method(**parameters)
|
11
|
+
::Invocation.build(binding)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Invocation
|
2
|
+
module Controls
|
3
|
+
module MixedParameters
|
4
|
+
def self.example(some_parameter, *parameters, some_other_parameter:, **named_parameters, &blk)
|
5
|
+
subject = Example.new
|
6
|
+
subject.some_method(some_parameter, *parameters, some_other_parameter: some_other_parameter, **named_parameters, &blk)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Example
|
10
|
+
def some_method(some_parameter, *parameters, some_other_parameter:, **named_parameters, &blk)
|
11
|
+
::Invocation.build(binding)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Invocation
|
2
|
+
module Controls
|
3
|
+
module NamedParameters
|
4
|
+
def self.example(some_parameter:, some_other_parameter:)
|
5
|
+
subject = Example.new
|
6
|
+
subject.some_method(some_parameter: some_parameter, some_other_parameter: some_other_parameter)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Example
|
10
|
+
def some_method(some_parameter:, some_other_parameter:)
|
11
|
+
::Invocation.build(binding)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Invocation
|
2
|
+
module Controls
|
3
|
+
module PositionalParameters
|
4
|
+
def self.example(some_parameter, some_other_parameter)
|
5
|
+
subject = Example.new
|
6
|
+
subject.some_method(some_parameter, some_other_parameter)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Example
|
10
|
+
def some_method(some_parameter, some_other_parameter)
|
11
|
+
::Invocation.build(binding)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Invocation
|
2
|
+
module Controls
|
3
|
+
module SplatParameter
|
4
|
+
def self.example(*parameters)
|
5
|
+
subject = Example.new
|
6
|
+
subject.some_method(*parameters)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Example
|
10
|
+
def some_method(*parameters)
|
11
|
+
::Invocation.build(binding)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Invocation
|
2
|
+
attr_reader :method_name
|
3
|
+
attr_reader :parameters
|
4
|
+
|
5
|
+
def initialize(method_name, parameters)
|
6
|
+
@method_name = method_name
|
7
|
+
@parameters = parameters
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.build(bndg)
|
11
|
+
instance = bndg.receiver
|
12
|
+
method_name = bndg.eval("__method__")
|
13
|
+
|
14
|
+
mthd = instance.method(method_name)
|
15
|
+
|
16
|
+
parameters = mthd.parameters
|
17
|
+
parameter_names = parameters.map { |p| p[1] }
|
18
|
+
|
19
|
+
parameter_values = parameter_names.map { |n| bndg.local_variable_get(n) }
|
20
|
+
|
21
|
+
params = []
|
22
|
+
parameter_names.each_with_index do |n, i|
|
23
|
+
parameter = Parameter.new(n, parameter_values[i])
|
24
|
+
params << parameter
|
25
|
+
end
|
26
|
+
|
27
|
+
new(method_name, params)
|
28
|
+
end
|
29
|
+
|
30
|
+
Parameter = Struct.new(:name, :value)
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: evt-invocation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- The Eventide Project
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: test_bench
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: " "
|
28
|
+
email: opensource@eventide-project.org
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/invocation.rb
|
34
|
+
- lib/invocation/controls.rb
|
35
|
+
- lib/invocation/controls/block_parameter.rb
|
36
|
+
- lib/invocation/controls/double_splat_parameter.rb
|
37
|
+
- lib/invocation/controls/mixed_parameters.rb
|
38
|
+
- lib/invocation/controls/named_parameters.rb
|
39
|
+
- lib/invocation/controls/no_parameters.rb
|
40
|
+
- lib/invocation/controls/positional_parameters.rb
|
41
|
+
- lib/invocation/controls/splat_parameter.rb
|
42
|
+
- lib/invocation/invocation.rb
|
43
|
+
homepage: https://github.com/eventide-project/invocation
|
44
|
+
licenses:
|
45
|
+
- MIT
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.4'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubygems_version: 3.0.1
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Extract information about a method's invocation including the method name,
|
66
|
+
parameter names, and parameter values
|
67
|
+
test_files: []
|