commit 9515c25b23298e2c4081189fde5ac54ab69bb428 Author: John Bintz Date: Fri Jun 17 16:01:49 2011 -0400 initial release diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4040c6c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.gem +.bundle +Gemfile.lock +pkg/* diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..b1a1c2a --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source "http://rubygems.org" + +# Specify your gem's dependencies in guard-rocco.gemspec +gemspec diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..14cfe0b --- /dev/null +++ b/Rakefile @@ -0,0 +1,2 @@ +require 'bundler' +Bundler::GemHelper.install_tasks diff --git a/guard-rocco.gemspec b/guard-rocco.gemspec new file mode 100644 index 0000000..10fee82 --- /dev/null +++ b/guard-rocco.gemspec @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) +require "guard/rocco/version" + +Gem::Specification.new do |s| + s.name = "guard-rocco" + s.version = Guard::RoccoVersion::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ["John Bintz"] + s.email = ["john@coswellproductions.com"] + s.homepage = "" + s.summary = %q{Guard to generate Rocco documentation} + s.description = %q{Guard to generate Rocco documentation} + + s.rubyforge_project = "guard-rocco" + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.require_paths = ["lib"] + + s.add_dependency 'guard', '>= 0.4.0' + s.add_dependency 'rocco' +end + diff --git a/lib/guard/rocco.rb b/lib/guard/rocco.rb new file mode 100644 index 0000000..aec2d04 --- /dev/null +++ b/lib/guard/rocco.rb @@ -0,0 +1,36 @@ +require 'rocco' +require 'guard/guard' + +module Guard + class Rocco < Guard + def initialize(watchers = [], options = {}) + super + + @options = { :dir => 'doc' }.merge(options) + end + + def start + UI.info "Guard::Rocco is waiting to build docs..." + end + + def run_all + all_paths.each { |path| build(path) } + end + + def run_on_change(paths = []) + paths.each { |path| build(path) } + end + + private + def build(path) + target = File.join(@options[:dir], path).gsub(%r{\.[^\.]+$}, '.html') + puts "rocco: #{path} -> #{target}" + File.open(target, 'wb') { |fh| fh.print ::Rocco.new(path, all_paths).to_html } + end + + def all_paths + Watcher.match_files(self, Dir['**/*']) + end + end +end + diff --git a/lib/guard/rocco/version.rb b/lib/guard/rocco/version.rb new file mode 100644 index 0000000..f5f51de --- /dev/null +++ b/lib/guard/rocco/version.rb @@ -0,0 +1,5 @@ +module Guard + module RoccoVersion + VERSION = '0.0.1' + end +end