wisco 0.2.0 → 0.2.2
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/wisco/commands/exec.rb +20 -7
- data/lib/wisco/commands/fixtures.rb +38 -0
- data/lib/wisco/path_utils.rb +1 -1
- data/lib/wisco/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b480d047c6f25a2c8ad8e234e034cb1d1cb571efbd9620b405a90a9e7816a807
|
|
4
|
+
data.tar.gz: baac61b7895d1a8fa7046a675910ecacfcae4e03afab83fa42d371f5a8a19b0b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f15e57668b56c77e593da83dbc759663d1bf2a7c3bb7f39fe7dc03bfea50365df9356aa7e996d9e060a34b5ba1f1946172d5cdbe91c92c02c49e72eec606a26f
|
|
7
|
+
data.tar.gz: d8339fb1ea9942a124a8cbd260ffd74912504dbe5ed38f24ba817e82bad9f930ebcb75f270f65afe23a09a82bbb2161bfee40c0adc96a76049ec698c90e62e2c
|
data/lib/wisco/commands/exec.rb
CHANGED
|
@@ -49,7 +49,12 @@ module Wisco
|
|
|
49
49
|
input_files = resolve_input_files(input, fixtures_dir)
|
|
50
50
|
|
|
51
51
|
if input_files.empty?
|
|
52
|
-
|
|
52
|
+
if %w[pick_lists methods].include?(section)
|
|
53
|
+
# No-param pick list or method — execute once with no input file
|
|
54
|
+
execute_one(section, key, nil, fixtures_dir, connector_full_path, connection, debug: debug)
|
|
55
|
+
else
|
|
56
|
+
warn "\tWarning: No ready input files found in #{fixture_dir_output}"
|
|
57
|
+
end
|
|
53
58
|
next
|
|
54
59
|
end
|
|
55
60
|
|
|
@@ -88,27 +93,35 @@ module Wisco
|
|
|
88
93
|
end
|
|
89
94
|
|
|
90
95
|
def execute_one(section, key, input_file, fixtures_dir, connector_full_path, connection, debug: false)
|
|
91
|
-
stem = File.basename(input_file, '.*')
|
|
96
|
+
stem = input_file ? File.basename(input_file, '.*') : 'execute'
|
|
92
97
|
output_file = File.join(fixtures_dir, "output_#{stem}.json")
|
|
93
98
|
error_file = File.join(fixtures_dir, "error_#{stem}.txt")
|
|
94
99
|
|
|
95
|
-
|
|
100
|
+
use_args = %w[pick_lists methods].include?(section)
|
|
101
|
+
exec_path = use_args ? "#{section}.#{key}" : "#{section}.#{key}.execute"
|
|
102
|
+
|
|
103
|
+
options = { connector: connector_full_path, output: output_file }
|
|
96
104
|
options[:connection] = connection if connection
|
|
105
|
+
if use_args
|
|
106
|
+
options[:args] = input_file if input_file
|
|
107
|
+
else
|
|
108
|
+
options[:input] = input_file
|
|
109
|
+
end
|
|
97
110
|
|
|
98
111
|
if debug
|
|
99
|
-
warn "[exec] path: #{
|
|
112
|
+
warn "[exec] path: #{exec_path}"
|
|
100
113
|
warn "[exec] connector: #{connector_full_path}"
|
|
101
114
|
warn "[exec] connection: #{connection.inspect}"
|
|
102
|
-
warn "[exec] input: #{input_file}"
|
|
115
|
+
warn "[exec] #{use_args ? 'args' : 'input'}: #{input_file.inspect}"
|
|
103
116
|
warn "[exec] output: #{output_file}"
|
|
104
117
|
end
|
|
105
118
|
|
|
106
119
|
begin
|
|
107
|
-
cmd = Workato::CLI::ExecCommand.new(path:
|
|
120
|
+
cmd = Workato::CLI::ExecCommand.new(path: exec_path, options: options)
|
|
108
121
|
cmd.call
|
|
109
122
|
rescue StandardError => e
|
|
110
123
|
File.write(error_file, "#{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}\n")
|
|
111
|
-
warn "Error executing #{section}.#{key} with #{File.basename(input_file)}: #{e.message}"
|
|
124
|
+
warn "Error executing #{section}.#{key} with #{input_file ? File.basename(input_file) : 'no input'}: #{e.message}"
|
|
112
125
|
warn " Details written to: #{error_file}"
|
|
113
126
|
return
|
|
114
127
|
end
|
|
@@ -44,6 +44,8 @@ module Wisco
|
|
|
44
44
|
|
|
45
45
|
if section == 'pick_lists'
|
|
46
46
|
process_pick_list(key, connector, fixtures_dir, overwrite: overwrite)
|
|
47
|
+
elsif section == 'methods'
|
|
48
|
+
process_method(key, connector, fixtures_dir, overwrite: overwrite)
|
|
47
49
|
else
|
|
48
50
|
input_fields_file = File.join(fixtures_dir, 'input_fields.json')
|
|
49
51
|
call_exec(
|
|
@@ -124,6 +126,42 @@ module Wisco
|
|
|
124
126
|
end
|
|
125
127
|
end
|
|
126
128
|
|
|
129
|
+
def process_method(key, connector, fixtures_dir, overwrite: false)
|
|
130
|
+
method_fn = connector[:methods]&.[](key.to_sym)
|
|
131
|
+
|
|
132
|
+
unless method_fn.respond_to?(:parameters)
|
|
133
|
+
warn " Warning: method '#{key}' is not callable — skipping."
|
|
134
|
+
return
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
params = method_fn.parameters # all params are real inputs (no connection to drop)
|
|
138
|
+
|
|
139
|
+
if params.empty?
|
|
140
|
+
puts " No input required: #{fixtures_dir}"
|
|
141
|
+
return
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
output_file = File.join(fixtures_dir, 'execute_input.json')
|
|
145
|
+
|
|
146
|
+
if File.exist?(output_file)
|
|
147
|
+
first_line = begin
|
|
148
|
+
File.open(output_file, &:readline).chomp
|
|
149
|
+
rescue StandardError
|
|
150
|
+
''
|
|
151
|
+
end
|
|
152
|
+
unless first_line == SENTINEL || overwrite
|
|
153
|
+
puts " Skipped (user-edited): #{output_file}"
|
|
154
|
+
return
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Positional array — each element is the param name as a placeholder string
|
|
159
|
+
template = params.map { |(_, name)| name.to_s }
|
|
160
|
+
content = "#{SENTINEL}\n#{JSON.pretty_generate(template)}\n"
|
|
161
|
+
File.write(output_file, content)
|
|
162
|
+
puts " Written: #{output_file}"
|
|
163
|
+
end
|
|
164
|
+
|
|
127
165
|
def process_pick_list(key, connector, fixtures_dir, overwrite: false)
|
|
128
166
|
pick_list_fn = connector[:pick_lists]&.[](key.to_sym)
|
|
129
167
|
|
data/lib/wisco/path_utils.rb
CHANGED
data/lib/wisco/version.rb
CHANGED