wisco 0.2.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd806fc6e7654c8df8d7fb20d08bd64f33cde8cff24770362a1752d2af96a23b
4
- data.tar.gz: 9b834ed0d9f1d6242be4b61bdefd15b46184b4d815d892c258e69ba341a5591d
3
+ metadata.gz: b480d047c6f25a2c8ad8e234e034cb1d1cb571efbd9620b405a90a9e7816a807
4
+ data.tar.gz: baac61b7895d1a8fa7046a675910ecacfcae4e03afab83fa42d371f5a8a19b0b
5
5
  SHA512:
6
- metadata.gz: 453649dd03027111cbc4fc0f0add8256c9369cfb971e941286df3021338d1bcaf1df6f09970d91c7e66604ac182be7933b31198a5cd3ff155160c2a6cff70671
7
- data.tar.gz: d6fe40803f89746010bc2cbb450abff2fa6713db9c120c6b3e1d5fab29120724fda5b090a35d9c04c7d43274202fb6253dde0c2d3f116de58f3a0d6e7022e96f
6
+ metadata.gz: f15e57668b56c77e593da83dbc759663d1bf2a7c3bb7f39fe7dc03bfea50365df9356aa7e996d9e060a34b5ba1f1946172d5cdbe91c92c02c49e72eec606a26f
7
+ data.tar.gz: d8339fb1ea9942a124a8cbd260ffd74912504dbe5ed38f24ba817e82bad9f930ebcb75f270f65afe23a09a82bbb2161bfee40c0adc96a76049ec698c90e62e2c
@@ -49,8 +49,8 @@ module Wisco
49
49
  input_files = resolve_input_files(input, fixtures_dir)
50
50
 
51
51
  if input_files.empty?
52
- if section == 'pick_lists'
53
- # Static/dynamic pick list no args needed; execute once with no input file
52
+ if %w[pick_lists methods].include?(section)
53
+ # No-param pick list or method execute once with no input file
54
54
  execute_one(section, key, nil, fixtures_dir, connector_full_path, connection, debug: debug)
55
55
  else
56
56
  warn "\tWarning: No ready input files found in #{fixture_dir_output}"
@@ -97,12 +97,12 @@ module Wisco
97
97
  output_file = File.join(fixtures_dir, "output_#{stem}.json")
98
98
  error_file = File.join(fixtures_dir, "error_#{stem}.txt")
99
99
 
100
- pick_list = (section == 'pick_lists')
101
- exec_path = pick_list ? "#{section}.#{key}" : "#{section}.#{key}.execute"
100
+ use_args = %w[pick_lists methods].include?(section)
101
+ exec_path = use_args ? "#{section}.#{key}" : "#{section}.#{key}.execute"
102
102
 
103
103
  options = { connector: connector_full_path, output: output_file }
104
104
  options[:connection] = connection if connection
105
- if pick_list
105
+ if use_args
106
106
  options[:args] = input_file if input_file
107
107
  else
108
108
  options[:input] = input_file
@@ -112,7 +112,7 @@ module Wisco
112
112
  warn "[exec] path: #{exec_path}"
113
113
  warn "[exec] connector: #{connector_full_path}"
114
114
  warn "[exec] connection: #{connection.inspect}"
115
- warn "[exec] #{pick_list ? 'args' : 'input'}: #{input_file.inspect}"
115
+ warn "[exec] #{use_args ? 'args' : 'input'}: #{input_file.inspect}"
116
116
  warn "[exec] output: #{output_file}"
117
117
  end
118
118
 
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  module Wisco
2
2
  module PathUtils
3
- VALID_SECTIONS = %w[actions triggers pick_lists].freeze
3
+ VALID_SECTIONS = %w[actions triggers pick_lists methods].freeze
4
4
 
5
5
  module_function
6
6
 
data/lib/wisco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wisco
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
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.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mbillington