diff options
Diffstat (limited to 'railties/guides')
-rw-r--r-- | railties/guides/rails_guides.rb | 31 | ||||
-rw-r--r-- | railties/guides/rails_guides/generator.rb | 9 |
2 files changed, 17 insertions, 23 deletions
diff --git a/railties/guides/rails_guides.rb b/railties/guides/rails_guides.rb index 0d9458bf0f..e6f0b694a6 100644 --- a/railties/guides/rails_guides.rb +++ b/railties/guides/rails_guides.rb @@ -5,40 +5,27 @@ $:.unshift pwd require 'rubygems' begin + # Guides generation in the Rails repo. as_lib = File.join(pwd, "../../activesupport/lib") ap_lib = File.join(pwd, "../../actionpack/lib") - $: << as_lib if File.directory?(as_lib) - $: << ap_lib if File.directory?(ap_lib) - - require "action_controller" - require "action_view" + $:.unshift as_lib if File.directory?(as_lib) + $:.unshift ap_lib if File.directory?(ap_lib) rescue LoadError - gem "actionpack", '>= 2.3' - - require "action_controller" - require "action_view" + # Guides generation from gems. + gem "actionpack", '>= 3.0' end begin gem 'RedCloth', '>= 4.1.1' + require 'redcloth' rescue Gem::LoadError $stderr.puts %(Generating Guides requires RedCloth 4.1.1+) exit 1 end -require 'redcloth' - -module RailsGuides - autoload :Generator, "rails_guides/generator" - autoload :Indexer, "rails_guides/indexer" - autoload :Helpers, "rails_guides/helpers" - autoload :TextileExtensions, "rails_guides/textile_extensions" - autoload :Levenshtein, "rails_guides/levenshtein" -end - +require "rails_guides/textile_extensions" RedCloth.send(:include, RailsGuides::TextileExtensions) -if $0 == __FILE__ - RailsGuides::Generator.new.generate -end +require "rails_guides/generator" +RailsGuides::Generator.new.generate diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb index 9a4a26cd0b..839a3879d2 100644 --- a/railties/guides/rails_guides/generator.rb +++ b/railties/guides/rails_guides/generator.rb @@ -1,6 +1,14 @@ require 'set' require 'fileutils' +require 'active_support/core_ext/string/output_safety' +require 'action_controller' +require 'action_view' + +require 'rails_guides/indexer' +require 'rails_guides/helpers' +require 'rails_guides/levenshtein' + module RailsGuides class Generator attr_reader :guides_dir, :source_dir, :output_dir @@ -56,7 +64,6 @@ module RailsGuides File.open(File.join(output_dir, output_file), 'w') do |f| view = ActionView::Base.new(source_dir) - view.output_buffer = ActiveSupport::SafeBuffer.new view.extend(Helpers) if guide =~ /\.textile\.erb$/ |