rails_guides.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. pwd = File.dirname(__FILE__)
  2. $:.unshift pwd
  3. # This is a predicate useful for the doc:guides task of applications.
  4. def bundler?
  5. # Note that rake sets the cwd to the one that contains the Rakefile
  6. # being executed.
  7. File.exists?('Gemfile')
  8. end
  9. # Loading Action Pack requires rack and erubis.
  10. require 'rubygems'
  11. begin
  12. # Guides generation in the Rails repo.
  13. as_lib = File.join(pwd, "../../activesupport/lib")
  14. ap_lib = File.join(pwd, "../../actionpack/lib")
  15. $:.unshift as_lib if File.directory?(as_lib)
  16. $:.unshift ap_lib if File.directory?(ap_lib)
  17. rescue LoadError
  18. # Guides generation from gems.
  19. gem "actionpack", '>= 3.0'
  20. end
  21. begin
  22. require 'redcloth'
  23. rescue Gem::LoadError
  24. # This can happen if doc:guides is executed in an application.
  25. $stderr.puts('Generating guides requires RedCloth 4.1.1+.')
  26. $stderr.puts(<<ERROR) if bundler?
  27. Please add
  28. gem 'RedCloth', '~> 4.2'
  29. to the Gemfile, run
  30. bundle install
  31. and try again.
  32. ERROR
  33. exit 1
  34. end
  35. require "rails_guides/textile_extensions"
  36. RedCloth.send(:include, RailsGuides::TextileExtensions)
  37. require "rails_guides/generator"
  38. RailsGuides::Generator.new.generate