wisco 0.3.9 → 0.4.1
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/list.rb +70 -1
- data/lib/wisco/version.rb +1 -1
- data/lib/wisco.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d835a3d768c20b2555e1b17ecd61bf1d3363db39b74aa6e2a3cd56c507ec136
|
|
4
|
+
data.tar.gz: 903542f44f76502b94f247337b4c77f6bb34d06c6d84f1f94ef0efab05a97917
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5cec2439df4a49df18a314a40535acd2d460e1116b80a87e550a356ad02b4a834d94c2c5a921ed342f4994411c5897bd7814d635a7ae0483c17957bc2d55ae31
|
|
7
|
+
data.tar.gz: 19ad6f559d813656907576b53d341f2222bce65e234f0ac42bd6285d8f59f8c55e8f0595a598ca02ec0e2608c8be5c4afe5af278027f3f75af94a62174cc540d
|
data/lib/wisco/commands/list.rb
CHANGED
|
@@ -12,9 +12,14 @@ module Wisco
|
|
|
12
12
|
|
|
13
13
|
module_function
|
|
14
14
|
|
|
15
|
-
def run(subcommand, target, sort: nil)
|
|
15
|
+
def run(subcommand, target, sort: nil, format: nil)
|
|
16
16
|
validate_sort!(sort)
|
|
17
17
|
|
|
18
|
+
if format
|
|
19
|
+
run_formatted(target, format: format)
|
|
20
|
+
return
|
|
21
|
+
end
|
|
22
|
+
|
|
18
23
|
case subcommand
|
|
19
24
|
when nil then run_tree(target)
|
|
20
25
|
when 'actions' then run_actions(target, sort: sort)
|
|
@@ -93,6 +98,70 @@ module Wisco
|
|
|
93
98
|
run_triggers(target_dir, sort: sort)
|
|
94
99
|
end
|
|
95
100
|
|
|
101
|
+
# ---------------------------------------------------------------------------
|
|
102
|
+
# Machine-readable output
|
|
103
|
+
# ---------------------------------------------------------------------------
|
|
104
|
+
|
|
105
|
+
def run_formatted(target_dir, format:)
|
|
106
|
+
require 'yaml' if format.downcase == 'yaml'
|
|
107
|
+
connector = Wisco::Connector.load_connector_from_config(target_dir)
|
|
108
|
+
data = build_connector_hash(connector)
|
|
109
|
+
if format.downcase == 'yaml'
|
|
110
|
+
puts data.to_yaml
|
|
111
|
+
else
|
|
112
|
+
puts JSON.pretty_generate(data)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def build_connector_hash(connector)
|
|
117
|
+
# Full connector serialization with context-aware lambda handling
|
|
118
|
+
data = serialize_value(connector, context: :root)
|
|
119
|
+
|
|
120
|
+
# Post-process object_definitions: convert Hash to sorted array of keys
|
|
121
|
+
if data.is_a?(Hash) && data['object_definitions'].is_a?(Hash)
|
|
122
|
+
data['object_definitions'] = data['object_definitions'].keys.map(&:to_s).sort
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
data
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def serialize_value(value, context: nil)
|
|
129
|
+
case value
|
|
130
|
+
when Proc
|
|
131
|
+
case context
|
|
132
|
+
when :methods, :pick_lists
|
|
133
|
+
# Extract parameter info; format type as string
|
|
134
|
+
{
|
|
135
|
+
'parameters' => value.parameters.map { |type, name| [type.to_s, name.to_s] }
|
|
136
|
+
}
|
|
137
|
+
else
|
|
138
|
+
# All other lambdas become "__is_lambda__" string
|
|
139
|
+
'__is_lambda__'
|
|
140
|
+
end
|
|
141
|
+
when Hash
|
|
142
|
+
# Recursively serialize each key-value pair, tracking context
|
|
143
|
+
value.each_with_object({}) do |(k, v), h|
|
|
144
|
+
next_context = determine_context(k, context)
|
|
145
|
+
h[k.to_s] = serialize_value(v, context: next_context)
|
|
146
|
+
end
|
|
147
|
+
when Array
|
|
148
|
+
value.map { |v| serialize_value(v, context: context) }
|
|
149
|
+
when Symbol
|
|
150
|
+
value.to_s
|
|
151
|
+
else
|
|
152
|
+
value
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def determine_context(key, parent_context)
|
|
157
|
+
# When traversing into :methods or :pick_lists hashes, set context for param extraction
|
|
158
|
+
case key
|
|
159
|
+
when :methods then :methods
|
|
160
|
+
when :pick_lists then :pick_lists
|
|
161
|
+
else parent_context
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
96
165
|
# ---------------------------------------------------------------------------
|
|
97
166
|
# List utilities
|
|
98
167
|
# ---------------------------------------------------------------------------
|
data/lib/wisco/version.rb
CHANGED
data/lib/wisco.rb
CHANGED
|
@@ -68,13 +68,14 @@ module Wisco
|
|
|
68
68
|
all Show tree + actions + triggers
|
|
69
69
|
PATH defaults to the current directory.
|
|
70
70
|
DESC
|
|
71
|
-
option :sort,
|
|
71
|
+
option :sort, type: :string, desc: 'Sort actions/triggers by key or title', enum: %w[key title]
|
|
72
|
+
option :format, type: :string, desc: 'Machine-readable output format (use with "all")', enum: %w[json yaml]
|
|
72
73
|
def list(subcommand = nil, path = nil)
|
|
73
74
|
if subcommand&.match?(%r{^[./~\\]|^[A-Za-z]:[/\\]})
|
|
74
75
|
path = subcommand
|
|
75
76
|
subcommand = nil
|
|
76
77
|
end
|
|
77
|
-
Wisco::Commands::List.run(subcommand, path || Dir.pwd, sort: options[:sort])
|
|
78
|
+
Wisco::Commands::List.run(subcommand, path || Dir.pwd, sort: options[:sort], format: options[:format])
|
|
78
79
|
end
|
|
79
80
|
|
|
80
81
|
desc 'exec PATH [TARGET_DIR]', 'Execute connector methods against fixture data'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wisco
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- mbillington
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|