forked from ruby-china/rails-guides-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rails_guides.rb
executable file
·54 lines (41 loc) · 1.18 KB
/
rails_guides.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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'
require 'redcarpet'
rescue Gem::LoadError
# This can happen if doc:guides is executed in an application.
$stderr.puts('Generating guides requires RedCloth & BlueCloth')
$stderr.puts(<<ERROR) if bundler?
Please add
gem 'RedCloth', '~> 4.2'
gem 'redcarpet', '~> 2.0'
to the Gemfile, run
bundle install
and try again.
ERROR
exit 1
end
require "rails_guides/text_process"
RedCloth.send(:include, RailsGuides::TextProcess)
require "rails_guides/generator"
require "rails_guides/version"
RailsGuides::Generator.new.generate