wisco 0.2.2 → 0.2.4
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 +13 -5
- data/lib/wisco/commands/fixtures.rb +60 -12
- data/lib/wisco/version.rb +1 -1
- data/lib/wisco.rb +7 -4
- 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: 3a60475b816732d204bb52da3c9b4a17c90ebd3471eb05254cc153c68ac5ad5b
|
|
4
|
+
data.tar.gz: 482f28c284946b0b915aa25a2abaefecd983a7b1e26b824f0576ab609e42d276
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5b3340475edcafba79c184332e869d33fa230c61ba9f769f89a2ec1da1081449b3e14f29b3bf6afc02a701bb9d4195a00909fb11642a4bbc5c8ce033c7d064c6
|
|
7
|
+
data.tar.gz: 5e526ccb7fdba3d62c2c35af71c2b81f904820eba2fa626bba2d1679167c2c4d0f642b34ee062ccdd232a6467106341d87694d9219ac2e7b5c0362c50db0eb60
|
data/lib/wisco/commands/exec.rb
CHANGED
|
@@ -10,7 +10,7 @@ module Wisco
|
|
|
10
10
|
module Exec
|
|
11
11
|
module_function
|
|
12
12
|
|
|
13
|
-
def run(path_arg, target_dir, input: nil, debug: false)
|
|
13
|
+
def run(path_arg, target_dir, input: nil, pagination: true, debug: false)
|
|
14
14
|
target_dir = File.expand_path(target_dir)
|
|
15
15
|
config_path = Wisco.config_path(target_dir)
|
|
16
16
|
|
|
@@ -51,7 +51,8 @@ module Wisco
|
|
|
51
51
|
if input_files.empty?
|
|
52
52
|
if %w[pick_lists methods].include?(section)
|
|
53
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,
|
|
54
|
+
execute_one(section, key, nil, fixtures_dir, connector_full_path, connection,
|
|
55
|
+
pagination: pagination, debug: debug)
|
|
55
56
|
else
|
|
56
57
|
warn "\tWarning: No ready input files found in #{fixture_dir_output}"
|
|
57
58
|
end
|
|
@@ -60,7 +61,7 @@ module Wisco
|
|
|
60
61
|
|
|
61
62
|
input_files.each do |input_file|
|
|
62
63
|
execute_one(section, key, input_file, fixtures_dir,
|
|
63
|
-
connector_full_path, connection, debug: debug)
|
|
64
|
+
connector_full_path, connection, pagination: pagination, debug: debug)
|
|
64
65
|
end
|
|
65
66
|
end
|
|
66
67
|
end
|
|
@@ -92,13 +93,20 @@ module Wisco
|
|
|
92
93
|
first_line == Wisco::Commands::Fixtures::SENTINEL
|
|
93
94
|
end
|
|
94
95
|
|
|
95
|
-
def execute_one(section, key, input_file, fixtures_dir, connector_full_path, connection,
|
|
96
|
+
def execute_one(section, key, input_file, fixtures_dir, connector_full_path, connection,
|
|
97
|
+
pagination: true, debug: false)
|
|
96
98
|
stem = input_file ? File.basename(input_file, '.*') : 'execute'
|
|
97
99
|
output_file = File.join(fixtures_dir, "output_#{stem}.json")
|
|
98
100
|
error_file = File.join(fixtures_dir, "error_#{stem}.txt")
|
|
99
101
|
|
|
100
102
|
use_args = %w[pick_lists methods].include?(section)
|
|
101
|
-
exec_path = use_args
|
|
103
|
+
exec_path = if use_args
|
|
104
|
+
"#{section}.#{key}"
|
|
105
|
+
elsif section == 'triggers'
|
|
106
|
+
pagination ? "#{section}.#{key}.poll" : "#{section}.#{key}.poll_page"
|
|
107
|
+
else
|
|
108
|
+
"#{section}.#{key}.execute"
|
|
109
|
+
end
|
|
102
110
|
|
|
103
111
|
options = { connector: connector_full_path, output: output_file }
|
|
104
112
|
options[:connection] = connection if connection
|
|
@@ -47,24 +47,45 @@ module Wisco
|
|
|
47
47
|
elsif section == 'methods'
|
|
48
48
|
process_method(key, connector, fixtures_dir, overwrite: overwrite)
|
|
49
49
|
else
|
|
50
|
+
# ── config_fields pre-check ──────────────────────────────────────
|
|
51
|
+
item = connector[section.to_sym]&.[](key.to_sym)
|
|
52
|
+
raw_cf = item&.[](:config_fields)
|
|
53
|
+
cf_file = File.join(fixtures_dir, 'config_fields.json')
|
|
54
|
+
cf_opt = nil # set to cf_file once the user has filled it in
|
|
55
|
+
|
|
56
|
+
if raw_cf
|
|
57
|
+
if config_fields_ready?(cf_file)
|
|
58
|
+
cf_opt = cf_file
|
|
59
|
+
else
|
|
60
|
+
write_config_fields_template(raw_cf, cf_file)
|
|
61
|
+
warn " Written: #{cf_file}"
|
|
62
|
+
warn " Action required: fill in config_fields.json, then re-run fixtures."
|
|
63
|
+
next
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# ── input_fields ─────────────────────────────────────────────────
|
|
50
68
|
input_fields_file = File.join(fixtures_dir, 'input_fields.json')
|
|
51
69
|
call_exec(
|
|
52
|
-
path:
|
|
53
|
-
connector:
|
|
54
|
-
connection:
|
|
55
|
-
output:
|
|
56
|
-
|
|
70
|
+
path: "#{section}.#{key}.input_fields",
|
|
71
|
+
connector: connector_full_path,
|
|
72
|
+
connection: connection,
|
|
73
|
+
output: input_fields_file,
|
|
74
|
+
config_fields: cf_opt,
|
|
75
|
+
debug: debug
|
|
57
76
|
)
|
|
58
77
|
|
|
59
78
|
generate_execute_input(input_fields_file, fixtures_dir, overwrite: overwrite, debug: debug)
|
|
60
79
|
|
|
80
|
+
# ── output_fields ────────────────────────────────────────────────
|
|
61
81
|
output_fields_file = File.join(fixtures_dir, 'output_fields.json')
|
|
62
82
|
call_exec(
|
|
63
|
-
path:
|
|
64
|
-
connector:
|
|
65
|
-
connection:
|
|
66
|
-
output:
|
|
67
|
-
|
|
83
|
+
path: "#{section}.#{key}.output_fields",
|
|
84
|
+
connector: connector_full_path,
|
|
85
|
+
connection: connection,
|
|
86
|
+
output: output_fields_file,
|
|
87
|
+
config_fields: cf_opt,
|
|
88
|
+
debug: debug
|
|
68
89
|
)
|
|
69
90
|
end
|
|
70
91
|
end
|
|
@@ -200,9 +221,36 @@ module Wisco
|
|
|
200
221
|
puts " Written: #{output_file}"
|
|
201
222
|
end
|
|
202
223
|
|
|
203
|
-
def
|
|
224
|
+
def config_fields_ready?(path)
|
|
225
|
+
return false unless File.exist?(path)
|
|
226
|
+
|
|
227
|
+
first_line = begin
|
|
228
|
+
File.open(path, &:readline).chomp
|
|
229
|
+
rescue StandardError
|
|
230
|
+
''
|
|
231
|
+
end
|
|
232
|
+
first_line != SENTINEL
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def write_config_fields_template(config_fields_array, output_file)
|
|
236
|
+
stringified = stringify_keys_deep(config_fields_array)
|
|
237
|
+
template = schema_to_template(stringified)
|
|
238
|
+
content = "#{SENTINEL}\n#{JSON.pretty_generate(template)}\n"
|
|
239
|
+
File.write(output_file, content)
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def stringify_keys_deep(obj)
|
|
243
|
+
case obj
|
|
244
|
+
when Hash then obj.transform_keys(&:to_s).transform_values { |v| stringify_keys_deep(v) }
|
|
245
|
+
when Array then obj.map { |e| stringify_keys_deep(e) }
|
|
246
|
+
else obj
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def call_exec(path:, connector:, connection:, output:, config_fields: nil, debug: false)
|
|
204
251
|
options = { connector: connector, output: output }
|
|
205
|
-
options[:connection]
|
|
252
|
+
options[:connection] = connection if connection
|
|
253
|
+
options[:config_fields] = config_fields if config_fields
|
|
206
254
|
|
|
207
255
|
if debug
|
|
208
256
|
warn "[fixtures] path: #{path}"
|
data/lib/wisco/version.rb
CHANGED
data/lib/wisco.rb
CHANGED
|
@@ -82,14 +82,17 @@ module Wisco
|
|
|
82
82
|
actions all keys in that section
|
|
83
83
|
get_users auto-detect section
|
|
84
84
|
DESC
|
|
85
|
-
option :input,
|
|
86
|
-
option :
|
|
85
|
+
option :input, type: :string, desc: 'Specific input file'
|
|
86
|
+
option :pagination, type: :boolean, default: true,
|
|
87
|
+
desc: 'Triggers only: true = .poll (with pagination), false = .poll_page (without)'
|
|
88
|
+
option :debug, type: :boolean, default: false, desc: 'Print ExecCommand call details'
|
|
87
89
|
def exec(path_arg, target_dir = nil)
|
|
88
90
|
Wisco::Commands::Exec.run(
|
|
89
91
|
path_arg,
|
|
90
92
|
target_dir || Dir.pwd,
|
|
91
|
-
input:
|
|
92
|
-
|
|
93
|
+
input: options[:input],
|
|
94
|
+
pagination: options[:pagination],
|
|
95
|
+
debug: options[:debug]
|
|
93
96
|
)
|
|
94
97
|
end
|
|
95
98
|
|