Class: Bundler::GemBytes::ScriptExecutor
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Bundler::GemBytes::ScriptExecutor
- Includes:
- Actions, Thor::Actions
- Defined in:
- lib/bundler/gem_bytes/script_executor.rb
Overview
Responsible for executing scripts using Thor and GemBytes actions
This class enables the execution of scripts from a file or URI, integrating with ‘Thor::Actions` to allow advanced file manipulation and action chaining. This can be particularly useful for tasks like creating or modifying files, managing dependencies, and implementing workflows for gem development.
Class Method Summary collapse
-
.source_paths ⇒ Array<String>
private
Sets the source paths for ‘Thor::Actions`.
Instance Method Summary collapse
-
#execute(path_or_uri) ⇒ void
Executes a script from a given URI or file path.
Methods included from Actions
Class Method Details
.source_paths ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sets the source paths for ‘Thor::Actions`
This determines where action scripts will be sourced from.
By default, the source path is set to the current working directory, which allows scripts to access files from the local file system during execution.
33 34 35 |
# File 'lib/bundler/gem_bytes/script_executor.rb', line 33 def self.source_paths [Dir.pwd] end |
Instance Method Details
#execute(path_or_uri) ⇒ void
This method returns an undefined value.
Executes a script from a given URI or file path
This method loads the script located at the specified ‘path_or_uri` and executes it within the context of this class which includes `Thor::Actions` and `Bundler::GemBytes::ScriptExecutor`. This allows the script to perform tasks such as modifying files, creating directories, and other common file system operations.
54 55 56 57 58 |
# File 'lib/bundler/gem_bytes/script_executor.rb', line 54 def execute(path_or_uri) apply(path_or_uri) rescue StandardError => e raise "Failed to execute script from #{path_or_uri}: #{e.message}" end |