Skip to content

Commit d4a6bca

Browse files
committed
patches documents.yaml in some v5.1.x versions
Doing integration tests for every single patch like this is proving to be too expensive. We are going to switch to a lighter approach by checking the modifications we expect in the repo, and assuming those modifications are the ones that allow the docs to be built. References rails/rails#29865.
1 parent 1266a4b commit d4a6bca

File tree

23 files changed

+3675
-6
lines changed

23 files changed

+3675
-6
lines changed

Rakefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ require 'rake/testtask'
33
task default: :test
44

55
Rake::TestTask.new do |t|
6-
t.test_files = FileList['test/*_test.rb']
6+
t.libs << 'test'
7+
t.test_files = FileList['test/**/*_test.rb']
78
end
89

910
namespace :test do

lib/generators/release.rb

+13-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def before_generation
2323
# This dependency could not be satisfied.
2424
contents.sub(/^.*delayed_job_active_record.*$/, '')
2525
end
26-
elsif version_number >= '4.2.8'
26+
elsif version_number == '4.2.8'
2727
# The Nokogiri dependency fixed in Gemfile.lock errs with
2828
#
2929
# nokogiri-1.7.0 requires ruby version >= 2.1.0, which is incompatible with the current version, ruby 2.0.0p598
@@ -45,12 +45,20 @@ def before_generation
4545
# See the comment above for 4.2.9.
4646
contents.sub(/gem 'sdoc'.*/, "gem 'sdoc', '~> 0.4.0'")
4747
end
48+
elsif version_number >= '5.1.2' && version_number <= '5.1.4'
49+
patch 'guides/source/documents.yaml' do |contents|
50+
# This guide was deleted and prevented Kindle guides from being
51+
# generated. See https://github.com/rails/rails/issues/29865.
52+
contents.sub(/^\s+name: Profiling Rails Applications[^-]+-\n/, '')
53+
end
4854
end
4955

