Class: Guard::Compass
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::Compass
- Includes:
- CompassHelper
- Defined in:
- lib/guard/compass.rb
Instance Attribute Summary collapse
-
#reporter ⇒ Object
Returns the value of attribute reporter.
-
#updater ⇒ Object
readonly
Returns the value of attribute updater.
-
#working_path ⇒ Object
readonly
Returns the value of attribute working_path.
Instance Method Summary collapse
-
#create_watchers ⇒ Object
Load Compass Configuration.
-
#initialize(options = {}) ⇒ Compass
constructor
A new instance of Compass.
-
#reload ⇒ Object
Reload the configuration.
- #root_path ⇒ Object
-
#run_all ⇒ Object
Compile all the sass|scss stylesheets.
-
#run_on_change(paths) ⇒ Object
Compile the changed stylesheets.
-
#start ⇒ Object
Compile all the sass|scss stylesheets.
- #stop ⇒ Object
- #valid_configuration_path? ⇒ Boolean
- #valid_sass_path? ⇒ Boolean
Methods included from CompassHelper
#check_for_sass_files!, #new_compiler_instance, #pathname
Constructor Details
Instance Attribute Details
#reporter ⇒ Object
Returns the value of attribute reporter.
26 27 28 |
# File 'lib/guard/compass.rb', line 26 def reporter @reporter end |
#updater ⇒ Object (readonly)
Returns the value of attribute updater.
25 26 27 |
# File 'lib/guard/compass.rb', line 25 def updater @updater end |
#working_path ⇒ Object (readonly)
Returns the value of attribute working_path.
25 26 27 |
# File 'lib/guard/compass.rb', line 25 def working_path @working_path end |
Instance Method Details
#create_watchers ⇒ Object
Load Compass Configuration
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/guard/compass.rb', line 35 def create_watchers # root_path is the path to the compass project # working_path is the current Guard (and by extension Compass) working directory watchers.clear config_file = ([:configuration_file] || ::Compass.detect_configuration_file(root_path)) config_path = pathname(working_path, config_file) src_path = pathname(root_path, ::Compass.configuration.sass_dir) watchers.push Watcher.new(%r{^#{src_path.relative_path_from(working_path)}/.*}) watchers.push Watcher.new(%r{^#{config_path.relative_path_from(working_path)}$}) Array(::Compass.configuration.additional_import_paths).each do |additional_path| watchers.push Watcher.new(%r{^#{pathname(additional_path).relative_path_from(working_path)}/.*}) end end |
#reload ⇒ Object
Reload the configuration
111 112 113 114 |
# File 'lib/guard/compass.rb', line 111 def reload create_updater true end |
#root_path ⇒ Object
53 54 55 |
# File 'lib/guard/compass.rb', line 53 def root_path [:project_path].nil? ? working_path : pathname(working_path, [:project_path]) end |
#run_all ⇒ Object
Compile all the sass|scss stylesheets
117 118 119 |
# File 'lib/guard/compass.rb', line 117 def run_all perform end |
#run_on_change(paths) ⇒ Object
Compile the changed stylesheets
122 123 124 |
# File 'lib/guard/compass.rb', line 122 def run_on_change(paths) perform end |
#start ⇒ Object
Compile all the sass|scss stylesheets
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/guard/compass.rb', line 94 def start create_updater if [:compile_on_start] reporter.announce "Guard::Compass is going to compile your stylesheets." perform else reporter.announce "Guard::Compass is waiting to compile your stylesheets." end true end |
#stop ⇒ Object
105 106 107 108 |
# File 'lib/guard/compass.rb', line 105 def stop @updater = nil true end |
#valid_configuration_path? ⇒ Boolean
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/guard/compass.rb', line 73 def valid_configuration_path? config_file = ([:configuration_file] || ::Compass.detect_configuration_file(root_path)) if config_file.nil? reporter.failure "Cannot find a Compass configuration file, please add information to your Guardfile guard 'compass' declaration." return false end config_path = pathname(working_path, config_file) if config_path.exist? true else reporter.failure "Compass configuration file not found: #{config_path}\nPlease check Guard configuration." false end end |
#valid_sass_path? ⇒ Boolean
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/guard/compass.rb', line 57 def valid_sass_path? if ::Compass.configuration.sass_dir.nil? reporter.failure("Sass files src directory not set.\nPlease check your Compass configuration.") return false end path = pathname(root_path, ::Compass.configuration.sass_dir ) unless path.exist? reporter.failure("Sass files src directory not found: #{path}\nPlease check your Compass configuration.") false else true end end |