initial very early release

This commit is contained in:
John Bintz 2011-09-28 13:15:01 -04:00
parent d26b195551
commit 94df11a761
6 changed files with 59 additions and 17 deletions

View File

@ -7,8 +7,8 @@ Gem::Specification.new do |s|
s.authors = ["John Bintz"]
s.email = ["john@coswellproductions.com"]
s.homepage = ""
s.summary = %q{TODO: Write a gem summary}
s.description = %q{TODO: Write a gem description}
s.summary = %q{Guard to run Varnish using Lacquer}
s.description = %q{Guard to run Varnish using Lacquer}
s.rubyforge_project = "guard-lacquer"
@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.add_runtime_dependency 'lacquer'
s.add_runtime_dependency 'lacquer', '>= 0.5.0.beta'
s.add_runtime_dependency 'guard'
s.add_development_dependency 'rspec', '~> 2.6.0'

BIN
images/varnish.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,2 +0,0 @@
require 'guard/lacquer'

View File

@ -1,30 +1,44 @@
require 'guard'
require 'guard/guard'
require 'lacquer'
require 'lacquer/varnishd'
p "made it"
require 'fileutils'
module Guard
class Lacquer < Guard::Guard
class Lacquer < Guard
autoload :Varnishd, 'guard/lacquer/varnishd'
def initialize(watchers = [], options = {})
super
@backend = ::Lacquer::Varnishd.new(
:listen => "127.0.0.1:#{options[:port]}",
:storage => "file,tmp/cache/varnish.store,32M",
:backend => options[:backend],
:sbin_path => File.split(`which varnishd`).first,
@options = {
:port => 3001,
:backend => '127.0.0.1:3000',
:storage => 'file,tmp/cache/varnish.store,32M',
:sbin_path => File.split(`which varnishd`.strip).first,
:pid_file => 'tmp/pids/varnish.pid'
)
}.merge(options)
@backend = Varnishd.new(@options)
if !File.file?(varnish_erb = 'config/varnish.vcl.erb')
UI.info "No config/varnish.vcl.erb found, copying default from Lacquer..."
FileUtils.mkdir_p File.split(varnish_erb).first
FileUtils.cp Gem.find_files('generators/lacquer/templates/varnish.vcl.erb').first, varnish_erb
end
end
def start
@backend.stop if @backend.running?
@backend.start
notify "Varnish started on port #{@options[:port]}, with backend #{@options[:backend]}."
end
def stop
@backend.start stop
@backend.stop
notify("Until next time...", :title => 'guard-varnish')
end
def reload
@ -45,6 +59,11 @@ module Guard
def run_on_deletion(paths)
restart
end
private
def notify(message)
Notifier.notify(message, :title => 'guard-lacquer', :image => File.expand_path("../../../images/varnish.png", __FILE__))
end
end
end

View File

@ -0,0 +1,25 @@
require 'lacquer'
require 'lacquer/varnishd'
class Guard::Lacquer::Varnishd < ::Lacquer::Varnishd
attr_accessor :pid_file
def self.root_path
Pathname.new(Dir.pwd)
end
def self.env
ENV['RAILS_ENV'] || 'development'
end
def initialize(options)
if options[:backend].split(':').first.empty?
options[:backend] = "127.0.0.1#{options[:backend]}"
end
self.pid_file = self.class.root_path.join(options[:pid_file])
options[:listen] = "127.0.0.1:#{options[:port]}"
super(Hash[options.collect { |k, v| [ k.to_s, v ] }])
end
end

View File

@ -1,4 +1,4 @@
require 'guard-lacquer'
require 'guard/lacquer'
RSpec.configure do |c|
c.mock_with :mocha