initial very early release
This commit is contained in:
parent
d26b195551
commit
94df11a761
@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|||||||
s.authors = ["John Bintz"]
|
s.authors = ["John Bintz"]
|
||||||
s.email = ["john@coswellproductions.com"]
|
s.email = ["john@coswellproductions.com"]
|
||||||
s.homepage = ""
|
s.homepage = ""
|
||||||
s.summary = %q{TODO: Write a gem summary}
|
s.summary = %q{Guard to run Varnish using Lacquer}
|
||||||
s.description = %q{TODO: Write a gem description}
|
s.description = %q{Guard to run Varnish using Lacquer}
|
||||||
|
|
||||||
s.rubyforge_project = "guard-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.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
||||||
s.require_paths = ["lib"]
|
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_runtime_dependency 'guard'
|
||||||
|
|
||||||
s.add_development_dependency 'rspec', '~> 2.6.0'
|
s.add_development_dependency 'rspec', '~> 2.6.0'
|
||||||
|
BIN
images/varnish.png
Normal file
BIN
images/varnish.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
@ -1,2 +0,0 @@
|
|||||||
require 'guard/lacquer'
|
|
||||||
|
|
@ -1,30 +1,44 @@
|
|||||||
require 'guard'
|
require 'guard'
|
||||||
require 'guard/guard'
|
require 'guard/guard'
|
||||||
require 'lacquer'
|
|
||||||
require 'lacquer/varnishd'
|
|
||||||
|
|
||||||
p "made it"
|
require 'fileutils'
|
||||||
|
|
||||||
module Guard
|
module Guard
|
||||||
class Lacquer < Guard::Guard
|
class Lacquer < Guard
|
||||||
|
autoload :Varnishd, 'guard/lacquer/varnishd'
|
||||||
|
|
||||||
def initialize(watchers = [], options = {})
|
def initialize(watchers = [], options = {})
|
||||||
super
|
super
|
||||||
|
|
||||||
@backend = ::Lacquer::Varnishd.new(
|
@options = {
|
||||||
:listen => "127.0.0.1:#{options[:port]}",
|
:port => 3001,
|
||||||
:storage => "file,tmp/cache/varnish.store,32M",
|
:backend => '127.0.0.1:3000',
|
||||||
:backend => options[:backend],
|
:storage => 'file,tmp/cache/varnish.store,32M',
|
||||||
:sbin_path => File.split(`which varnishd`).first,
|
:sbin_path => File.split(`which varnishd`.strip).first,
|
||||||
:pid_file => 'tmp/pids/varnish.pid'
|
: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
|
end
|
||||||
|
|
||||||
def start
|
def start
|
||||||
|
@backend.stop if @backend.running?
|
||||||
@backend.start
|
@backend.start
|
||||||
|
|
||||||
|
notify "Varnish started on port #{@options[:port]}, with backend #{@options[:backend]}."
|
||||||
end
|
end
|
||||||
|
|
||||||
def stop
|
def stop
|
||||||
@backend.start stop
|
@backend.stop
|
||||||
|
|
||||||
|
notify("Until next time...", :title => 'guard-varnish')
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload
|
def reload
|
||||||
@ -45,6 +59,11 @@ module Guard
|
|||||||
def run_on_deletion(paths)
|
def run_on_deletion(paths)
|
||||||
restart
|
restart
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def notify(message)
|
||||||
|
Notifier.notify(message, :title => 'guard-lacquer', :image => File.expand_path("../../../images/varnish.png", __FILE__))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
25
lib/guard/lacquer/varnishd.rb
Normal file
25
lib/guard/lacquer/varnishd.rb
Normal 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
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
require 'guard-lacquer'
|
require 'guard/lacquer'
|
||||||
|
|
||||||
RSpec.configure do |c|
|
RSpec.configure do |c|
|
||||||
c.mock_with :mocha
|
c.mock_with :mocha
|
||||||
|
Loading…
Reference in New Issue
Block a user