guard-lacquer/lib/guard/lacquer/varnishd.rb

39 lines
812 B
Ruby
Raw Permalink Normal View History

2011-09-29 16:18:20 +00:00
require 'guard/lacquer'
2011-09-28 17:15:01 +00:00
require 'lacquer'
require 'lacquer/varnishd'
class Guard::Lacquer::Varnishd < ::Lacquer::Varnishd
2011-09-29 16:18:20 +00:00
attr_accessor :pid_dir
2011-09-28 17:15:01 +00:00
def self.root_path
Pathname.new(Dir.pwd)
end
def self.env
ENV['RAILS_ENV'] || 'development'
end
2011-09-29 16:18:20 +00:00
def self.app_name
self.name.downcase.split("::").last
end
2011-09-28 17:15:01 +00:00
def initialize(options)
if options[:backend].split(':').first.empty?
options[:backend] = "127.0.0.1#{options[:backend]}"
end
2011-09-29 16:18:20 +00:00
options[:working_dir] ||= options[:name]
self.pid_dir = options[:pid_dir] || 'tmp/pids'
2011-09-28 17:15:01 +00:00
options[:listen] = "127.0.0.1:#{options[:port]}"
super(Hash[options.collect { |k, v| [ k.to_s, v ] }])
end
2011-09-29 16:18:20 +00:00
def pid_file
self.class.root_path.join(self.pid_dir).join("#{self.class.app_name}.#{self.class.env}.pid")
end
2011-09-28 17:15:01 +00:00
end