diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb
index a7f9239b62..8351bf8ffe 100644
--- a/lib/rdoc/rdoc.rb
+++ b/lib/rdoc/rdoc.rb
@@ -69,7 +69,7 @@ class RDoc::RDoc
##
# The current documentation store
- attr_reader :store
+ attr_accessor :store
##
# Add +klass+ that can generate output after parsing
@@ -208,15 +208,6 @@ def setup_output_dir(dir, force)
last
end
- ##
- # Sets the current documentation tree to +store+ and sets the store's rdoc
- # driver to this instance.
-
- def store= store
- @store = store
- @store.rdoc = self
- end
-
##
# Update the flag file in an output directory.
@@ -450,8 +441,6 @@ def remove_unparseable files
# current directory, so make sure you're somewhere writable before invoking.
def document options
- self.store = RDoc::Store.new
-
if RDoc::Options === options then
@options = options
else
@@ -460,6 +449,8 @@ def document options
end
@options.finish
+ @store = RDoc::Store.new(@options)
+
if @options.pipe then
handle_pipe
exit
@@ -469,12 +460,6 @@ def document options
@last_modified = setup_output_dir @options.op_dir, @options.force_update
end
- @store.encoding = @options.encoding
- @store.dry_run = @options.dry_run
- @store.main = @options.main_page
- @store.title = @options.title
- @store.path = @options.op_dir
-
@start_time = Time.now
@store.load_cache
diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb
index 2e7ca6282c..9f655f50b7 100644
--- a/lib/rdoc/ri/driver.rb
+++ b/lib/rdoc/ri/driver.rb
@@ -420,7 +420,7 @@ def initialize initial_options = {}
*options[:extra_doc_dirs]) do |path, type|
@doc_dirs << path
- store = RDoc::RI::Store.new path, type
+ store = RDoc::RI::Store.new(RDoc::Options.new, path: path, type: type)
store.load_cache
@stores << store
end
diff --git a/lib/rdoc/rubygems_hook.rb b/lib/rdoc/rubygems_hook.rb
index bf01081ef2..9c278b225a 100644
--- a/lib/rdoc/rubygems_hook.rb
+++ b/lib/rdoc/rubygems_hook.rb
@@ -188,13 +188,7 @@ def generate
@rdoc = new_rdoc
@rdoc.options = options
- store = RDoc::Store.new
- store.encoding = options.encoding
- store.dry_run = options.dry_run
- store.main = options.main_page
- store.title = options.title
-
- @rdoc.store = store
+ @rdoc.store = RDoc::Store.new(options)
say "Parsing documentation for #{@spec.full_name}"
diff --git a/lib/rdoc/servlet.rb b/lib/rdoc/servlet.rb
index 4e16a8ab50..9b8db0abaa 100644
--- a/lib/rdoc/servlet.rb
+++ b/lib/rdoc/servlet.rb
@@ -133,7 +133,7 @@ def do_GET req, res
show_documentation req, res
end
rescue WEBrick::HTTPStatus::NotFound => e
- generator = generator_for RDoc::Store.new
+ generator = generator_for RDoc::Store.new(@options)
not_found generator, req, res, e.message
rescue WEBrick::HTTPStatus::Status
@@ -291,7 +291,7 @@ def if_modified_since req, res, path = nil
def installed_docs
extra_counter = 0
ri_paths.map do |path, type|
- store = RDoc::Store.new path, type
+ store = RDoc::Store.new(@options, path: path, type: type)
exists = File.exist? store.cache_path
case type
@@ -420,15 +420,15 @@ def show_documentation req, res
def store_for source_name
case source_name
when 'home' then
- RDoc::Store.new RDoc::RI::Paths.home_dir, :home
+ RDoc::Store.new(@options, path: RDoc::RI::Paths.home_dir, type: :home)
when 'ruby' then
- RDoc::Store.new RDoc::RI::Paths.system_dir, :system
+ RDoc::Store.new(@options, path: RDoc::RI::Paths.system_dir, type: :system)
when 'site' then
- RDoc::Store.new RDoc::RI::Paths.site_dir, :site
+ RDoc::Store.new(@options, path: RDoc::RI::Paths.site_dir, type: :site)
when /\Aextra-(\d+)\z/ then
index = $1.to_i - 1
ri_dir = installed_docs[index][4]
- RDoc::Store.new ri_dir, :extra
+ RDoc::Store.new(@options, path: ri_dir, type: :extra)
else
ri_dir, type = ri_paths.find do |dir, dir_type|
next unless dir_type == :gem
@@ -439,7 +439,7 @@ def store_for source_name
raise WEBrick::HTTPStatus::NotFound,
"Could not find gem \"#{ERB::Util.html_escape(source_name)}\". Are you sure you installed it?" unless ri_dir
- store = RDoc::Store.new ri_dir, type
+ store = RDoc::Store.new(@options, path: ri_dir, type: type)
return store if File.exist? store.cache_path
diff --git a/lib/rdoc/store.rb b/lib/rdoc/store.rb
index eded996ac2..1fce9f6411 100644
--- a/lib/rdoc/store.rb
+++ b/lib/rdoc/store.rb
@@ -94,7 +94,7 @@ def message # :nodoc:
attr_accessor :path
- attr_writer :rdoc
+ attr_reader :options
##
# Type of ri datastore this was loaded from. See RDoc::RI::Driver,
@@ -120,11 +120,11 @@ def message # :nodoc:
##
# Creates a new Store of +type+ that will load or save to +path+
- def initialize path = nil, type = nil
- @dry_run = false
- @encoding = nil
- @path = path
- @rdoc = nil
+ def initialize(options, path: nil, type: nil)
+ @options = options
+ @dry_run = options.dry_run
+ @encoding = options.encoding
+ @path = path || options.op_dir
@type = type
@cache = {
@@ -135,10 +135,10 @@ def initialize path = nil, type = nil
:c_singleton_class_variables => {},
:encoding => @encoding,
:instance_methods => {},
- :main => nil,
+ :main => options.main_page,
:modules => [],
:pages => [],
- :title => nil,
+ :title => options.title,
}
@classes_hash = {}
@@ -977,10 +977,6 @@ def unique_modules
@unique_modules
end
- def options
- @rdoc&.options
- end
-
private
def marshal_load(file)
File.open(file, 'rb') {|io| Marshal.load(io, MarshalFilter)}
diff --git a/test/rdoc/support/test_case.rb b/test/rdoc/support/test_case.rb
index fcdc514424..77af538c0e 100644
--- a/test/rdoc/support/test_case.rb
+++ b/test/rdoc/support/test_case.rb
@@ -47,11 +47,12 @@ def setup
@pwd = Dir.pwd
- @store = RDoc::Store.new
+ @options = RDoc::Options.new
+ @store = RDoc::Store.new(@options)
@rdoc = RDoc::RDoc.new
@rdoc.store = @store
- @rdoc.options = RDoc::Options.new
+ @rdoc.options = @options
@rdoc.generator = Object.new
diff --git a/test/rdoc/test_rdoc_any_method.rb b/test/rdoc/test_rdoc_any_method.rb
index 4ea554a129..1dbd33bd51 100644
--- a/test/rdoc/test_rdoc_any_method.rb
+++ b/test/rdoc/test_rdoc_any_method.rb
@@ -180,7 +180,7 @@ def test_markup_code_with_line_numbers
B
EXPECTED
- @options.line_numbers = true
+ @c2_a.options.line_numbers = true
assert_equal <<-EXPECTED.chomp, @c2_a.markup_code
1 A
diff --git a/test/rdoc/test_rdoc_class_module.rb b/test/rdoc/test_rdoc_class_module.rb
index ee82116e90..cdfe3b9b59 100644
--- a/test/rdoc/test_rdoc_class_module.rb
+++ b/test/rdoc/test_rdoc_class_module.rb
@@ -791,7 +791,7 @@ def test_merge_constants
const = cm1.add_constant RDoc::Constant.new('C3', nil, 'one')
const.record_location tl1
- store = RDoc::Store.new
+ store = RDoc::Store.new(RDoc::Options.new)
tl = store.add_file 'one.rb'
cm2 = tl.add_class RDoc::ClassModule, 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
@@ -826,7 +826,7 @@ def test_merge_constants_version_0
const = cm1.add_constant RDoc::Constant.new('C3', nil, 'one')
const.record_location tl1
- store = RDoc::Store.new
+ store = RDoc::Store.new(RDoc::Options.new)
tl = store.add_file 'one.rb'
cm2 = tl.add_class RDoc::ClassModule, 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
@@ -859,7 +859,7 @@ def test_merge_extends
ext.record_location tl1
tl2 = @store.add_file 'two.rb'
- tl2.store = RDoc::Store.new
+ tl2.store = RDoc::Store.new(RDoc::Options.new)
cm2 = tl2.add_class RDoc::ClassModule, 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
@@ -895,7 +895,7 @@ def test_merge_includes
incl.record_location tl1
tl2 = @store.add_file 'two.rb'
- tl2.store = RDoc::Store.new
+ tl2.store = RDoc::Store.new(RDoc::Options.new)
cm2 = tl2.add_class RDoc::ClassModule, 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
@@ -931,7 +931,7 @@ def test_merge_includes_version_0
incl.record_location tl1
tl2 = @store.add_file 'one.rb'
- tl2.store = RDoc::Store.new
+ tl2.store = RDoc::Store.new(RDoc::Options.new)
cm2 = tl2.add_class RDoc::ClassModule, 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
@@ -1034,7 +1034,7 @@ def test_merge_sections
cm1.add_section 'section 2', comment('comment 2 a', tl1_1)
cm1.add_section 'section 4', comment('comment 4 a', tl1_1)
- store2 = RDoc::Store.new
+ store2 = RDoc::Store.new(RDoc::Options.new)
tl2_1 = store2.add_file 'one.rb'
tl2_2 = store2.add_file 'two.rb'
@@ -1086,7 +1086,7 @@ def test_merge_sections_overlap
cm1.add_section 'section', comment('comment 1 a', tl1_1)
cm1.add_section 'section', comment('comment 3', tl1_3)
- store2 = RDoc::Store.new
+ store2 = RDoc::Store.new(RDoc::Options.new)
tl2_1 = store2.add_file 'one.rb'
tl2_2 = store2.add_file 'two.rb'
tl2_3 = store2.add_file 'three.rb'
@@ -1382,7 +1382,7 @@ def test_update_aliases_reparent
end
def test_update_aliases_reparent_root
- store = RDoc::Store.new
+ store = RDoc::Store.new(RDoc::Options.new)
top_level = store.add_file 'file.rb'
diff --git a/test/rdoc/test_rdoc_code_object.rb b/test/rdoc/test_rdoc_code_object.rb
index 99aaa71038..6d0cbc5cd4 100644
--- a/test/rdoc/test_rdoc_code_object.rb
+++ b/test/rdoc/test_rdoc_code_object.rb
@@ -275,14 +275,6 @@ def test_metadata
assert_equal 'not_rdoc', @co.metadata['markup']
end
- def test_options
- assert_kind_of RDoc::Options, @co.options
-
- @co.store = @store
-
- assert_same @options, @co.options
- end
-
def test_parent_file_name
assert_equal '(unknown)', @co.parent_file_name
assert_equal 'xref_data.rb', @c1.parent_file_name
diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb
index 840fc261b3..ef8dbdca6a 100644
--- a/test/rdoc/test_rdoc_context.rb
+++ b/test/rdoc/test_rdoc_context.rb
@@ -290,7 +290,7 @@ def test_add_module_alias
end
def test_add_module_alias_top_level
- store = RDoc::Store.new
+ store = RDoc::Store.new(RDoc::Options.new)
top_level = store.add_file 'file.rb'
diff --git a/test/rdoc/test_rdoc_generator_ri.rb b/test/rdoc/test_rdoc_generator_ri.rb
index 195c0d2482..d453631470 100644
--- a/test/rdoc/test_rdoc_generator_ri.rb
+++ b/test/rdoc/test_rdoc_generator_ri.rb
@@ -52,7 +52,7 @@ def test_generate
assert_file File.join(@tmpdir, 'Object', 'method-i.ri')
assert_file File.join(@tmpdir, 'Object', 'method%21-i.ri')
- store = RDoc::RI::Store.new @tmpdir
+ store = RDoc::RI::Store.new(@options, path: @tmpdir)
store.load_cache
encoding = Encoding::UTF_8
diff --git a/test/rdoc/test_rdoc_method_attr.rb b/test/rdoc/test_rdoc_method_attr.rb
index 29ccc3372c..18d5a905e2 100644
--- a/test/rdoc/test_rdoc_method_attr.rb
+++ b/test/rdoc/test_rdoc_method_attr.rb
@@ -185,8 +185,7 @@ def test_equals2
def test_pretty_print
temp_dir do |tmpdir|
- s = RDoc::RI::Store.new tmpdir
- s.rdoc = @rdoc
+ s = RDoc::RI::Store.new(RDoc::Options.new, path: tmpdir)
top_level = s.add_file 'file.rb'
meth_bang = RDoc::AnyMethod.new nil, 'method!'
diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb
index 2041908d8a..050f92274f 100644
--- a/test/rdoc/test_rdoc_rdoc.rb
+++ b/test/rdoc/test_rdoc_rdoc.rb
@@ -7,7 +7,8 @@ def setup
super
@rdoc = RDoc::RDoc.new
- @rdoc.options = RDoc::Options.new
+ @options = RDoc::Options.new
+ @rdoc.options = @options
@stats = RDoc::Stats.new @store, 0, 0
@rdoc.instance_variable_set :@stats, @stats
@@ -244,7 +245,7 @@ def test_normalized_file_list_with_skipping_tests_disabled
end
def test_parse_file
- @rdoc.store = RDoc::Store.new
+ @rdoc.store = RDoc::Store.new(@options)
temp_dir do |dir|
@rdoc.options.root = Pathname(Dir.pwd)
@@ -261,7 +262,7 @@ def test_parse_file
end
def test_parse_file_binary
- @rdoc.store = RDoc::Store.new
+ @rdoc.store = RDoc::Store.new(@options)
root = File.dirname __FILE__
@@ -278,7 +279,7 @@ def test_parse_file_binary
end
def test_parse_file_include_root
- @rdoc.store = RDoc::Store.new
+ @rdoc.store = RDoc::Store.new(@options)
test_path = File.expand_path('..', __FILE__)
top_level = nil
@@ -300,7 +301,7 @@ def test_parse_file_include_root
end
def test_parse_file_page_dir
- @rdoc.store = RDoc::Store.new
+ @rdoc.store = RDoc::Store.new(@options)
temp_dir do |dir|
FileUtils.mkdir 'pages'
@@ -321,7 +322,7 @@ def test_parse_file_page_dir
def test_parse_file_relative
pwd = Dir.pwd
- @rdoc.store = RDoc::Store.new
+ @rdoc.store = RDoc::Store.new(@options)
temp_dir do |dir|
@rdoc.options.root = Pathname(dir)
@@ -343,7 +344,7 @@ def test_parse_file_relative
def test_parse_file_encoding
@rdoc.options.encoding = Encoding::ISO_8859_1
- @rdoc.store = RDoc::Store.new
+ @rdoc.store = RDoc::Store.new(@options)
tf = Tempfile.open 'test.txt' do |io|
io.write 'hi'
@@ -361,7 +362,7 @@ def test_parse_file_forbidden
omit 'chmod not supported' if Gem.win_platform?
omit "assumes that euid is not root" if Process.euid == 0
- @rdoc.store = RDoc::Store.new
+ @rdoc.store = RDoc::Store.new(@options)
tf = Tempfile.open 'test.txt' do |io|
io.write 'hi'
diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb
index 1a347233c0..e35cb0f77c 100644
--- a/test/rdoc/test_rdoc_ri_driver.rb
+++ b/test/rdoc/test_rdoc_ri_driver.rb
@@ -23,6 +23,7 @@ def setup
@options[:home] = @rdoc_home
@options[:use_stdout] = true
@options[:formatter] = @RM::ToRdoc
+ @rdoc_options = RDoc::Options.new
@driver = RDoc::RI::Driver.new @options
end
@@ -460,7 +461,7 @@ def test_ancestors_of_chained_inclusion
#
# Y is not chosen randomly, it has to be after Object in the alphabet
# to reproduce https://github.com/ruby/rdoc/issues/814.
- store = RDoc::RI::Store.new @home_ri
+ store = RDoc::RI::Store.new(@rdoc_options, path: @home_ri)
store.cache[:ancestors] = { "Z" => ["Object", "Y"], "Y" => ["X"] }
store.cache[:modules] = %W[X Y Z]
@driver.stores = [store]
@@ -538,7 +539,7 @@ def test_class_document
end
def test_complete
- store = RDoc::RI::Store.new @home_ri
+ store = RDoc::RI::Store.new(@rdoc_options, path: @home_ri)
store.cache[:ancestors] = {
'Foo' => %w[Object],
'Foo::Bar' => %w[Object],
@@ -963,7 +964,7 @@ def test_expand_class
end
def test_expand_class_2
- @store1 = RDoc::RI::Store.new @home_ri, :home
+ @store1 = RDoc::RI::Store.new(@rdoc_options, path: @home_ri, type: :home)
@top_level = @store1.add_file 'file.rb'
@@ -981,7 +982,7 @@ def test_expand_class_2
end
def test_expand_class_3
- @store1 = RDoc::RI::Store.new @home_ri, :home
+ @store1 = RDoc::RI::Store.new(@rdoc_options, path: @home_ri, type: :home)
@top_level = @store1.add_file 'file.rb'
@@ -1007,7 +1008,7 @@ def test_expand_name
assert_equal 'Z', e.name
- @driver.stores << RDoc::Store.new(nil, :system)
+ @driver.stores << RDoc::Store.new(@rdoc_options, type: :system)
assert_equal 'ruby:README', @driver.expand_name('ruby:README')
assert_equal 'ruby:', @driver.expand_name('ruby:')
@@ -1084,8 +1085,8 @@ def test_filter_methods_not_found
end
def test_find_store
- @driver.stores << RDoc::Store.new(nil, :system)
- @driver.stores << RDoc::Store.new('doc/gem-1.0/ri', :gem)
+ @driver.stores << RDoc::Store.new(@rdoc_options, type: :system)
+ @driver.stores << RDoc::Store.new(@rdoc_options, path: 'doc/gem-1.0/ri', type: :gem)
assert_equal 'ruby', @driver.find_store('ruby')
assert_equal 'gem-1.0', @driver.find_store('gem-1.0')
@@ -1466,7 +1467,7 @@ def test_setup_pager # this test doesn't do anything anymore :(
end
def util_ancestors_store
- store1 = RDoc::RI::Store.new @home_ri
+ store1 = RDoc::RI::Store.new(@rdoc_options, path: @home_ri)
store1.cache[:ancestors] = {
'Foo' => %w[Object],
'Foo::Bar' => %w[Foo],
@@ -1483,7 +1484,7 @@ def util_ancestors_store
Foo::Bar
]
- store2 = RDoc::RI::Store.new @home_ri
+ store2 = RDoc::RI::Store.new(@rdoc_options, path: @home_ri)
store2.cache[:ancestors] = {
'Foo' => %w[Mixin Object],
'Mixin' => %w[],
@@ -1514,7 +1515,7 @@ def util_multi_store
util_store
@home_ri2 = "#{@home_ri}2"
- @store2 = RDoc::RI::Store.new @home_ri2
+ @store2 = RDoc::RI::Store.new(@rdoc_options, path: @home_ri2)
@top_level = @store2.add_file 'file.rb'
@@ -1539,7 +1540,7 @@ def util_multi_store
end
def util_store
- @store1 = RDoc::RI::Store.new @home_ri, :home
+ @store1 = RDoc::RI::Store.new(@rdoc_options, path: @home_ri, type: :home)
@top_level = @store1.add_file 'file.rb'
diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb
index b16f8e3385..ccb86c2a2c 100644
--- a/test/rdoc/test_rdoc_rubygems_hook.rb
+++ b/test/rdoc/test_rdoc_rubygems_hook.rb
@@ -94,7 +94,7 @@ def test_document
options.files = []
rdoc = @hook.new_rdoc
- rdoc.store = RDoc::Store.new
+ rdoc.store = RDoc::Store.new(options)
@hook.instance_variable_set :@rdoc, rdoc
@hook.instance_variable_set :@file_info, []
diff --git a/test/rdoc/test_rdoc_servlet.rb b/test/rdoc/test_rdoc_servlet.rb
index a6faf84827..c5c68923ac 100644
--- a/test/rdoc/test_rdoc_servlet.rb
+++ b/test/rdoc/test_rdoc_servlet.rb
@@ -45,6 +45,7 @@ def @req.path= path
@system_dir = File.join @tempdir, 'base', 'system'
@home_dir = File.join @tempdir, 'home'
@gem_doc_dir = File.join @tempdir, 'doc'
+ @options = RDoc::Options.new
@orig_base = RDoc::RI::Paths::BASE
RDoc::RI::Paths::BASE.replace @base
@@ -199,7 +200,7 @@ def test_do_GET_root_search
end
def test_documentation_page_class
- store = RDoc::Store.new
+ store = RDoc::Store.new(@options)
generator = @s.generator_for store
@@ -214,7 +215,7 @@ def test_documentation_page_class
end
def test_documentation_page_not_found
- store = RDoc::Store.new
+ store = RDoc::Store.new(@options)
generator = @s.generator_for store
@@ -226,7 +227,7 @@ def test_documentation_page_not_found
end
def test_documentation_page_page
- store = RDoc::Store.new
+ store = RDoc::Store.new(@options)
generator = @s.generator_for store
@@ -239,7 +240,7 @@ def test_documentation_page_page
end
def test_documentation_page_page_with_nesting
- store = RDoc::Store.new
+ store = RDoc::Store.new(@options)
generator = @s.generator_for store
@@ -259,7 +260,7 @@ def test_documentation_source
end
def test_documentation_source_cached
- cached_store = RDoc::Store.new
+ cached_store = RDoc::Store.new(@options)
@stores['ruby'] = cached_store
@@ -282,7 +283,7 @@ def test_error
end
def test_generator_for
- store = RDoc::Store.new
+ store = RDoc::Store.new(@options)
store.main = 'MAIN_PAGE.rdoc'
store.title = 'Title'
@@ -349,7 +350,7 @@ def test_installed_docs
end
def test_not_found
- generator = @s.generator_for RDoc::Store.new
+ generator = @s.generator_for RDoc::Store.new(@options)
@req.path = '/ruby/Missing.html'
@@ -361,7 +362,7 @@ def test_not_found
end
def test_not_found_message
- generator = @s.generator_for RDoc::Store.new
+ generator = @s.generator_for RDoc::Store.new(@options)
@req.path = '/ruby/Missing.html'
@@ -532,7 +533,7 @@ def test_store_for_extra
end
def touch_system_cache_path
- store = RDoc::Store.new @system_dir
+ store = RDoc::Store.new(@options, path: @system_dir)
store.title = 'Standard Library Documentation'
FileUtils.mkdir_p File.dirname store.cache_path
@@ -541,7 +542,7 @@ def touch_system_cache_path
end
def touch_extra_cache_path
- store = RDoc::Store.new @extra_dirs.first
+ store = RDoc::Store.new(@options, path: @extra_dirs.first)
store.title = 'My Extra Documentation'
FileUtils.mkdir_p File.dirname store.cache_path
diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb
index 68892f5810..16a9d5d40c 100644
--- a/test/rdoc/test_rdoc_store.rb
+++ b/test/rdoc/test_rdoc_store.rb
@@ -9,8 +9,7 @@ def setup
super
@tmpdir = File.join Dir.tmpdir, "test_rdoc_ri_store_#{$$}"
- @s = RDoc::RI::Store.new @tmpdir
- @s.rdoc = @rdoc
+ @s = RDoc::RI::Store.new(RDoc::Options.new, path: @tmpdir)
@top_level = @s.add_file 'file.rb'
@@ -91,7 +90,7 @@ def assert_cache imethods, cmethods, attrs, modules,
:class_methods => cmethods,
:c_class_variables => {},
:c_singleton_class_variables => {},
- :encoding => nil,
+ :encoding => Encoding::UTF_8,
:instance_methods => imethods,
:modules => modules,
:pages => pages,
@@ -397,7 +396,7 @@ def test_load_all
@s.save
- s = RDoc::Store.new @tmpdir
+ s = RDoc::Store.new(RDoc::Options.new, path: @tmpdir)
s.load_all
@@ -448,6 +447,10 @@ def test_load_cache
Marshal.dump cache, io
end
+ # Store prioritize @encoding over the cached value
+ # See we need to unset @encoding to test the cached value
+ @s.encoding = nil
+
@s.load_cache
assert_equal cache, @s.cache
@@ -498,7 +501,7 @@ def test_load_cache_no_cache
:class_methods => {},
:c_class_variables => {},
:c_singleton_class_variables => {},
- :encoding => nil,
+ :encoding => Encoding::UTF_8,
:instance_methods => {},
:main => nil,
:modules => [],
@@ -531,6 +534,10 @@ def test_load_cache_legacy
Marshal.dump cache, io
end
+ # Store prioritize @encoding over the cached value
+ # See we need to unset @encoding to test the cached value
+ @s.encoding = nil
+
@s.load_cache
expected = {
@@ -686,7 +693,7 @@ def test_save
},
:main => nil,
:modules => %w[Mod Object Object::SubClass],
- :encoding => nil,
+ :encoding => Encoding::UTF_8,
:pages => %w[README.txt],
:title => nil,
}
@@ -838,13 +845,13 @@ def test_save_class_delete
meth.record_location @top_level
# load original, save newly updated class
- @s = RDoc::RI::Store.new @tmpdir
+ @s = RDoc::RI::Store.new(RDoc::Options.new, path: @tmpdir)
@s.load_cache
@s.save_class klass
@s.save_cache
# load from disk again
- @s = RDoc::RI::Store.new @tmpdir
+ @s = RDoc::RI::Store.new(RDoc::Options.new, path: @tmpdir)
@s.load_cache
@s.load_class 'Object'
@@ -882,7 +889,7 @@ def test_save_class_loaded
assert_file @s.method_file(@klass.full_name, @meth.full_name)
assert_file @s.method_file(@klass.full_name, @meth_bang.full_name)
- s = RDoc::Store.new @s.path
+ s = RDoc::Store.new(RDoc::Options.new, path: @s.path)
s.load_cache
loaded = s.load_class 'Object'
@@ -891,7 +898,7 @@ def test_save_class_loaded
s.save_class loaded
- s = RDoc::Store.new @s.path
+ s = RDoc::Store.new(RDoc::Options.new, path: @s.path)
s.load_cache
reloaded = s.load_class 'Object'
@@ -911,10 +918,10 @@ def test_save_class_merge
klass = RDoc::NormalClass.new 'Object'
klass.add_comment 'new comment', @top_level
- s = RDoc::RI::Store.new @tmpdir
+ s = RDoc::RI::Store.new(RDoc::Options.new, path: @tmpdir)
s.save_class klass
- s = RDoc::RI::Store.new @tmpdir
+ s = RDoc::RI::Store.new(RDoc::Options.new, path: @tmpdir)
inner = @RM::Document.new @RM::Paragraph.new 'new comment'
inner.file = @top_level
@@ -926,7 +933,7 @@ def test_save_class_merge
# This is a functional test
def test_save_class_merge_constant
- store = RDoc::Store.new
+ store = RDoc::Store.new(RDoc::Options.new)
tl = store.add_file 'file.rb'
klass = tl.add_class RDoc::NormalClass, 'C'
@@ -938,16 +945,16 @@ def test_save_class_merge_constant
@s.save_class klass
# separate parse run, independent store
- store = RDoc::Store.new
+ store = RDoc::Store.new(RDoc::Options.new)
tl = store.add_file 'file.rb'
klass2 = tl.add_class RDoc::NormalClass, 'C'
klass2.record_location tl
- s = RDoc::RI::Store.new @tmpdir
+ s = RDoc::RI::Store.new(RDoc::Options.new, path: @tmpdir)
s.save_class klass2
# separate `ri` run, independent store
- s = RDoc::RI::Store.new @tmpdir
+ s = RDoc::RI::Store.new(RDoc::Options.new, path: @tmpdir)
result = s.load_class 'C'