Class: Compass::Configuration::Watch
- Inherits:
-
Object
- Object
- Compass::Configuration::Watch
- Defined in:
- lib/compass/configuration/watch.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#full_glob ⇒ Object
readonly
Returns the value of attribute full_glob.
-
#glob ⇒ Object
readonly
Returns the value of attribute glob.
Instance Method Summary collapse
-
#initialize(glob, &block) ⇒ Watch
constructor
A new instance of Watch.
- #match?(changed_path) ⇒ Boolean
- #run_callback(base, relative, action) ⇒ Object
- #run_once_per_changeset? ⇒ Boolean
Constructor Details
#initialize(glob, &block) ⇒ Watch
Returns a new instance of Watch.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/compass/configuration/watch.rb', line 8 def initialize(glob, &block) unless block raise ArgumentError, "A Block must be supplied in order to be watched" end @callback = block unless glob raise ArgumentErrorn, "A glob must be supplied in order to be watched" end @glob = glob if Pathname.new(glob).absolute? @full_glob = glob else @full_glob = File.join(Compass.configuration.project_path, glob) end end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
4 5 6 |
# File 'lib/compass/configuration/watch.rb', line 4 def callback @callback end |
#full_glob ⇒ Object (readonly)
Returns the value of attribute full_glob.
6 7 8 |
# File 'lib/compass/configuration/watch.rb', line 6 def full_glob @full_glob end |
#glob ⇒ Object (readonly)
Returns the value of attribute glob.
5 6 7 |
# File 'lib/compass/configuration/watch.rb', line 5 def glob @glob end |
Instance Method Details
#match?(changed_path) ⇒ Boolean
33 34 35 |
# File 'lib/compass/configuration/watch.rb', line 33 def match?(changed_path) File.fnmatch(full_glob, changed_path, File::FNM_PATHNAME) end |
#run_callback(base, relative, action) ⇒ Object
25 26 27 |
# File 'lib/compass/configuration/watch.rb', line 25 def run_callback(base, relative, action) callback.call(base, relative, action) end |
#run_once_per_changeset? ⇒ Boolean
29 30 31 |
# File 'lib/compass/configuration/watch.rb', line 29 def run_once_per_changeset? false end |