Class: Pulsar::CreateCapfile

Inherits:
Object
  • Object
show all
Includes:
Interactor, Validator
Defined in:
lib/pulsar/interactors/create_capfile.rb

Instance Method Summary collapse

Methods included from Validator

#context_fail!, included, #validable_properties, #validate_context!

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pulsar/interactors/create_capfile.rb', line 9

def call
  default_capfile = "#{context.config_path}/apps/Capfile"
  app_capfile     = "#{context.config_path}/apps/#{context.application}/Capfile"
  import_tasks    = "Dir.glob(\"#{context.config_path}/recipes/**/*.rake\").each { |r| import r }"

  FileUtils.touch(context.capfile_path)
  Rake.sh("cat #{default_capfile} >> #{context.capfile_path}") if File.exist?(default_capfile)
  Rake.sh("cat #{app_capfile}     >> #{context.capfile_path}") if File.exist?(app_capfile)
  Rake.sh("echo '#{import_tasks}' >> #{context.capfile_path}")
rescue
  context_fail! $!.message
end