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.
Constant Summary collapse
- BINSTUB_PATH =
'bin/bun'
- RELATIVE_DIRECTORY =
'lib/bundlebun/vendor/bun'
Class Method Summary collapse
-
.binary_path ⇒ String
A full path to the bundled Bun binary we run (includes ‘.exe` on Windows).
-
.binary_path_exist? ⇒ Boolean
Does the bundled Bun binary exist?.
-
.binstub_exist? ⇒ Boolean
Does the binstub exist?.
-
.binstub_or_binary_path ⇒ String
Returns the preferred way to run Bun when bundlebun is installed.
-
.binstub_path ⇒ String
A relative path to binstub that bundlebun usually generates with installation Rake tasks.
-
.call ⇒ Integer
Runs the Bun runtime with parameters.
-
.full_directory ⇒ String
A full directory path to the bundled Bun executable from the root of the gem.
-
.relative_directory ⇒ String
A relative directory path to the bundled Bun executable from the root of the gem.
Instance Method Summary collapse
-
#call ⇒ Integer
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
Intialize the Bundlebun::Runner with arguments to run the Bun runtime later via #call.
97 98 99 |
# File 'lib/bundlebun/runner.rb', line 97 def initialize(arguments = '') @arguments = arguments end |
Class Method Details
.binary_path ⇒ String
A full path to the bundled Bun binary we run (includes ‘.exe` on Windows).
56 57 58 59 |
# File 'lib/bundlebun/runner.rb', line 56 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?
64 65 66 |
# File 'lib/bundlebun/runner.rb', line 64 def binary_path_exist? File.exist?(binary_path) end |
.binstub_exist? ⇒ Boolean
Does the binstub exist?
81 82 83 |
# File 'lib/bundlebun/runner.rb', line 81 def binstub_exist? File.exist?(binstub_path) end |
.binstub_or_binary_path ⇒ String
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).
74 75 76 |
# File 'lib/bundlebun/runner.rb', line 74 def binstub_or_binary_path binstub_exist? ? binstub_path : binary_path end |
.binstub_path ⇒ String
A relative path to binstub that bundlebun usually generates with installation Rake tasks.
34 35 36 |
# File 'lib/bundlebun/runner.rb', line 34 def binstub_path BINSTUB_PATH end |
.call ⇒ Integer
Runs the Bun runtime with parameters.
A wrapper for new, call.
27 28 29 |
# File 'lib/bundlebun/runner.rb', line 27 def call(...) new(...).call end |
.full_directory ⇒ String
A full directory path to the bundled Bun executable from the root of the gem.
48 49 50 |
# File 'lib/bundlebun/runner.rb', line 48 def full_directory File.("../../#{relative_directory}", __dir__) end |
.relative_directory ⇒ String
A relative directory path to the bundled Bun executable from the root of the gem.
41 42 43 |
# File 'lib/bundlebun/runner.rb', line 41 def relative_directory RELATIVE_DIRECTORY end |
Instance Method Details
#call ⇒ Integer
Runs the Bun executable with previously specified arguments.
Check other methods of Bundlebun::Runner to see how we determine what to run exactly.
112 113 114 115 |
# File 'lib/bundlebun/runner.rb', line 112 def call check_executable! exec(command) end |