opswalrus 1.0.15 → 1.0.16

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: 89bf0215bfa03656ade838eeecc4e8a9026c71290d65499d7df9ef9f93e482ec
4
- data.tar.gz: b434b04092d90139ce02b0f55b3c54f7027cc84d0190ed68d9d9baacf04d4c62
3
+ metadata.gz: f6d990ac1fac1a918ebca3eac342377ee61702f0864e635e378ad8e69d7ec0d5
4
+ data.tar.gz: 900661d04774a42b0a960624fd7fc51b9690c23ad15fba5aaf94f8a3e1241de6
5
5
  SHA512:
6
- metadata.gz: c2e19399736ff4e3f46a391484342c8411cfc4c29727f0104e3a5cd46313fd68da036ca41927036351cd9d74b9d3f7f7c50dcb61cc559174e40d8e0bd4c86c64
7
- data.tar.gz: 4bddab84402b4a89d80bdda60df5eeab729d3b22a0b99f28fa4730c5ab7de051acba633b36848a7cd63648c0aea6230ffb86d97db81f67c6349282142ccf7844
6
+ metadata.gz: 88e94b27da26afb8b925f1b363c6ccf889f3e105d28e3f7d2ccfd1d2d8fe1b61d443d64dc1829c42b8644216e19bad1c4e384757246414b62dc18104421cb8fe
7
+ data.tar.gz: 3e5b2b2062a592102bed054b7bae779a66b676ca8d47beb42cbab0a6cc6096e191129b3fd9a2c6fc815f8964bf78270b15687cbba99787c0323fb51c87e82c9c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opswalrus (1.0.15)
4
+ opswalrus (1.0.16)
5
5
  amazing_print (~> 1.5)
6
6
  bcrypt_pbkdf (~> 1.1)
7
7
  citrus (~> 3.0)
data/lib/opswalrus/app.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "citrus"
2
2
  require "io/console"
3
3
  require "json"
4
- require "logger"
4
+ # require "logger"
5
5
  require "random/formatter"
6
6
  require "ougai"
7
7
  require "shellwords"
@@ -6,94 +6,8 @@ require_relative "invocation"
6
6
 
7
7
  module OpsWalrus
8
8
 
9
- class HostProxyOpsFileInvocationBuilder
10
- def initialize(host_proxy, is_invocation_a_call_to_package_in_bundle_dir = false)
11
- @host_proxy = host_proxy
12
- @is_invocation_a_call_to_package_in_bundle_dir = is_invocation_a_call_to_package_in_bundle_dir
13
- @method_chain = []
14
- end
15
-
16
- def method_missing(method_name, *args, **kwargs)
17
- @method_chain << method_name.to_s
18
-
19
- if args.empty? && kwargs.empty? # when there are no args and no kwargs, we are just drilling down through another namespace
20
- self
21
- else
22
- # when there are args or kwargs, then the method invocation represents an attempt to run an OpsFile on a remote host,
23
- # so we want to build up a command and send it to the remote host via HostDSL#run_ops
24
- @method_chain.unshift(Bundler::BUNDLE_DIR) if @is_invocation_a_call_to_package_in_bundle_dir
25
-
26
- remote_run_command_args = @method_chain.join(" ")
27
-
28
- unless args.empty?
29
- remote_run_command_args << " "
30
- remote_run_command_args << args.join(" ")
31
- end
32
-
33
- unless kwargs.empty?
34
- remote_run_command_args << " "
35
- remote_run_command_args << kwargs.map do |k, v|
36
- case v
37
- when Array
38
- v.map {|v_element| "#{k}:#{v_element}" }
39
- else
40
- "#{k}:#{v}"
41
- end
42
- end.join(" ")
43
- end
44
-
45
- @host_proxy.run_ops(:run, "--script", remote_run_command_args)
46
- end
47
- end
48
- end
49
-
50
9
  # the subclasses of HostProxy will define methods that handle method dispatch via HostProxyOpsFileInvocationBuilder objects
51
10
  class HostProxy
