Class: Bundlebun::Runner
- Inherits:
-
Object
- Object
- Bundlebun::Runner
- Defined in:
- lib/bundlebun/runner.rb
Overview
Runner is the class that bundlebun uses to run the bundled Bun executable.
See Bundlebun.
Constant Summary collapse
- BINSTUB_PATH =
:nodoc:
'bin/bun'
- RELATIVE_DIRECTORY =
:nodoc:
'lib/bundlebun/vendor/bun'
Class Method Summary collapse
-
.binary_path ⇒ Object
A full path to the bundled Bun binary we run.
-
.binary_path_exist? ⇒ Boolean
Does the bundled Bun binary exist?.
-
.binstub_exist? ⇒ Boolean
Does the binstub exist?.
-
.binstub_or_binary_path ⇒ Object
Returns the preferred way to run Bun when bundlebun is installed.
-
.binstub_path ⇒ Object
A relative path to binstub bundlebun usually generates with installation Rake tasks.
-
.call ⇒ Object
Runs the Bun runtime with parameters (can be String or Array of strings).
-
.full_directory ⇒ Object
A full directory path to the bundled Bun executable from the root of the gem.
-
.relative_directory ⇒ Object
A relative directory path to the bundled Bun executable from the root of the gem.
Instance Method Summary collapse
-
#call ⇒ Object
Runs the Bun executable with previously specified arguments.
-
#initialize(arguments = '') ⇒ Runner
constructor
Intialize the runner with arguments to run the Bun runtime later via call.
Constructor Details
#initialize(arguments = '') ⇒ Runner
76 77 78 |
# File 'lib/bundlebun/runner.rb', line 76 def initialize(arguments = '') @arguments = arguments end |
Class Method Details
.binary_path ⇒ Object
A full path to the bundled Bun binary we run.
42 43 44 45 |
# File 'lib/bundlebun/runner.rb', line 42 def binary_path executable = "bun#{RUBY_PLATFORM.match?(/mingw|mswin/) ? ".exe" : ""}" File.join(full_directory, executable) end |
.binary_path_exist? ⇒ Boolean
Does the bundled Bun binary exist?
48 49 50 |
# File 'lib/bundlebun/runner.rb', line 48 def binary_path_exist? File.exist?(binary_path) end |
.binstub_exist? ⇒ Boolean
Does the binstub exist?
61 62 63 |
# File 'lib/bundlebun/runner.rb', line 61 def binstub_exist? File.exist?(binstub_path) end |
.binstub_or_binary_path ⇒ Object
Returns the preferred way to run Bun when bundlebun is installed.
If the binstub is installed (see binstub_path), use the binstub. If not, use the full binary path for the bundled executable (binary_path).
56 57 58 |
# File 'lib/bundlebun/runner.rb', line 56 def binstub_or_binary_path binstub_exist? ? binstub_path : binary_path end |
.binstub_path ⇒ Object
A relative path to binstub bundlebun usually generates with installation Rake tasks.
27 28 29 |
# File 'lib/bundlebun/runner.rb', line 27 def binstub_path BINSTUB_PATH end |
.call ⇒ Object
22 23 24 |
# File 'lib/bundlebun/runner.rb', line 22 def call(...) new(...).call end |
.full_directory ⇒ Object
A full directory path to the bundled Bun executable from the root of the gem.
37 38 39 |
# File 'lib/bundlebun/runner.rb', line 37 def full_directory File.("../../#{relative_directory}", __dir__) end |
.relative_directory ⇒ Object
A relative directory path to the bundled Bun executable from the root of the gem.
32 33 34 |
# File 'lib/bundlebun/runner.rb', line 32 def relative_directory RELATIVE_DIRECTORY end |
Instance Method Details
#call ⇒ Object
90 91 92 93 |
# File 'lib/bundlebun/runner.rb', line 90 def call check_executable! exec(command) end |