1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rdoc/rubygems_hook.rb: Updated for (upcoming) RubyGems 2

import.
* test/rdoc/test_rdoc_rubygems_hook.rb:  ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2012-11-27 06:01:41 +00:00
parent 1eac1cb21e
commit cb581e2059
3 changed files with 54 additions and 38 deletions

View file

@ -1,3 +1,9 @@
Tue Nov 27 14:56:45 2012 Eric Hodel <drbrain@segment7.net>
* lib/rdoc/rubygems_hook.rb: Updated for (upcoming) RubyGems 2
import.
* test/rdoc/test_rdoc_rubygems_hook.rb: ditto
Tue Nov 27 13:59:29 2012 Narihiro Nakamura <authornari@gmail.com>
* NEWS: add improvements of the garbage collector.

View file

@ -109,8 +109,10 @@ class RDoc::RubygemsHook
options.op_dir = destination
options.finish
generator = options.generator.new @rdoc.store, options
@rdoc.options = options
@rdoc.generator = options.generator.new options
@rdoc.generator = generator
say "Installing #{generator} documentation for #{@spec.full_name}"
@ -134,8 +136,6 @@ class RDoc::RubygemsHook
setup
::RDoc::RDoc.reset
options = ::RDoc::Options.new
options.default_title = "#{@spec.full_name} Documentation"
options.files = []
@ -158,6 +158,14 @@ class RDoc::RubygemsHook
@rdoc = new_rdoc
@rdoc.options = options
store = RDoc::Store.new
store.encoding = options.encoding if options.respond_to? :encoding
store.dry_run = options.dry_run
store.main = options.main_page
store.title = options.title
@rdoc.store = RDoc::Store.new
Dir.chdir @spec.full_gem_path do
@rdoc.parse_files options.files
end

View file

@ -12,7 +12,7 @@ class TestRDocRubygemsHook < Gem::TestCase
@a = quick_spec 'a'
@rdoc = RDoc::RubygemsHook.new @a
@hook = RDoc::RubygemsHook.new @a
begin
RDoc::RubygemsHook.load_rdoc
@ -24,8 +24,8 @@ class TestRDocRubygemsHook < Gem::TestCase
end
def test_initialize
assert @rdoc.generate_rdoc
assert @rdoc.generate_ri
assert @hook.generate_rdoc
assert @hook.generate_ri
rdoc = RDoc::RubygemsHook.new @a, false, false
@ -41,7 +41,7 @@ class TestRDocRubygemsHook < Gem::TestCase
-p
]
@rdoc.delete_legacy_args args
@hook.delete_legacy_args args
assert_empty args
end
@ -50,24 +50,26 @@ class TestRDocRubygemsHook < Gem::TestCase
options = RDoc::Options.new
options.files = []
@rdoc.instance_variable_set :@rdoc, @rdoc.new_rdoc
@rdoc.instance_variable_set :@file_info, []
rdoc = @hook.new_rdoc
rdoc.store = RDoc::Store.new
@hook.instance_variable_set :@rdoc, rdoc
@hook.instance_variable_set :@file_info, []
@rdoc.document 'darkfish', options, @a.doc_dir('rdoc')
@hook.document 'darkfish', options, @a.doc_dir('rdoc')
assert @rdoc.rdoc_installed?
assert @hook.rdoc_installed?
end
def test_generate
FileUtils.mkdir_p @a.doc_dir
FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
@rdoc.generate
@hook.generate
assert @rdoc.rdoc_installed?
assert @rdoc.ri_installed?
assert @hook.rdoc_installed?
assert @hook.ri_installed?
rdoc = @rdoc.instance_variable_get :@rdoc
rdoc = @hook.instance_variable_get :@rdoc
refute rdoc.options.hyperlink_all
end
@ -78,9 +80,9 @@ class TestRDocRubygemsHook < Gem::TestCase
FileUtils.mkdir_p @a.doc_dir
FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
@rdoc.generate
@hook.generate
rdoc = @rdoc.instance_variable_get :@rdoc
rdoc = @hook.instance_variable_get :@rdoc
assert rdoc.options.hyperlink_all
end
@ -91,21 +93,21 @@ class TestRDocRubygemsHook < Gem::TestCase
FileUtils.mkdir_p @a.doc_dir
FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
@rdoc.generate
@hook.generate
rdoc = @rdoc.instance_variable_get :@rdoc
rdoc = @hook.instance_variable_get :@rdoc
assert rdoc.options.hyperlink_all
end
def test_generate_disabled
@rdoc.generate_rdoc = false
@rdoc.generate_ri = false
@hook.generate_rdoc = false
@hook.generate_ri = false
@rdoc.generate
@hook.generate
refute @rdoc.rdoc_installed?
refute @rdoc.ri_installed?
refute @hook.rdoc_installed?
refute @hook.ri_installed?
end
def test_generate_force
@ -113,9 +115,9 @@ class TestRDocRubygemsHook < Gem::TestCase
FileUtils.mkdir_p @a.doc_dir 'rdoc'
FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
@rdoc.force = true
@hook.force = true
@rdoc.generate
@hook.generate
assert_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
assert_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
@ -126,32 +128,32 @@ class TestRDocRubygemsHook < Gem::TestCase
FileUtils.mkdir_p @a.doc_dir 'rdoc'
FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
@rdoc.generate
@hook.generate
refute_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
refute_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
end
def test_new_rdoc
assert_kind_of RDoc::RDoc, @rdoc.new_rdoc
assert_kind_of RDoc::RDoc, @hook.new_rdoc
end
def test_rdoc_installed?
refute @rdoc.rdoc_installed?
refute @hook.rdoc_installed?
FileUtils.mkdir_p @a.doc_dir 'rdoc'
assert @rdoc.rdoc_installed?
assert @hook.rdoc_installed?
end
def test_remove
FileUtils.mkdir_p @a.doc_dir 'rdoc'
FileUtils.mkdir_p @a.doc_dir 'ri'
@rdoc.remove
@hook.remove
refute @rdoc.rdoc_installed?
refute @rdoc.ri_installed?
refute @hook.rdoc_installed?
refute @hook.ri_installed?
assert_path_exists @a.doc_dir
end
@ -162,7 +164,7 @@ class TestRDocRubygemsHook < Gem::TestCase
FileUtils.chmod 0, @a.base_dir
e = assert_raises Gem::FilePermissionError do
@rdoc.remove
@hook.remove
end
assert_equal @a.base_dir, e.directory
@ -171,15 +173,15 @@ class TestRDocRubygemsHook < Gem::TestCase
end
def test_ri_installed?
refute @rdoc.ri_installed?
refute @hook.ri_installed?
FileUtils.mkdir_p @a.doc_dir 'ri'
assert @rdoc.ri_installed?
assert @hook.ri_installed?
end
def test_setup
@rdoc.setup
@hook.setup
assert_path_exists @a.doc_dir
end
@ -190,7 +192,7 @@ class TestRDocRubygemsHook < Gem::TestCase
FileUtils.chmod 0, @a.doc_dir
e = assert_raises Gem::FilePermissionError do
@rdoc.setup
@hook.setup
end
assert_equal @a.doc_dir, e.directory