wisco 0.2.3 → 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/fixtures.rb +60 -12
- 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: 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
|
|
@@ -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