evt-constant 2.1.0.1 → 2.2.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 +4 -4
- data/lib/constant/controls/script.rb +107 -0
- data/lib/constant/controls.rb +1 -0
- data/lib/constant/import/macro.rb +2 -0
- data/lib/constant/import.rb +16 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7b012e976058289cb87180483efb47e51d2f9f510e6089ec32f8ea12aaa2245b
|
|
4
|
+
data.tar.gz: 5a50636f4f77c8a5aa4920178a66749221fbce806440fa4958367bce3185ed82
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a5c0b2b1c190b528c213a38ea920fbd786a7d588ccc922987baba6a7e8fd1ddacfcea0075e339b0bd6be1c3cbf29d783a56a88b023d4e76916681982ad494e23
|
|
7
|
+
data.tar.gz: 11fae6756c40334c83284d299c7f5e6370d0f77ceff1965896b8849c5394eba4e16f70f0850c5f5ac4b3a627d136a35e168ad4b32c2f9edf56e29b28b4631c5d
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
require "open3"
|
|
2
|
+
|
|
3
|
+
module Constant
|
|
4
|
+
module Controls
|
|
5
|
+
module Script
|
|
6
|
+
def self.top_level_import(origin_name: nil, inner_constants: nil)
|
|
7
|
+
origin_name ||= "SomeOrigin"
|
|
8
|
+
inner_constants ||= ["SomeInnerConstant"]
|
|
9
|
+
|
|
10
|
+
inner_constant_definitions = inner_constants.map do |inner_constant_name|
|
|
11
|
+
"#{inner_constant_name} = ::Module.new"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
inner_constant_resolutions = inner_constants.map do |inner_constant_name|
|
|
15
|
+
"puts #{inner_constant_name}.name"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
definitions = inner_constant_definitions.join("\n")
|
|
19
|
+
resolutions = inner_constant_resolutions.join("\n")
|
|
20
|
+
|
|
21
|
+
source = <<~RUBY
|
|
22
|
+
require "constant"
|
|
23
|
+
|
|
24
|
+
module #{origin_name}
|
|
25
|
+
#{definitions}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
include Constant::Import
|
|
29
|
+
|
|
30
|
+
import #{origin_name}
|
|
31
|
+
|
|
32
|
+
#{resolutions}
|
|
33
|
+
RUBY
|
|
34
|
+
|
|
35
|
+
Example.new(source)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.top_level_refinement_import(origin_name: nil, inner_constants: nil)
|
|
39
|
+
origin_name ||= "SomeOrigin"
|
|
40
|
+
inner_constants ||= ["SomeInnerConstant"]
|
|
41
|
+
|
|
42
|
+
inner_constant_definitions = inner_constants.map do |inner_constant_name|
|
|
43
|
+
"#{inner_constant_name} = ::Module.new"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
inner_constant_resolutions = inner_constants.map do |inner_constant_name|
|
|
47
|
+
"puts #{inner_constant_name}.name"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
definitions = inner_constant_definitions.join("\n")
|
|
51
|
+
resolutions = inner_constant_resolutions.join("\n")
|
|
52
|
+
|
|
53
|
+
source = <<~RUBY
|
|
54
|
+
require "constant"
|
|
55
|
+
|
|
56
|
+
module #{origin_name}
|
|
57
|
+
#{definitions}
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
using Constant::Import
|
|
61
|
+
|
|
62
|
+
import #{origin_name}
|
|
63
|
+
|
|
64
|
+
#{resolutions}
|
|
65
|
+
RUBY
|
|
66
|
+
|
|
67
|
+
Example.new(source)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
class Example
|
|
71
|
+
include Initializer
|
|
72
|
+
|
|
73
|
+
initializer :source
|
|
74
|
+
|
|
75
|
+
def run
|
|
76
|
+
output, error_output, status = execute
|
|
77
|
+
|
|
78
|
+
if not status.success?
|
|
79
|
+
raise "Script failed\n\n#{source}\n#{error_output}"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
output.split("\n")
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def error
|
|
86
|
+
_, error_output, status = execute
|
|
87
|
+
|
|
88
|
+
if status.success?
|
|
89
|
+
raise "Script succeeded\n\n#{source}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
error_output
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def execute
|
|
96
|
+
load_path_options = $LOAD_PATH.map do |load_path_entry|
|
|
97
|
+
"-I#{load_path_entry}"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
command = ["ruby", *load_path_options, "-e", source]
|
|
101
|
+
|
|
102
|
+
Open3.capture3(*command)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
data/lib/constant/controls.rb
CHANGED
data/lib/constant/import.rb
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
module Constant
|
|
2
2
|
module Import
|
|
3
3
|
def self.included(base)
|
|
4
|
+
if base.equal?(::Object)
|
|
5
|
+
raise Constant::Error, "Constant::Import cannot be included at the top level, where the destination is Object. Activate the refinement instead: using Constant::Import"
|
|
6
|
+
end
|
|
7
|
+
|
|
4
8
|
base.extend(Macro)
|
|
5
9
|
end
|
|
6
10
|
|
|
11
|
+
refine ::Object do
|
|
12
|
+
def __import_constant(origin_constant, **kwargs)
|
|
13
|
+
Import.(origin_constant, self, **kwargs)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
alias import __import_constant
|
|
17
|
+
end
|
|
18
|
+
|
|
7
19
|
def self.call(origin_constant, destination_constant, **kwargs)
|
|
20
|
+
if not destination_constant.is_a?(::Module)
|
|
21
|
+
destination_constant = destination_constant.class
|
|
22
|
+
end
|
|
23
|
+
|
|
8
24
|
alias_name = kwargs[:alias]
|
|
9
25
|
|
|
10
26
|
if alias_name.nil? && destination_constant.ancestors.include?(origin_constant)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: evt-constant
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- The Eventide Project
|
|
@@ -48,6 +48,7 @@ files:
|
|
|
48
48
|
- lib/constant/constant.rb
|
|
49
49
|
- lib/constant/controls.rb
|
|
50
50
|
- lib/constant/controls/constant.rb
|
|
51
|
+
- lib/constant/controls/script.rb
|
|
51
52
|
- lib/constant/define.rb
|
|
52
53
|
- lib/constant/import.rb
|
|
53
54
|
- lib/constant/import/macro.rb
|
|
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
71
72
|
- !ruby/object:Gem::Version
|
|
72
73
|
version: '0'
|
|
73
74
|
requirements: []
|
|
74
|
-
rubygems_version: 4.0.
|
|
75
|
+
rubygems_version: 4.0.17
|
|
75
76
|
specification_version: 4
|
|
76
77
|
summary: ''
|
|
77
78
|
test_files: []
|