wisco 0.2.1 → 0.2.3

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: 51be86dee6508b94fdfb404c37a7550de6f73497df168fc78b220021bbfdb5bd
4
+ data.tar.gz: 015f92b59cee11340d40c075be7f8cd73f08efa2d18442ec37bc41def1aa1273
5
5
  SHA512:
6
- metadata.gz: 453649dd03027111cbc4fc0f0add8256c9369cfb971e941286df3021338d1bcaf1df6f09970d91c7e66604ac182be7933b31198a5cd3ff155160c2a6cff70671
7
- data.tar.gz: d6fe40803f89746010bc2cbb450abff2fa6713db9c120c6b3e1d5fab29120724fda5b090a35d9c04c7d43274202fb6253dde0c2d3f116de58f3a0d6e7022e96f
6
+ metadata.gz: 5a81968e4a3aaf8164fbe849c049a525f6bb9853cfb39e1fb5c9d4f090ca9f98669aa7151b9ab36efba1ec8875869df10401e2524a405bb12e590eb5e39bc869
7
+ data.tar.gz: b07cc5ea7da1bc2f34f12d342a63822250f818a0372dd70a4b6d2172badd2dad31f99cdf63a787841a97cee3302b75625d40fd1c2bfdae54152d7197444f6d91
@@ -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
 
@@ -49,9 +49,10 @@ 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
54
- execute_one(section, key, nil, fixtures_dir, connector_full_path, connection, debug: debug)
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,
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,17 +93,24 @@ 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, debug: false)
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
- pick_list = (section == 'pick_lists')
101
- exec_path = pick_list ? "#{section}.#{key}" : "#{section}.#{key}.execute"
102
+ use_args = %w[pick_lists methods].include?(section)
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
105
- if pick_list
113
+ if use_args
106
114
  options[:args] = input_file if input_file
107
115
  else
108
116
  options[:input] = input_file
@@ -112,7 +120,7 @@ module Wisco
112
120
  warn "[exec] path: #{exec_path}"
113
121
  warn "[exec] connector: #{connector_full_path}"
114
122
  warn "[exec] connection: #{connection.inspect}"
115
- warn "[exec] #{pick_list ? 'args' : 'input'}: #{input_file.inspect}"
123
+ warn "[exec] #{use_args ? 'args' : 'input'}: #{input_file.inspect}"
116
124
  warn "[exec] output: #{output_file}"
117
125
  end
118
126
 
@@ -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.3'
3
3
  end
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, type: :string, desc: 'Specific input file'
86
- option :debug, type: :boolean, default: false, desc: 'Print ExecCommand call details'
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: options[:input],
92
- debug: options[:debug]
93
+ input: options[:input],
94
+ pagination: options[:pagination],
95
+ debug: options[:debug]
93
96
  )
94
97
  end
95
98
 
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - mbillington