Module: Fontana::ServerRake

Includes:
CommandUtils
Defined in:
lib/fontana/server_rake.rb

Class Method Summary collapse

Methods included from CommandUtils

spawn_at_vendor_fontana, spawn_at_vendor_fontana_with_sweeper, system!, system_at_vendor_fontana!

Class Method Details

.call_fontana_task(name, options) ⇒ Object



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

def call_fontana_task(name, options)
  # options = task_options[name]
  options[:before].call if options[:before]

  cmd = ""
  if (envs = options[:env]) && !envs.empty?
    cmd << envs.map{|(k,v)| "#{k}=#{v}"}.join(" ") << ' '
  end
  cmd << "BUNDLE_GEMFILE=#{Fontana.gemfile} bundle exec rake #{name}"
  if Rake.application.options.trace
    cmd << " --trace -v"
  end
  FileUtils::Verbose.chdir(Fontana.home) do
    system!(cmd)
  end

  options[:after].call if options[:after]
end

.fontana_task(name, options = {}) ⇒ Object



30
31
32
33
34
35
# File 'lib/fontana/server_rake.rb', line 30

def fontana_task(name, options = {})
  full_name = (@namespaces + [name]).join(':')
  task(name => :"bundle:unset_env") do
    call_fontana_task(full_name, options)
  end
end

.namespace_with_fontana(name, target = nil, &block) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/fontana/server_rake.rb', line 37

def namespace_with_fontana(name, target = nil, &block)
  @namespaces ||= []
  @namespaces.push(target || name)
  begin
    namespace(name, &block)
  ensure
    @namespaces.pop
  end
end