evt-constant 2.1.0.1 → 2.1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17eced35f5905252a25ba020d494be512c92a9007a7958489c52248bd492b0f1
4
- data.tar.gz: ab36e7dac2d41e40455b8eac4eb71a0bdc74ea3fac996d314992b2b5b97b5f4b
3
+ metadata.gz: d0e34b89c8c9aec6ef54da871a992f086616ceee7f411ee1b43bf070cc9b80de
4
+ data.tar.gz: 34e6bf8e3b33b7fd2260e75400a9eed3ac82ebe8e3d86ff7b94b82877c3ec7ad
5
5
  SHA512:
6
- metadata.gz: ca38a280e592e840eb98e0a5df5d6b73551ca5112c9839052a5dd2f7eda2bef671444eeb844750d3bcd1a0f3d3d9bbf03319d1b1e5659fddccf2378a9fbcc0e6
7
- data.tar.gz: 1af28935125986c0dfc6974a491e87cd04cbbac32a9245b5c04c17bf6769401ebe66b3d4ad130dac893fcc2deb2385e3cccc9c878e6b730e232c2a5f83de7260
6
+ metadata.gz: 52f10483f068718f662c3471ab19b397dc33deaf477bd741b5359b7d8e71e8daff8df05a014c0cd5e6f04a427aa0fdc95b835f03dfafd2f06152fb7596041ac8
7
+ data.tar.gz: 86d07e6c53ec8cdbda773639f61e0a82ed9f7b20375fa966f1289a3f7e48c23147b2911c55ac703c2106becf7f4ed424ccfbeded5cb622b77b7d1c6974f50392
@@ -0,0 +1,61 @@
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
+ class Example
39
+ include Initializer
40
+
41
+ initializer :source
42
+
43
+ def run
44
+ load_path_options = $LOAD_PATH.map do |load_path_entry|
45
+ "-I#{load_path_entry}"
46
+ end
47
+
48
+ command = ["ruby", *load_path_options, "-e", source]
49
+
50
+ output, error_output, status = Open3.capture3(*command)
51
+
52
+ if not status.success?
53
+ raise "Script failed\n\n#{source}\n#{error_output}"
54
+ end
55
+
56
+ output.split("\n")
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,3 +1,4 @@
1
1
  require "securerandom"
2
2
 
3
3
  require "constant/controls/constant"
4
+ require "constant/controls/script"
@@ -2,7 +2,13 @@ module Constant
2
2
  module Import
3
3
  module Macro
4
4
  def __import_constant(origin_constant, **kwargs)
5
- Import.(origin_constant, self, **kwargs)
5
+ destination = self
6
+
7
+ if not destination.is_a?(::Module)
8
+ destination = destination.class
9
+ end
10
+
11
+ Import.(origin_constant, destination, **kwargs)
6
12
  end
7
13
 
8
14
  alias import __import_constant
@@ -2,6 +2,10 @@ module Constant
2
2
  module Import
3
3
  def self.included(base)
4
4
  base.extend(Macro)
5
+
6
+ if base.equal?(::Object)
7
+ TOPLEVEL_BINDING.receiver.extend(Macro)
8
+ end
5
9
  end
6
10
 
7
11
  def self.call(origin_constant, destination_constant, **kwargs)
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.1.0.1
4
+ version: 2.1.1.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.3
75
+ rubygems_version: 4.0.17
75
76
  specification_version: 4
76
77
  summary: ''
77
78
  test_files: []