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_binstub_path ⇒ String
A full path to binstub that bundlebun usually generates with installation Rake tasks.
-
.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.
112 113 114 |
# File 'lib/bundlebun/runner.rb', line 112 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).
69 70 71 72 73 74 |
# File 'lib/bundlebun/runner.rb', line 69 def binary_path return @binary_path if defined?(@binary_path) executable = "bun#{Bundlebun::Platform.windows? ? ".exe" : ""}" @binary_path = File.join(full_directory, executable) end |
.binary_path_exist? ⇒ Boolean
Does the bundled Bun binary exist?
79 80 81 |
# File 'lib/bundlebun/runner.rb', line 79 def binary_path_exist? File.exist?(binary_path) end |
.binstub_exist? ⇒ Boolean
Does the binstub exist?
96 97 98 |
# File 'lib/bundlebun/runner.rb', line 96 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 full path to binstub. If not, use the full binary path for the bundled executable (binary_path).
89 90 91 |
# File 'lib/bundlebun/runner.rb', line 89 def binstub_or_binary_path binstub_exist? ? full_binstub_path : binary_path end |
.binstub_path ⇒ String
A relative path to binstub that bundlebun usually generates with installation Rake tasks.
For Windows, the binstub path will return the bun.cmd
wrapper.
36 37 38 |
# File 'lib/bundlebun/runner.rb', line 36 def binstub_path Bundlebun::Platform.windows? ? "#{BINSTUB_PATH}.cmd" : 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_binstub_path ⇒ String
A full path to binstub that bundlebun usually generates with installation Rake tasks.
For Windows, that will use the bun.cmd
wrapper.
45 46 47 |
# File 'lib/bundlebun/runner.rb', line 45 def full_binstub_path File.(binstub_path) end |
.full_directory ⇒ String
A full directory path to the bundled Bun executable from the root of the gem.
59 60 61 62 63 |
# File 'lib/bundlebun/runner.rb', line 59 def full_directory return @full_directory if defined?(@full_directory) @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.
52 53 54 |
# File 'lib/bundlebun/runner.rb', line 52 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.
127 128 129 130 |
# File 'lib/bundlebun/runner.rb', line 127 def call check_executable! exec(command) end |