52
- # def self.define_host_proxy_class(ops_file)
53
- # klass = Class.new(HostProxy)
54
-
55
- # methods_defined = Set.new
56
-
57
- # # define methods for every import in the script
58
- # ops_file.local_symbol_table.each do |symbol_name, import_reference|
59
- # unless methods_defined.include? symbol_name
60
- # # puts "1. defining: #{symbol_name}(...)"
61
- # klass.define_method(symbol_name) do |*args, **kwargs, &block|
62
- # invocation_builder = case import_reference
63
- # # we know we're dealing with a package dependency reference, so we want to run an ops file contained within the bundle directory,
64
- # # therefore, we want to reference the specified ops file with respect to the bundle dir
65
- # when PackageDependencyReference
66
- # HostProxyOpsFileInvocationBuilder.new(self, true)
67
-
68
- # # we know we're dealing with a directory reference or OpsFile reference outside of the bundle dir, so we want to reference
69
- # # the specified ops file with respect to the root directory, and not with respect to the bundle dir
70
- # when DirectoryReference, OpsFileReference
71
- # HostProxyOpsFileInvocationBuilder.new(self, false)
72
- # end
73
-
74
- # invocation_builder.send(symbol_name, *args, **kwargs, &block)
75
- # end
76
- # methods_defined << symbol_name
77
- # end
78
- # end
79
-
80
- # # define methods for every Namespace or OpsFile within the namespace that the OpsFile resides within
81
- # sibling_symbol_table = Set.new
82
- # sibling_symbol_table |= ops_file.dirname.glob("*.ops").map {|ops_file_path| ops_file_path.basename(".ops").to_s } # OpsFiles
83
- # sibling_symbol_table |= ops_file.dirname.glob("*").select(&:directory?).map {|dir_path| dir_path.basename.to_s } # Namespaces
84
- # sibling_symbol_table.each do |symbol_name|
85
- # unless methods_defined.include? symbol_name
86
- # # puts "2. defining: #{symbol_name}(...)"
87
- # klass.define_method(symbol_name) do |*args, **kwargs, &block|
88
- # invocation_builder = HostProxyOpsFileInvocationBuilder.new(self, false)
89
- # invocation_builder.invoke(symbol_name, *args, **kwargs, &block)
90
- # end
91
- # methods_defined << symbol_name
92
- # end
93
- # end
94
-
95
- # klass
96
- # end
97
11
 
98
12
  def self.define_host_proxy_class(ops_file)
99
13
  klass = Class.new(HostProxy)
@@ -122,21 +36,6 @@ module OpsWalrus
122
36
 
123
37
  invocation_context._invoke(*args, **kwargs)
124
38
 
125
-
126
-
127
- # invocation_builder = case import_reference
128
- # # we know we're dealing with a package dependency reference, so we want to run an ops file contained within the bundle directory,
129
- # # therefore, we want to reference the specified ops file with respect to the bundle dir
130
- # when PackageDependencyReference
131
- # HostProxyOpsFileInvocationBuilder.new(self, true)
132
-
133
- # # we know we're dealing with a directory reference or OpsFile reference outside of the bundle dir, so we want to reference
134
- # # the specified ops file with respect to the root directory, and not with respect to the bundle dir
135
- # when DirectoryReference, OpsFileReference
136
- # HostProxyOpsFileInvocationBuilder.new(self, false)
137
- # end
138
-
139
- # invocation_builder.send(symbol_name, *args, **kwargs, &block)
140
39
  end
141
40
  methods_defined << symbol_name
142
41
  end
@@ -150,9 +49,6 @@ module OpsWalrus
150
49
  unless methods_defined.include? symbol_name
151
50
  # puts "2. defining: #{symbol_name}(...)"
152
51
  klass.define_method(symbol_name) do |*args, **kwargs, &block|
153
- # invocation_builder = HostProxyOpsFileInvocationBuilder.new(self, false)
154
- # invocation_builder.invoke(symbol_name, *args, **kwargs, &block)
155
-
156
52
  invocation_context = RemoteImportInvocationContext.new(@runtime_env, self, namespace_or_ops_file, false)
157
53
  invocation_context._invoke(*args, **kwargs)
158
54
  end
@@ -202,6 +98,7 @@ module OpsWalrus
202
98
  return ["", "", 0] if !desc_or_cmd && !cmd && !block # we were told to do nothing; like hitting enter at the bash prompt; we can do nothing successfully
203
99
 
204
100
  description = desc_or_cmd if cmd || block
101
+ description = WalrusLang.render(description, block.binding) if description && block
205
102
  cmd = block.call if block
206
103
  cmd ||= desc_or_cmd
207
104
 
@@ -264,6 +264,7 @@ module OpsWalrus
264
264
  return ["", "", 0] if !desc_or_cmd && !cmd && !block # we were told to do nothing; like hitting enter at the bash prompt; we can do nothing successfully
265
265
 
266
266
  description = desc_or_cmd if cmd || block
267
+ description = WalrusLang.render(description, block.binding) if description && block
267
268
  cmd = block.call if block
268
269
  cmd ||= desc_or_cmd
269
270
 
@@ -1,3 +1,3 @@
1
1
  module OpsWalrus
2
- VERSION = "1.0.15"
2
+ VERSION = "1.0.16"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opswalrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.15
4
+ version: 1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Ellis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-22 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amazing_print