bri 0.4.4 → 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/TODO +2 -3
- data/bin/bri +21 -7
- data/lib/bri.rb +18 -15
- data/lib/bri/mall.rb +12 -14
- data/lib/bri/match/base.rb +1 -1
- data/lib/bri/match/class.rb +5 -1
- data/lib/bri/match/method.rb +2 -1
- data/lib/bri/renderer.rb +28 -188
- 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.rb +24 -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_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/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
- metadata +19 -12
- 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 -112
- 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 -172
- data/spec/lib/bri/search/class_spec.rb +0 -66
- data/spec/lib/bri/search/instance_method_spec.rb +0 -173
- data/spec/lib/bri/search/method_spec.rb +0 -41
- data/spec/spec_helper.rb +0 -22
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Bri::Search::Class do
|
4
|
-
describe "#initialize" do
|
5
|
-
context "for an empty search" do
|
6
|
-
subject { Bri::Search::Class.new( "term" ) }
|
7
|
-
its( :term ) { should == "term" }
|
8
|
-
its( :matches ) { should be_empty }
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
describe "#search" do
|
14
|
-
context "basic functionality" do
|
15
|
-
before( :each ) do
|
16
|
-
store_one = double( RDoc::Store, :load_cache => true,
|
17
|
-
:load_class => true,
|
18
|
-
:friendly_path => "ruby core",
|
19
|
-
:module_names => %w{ ClassThree } )
|
20
|
-
store_two = double( RDoc::Store, :load_cache => true,
|
21
|
-
:load_class => true,
|
22
|
-
:friendly_path => "ruby core",
|
23
|
-
:module_names => %w{ ClassOne ClassTwo } )
|
24
|
-
allow(Bri::Mall.instance).to receive( :stores ).and_return( [ store_one, store_two ] )
|
25
|
-
allow(Bri::Match::Class).to receive( :new ).and_return( double( Bri::Match::Class ) )
|
26
|
-
end
|
27
|
-
|
28
|
-
context "if there are no matching modules in any store" do
|
29
|
-
subject { Bri::Search::Class.new( "I::Dont::Exist" ) }
|
30
|
-
it "should have no matches" do
|
31
|
-
subject.search
|
32
|
-
subject.matches.should == []
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "if there is a matching module in the stores" do
|
37
|
-
subject { Bri::Search::Class.new( "ClassOne" ) }
|
38
|
-
it "should have a match for each name" do
|
39
|
-
subject.search
|
40
|
-
subject.matches.size.should == 1
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "for the type :fully_qualified" do
|
46
|
-
context "when searching for the class BriDummySpecClass" do
|
47
|
-
subject { Bri::Search::Class.new( "BriDummySpecClass" ) }
|
48
|
-
|
49
|
-
it "should have matches" do
|
50
|
-
subject.search
|
51
|
-
subject.matches.should_not be_empty
|
52
|
-
subject.matches.any?{ |match| match.name == "BriDummySpecClass < Object" }.should be(true)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "when searching for the class IAmQuiteCertainIDontExist" do
|
57
|
-
subject { Bri::Search::Class.new( "IAmQuiteCertainIDontExist" ) }
|
58
|
-
|
59
|
-
it "should not have any matches" do
|
60
|
-
subject.search
|
61
|
-
subject.matches.any? { |match| match.name == "IAmQuiteCertainIDontExist" }.should be(false)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,173 +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( :rdoc_method ) { double( RDoc::AnyMethod, :full_name => "Foo",
|
8
|
-
:arglists => "",
|
9
|
-
:comment => document ) }
|
10
|
-
before( :each ) do
|
11
|
-
store_one = double( RDoc::RI::Store, :load_cache => true,
|
12
|
-
:load_class => true,
|
13
|
-
:load_method => rdoc_method,
|
14
|
-
:friendly_path => "ruby core",
|
15
|
-
:modules => %w{ ClassThree },
|
16
|
-
:instance_methods => { "ClassThree" => [ "method" ] } )
|
17
|
-
store_two = double( RDoc::RI::Store, :load_cache => true,
|
18
|
-
:load_class => true,
|
19
|
-
:load_method => rdoc_method,
|
20
|
-
:friendly_path => "ruby core",
|
21
|
-
:modules => %w{ ClassOne ClassTwo },
|
22
|
-
:instance_methods => { "ClassOne" => [ "method" ],
|
23
|
-
"ClassTwo" => [ "method", "my_other_method" ] } )
|
24
|
-
allow(Bri::Mall.instance).to receive(:stores).and_return( [ store_one, store_two ] )
|
25
|
-
allow(Bri::Match::Class).to receive( :new ).and_return( double( Bri::Match::Class ) )
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "a fully qualified search" do
|
29
|
-
context "if there are no matching methods in any store" do
|
30
|
-
subject { Bri::Search::InstanceMethod.new( "I::Dont::Exist#go_away" ) }
|
31
|
-
it "should have no matches" do
|
32
|
-
subject.search( :fully_qualified )
|
33
|
-
subject.matches.should == []
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "if there are matching methods in the stores" do
|
38
|
-
subject { Bri::Search::InstanceMethod.new( "ClassOne#method" ) }
|
39
|
-
it "should have a match for each method" do
|
40
|
-
subject.search( :fully_qualified )
|
41
|
-
subject.matches.size.should == 1
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "a partially qualified search" do
|
47
|
-
context "if there are no matching methods in any store" do
|
48
|
-
subject { Bri::Search::InstanceMethod.new( "#go_away" ) }
|
49
|
-
it "should have no matches" do
|
50
|
-
subject.search( :partially_qualified )
|
51
|
-
subject.matches.should == []
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "if there are matching methods in the stores" do
|
56
|
-
subject { Bri::Search::InstanceMethod.new( "#method" ) }
|
57
|
-
it "should have a match for each method" do
|
58
|
-
subject.search( :partially_qualified )
|
59
|
-
subject.matches.size.should == 3
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "an unqualified search" do
|
65
|
-
context "if there are no matching methods in any store" do
|
66
|
-
subject { Bri::Search::InstanceMethod.new( "go_away" ) }
|
67
|
-
it "should have no matches" do
|
68
|
-
subject.search( :unqualified )
|
69
|
-
subject.matches.should == []
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context "if there are matching methods in the stores" do
|
74
|
-
context "if there are matching methods, where the match starts at the beginning of the method name" do
|
75
|
-
subject { Bri::Search::InstanceMethod.new( "method" ) }
|
76
|
-
it "should have a match for each method" do
|
77
|
-
subject.search( :unqualified )
|
78
|
-
subject.matches.size.should == 3
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context "if there are matching methods, but none where the match starts at the beginning of the method name" do
|
83
|
-
subject { Bri::Search::InstanceMethod.new( "other" ) }
|
84
|
-
it "should have a match for each method" do
|
85
|
-
subject.search( :unqualified )
|
86
|
-
subject.matches.size.should == 1
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
context "real searches going through rdoc" do
|
94
|
-
context "a fully qualified search" do
|
95
|
-
context "with no matching methods" do
|
96
|
-
it "should have no matches" do
|
97
|
-
search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#i_dont_exist" )
|
98
|
-
search_instance.search( :fully_qualified )
|
99
|
-
search_instance.matches.should be_empty
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
context "with a matching method" do
|
104
|
-
it "should have a match" do
|
105
|
-
search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#bri_dummy_spec_instance_method" )
|
106
|
-
search_instance.search( :fully_qualified )
|
107
|
-
search_instance.matches.should_not be_empty
|
108
|
-
search_instance.matches.first.full_name.should == "BriDummySpecClass#bri_dummy_spec_instance_method"
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context "a partially qualified search" do
|
114
|
-
context "with no matching methods" do
|
115
|
-
it "should have no matches" do
|
116
|
-
search_instance = Bri::Search::InstanceMethod.new( "#i_dont_exist" )
|
117
|
-
search_instance.search( :partially_qualified )
|
118
|
-
search_instance.matches.should be_empty
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
context "with one matching method" do
|
123
|
-
it "should have one match" do
|
124
|
-
search_instance = Bri::Search::InstanceMethod.new( "#bri_dummy_spec_instance_method" )
|
125
|
-
search_instance.search( :partially_qualified )
|
126
|
-
search_instance.matches.should_not be_empty
|
127
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method" }.should be(true)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
context "with multiple matching methods" do
|
132
|
-
it "should have all matches" do
|
133
|
-
search_instance = Bri::Search::InstanceMethod.new( "#bri_dummy_spec_instance_method_with_arguments" )
|
134
|
-
search_instance.search( :partially_qualified )
|
135
|
-
search_instance.matches.should_not be_empty
|
136
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method_with_arguments" }.should be(true)
|
137
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClassTwo#bri_dummy_spec_instance_method_with_arguments" }.should be(true)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
context "an unqualified search" do
|
143
|
-
context "with no matching methods" do
|
144
|
-
it "should have no matches" do
|
145
|
-
search_instance = Bri::Search::InstanceMethod.new( "i_dont_exist_go_away" )
|
146
|
-
search_instance.search( :unqualified )
|
147
|
-
search_instance.matches.should be_empty
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
context "with one matching method" do
|
152
|
-
it "should have one match" do
|
153
|
-
search_instance = Bri::Search::InstanceMethod.new( "bri_dummy_spec_instance_method" )
|
154
|
-
search_instance.search( :unqualified )
|
155
|
-
search_instance.matches.should_not be_empty
|
156
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method" }.should be(true)
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
context "with multiple matching methods" do
|
161
|
-
it "should have all matches" do
|
162
|
-
search_instance = Bri::Search::InstanceMethod.new( "bri_dummy_spec" )
|
163
|
-
search_instance.search( :unqualified )
|
164
|
-
search_instance.matches.should_not be_empty
|
165
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method" }.should be(true)
|
166
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method_with_arguments" }.should be(true)
|
167
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClassTwo#bri_dummy_spec_instance_method_with_arguments" }.should be(true)
|
168
|
-
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method_with_default_arguments" }.should be(true)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
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}}
|