yard 0.8.7.6 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yard might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/LICENSE +2 -2
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/bin/yard +0 -0
- data/bin/yardoc +0 -0
- data/bin/yri +0 -0
- data/docs/GettingStarted.md +88 -6
- data/docs/images/handlers-class-diagram.png +0 -0
- data/docs/images/overview-class-diagram.png +0 -0
- data/docs/images/parser-class-diagram.png +0 -0
- data/docs/templates/default/fulldoc/html/full_list_tag.erb +6 -4
- data/lib/yard/autoload.rb +3 -0
- data/lib/yard/cli/yardoc.rb +1 -1
- data/lib/yard/code_objects/base.rb +4 -1
- data/lib/yard/code_objects/extra_file_object.rb +3 -1
- data/lib/yard/code_objects/proxy.rb +2 -2
- data/lib/yard/docstring.rb +11 -6
- data/lib/yard/handlers/base.rb +1 -2
- data/lib/yard/handlers/c/base.rb +19 -0
- data/lib/yard/handlers/c/handler_methods.rb +42 -8
- data/lib/yard/handlers/c/init_handler.rb +1 -1
- data/lib/yard/handlers/c/method_handler.rb +3 -3
- data/lib/yard/handlers/ruby/decorator_handler_methods.rb +132 -0
- data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +1 -1
- data/lib/yard/handlers/ruby/private_class_method_handler.rb +6 -39
- data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -30
- data/lib/yard/handlers/ruby/public_class_method_handler.rb +13 -0
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +1 -0
- data/lib/yard/handlers/ruby/visibility_handler.rb +5 -8
- data/lib/yard/logging.rb +1 -0
- data/lib/yard/parser/ruby/ruby_parser.rb +2 -2
- data/lib/yard/parser/source_parser.rb +6 -6
- data/lib/yard/rake/yardoc_task.rb +2 -2
- data/lib/yard/serializers/file_system_serializer.rb +33 -1
- data/lib/yard/server/commands/display_file_command.rb +8 -3
- data/lib/yard/server/commands/display_object_command.rb +7 -3
- data/lib/yard/server/doc_server_helper.rb +2 -8
- data/lib/yard/server/doc_server_serializer.rb +2 -4
- data/lib/yard/server/router.rb +1 -1
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +57 -8
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -10
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +1 -2
- data/lib/yard/server/templates/default/method_details/html/permalink.erb +3 -3
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +4 -4
- data/lib/yard/tags/directives.rb +1 -0
- data/lib/yard/tags/library.rb +9 -7
- data/lib/yard/tags/overload_tag.rb +4 -1
- data/lib/yard/templates/helpers/html_helper.rb +4 -3
- data/lib/yard/templates/template_options.rb +3 -0
- data/lib/yard/version.rb +1 -1
- data/spec/cli/command_parser_spec.rb +14 -14
- data/spec/cli/command_spec.rb +11 -11
- data/spec/cli/config_spec.rb +32 -32
- data/spec/cli/diff_spec.rb +86 -90
- data/spec/cli/display_spec.rb +6 -6
- data/spec/cli/gems_spec.rb +28 -28
- data/spec/cli/graph_spec.rb +8 -8
- data/spec/cli/help_spec.rb +8 -8
- data/spec/cli/i18n_spec.rb +33 -37
- data/spec/cli/list_spec.rb +2 -2
- data/spec/cli/markup_types_spec.rb +3 -3
- data/spec/cli/server_spec.rb +74 -88
- data/spec/cli/stats_spec.rb +14 -14
- data/spec/cli/yardoc_spec.rb +316 -321
- data/spec/cli/yri_spec.rb +45 -45
- data/spec/code_objects/base_spec.rb +174 -173
- data/spec/code_objects/class_object_spec.rb +65 -65
- data/spec/code_objects/code_object_list_spec.rb +13 -11
- data/spec/code_objects/constants_spec.rb +68 -58
- data/spec/code_objects/extra_file_object_spec.rb +71 -59
- data/spec/code_objects/macro_object_spec.rb +64 -64
- data/spec/code_objects/method_object_spec.rb +80 -72
- data/spec/code_objects/module_object_spec.rb +47 -47
- data/spec/code_objects/namespace_object_spec.rb +51 -51
- data/spec/code_objects/proxy_spec.rb +54 -54
- data/spec/config_spec.rb +104 -104
- data/spec/core_ext/array_spec.rb +5 -5
- data/spec/core_ext/file_spec.rb +33 -33
- data/spec/core_ext/hash_spec.rb +5 -5
- data/spec/core_ext/insertion_spec.rb +18 -18
- data/spec/core_ext/module_spec.rb +6 -6
- data/spec/core_ext/string_spec.rb +17 -17
- data/spec/core_ext/symbol_hash_spec.rb +42 -39
- data/spec/docstring_parser_spec.rb +65 -65
- data/spec/docstring_spec.rb +137 -130
- data/spec/handlers/alias_handler_spec.rb +39 -39
- data/spec/handlers/attribute_handler_spec.rb +35 -35
- data/spec/handlers/base_spec.rb +60 -51
- data/spec/handlers/c/alias_handler_spec.rb +6 -6
- data/spec/handlers/c/attribute_handler_spec.rb +12 -12
- data/spec/handlers/c/class_handler_spec.rb +35 -22
- data/spec/handlers/c/constant_handler_spec.rb +24 -22
- data/spec/handlers/c/init_handler_spec.rb +10 -10
- data/spec/handlers/c/method_handler_spec.rb +150 -65
- data/spec/handlers/c/mixin_handler_spec.rb +5 -5
- data/spec/handlers/c/module_handler_spec.rb +27 -15
- data/spec/handlers/c/override_comment_handler_spec.rb +14 -14
- data/spec/handlers/c/path_handler_spec.rb +8 -8
- data/spec/handlers/c/spec_helper.rb +10 -0
- data/spec/handlers/c/struct_handler_spec.rb +3 -3
- data/spec/handlers/class_condition_handler_spec.rb +18 -18
- data/spec/handlers/class_handler_spec.rb +97 -97
- data/spec/handlers/class_method_handler_shared_examples.rb +132 -0
- data/spec/handlers/class_variable_handler_spec.rb +3 -3
- data/spec/handlers/constant_handler_spec.rb +32 -29
- data/spec/handlers/decorator_handler_methods_spec.rb +405 -0
- data/spec/handlers/dsl_handler_spec.rb +108 -109
- data/spec/handlers/examples/constant_handler_001.rb.txt +4 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
- data/spec/handlers/exception_handler_spec.rb +23 -23
- data/spec/handlers/extend_handler_spec.rb +9 -9
- data/spec/handlers/legacy_base_spec.rb +60 -60
- data/spec/handlers/method_condition_handler_spec.rb +5 -5
- data/spec/handlers/method_handler_spec.rb +92 -92
- data/spec/handlers/mixin_handler_spec.rb +25 -25
- data/spec/handlers/module_function_handler_spec.rb +24 -24
- data/spec/handlers/module_handler_spec.rb +15 -15
- data/spec/handlers/private_class_method_handler_spec.rb +4 -48
- data/spec/handlers/private_constant_handler_spec.rb +8 -8
- data/spec/handlers/processor_spec.rb +12 -12
- data/spec/handlers/public_class_method_handler_spec.rb +10 -0
- data/spec/handlers/ruby/base_spec.rb +16 -16
- data/spec/handlers/ruby/legacy/base_spec.rb +20 -18
- data/spec/handlers/spec_helper.rb +1 -1
- data/spec/handlers/visibility_handler_spec.rb +25 -21
- data/spec/handlers/yield_handler_spec.rb +28 -28
- data/spec/i18n/locale_spec.rb +16 -16
- data/spec/i18n/message_spec.rb +8 -8
- data/spec/i18n/messages_spec.rb +14 -14
- data/spec/i18n/pot_generator_spec.rb +32 -32
- data/spec/i18n/text_spec.rb +22 -22
- data/spec/logging_spec.rb +12 -12
- data/spec/options_spec.rb +56 -56
- data/spec/parser/base_spec.rb +9 -9
- data/spec/parser/c_parser_spec.rb +50 -50
- data/spec/parser/ruby/ast_node_spec.rb +7 -7
- data/spec/parser/ruby/legacy/statement_list_spec.rb +106 -106
- data/spec/parser/ruby/legacy/token_list_spec.rb +27 -27
- data/spec/parser/ruby/ruby_parser_spec.rb +123 -113
- data/spec/parser/source_parser_spec.rb +224 -224
- data/spec/parser/tag_parsing_spec.rb +6 -7
- data/spec/rake/yardoc_task_spec.rb +38 -48
- data/spec/registry_spec.rb +143 -143
- data/spec/registry_store_spec.rb +165 -165
- data/spec/rubygems/doc_manager_spec.rb +38 -38
- data/spec/serializers/file_system_serializer_spec.rb +53 -33
- data/spec/serializers/yardoc_serializer_spec.rb +15 -15
- data/spec/server/adapter_spec.rb +15 -15
- data/spec/server/commands/base_spec.rb +29 -29
- data/spec/server/commands/library_command_spec.rb +12 -12
- data/spec/server/commands/static_file_command_spec.rb +28 -28
- data/spec/server/doc_server_helper_spec.rb +8 -8
- data/spec/server/doc_server_serializer_spec.rb +23 -18
- data/spec/server/rack_adapter_spec.rb +6 -6
- data/spec/server/router_spec.rb +39 -39
- data/spec/server/static_caching_spec.rb +16 -16
- data/spec/server/webrick_servlet_spec.rb +6 -7
- data/spec/server_spec.rb +3 -3
- data/spec/spec_helper.rb +11 -2
- data/spec/tags/default_factory_spec.rb +64 -64
- data/spec/tags/default_tag_spec.rb +5 -5
- data/spec/tags/directives_spec.rb +121 -121
- data/spec/tags/library_spec.rb +14 -14
- data/spec/tags/overload_tag_spec.rb +24 -24
- data/spec/tags/ref_tag_list_spec.rb +12 -12
- data/spec/templates/class_spec.rb +3 -3
- data/spec/templates/constant_spec.rb +4 -4
- data/spec/templates/engine_spec.rb +47 -48
- data/spec/templates/examples/class001.html +129 -101
- data/spec/templates/examples/class002.html +31 -27
- data/spec/templates/examples/method001.html +54 -47
- data/spec/templates/examples/method002.html +33 -28
- data/spec/templates/examples/method003.html +70 -64
- data/spec/templates/examples/method004.html +13 -9
- data/spec/templates/examples/method005.html +38 -32
- data/spec/templates/examples/module001.html +343 -339
- data/spec/templates/examples/module002.html +147 -124
- data/spec/templates/examples/module003.html +94 -81
- data/spec/templates/examples/module004.html +40 -33
- data/spec/templates/helpers/base_helper_spec.rb +91 -95
- data/spec/templates/helpers/html_helper_spec.rb +276 -279
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +16 -15
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +27 -34
- data/spec/templates/helpers/markup_helper_spec.rb +57 -57
- data/spec/templates/helpers/method_helper_spec.rb +20 -20
- data/spec/templates/helpers/shared_signature_examples.rb +33 -31
- data/spec/templates/helpers/text_helper_spec.rb +6 -6
- data/spec/templates/method_spec.rb +7 -7
- data/spec/templates/module_spec.rb +7 -7
- data/spec/templates/onefile_spec.rb +7 -7
- data/spec/templates/section_spec.rb +66 -69
- data/spec/templates/spec_helper.rb +1 -1
- data/spec/templates/tag_spec.rb +5 -5
- data/spec/templates/template_spec.rb +158 -158
- data/spec/verifier_spec.rb +52 -52
- data/templates/default/fulldoc/html/css/full_list.css +32 -31
- data/templates/default/fulldoc/html/css/style.css +212 -77
- data/templates/default/fulldoc/html/frames.erb +6 -15
- data/templates/default/fulldoc/html/full_list.erb +14 -21
- data/templates/default/fulldoc/html/full_list_class.erb +1 -1
- data/templates/default/fulldoc/html/full_list_file.erb +6 -4
- data/templates/default/fulldoc/html/full_list_method.erb +8 -6
- data/templates/default/fulldoc/html/js/app.js +100 -76
- data/templates/default/fulldoc/html/js/full_list.js +170 -135
- data/templates/default/fulldoc/html/setup.rb +50 -7
- data/templates/default/layout/html/breadcrumb.erb +0 -2
- data/templates/default/layout/html/headers.erb +2 -1
- data/templates/default/layout/html/layout.erb +16 -10
- data/templates/default/layout/html/script_setup.erb +1 -2
- data/templates/default/layout/html/search.erb +7 -2
- data/templates/default/layout/html/setup.rb +16 -0
- data/templates/default/method/html/header.erb +7 -6
- data/templates/default/module/html/attribute_summary.erb +1 -1
- data/templates/default/module/html/box_info.erb +24 -18
- data/templates/default/module/html/constant_summary.erb +9 -11
- data/templates/default/module/html/item_summary.erb +1 -1
- data/templates/default/module/html/method_summary.erb +1 -1
- data/templates/guide/fulldoc/html/setup.rb +1 -1
- data/yard.gemspec +1 -2
- metadata +10 -7
- data/spec/handlers/examples/private_class_method_handler_001.rb.txt +0 -9
- data/spec/handlers/examples/private_class_method_handler_002.rb.txt +0 -18
- data/spec/handlers/examples/private_class_method_handler_003.rb.txt +0 -11
data/spec/registry_store_spec.rb
CHANGED
@@ -7,105 +7,105 @@ describe YARD::RegistryStore do
|
|
7
7
|
@serializer = Serializers::YardocSerializer.new('foo')
|
8
8
|
@foo = CodeObjects::MethodObject.new(nil, :foo)
|
9
9
|
@bar = CodeObjects::ClassObject.new(nil, :Bar)
|
10
|
-
Serializers::YardocSerializer.
|
10
|
+
allow(Serializers::YardocSerializer).to receive(:new).and_return(@serializer)
|
11
11
|
end
|
12
12
|
|
13
|
-
describe
|
14
|
-
it "
|
15
|
-
File.
|
16
|
-
File.
|
17
|
-
File.
|
18
|
-
File.
|
19
|
-
@serializer.
|
20
|
-
@store.load('foo').
|
21
|
-
@store.root.
|
22
|
-
@store.get('A').
|
13
|
+
describe "#load" do
|
14
|
+
it "loads root.dat as full object list if it is a Hash" do
|
15
|
+
expect(File).to receive(:directory?).with('foo').and_return(true)
|
16
|
+
expect(File).to receive(:file?).with('foo/checksums').and_return(false)
|
17
|
+
expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
|
18
|
+
expect(File).to receive(:file?).with('foo/object_types').and_return(false)
|
19
|
+
expect(@serializer).to receive(:deserialize).with('root').and_return({:root => @foo, :A => @bar})
|
20
|
+
expect(@store.load('foo')).to be true
|
21
|
+
expect(@store.root).to eq @foo
|
22
|
+
expect(@store.get('A')).to eq @bar
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
26
|
-
File.
|
27
|
-
File.
|
28
|
-
File.
|
29
|
-
Marshal.
|
25
|
+
it "loads old yardoc format if .yardoc is a file" do
|
26
|
+
expect(File).to receive(:directory?).with('foo').and_return(false)
|
27
|
+
expect(File).to receive(:file?).with('foo').and_return(true)
|
28
|
+
expect(File).to receive(:read_binary).with('foo').and_return('FOO')
|
29
|
+
expect(Marshal).to receive(:load).with('FOO')
|
30
30
|
|
31
31
|
@store.load('foo')
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
35
|
-
File.
|
36
|
-
File.
|
37
|
-
File.
|
38
|
-
File.
|
39
|
-
File.
|
34
|
+
it "loads new yardoc format if .yardoc is a directory" do
|
35
|
+
expect(File).to receive(:directory?).with('foo').and_return(true)
|
36
|
+
expect(File).to receive(:file?).with('foo/checksums').and_return(false)
|
37
|
+
expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
|
38
|
+
expect(File).to receive(:file?).with('foo/object_types').and_return(false)
|
39
|
+
expect(File).to receive(:file?).with('foo/objects/root.dat').and_return(false)
|
40
40
|
|
41
|
-
@store.load('foo').
|
41
|
+
expect(@store.load('foo')).to be true
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
45
|
-
File.
|
46
|
-
File.
|
47
|
-
File.
|
48
|
-
@store.load('myyardoc').
|
44
|
+
it "returns true if .yardoc is loaded (file)" do
|
45
|
+
expect(File).to receive(:directory?).with('myyardoc').and_return(false)
|
46
|
+
expect(File).to receive(:file?).with('myyardoc').and_return(true)
|
47
|
+
expect(File).to receive(:read_binary).with('myyardoc').and_return(Marshal.dump(''))
|
48
|
+
expect(@store.load('myyardoc')).to be true
|
49
49
|
end
|
50
50
|
|
51
|
-
it "
|
52
|
-
File.
|
53
|
-
File.
|
54
|
-
File.
|
55
|
-
File.
|
56
|
-
File.
|
57
|
-
@store.load('foo').
|
51
|
+
it "returns true if .yardoc is loaded (directory)" do
|
52
|
+
expect(File).to receive(:directory?).with('foo').and_return(true)
|
53
|
+
expect(File).to receive(:file?).with('foo/checksums').and_return(false)
|
54
|
+
expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
|
55
|
+
expect(File).to receive(:file?).with('foo/object_types').and_return(false)
|
56
|
+
expect(File).to receive(:file?).with('foo/objects/root.dat').and_return(false)
|
57
|
+
expect(@store.load('foo')).to be true
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
61
|
-
@store.load('NONEXIST').
|
60
|
+
it "returns false if .yardoc does not exist" do
|
61
|
+
expect(@store.load('NONEXIST')).to be false
|
62
62
|
end
|
63
63
|
|
64
|
-
it "
|
65
|
-
@store.load(nil).
|
64
|
+
it "returns false if there is no file to load" do
|
65
|
+
expect(@store.load(nil)).to be false
|
66
66
|
end
|
67
67
|
|
68
|
-
it "
|
69
|
-
File.
|
70
|
-
File.
|
71
|
-
File.
|
72
|
-
File.
|
73
|
-
File.
|
74
|
-
File.
|
68
|
+
it "loads checksums if they exist" do
|
69
|
+
expect(File).to receive(:directory?).with('foo').and_return(true)
|
70
|
+
expect(File).to receive(:file?).with('foo/checksums').and_return(true)
|
71
|
+
expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
|
72
|
+
expect(File).to receive(:file?).with('foo/objects/root.dat').and_return(false)
|
73
|
+
expect(File).to receive(:file?).with('foo/object_types').and_return(false)
|
74
|
+
expect(File).to receive(:readlines).with('foo/checksums').and_return([
|
75
75
|
'file1 CHECKSUM1', ' file2 CHECKSUM2 '
|
76
76
|
])
|
77
|
-
@store.load('foo').
|
78
|
-
@store.checksums.
|
79
|
-
end
|
80
|
-
|
81
|
-
it "
|
82
|
-
File.
|
83
|
-
File.
|
84
|
-
File.
|
85
|
-
File.
|
86
|
-
File.
|
87
|
-
File.
|
88
|
-
@store.load('foo').
|
89
|
-
@store.proxy_types.
|
90
|
-
end
|
91
|
-
|
92
|
-
it "
|
93
|
-
File.
|
94
|
-
File.
|
95
|
-
File.
|
96
|
-
File.
|
97
|
-
File.
|
98
|
-
File.
|
99
|
-
@store.load('foo').
|
100
|
-
@store.root.
|
77
|
+
expect(@store.load('foo')).to be true
|
78
|
+
expect(@store.checksums).to eq({'file1' => 'CHECKSUM1', 'file2' => 'CHECKSUM2'})
|
79
|
+
end
|
80
|
+
|
81
|
+
it "loads proxy_types if they exist" do
|
82
|
+
expect(File).to receive(:directory?).with('foo').and_return(true)
|
83
|
+
expect(File).to receive(:file?).with('foo/checksums').and_return(false)
|
84
|
+
expect(File).to receive(:file?).with('foo/proxy_types').and_return(true)
|
85
|
+
expect(File).to receive(:file?).with('foo/object_types').and_return(false)
|
86
|
+
expect(File).to receive(:file?).with('foo/objects/root.dat').and_return(false)
|
87
|
+
expect(File).to receive(:read_binary).with('foo/proxy_types').and_return(Marshal.dump({'a' => 'b'}))
|
88
|
+
expect(@store.load('foo')).to be true
|
89
|
+
expect(@store.proxy_types).to eq({'a' => 'b'})
|
90
|
+
end
|
91
|
+
|
92
|
+
it "loads root object if it exists" do
|
93
|
+
expect(File).to receive(:directory?).with('foo').and_return(true)
|
94
|
+
expect(File).to receive(:file?).with('foo/checksums').and_return(false)
|
95
|
+
expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
|
96
|
+
expect(File).to receive(:file?).with('foo/object_types').and_return(false)
|
97
|
+
expect(File).to receive(:file?).with('foo/objects/root.dat').and_return(true)
|
98
|
+
expect(File).to receive(:read_binary).with('foo/objects/root.dat').and_return(Marshal.dump(@foo))
|
99
|
+
expect(@store.load('foo')).to be true
|
100
|
+
expect(@store.root).to eq @foo
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
describe
|
104
|
+
describe "#save" do
|
105
105
|
before do
|
106
|
-
@store.
|
107
|
-
@store.
|
108
|
-
@store.
|
106
|
+
allow(@store).to receive(:write_proxy_types)
|
107
|
+
allow(@store).to receive(:write_checksums)
|
108
|
+
allow(@store).to receive(:destroy)
|
109
109
|
end
|
110
110
|
|
111
111
|
after do
|
@@ -113,7 +113,7 @@ describe YARD::RegistryStore do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def saves_to_singledb
|
116
|
-
@serializer.
|
116
|
+
expect(@serializer).to receive(:serialize).once.with(instance_of(Hash))
|
117
117
|
@store.save(true, 'foo')
|
118
118
|
end
|
119
119
|
|
@@ -123,24 +123,24 @@ describe YARD::RegistryStore do
|
|
123
123
|
|
124
124
|
def saves_to_multidb
|
125
125
|
times = @store.keys.size
|
126
|
-
@serializer.
|
126
|
+
expect(@serializer).to receive(:serialize).exactly(times).times
|
127
127
|
@store.save(true, 'foo')
|
128
128
|
@last = times
|
129
129
|
end
|
130
130
|
|
131
|
-
it "
|
131
|
+
it "saves as single object db if single_object_db is nil and there are less than 3000 objects" do
|
132
132
|
Registry.single_object_db = nil
|
133
133
|
add_items(100)
|
134
134
|
saves_to_singledb
|
135
135
|
end
|
136
136
|
|
137
|
-
it "
|
137
|
+
it "saves as single object db if single_object_db is nil and there are more than 3000 objects" do
|
138
138
|
Registry.single_object_db = nil
|
139
139
|
add_items(5000)
|
140
140
|
saves_to_singledb
|
141
141
|
end
|
142
142
|
|
143
|
-
it "
|
143
|
+
it "saves as single object db if single_object_db is true (and any amount of objects)" do
|
144
144
|
Registry.single_object_db = true
|
145
145
|
add_items(100)
|
146
146
|
saves_to_singledb
|
@@ -148,7 +148,7 @@ describe YARD::RegistryStore do
|
|
148
148
|
saves_to_singledb
|
149
149
|
end
|
150
150
|
|
151
|
-
it "
|
151
|
+
it "never saves as single object db if single_object_db is false" do
|
152
152
|
Registry.single_object_db = false
|
153
153
|
add_items(100)
|
154
154
|
saves_to_multidb
|
@@ -157,159 +157,159 @@ describe YARD::RegistryStore do
|
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
-
describe
|
161
|
-
it "
|
160
|
+
describe "#put" do
|
161
|
+
it "assigns values" do
|
162
162
|
@store.put(:YARD, @foo)
|
163
|
-
@store.get(:YARD).
|
163
|
+
expect(@store.get(:YARD)).to eq @foo
|
164
164
|
end
|
165
165
|
|
166
|
-
it "
|
166
|
+
it "treats '' as root" do
|
167
167
|
@store.put('', @foo)
|
168
|
-
@store.get(:root).
|
168
|
+
expect(@store.get(:root)).to eq @foo
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
-
describe
|
173
|
-
it "
|
172
|
+
describe "#get" do
|
173
|
+
it "hits cache if object exists" do
|
174
174
|
@store.put(:YARD, @foo)
|
175
|
-
@store.get(:YARD).
|
175
|
+
expect(@store.get(:YARD)).to eq @foo
|
176
176
|
end
|
177
177
|
|
178
|
-
it "
|
179
|
-
serializer =
|
180
|
-
serializer.
|
178
|
+
it "hits backstore on cache miss and cache is not fully loaded" do
|
179
|
+
serializer = double(:serializer)
|
180
|
+
expect(serializer).to receive(:deserialize).once.with(:YARD).and_return(@foo)
|
181
181
|
@store.load('foo')
|
182
182
|
@store.instance_variable_set("@loaded_objects", 0)
|
183
183
|
@store.instance_variable_set("@available_objects", 100)
|
184
184
|
@store.instance_variable_set("@serializer", serializer)
|
185
|
-
@store.get(:YARD).
|
186
|
-
@store.get(:YARD).
|
187
|
-
@store.instance_variable_get("@loaded_objects").
|
185
|
+
expect(@store.get(:YARD)).to eq @foo
|
186
|
+
expect(@store.get(:YARD)).to eq @foo
|
187
|
+
expect(@store.instance_variable_get("@loaded_objects")).to eq 1
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
191
|
[:keys, :values].each do |item|
|
192
192
|
describe "##{item}" do
|
193
|
-
it "
|
194
|
-
File.
|
193
|
+
it "loads entire database if reload=true" do
|
194
|
+
expect(File).to receive(:directory?).with('foo').and_return(true)
|
195
195
|
@store.load('foo')
|
196
|
-
@store.
|
196
|
+
expect(@store).to receive(:load_all)
|
197
197
|
@store.send(item, true)
|
198
198
|
end
|
199
199
|
|
200
|
-
it "
|
201
|
-
File.
|
200
|
+
it "does not load entire database if reload=false" do
|
201
|
+
expect(File).to receive(:directory?).with('foo').and_return(true)
|
202
202
|
@store.load('foo')
|
203
|
-
@store.
|
203
|
+
expect(@store).not_to receive(:load_all)
|
204
204
|
@store.send(item, false)
|
205
205
|
end
|
206
206
|
end
|
207
207
|
end
|
208
208
|
|
209
|
-
describe
|
209
|
+
describe "#paths_for_type" do
|
210
210
|
after { Registry.clear }
|
211
211
|
|
212
|
-
it "
|
213
|
-
File.
|
214
|
-
File.
|
215
|
-
File.
|
216
|
-
File.
|
217
|
-
@serializer.
|
212
|
+
it "sets all object types if not set by object_types" do
|
213
|
+
expect(File).to receive(:directory?).with('foo').and_return(true)
|
214
|
+
expect(File).to receive(:file?).with('foo/checksums').and_return(false)
|
215
|
+
expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
|
216
|
+
expect(File).to receive(:file?).with('foo/object_types').and_return(false)
|
217
|
+
expect(@serializer).to receive(:deserialize).with('root').and_return({:'A#foo' => @foo, :A => @bar})
|
218
218
|
@store.load('foo')
|
219
|
-
@store.paths_for_type(:method).
|
220
|
-
@store.paths_for_type(:class).
|
219
|
+
expect(@store.paths_for_type(:method)).to eq ['#foo']
|
220
|
+
expect(@store.paths_for_type(:class)).to eq ['Bar']
|
221
221
|
end
|
222
222
|
|
223
|
-
it "
|
223
|
+
it "keeps track of types when assigning values" do
|
224
224
|
@store.put(:abc, @foo)
|
225
|
-
@store.paths_for_type(@foo.type).
|
225
|
+
expect(@store.paths_for_type(@foo.type)).to eq ['abc']
|
226
226
|
end
|
227
227
|
|
228
|
-
it "
|
228
|
+
it "reassigns path if type changes" do
|
229
229
|
foo = CodeObjects::ClassObject.new(:root, :Foo)
|
230
230
|
@store.put('Foo', foo)
|
231
|
-
@store.get('Foo').type.
|
232
|
-
@store.paths_for_type(:class).
|
231
|
+
expect(@store.get('Foo').type).to eq :class
|
232
|
+
expect(@store.paths_for_type(:class)).to eq ["Foo"]
|
233
233
|
foo = CodeObjects::ModuleObject.new(:root, :Foo)
|
234
234
|
@store.put('Foo', foo)
|
235
|
-
@store.get('Foo').type.
|
236
|
-
@store.paths_for_type(:class).
|
237
|
-
@store.paths_for_type(:module).
|
235
|
+
expect(@store.get('Foo').type).to eq :module
|
236
|
+
expect(@store.paths_for_type(:class)).to eq []
|
237
|
+
expect(@store.paths_for_type(:module)).to eq ["Foo"]
|
238
238
|
end
|
239
239
|
end
|
240
240
|
|
241
|
-
describe
|
242
|
-
it "
|
241
|
+
describe "#values_for_type" do
|
242
|
+
it "returns all objects with type" do
|
243
243
|
@store.put(:abc, @foo)
|
244
|
-
@store.values_for_type(@foo.type).
|
244
|
+
expect(@store.values_for_type(@foo.type)).to eq [@foo]
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
248
|
-
describe
|
249
|
-
it "
|
250
|
-
foomock =
|
251
|
-
barmock =
|
252
|
-
foomock.
|
253
|
-
barmock.
|
254
|
-
foomock.
|
255
|
-
barmock.
|
256
|
-
File.
|
257
|
-
File.
|
258
|
-
File.
|
259
|
-
File.
|
260
|
-
File.
|
261
|
-
@store.
|
248
|
+
describe "#load_all" do
|
249
|
+
it "loads the entire database" do
|
250
|
+
foomock = double(:Foo)
|
251
|
+
barmock = double(:Bar)
|
252
|
+
allow(foomock).to receive(:type).and_return(:class)
|
253
|
+
allow(barmock).to receive(:type).and_return(:class)
|
254
|
+
expect(foomock).to receive(:path).and_return('Foo')
|
255
|
+
expect(barmock).to receive(:path).and_return('Bar')
|
256
|
+
expect(File).to receive(:directory?).with('foo').and_return(true)
|
257
|
+
expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
|
258
|
+
expect(File).to receive(:file?).with('foo/object_types').and_return(false)
|
259
|
+
expect(File).to receive(:file?).with('foo/checksums').and_return(false)
|
260
|
+
expect(File).to receive(:file?).with('foo/objects/root.dat').and_return(false)
|
261
|
+
expect(@store).to receive(:all_disk_objects).at_least(1).times.and_return(['foo/objects/foo', 'foo/objects/bar'])
|
262
262
|
@store.load('foo')
|
263
263
|
serializer = @store.instance_variable_get("@serializer")
|
264
|
-
serializer.
|
265
|
-
serializer.
|
264
|
+
expect(serializer).to receive(:deserialize).with('foo/objects/foo', true).and_return(foomock)
|
265
|
+
expect(serializer).to receive(:deserialize).with('foo/objects/bar', true).and_return(barmock)
|
266
266
|
@store.send(:load_all)
|
267
|
-
@store.instance_variable_get("@available_objects").
|
268
|
-
@store.instance_variable_get("@loaded_objects").
|
269
|
-
@store[:Foo].
|
270
|
-
@store[:Bar].
|
267
|
+
expect(@store.instance_variable_get("@available_objects")).to eq 2
|
268
|
+
expect(@store.instance_variable_get("@loaded_objects")).to eq 2
|
269
|
+
expect(@store[:Foo]).to eq foomock
|
270
|
+
expect(@store[:Bar]).to eq barmock
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
|
-
describe
|
275
|
-
it "
|
276
|
-
File.
|
277
|
-
File.
|
274
|
+
describe "#destroy" do
|
275
|
+
it "destroys file ending in .yardoc when force=false" do
|
276
|
+
expect(File).to receive(:file?).with('foo.yardoc').and_return(true)
|
277
|
+
expect(File).to receive(:unlink).with('foo.yardoc')
|
278
278
|
@store.instance_variable_set("@file", 'foo.yardoc')
|
279
|
-
@store.destroy.
|
279
|
+
expect(@store.destroy).to be true
|
280
280
|
end
|
281
281
|
|
282
|
-
it "
|
283
|
-
File.
|
284
|
-
FileUtils.
|
282
|
+
it "destroys dir ending in .yardoc when force=false" do
|
283
|
+
expect(File).to receive(:directory?).with('foo.yardoc').and_return(true)
|
284
|
+
expect(FileUtils).to receive(:rm_rf).with('foo.yardoc')
|
285
285
|
@store.instance_variable_set("@file", 'foo.yardoc')
|
286
|
-
@store.destroy.
|
286
|
+
expect(@store.destroy).to be true
|
287
287
|
end
|
288
288
|
|
289
|
-
it "
|
290
|
-
File.
|
291
|
-
File.
|
292
|
-
File.
|
293
|
-
FileUtils.
|
289
|
+
it "does not destroy file/dir not ending in .yardoc when force=false" do
|
290
|
+
expect(File).not_to receive(:file?).with('foo')
|
291
|
+
expect(File).not_to receive(:directory?).with('foo')
|
292
|
+
expect(File).not_to receive(:unlink).with('foo')
|
293
|
+
expect(FileUtils).not_to receive(:rm_rf).with('foo')
|
294
294
|
@store.instance_variable_set("@file", 'foo')
|
295
|
-
@store.destroy.
|
295
|
+
expect(@store.destroy).to be false
|
296
296
|
end
|
297
297
|
|
298
|
-
it "
|
299
|
-
File.
|
300
|
-
File.
|
298
|
+
it "destroys any file/dir when force=true" do
|
299
|
+
expect(File).to receive(:file?).with('foo').and_return(true)
|
300
|
+
expect(File).to receive(:unlink).with('foo')
|
301
301
|
@store.instance_variable_set("@file", 'foo')
|
302
|
-
@store.destroy(true).
|
302
|
+
expect(@store.destroy(true)).to be true
|
303
303
|
end
|
304
304
|
end
|
305
305
|
|
306
|
-
describe
|
307
|
-
it "
|
306
|
+
describe "#locale" do
|
307
|
+
it "loads ./po/LOCALE_NAME.po" do
|
308
308
|
fr_locale = I18n::Locale.new("fr")
|
309
|
-
I18n::Locale.
|
310
|
-
Registry.
|
311
|
-
fr_locale.
|
312
|
-
@store.locale("fr").
|
309
|
+
expect(I18n::Locale).to receive(:new).with("fr").and_return(fr_locale)
|
310
|
+
expect(Registry).to receive(:po_dir).and_return("po")
|
311
|
+
expect(fr_locale).to receive(:load).with("po")
|
312
|
+
expect(@store.locale("fr")).to eq fr_locale
|
313
313
|
end
|
314
314
|
end
|
315
315
|
end
|