Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added :root option to better reflect the directory structure of the app #8

Closed
wants to merge 2 commits into from

2 participants

@adamsinger

In the spirit of Rails 3.1 future-proofing, I wanted to add an option so that if I have a SCSS file in /app/assets/stylesheets/foo.scss, that it would be compiled to /public/stylesheets/foo.css. The :root option accomplishes this.

@hawx
Owner

I don't know if that really does what you would expect from root, as I'd expect you to set root to . for the readme example to work. But it does seem much better than the current method of just going up one directory.

@hawx
Owner

I've made these changes http://github.com/hawx/guard-sass/compare/da613ad3599970204200…71370b99435a3805fc8d.

It now determines paths from the directory that guard was called from which is what should have been happening from the start.

I also added a :root option which allows you to say the directory the output is found from. Though now that paths are found from where guard was called I'm not sure there is any point as you could just set :output differently. I may remove this, before releasing?

So, does that solve the problem you had?

@adamsinger
@hawx
Owner

I've pushed a new version (0.2.0), but without :root as since I've changed the way paths are calculated it was pointless. Also as a bonus there is a new guard-coffeescript style short notation!

@hawx hawx closed this
@adamsinger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 16, 2011
  1. Added support for the :root option to better mimic the directory stru…

    Adam Singer authored
    …cture of an app
Commits on Jun 17, 2011
  1. Updated the readme to reflect the added :root option

    Adam Singer authored
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +5 −0 Readme.md
  2. +3 −1 lib/guard/sass.rb
View
5 Readme.md
@@ -31,6 +31,11 @@ Defaults to writing to 'css/' but this can be changed....
watch(%r{^sass/(.*)})
end
+You can also specify a `:root` option to better mimic your app's directory structure...
+
+ guard 'sass', :output => 'public/stylesheets', :root => 'app/assets/stylesheets' do
+ watch(%r{^app/assets/stylesheets/.+\.s[ac]ss})
+ end
## Contributors
View
4 lib/guard/sass.rb
@@ -39,7 +39,9 @@ def build_sass(file)
# @return [String] path to file where output should be written
#
def get_output(file)
- folder = File.join File.dirname(file), '..', @options[:output]
+ root = ''
+ root = File.dirname(file).gsub!(/^#{@options[:root]}/, '')
+ folder = File.join @options[:output], root
FileUtils.mkdir_p folder
r = File.join folder, File.basename(file).split('.')[0]
r << '.css'
Something went wrong with that request. Please try again.