Class: Gitlab::QA::Docker::Command
- Inherits:
-
Object
- Object
- Gitlab::QA::Docker::Command
- Defined in:
- lib/gitlab/qa/docker/command.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(*args) ⇒ Object
- #env(name, value) ⇒ Object
- #execute!(&block) ⇒ Object
-
#initialize(cmd = nil) ⇒ Command
constructor
A new instance of Command.
- #name(identity) ⇒ Object
- #to_s ⇒ Object
- #volume(from, to) ⇒ Object
Constructor Details
#initialize(cmd = nil) ⇒ Command
Returns a new instance of Command.
7 8 9 |
# File 'lib/gitlab/qa/docker/command.rb', line 7 def initialize(cmd = nil) @args = Array(cmd) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/gitlab/qa/docker/command.rb', line 5 def args @args end |
Class Method Details
.execute(cmd, &block) ⇒ Object
35 36 37 |
# File 'lib/gitlab/qa/docker/command.rb', line 35 def self.execute(cmd, &block) new(cmd).execute!(&block) end |
Instance Method Details
#<<(*args) ⇒ Object
11 12 13 |
# File 'lib/gitlab/qa/docker/command.rb', line 11 def <<(*args) tap { @args.concat(args) } end |
#env(name, value) ⇒ Object
23 24 25 |
# File 'lib/gitlab/qa/docker/command.rb', line 23 def env(name, value) tap { @args << %(-e #{name}="#{value}") } end |
#execute!(&block) ⇒ Object
31 32 33 |
# File 'lib/gitlab/qa/docker/command.rb', line 31 def execute!(&block) Docker::Shellout.execute!(self, &block) end |
#name(identity) ⇒ Object
19 20 21 |
# File 'lib/gitlab/qa/docker/command.rb', line 19 def name(identity) tap { @args << "--name #{identity}" } end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/gitlab/qa/docker/command.rb', line 27 def to_s "docker #{@args.join(' ')}" end |
#volume(from, to) ⇒ Object
15 16 17 |
# File 'lib/gitlab/qa/docker/command.rb', line 15 def volume(from, to) tap { @args << "-v #{from}:#{to}" } end |