50-
patch 'Gemfile' do |contents|
51-
# kindlerb didn't have a version constraint in some early Gemfiles, and
52-
# the current one is no longer compatible.
53-
contents.sub(/gem ["']kindlerb["']$/, "gem 'kindlerb', '0.1.1'")
56+
if version_number <= '4.2.0'
57+
patch 'Gemfile' do |contents|
58+
# kindlerb didn't have a version constraint in some early Gemfiles, and
59+
# the current one is no longer compatible.
60+
contents.sub(/gem ["']kindlerb["']$/, "gem 'kindlerb', '0.1.1'")
61+
end
5462
end
5563
end
5664

test/fixtures/releases/v4.0.0/Gemfile

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec
4+
5+
gem 'mocha', '~> 0.13.0', require: false
6+
gem 'rack-cache', '~> 1.2'
7+
gem 'bcrypt-ruby', '~> 3.0.0'
8+
gem 'jquery-rails', '~> 2.2.0'
9+
gem 'turbolinks'
10+
gem 'coffee-rails', '~> 4.0.0'
11+
12+
# This needs to be with require false to avoid
13+
# it being automatically loaded by sprockets
14+
gem 'uglifier', '>= 1.3.0', require: false
15+
16+
group :doc do
17+
gem 'sdoc'
18+
gem 'redcarpet', '~> 2.2.2', platforms: :ruby
19+
gem 'w3c_validators'
20+
gem 'kindlerb'
21+
end
22+
23+
# AS
24+
gem 'dalli', '>= 2.2.1'
25+
26+
# Add your own local bundler stuff
27+
local_gemfile = File.dirname(__FILE__) + "/.Gemfile"
28+
instance_eval File.read local_gemfile if File.exists? local_gemfile
29+
30+
group :test do
31+
platforms :mri_19 do
32+
gem 'ruby-prof', '~> 0.11.2'
33+
end
34+
35+
platforms :mri_19, :mri_20 do
36+
gem 'debugger'
37+
end
38+
39+
gem 'benchmark-ips'
40+
end
41+
42+
platforms :ruby do
43+
gem 'yajl-ruby'
44+
gem 'nokogiri', '>= 1.4.5'
45+
46+
# Needed for compiling the ActionDispatch::Journey parser
47+
gem 'racc', '>=1.4.6', require: false
48+
49+
# AR
50+
gem 'sqlite3', '~> 1.3.6'
51+
52+
group :db do
53+
gem 'pg', '>= 0.11.0'
54+
gem 'mysql', '>= 2.9.0'
55+
gem 'mysql2', '>= 0.3.10'
56+
end
57+
end
58+
59+
platforms :jruby do
60+
gem 'json'
61+
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.2.7'
62+
63+
group :db do
64+
gem 'activerecord-jdbcmysql-adapter', '>= 1.2.7'
65+
gem 'activerecord-jdbcpostgresql-adapter', '>= 1.2.7'
66+
end
67+
end
68+
69+
# gems that are necessary for ActiveRecord tests with Oracle database
70+
if ENV['ORACLE_ENHANCED']
71+
platforms :ruby do
72+
gem 'ruby-oci8', '>= 2.0.4'
73+
end
74+
gem 'activerecord-oracle_enhanced-adapter', github: 'rsim/oracle-enhanced', branch: 'master'
75+
end
76+
77+
# A gem necessary for ActiveRecord tests with IBM DB
78+
gem 'ibm_db' if ENV['IBM_DB']
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec
4+
5+
gem 'mocha', '~> 0.13.0', require: false
6+
gem 'rack-cache', '~> 1.2'
7+
gem 'bcrypt-ruby', '~> 3.0.0'
8+
gem 'jquery-rails', '~> 2.2.0'
9+
gem 'turbolinks'
10+
gem 'coffee-rails', '~> 4.0.0'
11+
12+
# This needs to be with require false to avoid
13+
# it being automatically loaded by sprockets
14+
gem 'uglifier', '>= 1.3.0', require: false
15+
16+
group :doc do
17+
gem 'sdoc'
18+
gem 'redcarpet', '~> 2.2.2', platforms: :ruby
19+
gem 'w3c_validators'
20+
gem 'kindlerb', '0.1.1'
21+
end
22+
23+
# AS
24+
gem 'dalli', '>= 2.2.1'
25+
26+
# Add your own local bundler stuff
27+
local_gemfile = File.dirname(__FILE__) + "/.Gemfile"
28+
instance_eval File.read local_gemfile if File.exists? local_gemfile
29+
30+
group :test do
31+
platforms :mri_19 do
32+
gem 'ruby-prof', '~> 0.11.2'
33+
end
34+
35+
platforms :mri_19, :mri_20 do
36+
gem 'debugger'
37+
end
38+
39+
gem 'benchmark-ips'
40+
end
41+
42+
platforms :ruby do
43+
gem 'yajl-ruby'
44+
gem 'nokogiri', '>= 1.4.5'
45+
46+
# Needed for compiling the ActionDispatch::Journey parser
47+
gem 'racc', '>=1.4.6', require: false
48+
49+
# AR
50+
gem 'sqlite3', '~> 1.3.6'
51+
52+
group :db do
53+
gem 'pg', '>= 0.11.0'
54+
gem 'mysql', '>= 2.9.0'
55+
gem 'mysql2', '>= 0.3.10'
56+
end
57+
end
58+
59+
platforms :jruby do
60+
gem 'json'
61+
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.2.7'
62+
63+
group :db do
64+
gem 'activerecord-jdbcmysql-adapter', '>= 1.2.7'
65+
gem 'activerecord-jdbcpostgresql-adapter', '>= 1.2.7'
66+
end
67+
end
68+
69+
# gems that are necessary for ActiveRecord tests with Oracle database
70+
if ENV['ORACLE_ENHANCED']
71+
platforms :ruby do
72+
gem 'ruby-oci8', '>= 2.0.4'
73+
end
74+
gem 'activerecord-oracle_enhanced-adapter', github: 'rsim/oracle-enhanced', branch: 'master'
75+
end
76+
77+
# A gem necessary for ActiveRecord tests with IBM DB
78+
gem 'ibm_db' if ENV['IBM_DB']
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
require 'rdoc/task'
2+
3+
module Rails
4+
module API
5+
class Task < RDoc::Task
6+
RDOC_FILES = {
7+
'activesupport' => {
8+
:include => %w(
9+
README.rdoc
10+
CHANGELOG.md
11+
lib/active_support/**/*.rb
12+
),
13+
:exclude => 'lib/active_support/vendor/*'
14+
},
15+
16+
'activerecord' => {
17+
:include => %w(
18+
README.rdoc
19+
CHANGELOG.md
20+
lib/active_record/**/*.rb
21+
),
22+
:exclude => 'lib/active_record/vendor/*'
23+
},
24+
25+
'activemodel' => {
26+
:include => %w(
27+
README.rdoc
28+
CHANGELOG.md
29+
lib/active_model/**/*.rb
30+
)
31+
},
32+
33+
'actionpack' => {
34+
:include => %w(
35+
README.rdoc
36+
CHANGELOG.md
37+
lib/abstract_controller/**/*.rb
38+
lib/action_controller/**/*.rb
39+
lib/action_dispatch/**/*.rb
40+
lib/action_view/**/*.rb
41+
),
42+
:exclude => 'lib/action_controller/vendor/*'
43+
},
44+
45+
'actionmailer' => {
46+
:include => %w(
47+
README.rdoc
48+
CHANGELOG.md
49+
lib/action_mailer/**/*.rb
50+
),
51+
:exclude => 'lib/action_mailer/vendor/*'
52+
},
53+
54+
'railties' => {
55+
:include => %w(
56+
README.rdoc
57+
CHANGELOG.md
58+
MIT-LICENSE
59+
lib/**/*.rb
60+
),
61+
:exclude => 'lib/rails/generators/rails/**/templates/**/*.rb'
62+
}
63+
}
64+
65+
def initialize(name)
66+
super
67+
68+
# Every time rake runs this task is instantiated as all the rest.
69+
# Be lazy computing stuff to have as light impact as possible to
70+
# the rest of tasks.
71+
before_running_rdoc do
72+
load_and_configure_sdoc
73+
configure_rdoc_files
74+
setup_horo_variables
75+
end
76+
end
77+
78+
# Hack, ignore the desc calls performed by the original initializer.
79+
def desc(description)
80+
# no-op
81+
end
82+
83+
def load_and_configure_sdoc
84+
require 'sdoc'
85+
86+
self.title = 'Ruby on Rails API'
87+
self.rdoc_dir = api_dir
88+
89+
options << '-m' << api_main
90+
options << '-e' << 'UTF-8'
91+
92+
options << '-f' << 'sdoc'
93+
options << '-T' << 'rails'
94+
rescue LoadError
95+
$stderr.puts %(Unable to load SDoc, please add\n\n gem 'sdoc', require: false\n\nto the Gemfile.)
96+
exit 1
97+
end
98+
99+
def configure_rdoc_files
100+
rdoc_files.include(api_main)
101+
102+
RDOC_FILES.each do |component, cfg|
103+
cdr = component_root_dir(component)
104+
105+
Array(cfg[:include]).each do |pattern|
106+
rdoc_files.include("#{cdr}/#{pattern}")
107+
end
108+
109+
Array(cfg[:exclude]).each do |pattern|
110+
rdoc_files.exclude("#{cdr}/#{pattern}")
111+
end
112+
end
113+
end
114+
115+
def setup_horo_variables
116+
ENV['HORO_PROJECT_NAME'] = 'Ruby on Rails'
117+
ENV['HORO_PROJECT_VERSION'] = rails_version
118+
end
119+
120+
def api_main
121+
component_root_dir('railties') + '/RDOC_MAIN.rdoc'
122+
end
123+
end
124+
125+
class RepoTask < Task
126+
def load_and_configure_sdoc
127+
super
128+
options << '-g' # link to GitHub, SDoc flag
129+
end
130+
131+
def component_root_dir(component)
132+
component
133+
end
134+
135+
def api_dir
136+
'doc/rdoc'
137+
end
138+
139+
def rails_version
140+
"master@#{`git rev-parse HEAD`[0, 7]}"
141+
end
142+
end
143+
144+
class AppTask < Task
145+
def component_root_dir(gem_name)
146+
$:.grep(%r{#{gem_name}[\w.-]*/lib\z}).first[0..-5]
147+
end
148+
149+
def api_dir
150+
'doc/api'
151+
end
152+
153+
def rails_version
154+
Rails::VERSION::STRING
155+
end
156+
end
157+
end
158+
end

0 commit comments

Comments
 (0)