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
- #==(other) ⇒ 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, opt = :z) ⇒ 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
39 40 41 |
# File 'lib/gitlab/qa/docker/command.rb', line 39 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 |
#==(other) ⇒ Object
31 32 33 |
# File 'lib/gitlab/qa/docker/command.rb', line 31 def ==(other) to_s == other.to_s end |
#env(name, value) ⇒ Object
23 24 25 |
# File 'lib/gitlab/qa/docker/command.rb', line 23 def env(name, value) tap { @args.push(%(--env #{name}="#{value}")) } end |
#execute!(&block) ⇒ Object
35 36 37 |
# File 'lib/gitlab/qa/docker/command.rb', line 35 def execute!(&block) Docker::Shellout.new(self).execute!(&block) end |
#name(identity) ⇒ Object
19 20 21 |
# File 'lib/gitlab/qa/docker/command.rb', line 19 def name(identity) tap { @args.push("--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, opt = :z) ⇒ Object
15 16 17 |
# File 'lib/gitlab/qa/docker/command.rb', line 15 def volume(from, to, opt = :z) tap { @args.push("--volume #{from}:#{to}:#{opt}") } end |