class Guard::Middleman

Public Class Methods

new(options={}) click to toggle source
Calls superclass method
# File lib/guard/middleman.rb, line 7
def initialize(options={})
  super
  # init stuff here, thx!
  @options = Thor::CoreExt::HashWithIndifferentAccess.new(
    {:run_on_start => false, :bundler => File.exist?("#{Dir.pwd}/Gemfile")}.merge(options)
  )
end

Public Instance Methods

bundler?() click to toggle source
# File lib/guard/middleman.rb, line 15
def bundler?
  @options[:bundler]
end
reload() click to toggle source

Called on Ctrl-Z signal This method should be mainly used for “reload” (really!) actions like reloading passenger/spork/bundler/…

# File lib/guard/middleman.rb, line 42
def reload
  true
end
run_all() click to toggle source

Called on Ctrl-\ signal This method should be principally used for long action like running all specs/tests/…

# File lib/guard/middleman.rb, line 48
def run_all
  Kernel.system(build_command)
end
run_on_change(paths) click to toggle source

Called on file(s) modifications

# File lib/guard/middleman.rb, line 53
def run_on_change(paths)
  system(build_command)
end
start() click to toggle source

Called once when Guard starts Please override initialize method to init stuff

# File lib/guard/middleman.rb, line 28
def start
  if @options[:run_on_start]
    Kernel.system(build_command)
  end
  true
end
stop() click to toggle source

Called on Ctrl-C signal (when Guard quits)

# File lib/guard/middleman.rb, line 36
def stop
  true
end

Private Instance Methods

build_command() click to toggle source
# File lib/guard/middleman.rb, line 58
def build_command
  cmd = []
  cmd << "bundle exec" if bundler?
  cmd << "middleman build"
  cmd << '--verbose'   if @options[:verbose]
  cmd << '--clean'     if @options[:clean]
  cmd << '--no-clean'  if @options[:no_clean] || @options['no-clean']
  cmd << "--glob=#{@options[:glob]}" if @options[:glob]
  cmd << "--instrument=#{@options[:instrument]}" if @options[:instrument]
  cmd << '--profile' if @options[:profile]

  cmd.join(' ')
end