Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! I cleaned up your code for you! #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
Packages your javascript files together when you save your source file.

## Use
if you haven't already `gem install sprockets`
then `gem install guard-sprockets`
in your project's directory root
`guard init`
`guard init sprockets`
if you haven't already `gem install sprockets`
then `gem install guard-sprockets`
in your project's directory root
`guard init`
`guard init sprockets`

which will add this to your Guardfile
which will add this to your Guardfile

guard 'sprockets', :destination => "public/javascripts" do
watch (%r{app/assets/javascripts/application.js})
end

change the destination to your public facing javascript directory and the `watch` regex to point at where your source javascript file is.
change the destination to your public facing javascript directory and the `watch` regex to point at where your source javascript file is.

The base configuration would work for a rails 3 project with a directory structure like

The base configuration would work for a rails 3 project with a directory structure like

|-- app
| |-- controllers
| |-- assets
| | |-- sass
| | `-- javascripts
| | `-- application.js # your source javascript file
| | `-- application.js # your source javascript file
| |-- helpers
| |-- mailers
| |-- models
Expand Down
4 changes: 2 additions & 2 deletions guard-sprockets.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Gem::Specification.new do |s|
s.description = %q{guard file for sprockets}

s.rubyforge_project = "guard-sprockets"

s.add_dependency 'guard', '>= 0.2.2'
s.add_dependency "sprockets"

s.files = Dir.glob('{lib}/**/*') #+ %w[LICENSE README.rdoc]
s.require_path = 'lib'
end
8 changes: 4 additions & 4 deletions lib/guard/sprockets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
module Guard
class Sprockets < Guard
def initialize(watchers=[], options={})
super
super
@destination = options[:destination]
end

def start
UI.info "Sprockets waiting for js file changes..."
end

def run_all
true
end

def run_on_change(paths)
sprocketize paths.first
end

private

def sprocketize(path)
parts = path.split('/')
file = parts.pop
Expand Down