Class: Browserctl::Runner
- Inherits:
-
Object
- Object
- Browserctl::Runner
- Defined in:
- lib/browserctl/runner.rb
Constant Summary collapse
- SEARCH_PATHS =
[ "./.browserctl/workflows", File.("~/.browserctl/workflows") ].freeze
- SAFE_WORKFLOW_NAME =
/\A[a-zA-Z0-9_-]+\z/
Class Method Summary collapse
Instance Method Summary collapse
-
#describe_workflow(name) ⇒ Hash
Returns detailed information about a workflow.
-
#list_workflows ⇒ Array<Hash>
Lists all registered workflows from the standard search paths.
-
#run_workflow(name, **params) ⇒ Boolean
Runs a named workflow with the given parameters.
Class Method Details
.load_params_file(path) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/browserctl/runner.rb', line 43 def self.load_params_file(path) raise "params file not found: #{path}" unless File.exist?(path) case File.extname(path).downcase when ".yml", ".yaml" require "yaml" YAML.safe_load_file(path, symbolize_names: true) when ".json" JSON.parse(File.read(path), symbolize_names: true) else raise "unsupported params file format: #{path} (use .yml, .yaml, or .json)" end rescue Psych::SyntaxError => e raise "invalid YAML in #{path}: #{e.}" rescue JSON::ParserError => e raise "invalid JSON in #{path}: #{e.}" end |
Instance Method Details
#describe_workflow(name) ⇒ Hash
Returns detailed information about a workflow.
36 37 38 39 |
# File 'lib/browserctl/runner.rb', line 36 def describe_workflow(name) defn = fetch_workflow(name) { name: defn.name, desc: defn.description, params: format_params(defn), steps: defn.steps.map(&:label) } end |
#list_workflows ⇒ Array<Hash>
Lists all registered workflows from the standard search paths.
28 29 30 31 |
# File 'lib/browserctl/runner.rb', line 28 def list_workflows load_all_workflows Browserctl.registry_snapshot.map { |name, defn| { name: name, desc: defn.description } } end |