Class: Compass::Configuration::Watch

Inherits:
Object
  • Object
show all
Defined in:
lib/compass/configuration/watch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#callbackObject (readonly)

Returns the value of attribute callback.



4
5
6
# File 'lib/compass/configuration/watch.rb', line 4

def callback
  @callback
end

#full_globObject (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

#globObject (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

Returns:

  • (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

Returns:

  • (Boolean)


29
30
31
# File 'lib/compass/configuration/watch.rb', line 29

def run_once_per_changeset?
  false
end