From cfa7f86bc9961751d3614dfb8b50df85e5137905 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sat, 18 Jun 2011 12:33:23 -0400 Subject: [PATCH] finish some docs --- README.md | 13 +++++++++++++ lib/guard/rocco.rb | 8 ++++++-- lib/guard/rocco/templates/Guardfile | 6 ++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 README.md create mode 100644 lib/guard/rocco/templates/Guardfile 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 +