Class: Gembrew::DockerRunner
- Inherits:
-
Object
- Object
- Gembrew::DockerRunner
- Defined in:
- lib/gembrew/docker_runner.rb
Constant Summary collapse
- IMAGE =
'homebrew/brew:main'- TAP_PATH =
'/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/gembrew/homebrew-tap'
Instance Attribute Summary collapse
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
Instance Method Summary collapse
- #call(*command, interactive: false, pristine: false) ⇒ Object
-
#initialize(project_path: Pathname.pwd, command_runner: nil) ⇒ DockerRunner
constructor
A new instance of DockerRunner.
Constructor Details
#initialize(project_path: Pathname.pwd, command_runner: nil) ⇒ DockerRunner
Returns a new instance of DockerRunner.
10 11 12 13 |
# File 'lib/gembrew/docker_runner.rb', line 10 def initialize(project_path: Pathname.pwd, command_runner: nil) @project_path = Pathname(project_path). @command_runner = command_runner || method(:run_command) end |
Instance Attribute Details
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
8 9 10 |
# File 'lib/gembrew/docker_runner.rb', line 8 def project_path @project_path end |
Instance Method Details
#call(*command, interactive: false, pristine: false) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gembrew/docker_runner.rb', line 15 def call(*command, interactive: false, pristine: false) docker_command = ['docker', 'run', '--rm', '--init', '--name', container_name] docker_command << '--pull=always' if pristine docker_command << '-it' if interactive docker_command.concat environment(interactive: interactive, pristine: pristine) unless pristine docker_command.push '--workdir', '/work' docker_command.push '--volume', "#{project_path}:/work" docker_command.push '--volume', "#{project_path}:#{TAP_PATH}" end docker_command << IMAGE docker_command.concat command command_runner.call(*docker_command, chdir: project_path) end |