Permalink
Browse files

guard 'compass' :configuration_file => 'my_custom.rb'

Should now work. Need to create the watchers as
well.
  • Loading branch information...
oliamb committed Oct 30, 2010
1 parent 126240e commit 8ef8bd1457b137d6f96eea35fc3bb82e4f33f8bd
Showing with 325 additions and 51 deletions.
  1. +3 −2 Guardfile
  2. +16 −0 README.textile
  3. +38 −6 lib/guard/compass.rb
  4. +6 −1 lib/guard/compass/templates/Guardfile
  5. +19 −0 lib/guard/reporter.rb
  6. BIN .../fixtures/bad_src_directory/.sass-cache/77242121e92e5208094a0a0f6fbd9eb05d2c3832/_utilities.scssc
  7. BIN spec/fixtures/bad_src_directory/.sass-cache/804c142587e371bce0dd76315d953aa707422b74/_reset.scssc
  8. +5 −0 spec/fixtures/bad_src_directory/bad_src/ie.scss
  9. +3 −0 spec/fixtures/bad_src_directory/bad_src/print.scss
  10. +6 −0 spec/fixtures/bad_src_directory/bad_src/screen.scss
  11. +9 −0 spec/fixtures/bad_src_directory/config.rb
  12. BIN ...fixtures/custom_config_file/.sass-cache/77242121e92e5208094a0a0f6fbd9eb05d2c3832/_utilities.scssc
  13. BIN spec/fixtures/custom_config_file/.sass-cache/804c142587e371bce0dd76315d953aa707422b74/_reset.scssc
  14. +9 −0 spec/fixtures/custom_config_file/another_config_location/config.rb
  15. +5 −0 spec/fixtures/custom_config_file/another_src_location/ie.scss
  16. +3 −0 spec/fixtures/custom_config_file/another_src_location/print.scss
  17. +6 −0 spec/fixtures/custom_config_file/another_src_location/screen.scss
  18. +1 −0 spec/fixtures/dsl/simple/Guardfile
  19. BIN spec/fixtures/no_config_file/.sass-cache/77242121e92e5208094a0a0f6fbd9eb05d2c3832/_utilities.scssc
  20. BIN spec/fixtures/no_config_file/.sass-cache/804c142587e371bce0dd76315d953aa707422b74/_reset.scssc
  21. +5 −0 spec/fixtures/no_config_file/src/ie.scss
  22. +3 −0 spec/fixtures/no_config_file/src/print.scss
  23. +6 −0 spec/fixtures/no_config_file/src/screen.scss
  24. +142 −39 spec/guard/compass_spec.rb
  25. +19 −0 spec/guard/dsl_spec.rb
  26. +19 −0 spec/guard/reporter_spec.rb
  27. +2 −3 spec/spec_helper.rb
