diff options
author | Xavier Noria <fxn@hashref.com> | 2010-03-17 23:03:48 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-03-17 23:03:48 +0100 |
commit | 61f6749fb7c05df6595fd810a181eb9134000f1c (patch) | |
tree | 66dc8a6ada52e1364927f2cd0ba44f639dabbeb5 /railties | |
parent | b6edffa640674b10c81bf2905d455cafb52c068f (diff) | |
download | rails-61f6749fb7c05df6595fd810a181eb9134000f1c.tar.gz rails-61f6749fb7c05df6595fd810a181eb9134000f1c.tar.bz2 rails-61f6749fb7c05df6595fd810a181eb9134000f1c.zip |
guides generator skips untouched guides by default, override with ALL=1
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/rails_guides/generator.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb index 839a3879d2..670d2bc4db 100644 --- a/railties/guides/rails_guides/generator.rb +++ b/railties/guides/rails_guides/generator.rb @@ -15,7 +15,7 @@ module RailsGuides def initialize(output=nil) initialize_dirs(output) - reset_output_dir + create_output_dir_if_needed end def generate @@ -30,14 +30,14 @@ module RailsGuides @output_dir = output || File.join(@guides_dir, "output") end - def reset_output_dir - FileUtils.rm_rf(output_dir) + def create_output_dir_if_needed FileUtils.mkdir_p(output_dir) end def generate_guides guides_to_generate.each do |guide| - generate_guide(guide) + output_file = output_file_for(guide) + generate_guide(guide, output_file) if generate?(guide, output_file) end end @@ -58,10 +58,18 @@ module RailsGuides FileUtils.cp_r(File.join(guides_dir, 'files'), File.join(output_dir, 'files')) end - def generate_guide(guide) - output_file = guide.sub(/\.textile(?:\.erb)?$/, '.html') - puts "Generating #{output_file}" + def output_file_for(guide) + guide.sub(/\.textile(?:\.erb)?$/, '.html') + end + + def generate?(source_file, output_file) + fin = File.join(source_dir, source_file) + fout = File.join(output_dir, output_file) + ENV['ALL'] == '1' || !File.exists?(fout) || File.mtime(fout) < File.mtime(fin) + end + def generate_guide(guide, output_file) + puts "Generating #{output_file}" File.open(File.join(output_dir, output_file), 'w') do |f| view = ActionView::Base.new(source_dir) view.extend(Helpers) |