Class: Samus::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/samus/action.rb

Direct Known Subclasses

BuildAction, PublishAction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Action

Returns a new instance of Action.



6
7
8
9
10
11
12
13
# File 'lib/samus/action.rb', line 6

def initialize(opts = {})
  @raw_options = opts
  @dry_run = opts[:dry_run]
  @allow_fail = false
  @command = nil
  @creds = nil
  @arguments = opts[:arguments] || {}
end

Instance Attribute Details

#files=(value) ⇒ Object (writeonly)

Sets the attribute files

Parameters:

  • value

    the value to set the attribute files to.



56
57
58
# File 'lib/samus/action.rb', line 56

def files=(value)
  @files = value
end

Instance Method Details

#action=(name) ⇒ Object



44
45
46
# File 'lib/samus/action.rb', line 44

def action=(name)
  @command = Command.new(stage, name)
end

#allowFail=(value) ⇒ Object



52
53
54
# File 'lib/samus/action.rb', line 52

def allowFail=(value)
  @allow_fail = value
end

#arguments=(args) ⇒ Object



58
59
60
# File 'lib/samus/action.rb', line 58

def arguments=(args)
  args.each { |k, v| @arguments[k] = v }
end

#command_optionsObject



35
36
37
38
39
40
41
42
# File 'lib/samus/action.rb', line 35

def command_options
  {
    arguments: @creds ? @arguments.merge(@creds.load) : @arguments,
    files: @files,
    dry_run: @dry_run,
    allow_fail: @allow_fail
  }
end

#credentials=(key) ⇒ Object



48
49
50
# File 'lib/samus/action.rb', line 48

def credentials=(key)
  @creds = Credentials.new(key)
end

#load(opts = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/samus/action.rb', line 19

def load(opts = {})
  opts.each do |key, value|
    meth = "#{key}="
    if respond_to?(meth)
      send(meth, value)
    else
      Samus.error("Unknown action property: #{key}")
    end
  end
  self
end

#runObject



31
32
33
# File 'lib/samus/action.rb', line 31

def run
  @command.run(command_options) if @command
end

#stageObject

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/samus/action.rb', line 15

def stage
  raise NotImplementedError, 'action must define stage'
end