Class: PoolParty::Tasks

Inherits:
Object show all
Includes:
Callbacks
Defined in:
lib/poolparty/tasks.rb

Instance Method Summary collapse

Methods included from Callbacks

included

Constructor Details

#initialize {|_self| ... } ⇒ Tasks

Setup and define all the tasks

Yields:

  • (_self)

Yield Parameters:



6
7
8
# File 'lib/poolparty/tasks.rb', line 6

def initialize
  yield self if block_given?
end

Instance Method Details

#compiled_rakefileObject



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

def compiled_rakefile
  rake_str = []
  
  Dir["#{File.expand_path(File.dirname(__FILE__))}/tasks/*.rake"].each { |t| rake_str << open(t).read }
  plugin_rakefiles
  
  @compiled_rakefile ||= eval(rake_str.join("\n")) # Not ideal
end

#define_tasksObject

Define the tasks in the rakefile From the rakefile



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/poolparty/tasks.rb', line 11

def define_tasks
  # Run the command on the local system
  def run(cmd)
    Kernel.system(cmd.runnable)
  end
  # Basic setup action
  def setup_application
    @options ||= PoolParty.options(ARGV.dup)
  end
  
  # Require the poolparty specific tasks
  compiled_rakefile
  
  desc "Reload the static variables"
  task :reload do
    reload!
  end
  true
end

#plugin_rakefilesObject



43
44
45
# File 'lib/poolparty/tasks.rb', line 43

def plugin_rakefiles
  Dir["#{PoolParty.plugin_dir}/*/Rakefile"].each {|t| load t }
end

#reload!Object



31
32
33
# File 'lib/poolparty/tasks.rb', line 31

def reload!
  @compiled_rakefile = nil
end

#run(cmd) ⇒ Object

Run the command on the local system



13
14
15
# File 'lib/poolparty/tasks.rb', line 13

def run(cmd)
  Kernel.system(cmd.runnable)
end

#setup_applicationObject

Basic setup action



17
18
19
# File 'lib/poolparty/tasks.rb', line 17

def setup_application
  @options ||= PoolParty.options(ARGV.dup)
end