View
@@ -1,6 +1,7 @@
guard 'rspec', :version => 2 do
require 'growl' rescue nil
watch('^spec/(.*)_spec.rb')
- watch('^lib/(.*).rb') { |m| "spec/#{m[1]}_spec.rb" }
- watch('^spec/spec_helper.rb') { "spec" }
+ watch('^lib/(.*).rb') { |m| "spec/#{m[1]}_spec.rb" }
+ watch('^spec/spec_helper.rb') { "spec" }
+ watch('^spec/fixtures/(.*)') { "spec" }
end
View
@@ -23,6 +23,22 @@ $ guard
Your scss(or sass) stylesheets are now guarded.
+h2. Configure Guard::Compass plug-in
+
+The default configuration generated by 'guard init compass' looks like this
+
+bc. guard 'compass' do
+ watch('^src/(.*)\.s[ac]ss')
+end
+
+the compass guard accept two options:
+
+ * :workdir: all compass relative path will be computed from there
+ * :configuration_file: relative or absolute path to your compass configuration file
+
+By default, the working directory is the folder where you run guard in and
+the configuration_file is computed by compass
+
h2. Roadmap
h3. 0.1.0
View
@@ -1,19 +1,22 @@
require 'guard'
require 'guard/guard'
+require 'guard/reporter'
require 'compass'
require 'compass/commands'
require 'compass/logger'
module Guard
class Compass < Guard
- attr_reader :updater
+ attr_reader :updater, :options
+ attr_accessor :reporter
VERSION = '0.0.6'
def initialize(watchers = [], options = {})
super
- @options[:workdir] = File.expand_path(File.dirname("."))
+ @reporter = Reporter.new
+ @options[:workdir] ||= File.expand_path(File.dirname("."))
end
# Guard Interface Implementation
@@ -38,19 +41,48 @@ def reload
# Compile all the sass|scss stylesheets
def run_all
- @updater.execute
- true
+ perform
end
# Compile the changed stylesheets
def run_on_change(paths)
- @updater.execute
- true
+ perform
end
private
+ def perform
+ if valid_sass_path?
+ @updater.execute
+ true
+ else
+ false
+ end
+ end
+
def create_updater
+ if(options[:configuration_file])
+ filepath = Pathname.new(options[:configuration_file])
+ if(filepath.relative?)
+ filepath = Pathname.new([options[:workdir], options[:configuration_file]].join("/"))
+ end
+ if(filepath.exist?)
+ ::Compass.add_configuration filepath
+ options[:configuration_file] = filepath
+ else
+ reporter.failure "Cannot find the Compass configuration file: " + filepath + "\nPlease check your configuration."
+ end
+ end
@updater = ::Compass::Commands::UpdateProject.new(@options[:workdir] , @options)
+ valid_sass_path?
+ end
+
+ def valid_sass_path?
+ unless File.exists? ::Compass.configuration.sass_path
+ reporter.failure("Sass files src directory not found: #{::Compass.configuration.sass_path}\nPlease check your Compass configuration.")
+ false
+ else
+ true
+ end
end
end
end
@@ -1,3 +1,8 @@
guard 'compass' do
watch('^src/(.*)\.s[ac]ss')
-end
+end
+
+# # Alternative
+# guard 'compass', :workdir => 'not_current_dir', :configuration_file => 'path/to/my/compass_config.rb' do
+# watch('^src/(.*)\.s[ac]ss')
+# end
View
@@ -0,0 +1,19 @@
+module Guard
+ # Send a report to the Guard UI
+ # The Reporter is a wrapper arround guard UI because
+ # it is currently subject to change.
+ class Reporter
+ def success(message)
+ UI.info(message)
+ end
+ def failure(message)
+ UI.error(message)
+ end
+ def unstable(message)
+ UI.info(message)
+ end
+ def announce(message)
+ UI.info(message)
+ end
+ end
+end
@@ -0,0 +1,5 @@
+/* Welcome to Compass. Use this file to write IE specific override styles.
+ * Import this file using the following HTML or equivalent:
+ * <!--[if IE]>
+ * <link href="/stylesheets/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
+ * <![endif]--> */
@@ -0,0 +1,3 @@
+/* Welcome to Compass. Use this file to define print styles.
+ * Import this file using the following HTML or equivalent:
+ * <link href="/stylesheets/print.css" media="print" rel="stylesheet" type="text/css" /> */
@@ -0,0 +1,6 @@
+/* Welcome to Compass.
+ * In this file you should write your main styles. (or centralize your imports)
+ * Import this file using the following HTML or equivalent:
+ * <link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" /> */
+
+@import "compass/reset";
@@ -0,0 +1,9 @@
+# Require any additional compass plugins here.
+# Set this to the root of your project when deployed:
+http_path = "/"
+css_dir = "stylesheets"
+sass_dir = "src"
+images_dir = "images"
+javascripts_dir = "javascripts"
+# To enable relative paths to assets via compass helper functions. Uncomment:
+# relative_assets = true
@@ -0,0 +1,9 @@
+# Require any additional compass plugins here.
+# Set this to the root of your project when deployed:
+http_path = "/"
+css_dir = "another_stylesheets_location"
+sass_dir = "another_src_location"
+images_dir = "another_images_location"
+javascripts_dir = "another_javascripts_location"
+# To enable relative paths to assets via compass helper functions. Uncomment:
+# relative_assets = true
@@ -0,0 +1,5 @@
+/* Welcome to Compass. Use this file to write IE specific override styles.
+ * Import this file using the following HTML or equivalent:
+ * <!--[if IE]>
+ * <link href="/stylesheets/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
+ * <![endif]--> */
@@ -0,0 +1,3 @@
+/* Welcome to Compass. Use this file to define print styles.
+ * Import this file using the following HTML or equivalent:
+ * <link href="/stylesheets/print.css" media="print" rel="stylesheet" type="text/css" /> */
@@ -0,0 +1,6 @@
+/* Welcome to Compass.
+ * In this file you should write your main styles. (or centralize your imports)
+ * Import this file using the following HTML or equivalent:
+ * <link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" /> */
+
+@import "compass/reset";
@@ -0,0 +1 @@
+guard 'compass', :workdir => 'test', :configuration_file => 'test_also.rb'
@@ -0,0 +1,5 @@
+/* Welcome to Compass. Use this file to write IE specific override styles.
+ * Import this file using the following HTML or equivalent:
+ * <!--[if IE]>
+ * <link href="/stylesheets/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
+ * <![endif]--> */
@@ -0,0 +1,3 @@
+/* Welcome to Compass. Use this file to define print styles.
+ * Import this file using the following HTML or equivalent:
+ * <link href="/stylesheets/print.css" media="print" rel="stylesheet" type="text/css" /> */
@@ -0,0 +1,6 @@
+/* Welcome to Compass.
+ * In this file you should write your main styles. (or centralize your imports)
+ * Import this file using the following HTML or equivalent:
+ * <link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" /> */
+
+@import "compass/reset";
Oops, something went wrong.

0 comments on commit 8ef8bd1

Please sign in to comment.