bri 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +14 -0
- data/README +3 -3
- data/TODO +4 -2
- data/bin/bri +2 -1
- data/lib/bri/mall.rb +2 -1
- data/lib/bri/match/class.rb +1 -1
- data/lib/bri/renderer.rb +55 -13
- data/lib/bri/search/class_method.rb +2 -0
- data/lib/bri/search/instance_method.rb +2 -0
- data/lib/bri/search/method.rb +8 -2
- data/lib/bri/templates.rb +1 -1
- data/spec/bri_dummy_spec_class.rb +132 -0
- data/spec/lib/bri/match/class_spec.rb +125 -0
- data/spec/lib/bri/match/method_spec.rb +112 -0
- data/spec/lib/bri/renderer_spec.rb +338 -0
- data/spec/lib/bri/search/{class_method_search_spec.rb → class_method_spec.rb} +80 -0
- data/spec/lib/bri/search/class_spec.rb +52 -19
- data/spec/lib/bri/search/instance_method_spec.rb +81 -0
- data/spec/spec_helper.rb +7 -1
- metadata +8 -6
- data/spec/lib/bri/match/class_match_spec.rb +0 -90
- data/spec/lib/bri/match/method_match_spec.rb +0 -25
@@ -1,32 +1,65 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Bri::Search::Class do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
:modules => %w{ ClassOne ClassTwo } )
|
11
|
-
Bri::Mall.instance.stub!( :stores => [ store_one, store_two ] )
|
12
|
-
Bri::Match::Class.stub!( :new ).and_return( mock( Bri::Match::Class ) )
|
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
|
13
10
|
end
|
14
11
|
|
12
|
+
|
15
13
|
describe "#search" do
|
16
|
-
context "
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
context "basic functionality" do
|
15
|
+
before( :each ) do
|
16
|
+
store_one = mock( RDoc::RI::Store, :load_cache => true,
|
17
|
+
:load_class => true,
|
18
|
+
:modules => %w{ ClassThree } )
|
19
|
+
store_two = mock( RDoc::RI::Store, :load_cache => true,
|
20
|
+
:load_class => true,
|
21
|
+
:modules => %w{ ClassOne ClassTwo } )
|
22
|
+
Bri::Mall.instance.stub!( :stores => [ store_one, store_two ] )
|
23
|
+
Bri::Match::Class.stub!( :new ).and_return( mock( Bri::Match::Class ) )
|
24
|
+
end
|
25
|
+
|
26
|
+
context "if there are no matching modules in any store" do
|
27
|
+
subject { Bri::Search::Class.new( "I::Dont::Exist" ) }
|
28
|
+
it "should have no matches" do
|
29
|
+
subject.search
|
30
|
+
subject.matches.should == []
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "if there is a matching module in the stores" do
|
35
|
+
subject { Bri::Search::Class.new( "ClassOne" ) }
|
36
|
+
it "should have a match for each name" do
|
37
|
+
subject.search
|
38
|
+
subject.matches.size.should == 1
|
39
|
+
end
|
21
40
|
end
|
22
41
|
end
|
23
42
|
|
24
|
-
context "
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
43
|
+
context "for the type :fully_qualified" do
|
44
|
+
context "when searching for the class BriDummySpecClass" do
|
45
|
+
subject { Bri::Search::Class.new( "BriDummySpecClass" ) }
|
46
|
+
|
47
|
+
it "should have matches" do
|
48
|
+
subject.search
|
49
|
+
subject.matches.should_not be_empty
|
50
|
+
subject.matches.any?{ |match| match.name == "BriDummySpecClass" }.should be_true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when searching for the class IAmQuiteCertainIDontExist" do
|
55
|
+
subject { Bri::Search::Class.new( "IAmQuiteCertainIDontExist" ) }
|
56
|
+
|
57
|
+
it "should not have any matches" do
|
58
|
+
subject.search
|
59
|
+
subject.matches.any? { |match| match.name == "IAmQuiteCertainIDontExist" }.should be_false
|
60
|
+
end
|
29
61
|
end
|
30
62
|
end
|
63
|
+
|
31
64
|
end
|
32
65
|
end
|
@@ -87,4 +87,85 @@ describe Bri::Search::InstanceMethod do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
90
|
+
|
91
|
+
context "real searches going through rdoc" do
|
92
|
+
context "a fully qualified search" do
|
93
|
+
context "with no matching methods" do
|
94
|
+
it "should have no matches" do
|
95
|
+
search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#i_dont_exist" )
|
96
|
+
search_instance.search( :fully_qualified )
|
97
|
+
search_instance.matches.should be_empty
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "with a matching method" do
|
102
|
+
it "should have a match" do
|
103
|
+
search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#bri_dummy_spec_instance_method" )
|
104
|
+
search_instance.search( :fully_qualified )
|
105
|
+
search_instance.matches.should_not be_empty
|
106
|
+
search_instance.matches.first.full_name.should == "BriDummySpecClass#bri_dummy_spec_instance_method"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context "a partially qualified search" do
|
112
|
+
context "with no matching methods" do
|
113
|
+
it "should have no matches" do
|
114
|
+
search_instance = Bri::Search::InstanceMethod.new( "#i_dont_exist" )
|
115
|
+
search_instance.search( :partially_qualified )
|
116
|
+
search_instance.matches.should be_empty
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context "with one matching method" do
|
121
|
+
it "should have one match" do
|
122
|
+
search_instance = Bri::Search::InstanceMethod.new( "#bri_dummy_spec_instance_method" )
|
123
|
+
search_instance.search( :partially_qualified )
|
124
|
+
search_instance.matches.should_not be_empty
|
125
|
+
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method" }.should be_true
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context "with multiple matching methods" do
|
130
|
+
it "should have all matches" do
|
131
|
+
search_instance = Bri::Search::InstanceMethod.new( "#bri_dummy_spec_instance_method_with_arguments" )
|
132
|
+
search_instance.search( :partially_qualified )
|
133
|
+
search_instance.matches.should_not be_empty
|
134
|
+
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method_with_arguments" }.should be_true
|
135
|
+
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClassTwo#bri_dummy_spec_instance_method_with_arguments" }.should be_true
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context "an unqualified search" do
|
141
|
+
context "with no matching methods" do
|
142
|
+
it "should have no matches" do
|
143
|
+
search_instance = Bri::Search::InstanceMethod.new( "i_dont_exist_go_away" )
|
144
|
+
search_instance.search( :unqualified )
|
145
|
+
search_instance.matches.should be_empty
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context "with one matching method" do
|
150
|
+
it "should have one match" do
|
151
|
+
search_instance = Bri::Search::InstanceMethod.new( "bri_dummy_spec_instance_method" )
|
152
|
+
search_instance.search( :unqualified )
|
153
|
+
search_instance.matches.should_not be_empty
|
154
|
+
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method" }.should be_true
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context "with multiple matching methods" do
|
159
|
+
it "should have all matches" do
|
160
|
+
search_instance = Bri::Search::InstanceMethod.new( "bri_dummy_spec" )
|
161
|
+
search_instance.search( :unqualified )
|
162
|
+
search_instance.matches.should_not be_empty
|
163
|
+
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method" }.should be_true
|
164
|
+
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method_with_arguments" }.should be_true
|
165
|
+
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClassTwo#bri_dummy_spec_instance_method_with_arguments" }.should be_true
|
166
|
+
search_instance.matches.any? { |match| match.full_name == "BriDummySpecClass#bri_dummy_spec_instance_method_with_default_arguments" }.should be_true
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
90
171
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1 +1,7 @@
|
|
1
|
-
|
1
|
+
spec_root = File.dirname( __FILE__ )
|
2
|
+
require File.join( spec_root, '..', 'lib', 'bri.rb' )
|
3
|
+
|
4
|
+
puts "Regenerating ri document cache"
|
5
|
+
output_path = File.join( spec_root, 'ri' )
|
6
|
+
class_file = File.join( spec_root, 'bri_dummy_spec_class.rb' )
|
7
|
+
%x{rdoc --ri #{class_file}}
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: bri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sven Riedel
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-02-
|
13
|
+
date: 2011-02-20 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -64,12 +64,14 @@ files:
|
|
64
64
|
- lib/bri/templates.rb
|
65
65
|
- lib/bri/renderer.rb
|
66
66
|
- spec/spec_helper.rb
|
67
|
+
- spec/bri_dummy_spec_class.rb
|
67
68
|
- spec/lib/bri/mall_spec.rb
|
68
69
|
- spec/lib/bri/matcher_spec.rb
|
69
|
-
- spec/lib/bri/
|
70
|
-
- spec/lib/bri/match/
|
70
|
+
- spec/lib/bri/renderer_spec.rb
|
71
|
+
- spec/lib/bri/match/class_spec.rb
|
72
|
+
- spec/lib/bri/match/method_spec.rb
|
71
73
|
- spec/lib/bri/search/class_spec.rb
|
72
|
-
- spec/lib/bri/search/
|
74
|
+
- spec/lib/bri/search/class_method_spec.rb
|
73
75
|
- spec/lib/bri/search/instance_method_spec.rb
|
74
76
|
- spec/lib/bri/search/method_spec.rb
|
75
77
|
has_rdoc: true
|
@@ -99,6 +101,6 @@ rubyforge_project:
|
|
99
101
|
rubygems_version: 1.5.0
|
100
102
|
signing_key:
|
101
103
|
specification_version: 3
|
102
|
-
summary: Beautified RI in the spirit of fastri/qri. Unlike fastri, bri builds on top of the rdoc 2.x backend, only output and formatting is handled by bri
|
104
|
+
summary: Beautified RI in the spirit of fastri/qri. Unlike fastri, bri builds on top of the rdoc 2.x/3.x backend, only output and formatting is handled by bri
|
103
105
|
test_files: []
|
104
106
|
|
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Bri::Match::Class do
|
4
|
-
let( :fake_paragraph ) do
|
5
|
-
mock( RDoc::Markup::Paragraph, :parts => [ "This is row one",
|
6
|
-
"And this is row 2" ] )
|
7
|
-
end
|
8
|
-
|
9
|
-
let( :fake_description ) do
|
10
|
-
mock( RDoc::Markup::Document, :parts => [ fake_paragraph ] )
|
11
|
-
end
|
12
|
-
|
13
|
-
let( :fake_include ) do
|
14
|
-
mock( RDoc::Include, :full_name => "Included::Module" )
|
15
|
-
end
|
16
|
-
|
17
|
-
let( :fake_constant ) do
|
18
|
-
mock( RDoc::Constant, :name => "MockConstant", :value => "This is my value" )
|
19
|
-
end
|
20
|
-
|
21
|
-
let( :fake_attribute ) do
|
22
|
-
mock( RDoc::Constant, :name => "attribute", :rw => 'R' )
|
23
|
-
end
|
24
|
-
|
25
|
-
let( :fake_public_instance_method ) do
|
26
|
-
mock( RDoc::AnyMethod, :name => "public_instance",
|
27
|
-
:singleton => false,
|
28
|
-
:visibility => :public )
|
29
|
-
end
|
30
|
-
|
31
|
-
let( :fake_protected_instance_method ) do
|
32
|
-
mock( RDoc::AnyMethod, :name => "protected_instance",
|
33
|
-
:singleton => false,
|
34
|
-
:visibility => :protected )
|
35
|
-
end
|
36
|
-
|
37
|
-
let( :fake_private_instance_method ) do
|
38
|
-
mock( RDoc::AnyMethod, :name => "private_instance",
|
39
|
-
:singleton => false,
|
40
|
-
:visibility => :private )
|
41
|
-
end
|
42
|
-
|
43
|
-
let( :fake_public_class_method ) do
|
44
|
-
mock( RDoc::AnyMethod, :name => "public_class",
|
45
|
-
:singleton => true,
|
46
|
-
:visibility => :public )
|
47
|
-
end
|
48
|
-
|
49
|
-
let( :fake_protected_class_method ) do
|
50
|
-
mock( RDoc::AnyMethod, :name => "protected_class",
|
51
|
-
:singleton => true,
|
52
|
-
:visibility => :protected )
|
53
|
-
end
|
54
|
-
|
55
|
-
let( :fake_private_class_method ) do
|
56
|
-
mock( RDoc::AnyMethod, :name => "private_class",
|
57
|
-
:singleton => true,
|
58
|
-
:visibility => :private )
|
59
|
-
end
|
60
|
-
|
61
|
-
let( :rdoc_class ) { mock( RDoc::NormalClass, :type => "module",
|
62
|
-
:name => "MyModule",
|
63
|
-
:comment => fake_description,
|
64
|
-
:includes => [ fake_include ],
|
65
|
-
:constants => [ fake_constant ],
|
66
|
-
:attributes => [ fake_attribute ],
|
67
|
-
:method_list => [ fake_public_instance_method,
|
68
|
-
fake_protected_instance_method,
|
69
|
-
fake_private_instance_method,
|
70
|
-
fake_public_class_method,
|
71
|
-
fake_protected_class_method,
|
72
|
-
fake_private_class_method ]
|
73
|
-
)
|
74
|
-
}
|
75
|
-
|
76
|
-
describe "#initialize" do
|
77
|
-
context "a class with everything" do
|
78
|
-
subject { Bri::Match::Class.new( rdoc_class ) }
|
79
|
-
|
80
|
-
its( :type ) { should == rdoc_class.type }
|
81
|
-
its( :name ) { should == rdoc_class.name }
|
82
|
-
its( :description_paragraphs ) { should == fake_description.parts.collect { |p| p.parts.join( " " ) } }
|
83
|
-
its( :includes ) { should == rdoc_class.includes.collect{ |i| i.full_name } }
|
84
|
-
its( :constants ) { should == rdoc_class.constants.collect { |c| { :name => c.name, :value => c.value } } }
|
85
|
-
its( :attributes ) { should == rdoc_class.attributes.collect { |a| "#{a.name} (#{a.rw})" } }
|
86
|
-
its( :instance_methods ) { should == rdoc_class.method_list.select { |m| m.visibility == :public && m.singleton == false }.collect { |m| m.name } }
|
87
|
-
its( :class_methods ) { should == rdoc_class.method_list.select { |m| m.visibility == :public && m.singleton == true }.collect { |m| m.name } }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Bri::Match::Method do
|
4
|
-
let( :fake_paragraph ) do
|
5
|
-
RDoc::Markup::Paragraph.new "This is line one", "This is line two"
|
6
|
-
end
|
7
|
-
|
8
|
-
let( :fake_description ) do
|
9
|
-
mock( RDoc::Markup::Document, :parts => [ fake_paragraph ] )
|
10
|
-
end
|
11
|
-
|
12
|
-
let( :rdoc_method ) do
|
13
|
-
mock( RDoc::AnyMethod, :full_name => "This::IS::My.full_name",
|
14
|
-
:arglists => "First\nSecond\nThird",
|
15
|
-
:comment => fake_description )
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#initialize" do
|
19
|
-
subject { Bri::Match::Method.new( rdoc_method ) }
|
20
|
-
|
21
|
-
its( :full_name ) { should == rdoc_method.full_name }
|
22
|
-
its( :call_syntaxes ) { should == " First\n Second\n Third\n" }
|
23
|
-
its( :description_paragraphs ) { should == [ " This is line one This is line two" ] }
|
24
|
-
end
|
25
|
-
end
|