aboutsummaryrefslogtreecommitdiffstats
path: root/guides/rails_guides.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2012-03-17 08:32:49 -0700
committerXavier Noria <fxn@hashref.com>2012-03-17 08:32:49 -0700
commit6d87cd028b32570973450424db164e5405a0ee13 (patch)
tree38008699f54532c6ba446ec806ccc33ad26b10fd /guides/rails_guides.rb
parent9d06b49913dd2a2254d87c7af1af9f1e4d7f64ec (diff)
downloadrails-6d87cd028b32570973450424db164e5405a0ee13.tar.gz
rails-6d87cd028b32570973450424db164e5405a0ee13.tar.bz2
rails-6d87cd028b32570973450424db164e5405a0ee13.zip
moves the guides up to the root directory
Diffstat (limited to 'guides/rails_guides.rb')
-rw-r--r--guides/rails_guides.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/guides/rails_guides.rb b/guides/rails_guides.rb
new file mode 100644
index 0000000000..e662ad2ed9
--- /dev/null
+++ b/guides/rails_guides.rb
@@ -0,0 +1,50 @@
+pwd = File.dirname(__FILE__)
+$:.unshift pwd
+
+# This is a predicate useful for the doc:guides task of applications.
+def bundler?
+ # Note that rake sets the cwd to the one that contains the Rakefile
+ # being executed.
+ File.exists?('Gemfile')
+end
+
+# Loading Action Pack requires rack and erubis.
+require 'rubygems'
+
+begin
+ # Guides generation in the Rails repo.
+ as_lib = File.join(pwd, "../activesupport/lib")
+ ap_lib = File.join(pwd, "../actionpack/lib")
+
+ $:.unshift as_lib if File.directory?(as_lib)
+ $:.unshift ap_lib if File.directory?(ap_lib)
+rescue LoadError
+ # Guides generation from gems.
+ gem "actionpack", '>= 3.0'
+end
+
+begin
+ require 'redcloth'
+rescue Gem::LoadError
+ # This can happen if doc:guides is executed in an application.
+ $stderr.puts('Generating guides requires RedCloth 4.1.1+.')
+ $stderr.puts(<<ERROR) if bundler?
+Please add
+
+ gem 'RedCloth', '~> 4.2'
+
+to the Gemfile, run
+
+ bundle install
+
+and try again.
+ERROR
+
+ exit 1
+end
+
+require "rails_guides/textile_extensions"
+RedCloth.send(:include, RailsGuides::TextileExtensions)
+
+require "rails_guides/generator"
+RailsGuides::Generator.new.generate