Class: ElasticWhenever::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_whenever/task.rb,
lib/elastic_whenever/task/role.rb,
lib/elastic_whenever/task/rule.rb,
lib/elastic_whenever/task/target.rb,
lib/elastic_whenever/task/cluster.rb,
lib/elastic_whenever/task/definition.rb

Defined Under Namespace

Classes: Cluster, Definition, Role, Rule, Target

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, verbose, bundle_command, expression) ⇒ Task

Returns a new instance of Task.



6
7
8
9
10
11
12
# File 'lib/elastic_whenever/task.rb', line 6

def initialize(environment, verbose, bundle_command, expression)
  @environment = environment
  @verbose_mode = verbose ? nil : "--silent"
  @bundle_command = bundle_command.split(" ")
  @expression = expression
  @commands = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



30
31
32
# File 'lib/elastic_whenever/task.rb', line 30

def method_missing(name, *args)
  Logger.instance.warn("Skipping unsupported method: #{name}")
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



3
4
5
# File 'lib/elastic_whenever/task.rb', line 3

def commands
  @commands
end

#expressionObject (readonly)

Returns the value of attribute expression.



4
5
6
# File 'lib/elastic_whenever/task.rb', line 4

def expression
  @expression
end

Instance Method Details

#command(task) ⇒ Object



14
15
16
# File 'lib/elastic_whenever/task.rb', line 14

def command(task)
  @commands << task.split(" ")
end

#rake(task) ⇒ Object



18
19
20
# File 'lib/elastic_whenever/task.rb', line 18

def rake(task)
  @commands << [@bundle_command, "rake", task, @verbose_mode].flatten.compact
end

#runner(src) ⇒ Object



22
23
24
# File 'lib/elastic_whenever/task.rb', line 22

def runner(src)
  @commands << [@bundle_command, "bin/rails", "runner", "-e", @environment, src].flatten
end

#script(script) ⇒ Object



26
27
28
# File 'lib/elastic_whenever/task.rb', line 26

def script(script)
  @commands << [@bundle_command, "script/#{script}"].flatten
end