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, bundle_command, frequency, options = {}) ⇒ Task

Returns a new instance of Task.



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

def initialize(environment, bundle_command, frequency, options = {})
  @environment = environment
  @bundle_command = bundle_command.split(" ")
  @frequency = frequency
  @options = options
  @commands = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



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

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

#frequencyObject (readonly)

Returns the value of attribute frequency.



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

def frequency
  @frequency
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#command(task) ⇒ Object



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

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

#rake(task) ⇒ Object



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

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

#runner(src) ⇒ Object



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

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

#script(script) ⇒ Object



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

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