hashrocket killa
This commit is contained in:
parent
147b0a6626
commit
6760d855bc
70 changed files with 385 additions and 511 deletions
|
@ -2,7 +2,6 @@
|
|||
module Middleman
|
||||
module CoreExtensions
|
||||
module FileWatcher
|
||||
|
||||
IGNORE_LIST = [
|
||||
/^bin(\/|$)/,
|
||||
/^\.bundle(\/|$)/,
|
||||
|
@ -23,7 +22,6 @@ module Middleman
|
|||
|
||||
# Setup extension
|
||||
class << self
|
||||
|
||||
# Once registered
|
||||
def included(app)
|
||||
require 'pathname'
|
||||
|
@ -51,7 +49,6 @@ module Middleman
|
|||
|
||||
# Instance methods
|
||||
module InstanceMethods
|
||||
|
||||
# Access the file api
|
||||
# @return [Middleman::CoreExtensions::FileWatcher::API]
|
||||
def files
|
||||
|
@ -61,10 +58,9 @@ module Middleman
|
|||
|
||||
# Core File Change API class
|
||||
class API
|
||||
|
||||
attr_reader :app
|
||||
attr_reader :known_paths
|
||||
delegate :logger, :to => :app
|
||||
delegate :logger, to: :app
|
||||
|
||||
# Initialize api and internal path cache
|
||||
def initialize(app)
|
||||
|
@ -101,7 +97,7 @@ module Middleman
|
|||
path = Pathname(path)
|
||||
logger.debug "== File Change: #{path}"
|
||||
@known_paths << path
|
||||
self.run_callbacks(path, :changed)
|
||||
run_callbacks(path, :changed)
|
||||
end
|
||||
|
||||
# Notify callbacks that a file was deleted
|
||||
|
@ -112,7 +108,7 @@ module Middleman
|
|||
path = Pathname(path)
|
||||
logger.debug "== File Deletion: #{path}"
|
||||
@known_paths.delete(path)
|
||||
self.run_callbacks(path, :deleted)
|
||||
run_callbacks(path, :deleted)
|
||||
end
|
||||
|
||||
# Manually trigger update events
|
||||
|
@ -150,7 +146,7 @@ module Middleman
|
|||
|
||||
def exists?(path)
|
||||
p = Pathname(path)
|
||||
p = p.relative_path_from(Pathname(@app.root)) if !p.relative?
|
||||
p = p.relative_path_from(Pathname(@app.root)) unless p.relative?
|
||||
@known_paths.include?(p)
|
||||
end
|
||||
|
||||
|
@ -162,7 +158,7 @@ module Middleman
|
|||
app.config[:file_watcher_ignore].any? { |r| path =~ r }
|
||||
end
|
||||
|
||||
protected
|
||||
protected
|
||||
|
||||
# Notify callbacks for a file given an array of callbacks
|
||||
#
|
||||
|
@ -171,7 +167,7 @@ module Middleman
|
|||
# @return [void]
|
||||
def run_callbacks(path, callbacks_name)
|
||||
path = path.to_s
|
||||
self.send(callbacks_name).each do |callback, matcher|
|
||||
send(callbacks_name).each do |callback, matcher|
|
||||
next unless matcher.nil? || path.match(matcher)
|
||||
@app.instance_exec(path, &callback)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue