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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51be86dee6508b94fdfb404c37a7550de6f73497df168fc78b220021bbfdb5bd
4
- data.tar.gz: 015f92b59cee11340d40c075be7f8cd73f08efa2d18442ec37bc41def1aa1273
3
+ metadata.gz: 3a60475b816732d204bb52da3c9b4a17c90ebd3471eb05254cc153c68ac5ad5b
4
+ data.tar.gz: 482f28c284946b0b915aa25a2abaefecd983a7b1e26b824f0576ab609e42d276
5
5
  SHA512:
6
- metadata.gz: 5a81968e4a3aaf8164fbe849c049a525f6bb9853cfb39e1fb5c9d4f090ca9f98669aa7151b9ab36efba1ec8875869df10401e2524a405bb12e590eb5e39bc869
7
- data.tar.gz: b07cc5ea7da1bc2f34f12d342a63822250f818a0372dd70a4b6d2172badd2dad31f99cdf63a787841a97cee3302b75625d40fd1c2bfdae54152d7197444f6d91
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: "#{section}.#{key}.input_fields",
53
- connector: connector_full_path,
54
- connection: connection,
55
- output: input_fields_file,
56
- debug: debug
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: "#{section}.#{key}.output_fields",
64
- connector: connector_full_path,
65
- connection: connection,
66
- output: output_fields_file,
67
- debug: debug
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 call_exec(path:, connector:, connection:, output:, debug: false)
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] = connection if 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
@@ -1,3 +1,3 @@
1
1
  module Wisco
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wisco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - mbillington