diff --git a/README.md b/README.md new file mode 100644 index 0000000..3fc5b5b --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +It's a [Guard](http://github.com/guard/guard) for the [Rocco](http://github.com/rtomayko/rocco) documentation system! + + guard 'rocco' do + watch(%r{app/.*\.(rb|coffee)}) + watch(%r{lib/.*\.rb}) + end + +Only one option for now: + +* `:dir` specifies the output dir (default `doc`) + +`gem install guard-rocco` or Bundle it up with `gem 'guard-rocco'`. Yeah! + diff --git a/lib/guard/rocco.rb b/lib/guard/rocco.rb index aec2d04..5afc405 100644 --- a/lib/guard/rocco.rb +++ b/lib/guard/rocco.rb @@ -22,8 +22,8 @@ module Guard end private - def build(path) - target = File.join(@options[:dir], path).gsub(%r{\.[^\.]+$}, '.html') + def build(path, target = nil) + target ||= self.filename_to_target(path) puts "rocco: #{path} -> #{target}" File.open(target, 'wb') { |fh| fh.print ::Rocco.new(path, all_paths).to_html } end @@ -31,6 +31,10 @@ module Guard def all_paths Watcher.match_files(self, Dir['**/*']) end + + def self.filename_to_target(path) + File.join(@options[:dir], path).gsub(%r{\.[^\.]+$}, '.html') + end end end diff --git a/lib/guard/rocco/templates/Guardfile b/lib/guard/rocco/templates/Guardfile new file mode 100644 index 0000000..ac0a2a4 --- /dev/null +++ b/lib/guard/rocco/templates/Guardfile @@ -0,0 +1,6 @@ +guard 'rocco' do + # For Rails 3.0.x and 3.1 + watch(%r{app/.*\.(rb|coffee)}) + watch(%r{lib/.*\.rb}) +end +