bri 0.5.0 → 1.0.0.pre.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog +0 -2
- data/TODO +2 -3
- data/bin/bri +21 -8
- data/lib/bri/mall.rb +12 -17
- data/lib/bri/match/base.rb +2 -7
- data/lib/bri/match/class.rb +6 -3
- data/lib/bri/match/method.rb +3 -3
- data/lib/bri/renderer/blank_line.rb +9 -0
- data/lib/bri/renderer/default.rb +27 -0
- data/lib/bri/renderer/document.rb +11 -0
- data/lib/bri/renderer/heading.rb +9 -0
- data/lib/bri/renderer/list/base.rb +18 -0
- data/lib/bri/renderer/list/bullet.rb +15 -0
- data/lib/bri/renderer/list/labeled.rb +15 -0
- data/lib/bri/renderer/list/lower_lettered.rb +18 -0
- data/lib/bri/renderer/list/note.rb +15 -0
- data/lib/bri/renderer/list/numbered.rb +18 -0
- data/lib/bri/renderer/list/upper_lettered.rb +18 -0
- data/lib/bri/renderer/list.rb +24 -0
- data/lib/bri/renderer/list_item.rb +24 -0
- data/lib/bri/renderer/paragraph.rb +11 -0
- data/lib/bri/renderer/result.rb +73 -0
- data/lib/bri/renderer/rule.rb +9 -0
- data/lib/bri/renderer/verbatim.rb +14 -0
- data/lib/bri/renderer.rb +28 -188
- data/lib/bri/search/class.rb +3 -1
- data/lib/bri/search/method.rb +3 -3
- data/lib/bri/templates.rb +7 -38
- data/lib/bri/text_formatting_utils.rb +92 -0
- data/lib/bri.rb +18 -15
- metadata +27 -17
- data/spec/bri_dummy_spec_class.rb +0 -132
- data/spec/lib/bri/mall_spec.rb +0 -38
- data/spec/lib/bri/match/class_spec.rb +0 -125
- data/spec/lib/bri/match/method_spec.rb +0 -116
- data/spec/lib/bri/matcher_spec.rb +0 -70
- data/spec/lib/bri/renderer_spec.rb +0 -338
- data/spec/lib/bri/search/class_method_spec.rb +0 -173
- data/spec/lib/bri/search/class_spec.rb +0 -66
- data/spec/lib/bri/search/instance_method_spec.rb +0 -174
- data/spec/lib/bri/search/method_spec.rb +0 -41
- data/spec/spec_helper.rb +0 -22
@@ -1,174 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Bri::Search::InstanceMethod do
|
4
|
-
context "the searches" do
|
5
|
-
let( :paragraph ) { RDoc::Markup::Paragraph.new( "Foo Description" ) }
|
6
|
-
let( :document ) { double( RDoc::Markup::Document, :parts => [ paragraph ] ) }
|
7
|
-
let( :comment ) { double( RDoc::Comment, :instance_variable_get => document ) }
|
8
|
-
let( :rdoc_method ) { double( RDoc::AnyMethod, :full_name => "Foo",
|
9
|
-
:arglists => "",
|
10
|
-
:comment => comment ) }
|
11
|
-
before( :each ) do
|
12
|
-
store_one = double( RDoc::RI::Store, :load_cache => true,
|
13
|
-
:load_class => true,
|
14
|
-
:load_method => rdoc_method,
|
15
|
-
:friendly_path => "ruby core",
|
16
|
-
:modules => %w{ ClassThree },
|
17
|
-
:instance_methods => { "ClassThree" => [ "method" ] } )
|
18
|
-
store_two = double( RDoc::RI::Store, :load_cache => true,
|
19
|
-
:load_class => true,
|
20
|
-
:load_method => rdoc_method,
|
21
|
-
:friendly_path => "ruby core",
|
22
|
-
:modules => %w{ ClassOne ClassTwo },
|
23
|
-
:instance_methods => { "ClassOne" => [ "method" ],
|
24
|
-
"ClassTwo" => [ "method", "my_other_method" ] } )
|
25
|
-
allow(Bri::Mall.instance).to receive(:stores).and_return( [ store_one, store_two ] )
|
26
|
-
allow(Bri::Match::Class).to receive( :new ).and_return( double( Bri::Match::Class ) )
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "a fully qualified search" do
|
30
|
-
context "if there are no matching methods in any store" do
|
31
|
-
subject { Bri::Search::InstanceMethod.new( "I::Dont::Exist#go_away" ) }
|
32
|
-
it "should have no matches" do
|
33
|
-
subject.search( :fully_qualified )
|
34
|
-
subject.matches.should == []
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context "if there are matching methods in the stores" do
|
39
|
-
subject { Bri::Search::InstanceMethod.new( "ClassOne#method" ) }
|
40
|
-
it "should have a match for each method" do
|
41
|
-
subject.search( :fully_qualified )
|
42
|
-
subject.matches.size.should == 1
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "a partially qualified search" do
|
48
|
-
context "if there are no matching methods in any store" do
|
49
|
-
subject { Bri::Search::InstanceMethod.new( "#go_away" ) }
|
50
|
-
it "should have no matches" do
|
51
|
-
subject.search( :partially_qualified )
|
52
|
-
subject.matches.should == []
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "if there are matching methods in the stores" do
|
57
|
-
subject { Bri::Search::InstanceMethod.new( "#method" ) }
|
58
|
-
it "should have a match for each method" do
|
59
|
-
subject.search( :partially_qualified )
|
60
|
-
subject.matches.size.should == 3
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "an unqualified search" do
|
66
|
-
context "if there are no matching methods in any store" do
|
67
|
-
subject { Bri::Search::InstanceMethod.new( "go_away" ) }
|
68
|
-
it "should have no matches" do
|
69
|
-
subject.search( :unqualified )
|
70
|
-
subject.matches.should == []
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context "if there are matching methods in the stores" do
|
75
|
-
context "if there are matching methods, where the match starts at the beginning of the method name" do
|
76
|
-
subject { Bri::Search::InstanceMethod.new( "method" ) }
|
77
|
-
it "should have a match for each method" do
|
78
|
-
subject.search( :unqualified )
|
79
|
-
subject.matches.size.should == 3
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context "if there are matching methods, but none where the match starts at the beginning of the method name" do
|
84
|
-
subject { Bri::Search::InstanceMethod.new( "other" ) }
|
85
|
-
it "should have a match for each method" do
|
86
|
-
subject.search( :unqualified )
|
87
|
-
subject.matches.size.should == 1
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "real searches going through rdoc" do
|
95
|
-
context "a fully qualified search" do
|
96
|
-
context "with no matching methods" do
|
97
|
-
it "should have no matches" do
|
98
|
-
search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#i_dont_exist" )
|
99
|
-
search_instance.search( :fully_qualified )
|
100
|
-
search_instance.matches.should be_empty
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context "with a matching method" do
|
105
|
-
it "should have a match" do
|
106
|
-
search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#bri_dummy_spec_instance_method" )
|
107
|
-
search_instance.search( :fully_qualified )
|
108
|
-
search_instance.matches.should_not be_empty
|
109
|
-
search_instance.matches.first.full_name.should == "BriDummySpecClass#bri_dummy_spec_instance_method"
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
context "a partially qualified search" do
|
115
|
-
context "with no matching methods" do
|
116
|
-
it "should have no matches" do
|
117
|
-
search_instance = Bri::Search::InstanceMethod.new( "#i_dont_exist" )
|
118
|
-
search_instance.search( :partially_qualified )
|
119
|
-
search_instance.matches.should be_empty
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
context "with one matching method" do
|
124
|
-
it "should have one match" do
|
125
|
-
search_instance = Bri::Search::InstanceMethod.new( "#bri_dummy_spec_instance_method" )
|
126
|
-
search_instance.search( :partially_qualified )
|
127
|
-
search_instance.matches.should_not be_empty
|
128
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method" }.should be(true)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
context "with multiple matching methods" do
|
133
|
-
it "should have all matches" do
|
134
|
-
search_instance = Bri::Search::InstanceMethod.new( "#bri_dummy_spec_instance_method_with_arguments" )
|
135
|
-
search_instance.search( :partially_qualified )
|
136
|
-
search_instance.matches.should_not be_empty
|
137
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method_with_arguments" }.should be(true)
|
138
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClassTwo#bri_dummy_spec_instance_method_with_arguments" }.should be(true)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
context "an unqualified search" do
|
144
|
-
context "with no matching methods" do
|
145
|
-
it "should have no matches" do
|
146
|
-
search_instance = Bri::Search::InstanceMethod.new( "i_dont_exist_go_away" )
|
147
|
-
search_instance.search( :unqualified )
|
148
|
-
search_instance.matches.should be_empty
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
context "with one matching method" do
|
153
|
-
it "should have one match" do
|
154
|
-
search_instance = Bri::Search::InstanceMethod.new( "bri_dummy_spec_instance_method" )
|
155
|
-
search_instance.search( :unqualified )
|
156
|
-
search_instance.matches.should_not be_empty
|
157
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method" }.should be(true)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
context "with multiple matching methods" do
|
162
|
-
it "should have all matches" do
|
163
|
-
search_instance = Bri::Search::InstanceMethod.new( "bri_dummy_spec" )
|
164
|
-
search_instance.search( :unqualified )
|
165
|
-
search_instance.matches.should_not be_empty
|
166
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method" }.should be(true)
|
167
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method_with_arguments" }.should be(true)
|
168
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClassTwo#bri_dummy_spec_instance_method_with_arguments" }.should be(true)
|
169
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method_with_default_arguments" }.should be(true)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Bri::Search::Method do
|
4
|
-
describe "#initialize" do
|
5
|
-
context "the searchterm is a class" do
|
6
|
-
subject { Bri::Search::Method.new( "Class" ) }
|
7
|
-
its( :class_term ) { should == "Class" }
|
8
|
-
its( :method_term ) { should be_nil }
|
9
|
-
end
|
10
|
-
|
11
|
-
context "the search term is a fully qualified class method" do
|
12
|
-
subject { Bri::Search::Method.new( "Class.method" ) }
|
13
|
-
its( :class_term ) { should == "Class" }
|
14
|
-
its( :method_term ) { should == "method" }
|
15
|
-
end
|
16
|
-
|
17
|
-
context "the search term is a fully qualified instance method" do
|
18
|
-
subject { Bri::Search::Method.new( "Class#method" ) }
|
19
|
-
its( :class_term ) { should == "Class" }
|
20
|
-
its( :method_term ) { should == "method" }
|
21
|
-
end
|
22
|
-
|
23
|
-
context "the search term begins with a ." do
|
24
|
-
subject { Bri::Search::Method.new( ".method" ) }
|
25
|
-
its( :class_term ) { should be_nil }
|
26
|
-
its( :method_term ) { should == "method" }
|
27
|
-
end
|
28
|
-
|
29
|
-
context "the search term begins with a #" do
|
30
|
-
subject { Bri::Search::Method.new( "#method" ) }
|
31
|
-
its( :class_term ) { should be_nil }
|
32
|
-
its( :method_term ) { should == "method" }
|
33
|
-
end
|
34
|
-
|
35
|
-
context "the search term is not a class and does not contain a . or #" do
|
36
|
-
subject { Bri::Search::Method.new( "method" ) }
|
37
|
-
its( :class_term ) { should be_nil }
|
38
|
-
its( :method_term ) { should == "method" }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'rspec/its'
|
2
|
-
require 'byebug'
|
3
|
-
require_relative '../lib/bri'
|
4
|
-
|
5
|
-
RSpec.configure do |config|
|
6
|
-
config.mock_with :rspec do |mocks|
|
7
|
-
mocks.syntax = [ :should, :expect ]
|
8
|
-
end
|
9
|
-
|
10
|
-
config.expect_with :rspec do |expect|
|
11
|
-
expect.syntax = [ :should, :expect ]
|
12
|
-
end
|
13
|
-
|
14
|
-
config.order = :random
|
15
|
-
Kernel.srand config.seed
|
16
|
-
end
|
17
|
-
|
18
|
-
RSpec::Expectations.configuration.on_potential_false_positives = :nothing
|
19
|
-
|
20
|
-
puts "Regenerating ri document cache"
|
21
|
-
class_file = File.join( __dir__, 'bri_dummy_spec_class.rb' )
|
22
|
-
%x{rdoc --ri #{class_file}}
|