mactag 0.5.4 → 0.6.0
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.
- data/README.markdown +35 -30
- data/Rakefile +10 -8
- data/VERSION +1 -1
- data/lib/generators/mactag/templates/mactag.rb +26 -85
- data/lib/mactag.rb +7 -1
- data/lib/mactag/builder.rb +4 -6
- data/lib/mactag/bundler.rb +21 -19
- data/lib/mactag/config.rb +22 -16
- data/lib/mactag/ctags.rb +2 -0
- data/lib/mactag/dsl.rb +197 -32
- data/lib/mactag/indexer.rb +9 -0
- data/lib/mactag/indexer/app.rb +22 -0
- data/lib/mactag/indexer/gem.rb +72 -0
- data/lib/mactag/{tag → indexer}/plugin.rb +10 -9
- data/lib/mactag/indexer/rails.rb +46 -0
- data/spec/mactag/builder_spec.rb +11 -11
- data/spec/mactag/config_spec.rb +24 -29
- data/spec/mactag/ctags_spec.rb +4 -4
- data/spec/mactag/dsl_spec.rb +179 -47
- data/spec/mactag/indexer/app_spec.rb +20 -0
- data/spec/mactag/indexer/gem_spec.rb +180 -0
- data/spec/mactag/{tag → indexer}/plugin_spec.rb +32 -23
- data/spec/mactag/indexer/rails_spec.rb +112 -0
- data/spec/spec_helper.rb +18 -0
- metadata +53 -28
- data/.gemtest +0 -0
- data/lib/mactag/tag.rb +0 -9
- data/lib/mactag/tag/app.rb +0 -30
- data/lib/mactag/tag/gem.rb +0 -80
- data/lib/mactag/tag/rails.rb +0 -86
- data/spec/mactag/tag/app_spec.rb +0 -9
- data/spec/mactag/tag/gem_spec.rb +0 -117
- data/spec/mactag/tag/rails_spec.rb +0 -105
- data/spec/mactag/tag_spec.rb +0 -5
data/spec/mactag/builder_spec.rb
CHANGED
@@ -7,19 +7,19 @@ describe Mactag::Builder do
|
|
7
7
|
|
8
8
|
describe '#<<' do
|
9
9
|
before do
|
10
|
-
@tag = Mactag::
|
10
|
+
@tag = Mactag::Indexer::App.new('app')
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'adds single tag' do
|
14
14
|
@builder << @tag
|
15
15
|
|
16
|
-
@builder.
|
16
|
+
@builder.tags.should =~ [@tag]
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'adds multiple tags' do
|
20
20
|
@builder << [@tag, @tag]
|
21
21
|
|
22
|
-
@builder.
|
22
|
+
@builder.tags.should =~ [@tag, @tag]
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -32,12 +32,12 @@ describe Mactag::Builder do
|
|
32
32
|
|
33
33
|
it 'flattens all files' do
|
34
34
|
@builder.stub(:all) { [['app'], 'lib'] }
|
35
|
-
@builder.files.should
|
35
|
+
@builder.files.should =~ ['app', 'lib']
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'compacts all files' do
|
39
39
|
@builder.stub(:all) { [nil, 'app', nil, 'lib', nil] }
|
40
|
-
@builder.files.should
|
40
|
+
@builder.files.should =~ ['app', 'lib']
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'expands all files' do
|
@@ -56,7 +56,7 @@ describe Mactag::Builder do
|
|
56
56
|
|
57
57
|
it 'uniquifies files' do
|
58
58
|
@builder.stub(:all) { ['app', 'lib', 'lib', 'app'] }
|
59
|
-
@builder.files.should
|
59
|
+
@builder.files.should == ['app', 'lib']
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'does not return directories' do
|
@@ -70,21 +70,21 @@ describe Mactag::Builder do
|
|
70
70
|
describe '#directories' do
|
71
71
|
it 'returns all file dirnames' do
|
72
72
|
@builder.stub(:files) { ['app/models/user.rb', 'lib/validate.rb'] }
|
73
|
-
@builder.directories.should
|
73
|
+
@builder.directories.should =~ ['app/models', 'lib']
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'returns uniq directories' do
|
77
77
|
@builder.stub(:files) { ['app/models/user.rb', 'app/models/post.rb'] }
|
78
|
-
@builder.directories.should
|
78
|
+
@builder.directories.should =~ ['app/models']
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
describe '#all' do
|
83
83
|
it 'returns all files' do
|
84
|
-
@builder << Mactag::
|
85
|
-
@builder << Mactag::
|
84
|
+
@builder << Mactag::Indexer::App.new('app')
|
85
|
+
@builder << Mactag::Indexer::App.new('lib')
|
86
86
|
|
87
|
-
@builder.all.should
|
87
|
+
@builder.all.should =~ ['app', 'lib']
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'returns empty array when no tags' do
|
data/spec/mactag/config_spec.rb
CHANGED
@@ -1,44 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Mactag::Config do
|
4
|
-
|
5
|
-
it
|
6
|
-
Mactag::Config.
|
4
|
+
context 'configuration options' do
|
5
|
+
it "should have option 'binary'" do
|
6
|
+
Mactag::Config.should respond_to(:binary)
|
7
|
+
Mactag::Config.should respond_to(:binary=)
|
7
8
|
end
|
8
|
-
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
Mactag::Config.
|
10
|
+
it "should have option 'tags_file'" do
|
11
|
+
Mactag::Config.should respond_to(:tags_file)
|
12
|
+
Mactag::Config.should respond_to(:tags_file=)
|
13
13
|
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#gem_home' do
|
17
|
-
context 'when using RVM' do
|
18
|
-
before do
|
19
|
-
Mactag::Config.stub(:rvm) { true }
|
20
|
-
File.stub(:join) { '/path/to/rvm/gems' }
|
21
|
-
end
|
22
14
|
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
it "should have option 'rvm'" do
|
16
|
+
Mactag::Config.should respond_to(:rvm)
|
17
|
+
Mactag::Config.should respond_to(:rvm=)
|
26
18
|
end
|
27
19
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'is the default gem path' do
|
34
|
-
Mactag::Config.gem_home.should eq('/Library/Ruby/Gems/1.8/gems')
|
35
|
-
end
|
20
|
+
it "should have option 'gem_home'" do
|
21
|
+
Mactag::Config.should respond_to(:gem_home)
|
22
|
+
Mactag::Config.should respond_to(:gem_home=)
|
36
23
|
end
|
37
24
|
end
|
38
25
|
|
39
|
-
|
40
|
-
|
41
|
-
Mactag::Config
|
26
|
+
it 'should be configurable' do
|
27
|
+
Mactag.configure do |config|
|
28
|
+
config.should == Mactag::Config
|
42
29
|
end
|
43
30
|
end
|
31
|
+
|
32
|
+
it "requires '{INPUT}' and '{OUTPUT}' in binary string" do
|
33
|
+
proc {
|
34
|
+
Mactag.configure do |config|
|
35
|
+
config.binary = 'ctags -o {foo} -e {bar}'
|
36
|
+
end
|
37
|
+
}.should raise_exception
|
38
|
+
end
|
44
39
|
end
|
data/spec/mactag/ctags_spec.rb
CHANGED
@@ -8,12 +8,12 @@ describe Mactag::Ctags do
|
|
8
8
|
describe '#initialize' do
|
9
9
|
it 'handles a single file' do
|
10
10
|
@ctags = Mactag::Ctags.new('in', 'out')
|
11
|
-
@ctags.
|
11
|
+
@ctags.input.should =~ ['in']
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'handles multiple files' do
|
15
15
|
@ctags = Mactag::Ctags.new(['in_1', 'in_2'], 'out')
|
16
|
-
@ctags.
|
16
|
+
@ctags.input.should =~ ['in_1', 'in_2']
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -24,7 +24,7 @@ describe Mactag::Ctags do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'is correct command' do
|
27
|
-
@ctags.send(:command).should
|
27
|
+
@ctags.send(:command).should == 'cd root && binary'
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -34,7 +34,7 @@ describe Mactag::Ctags do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'returns correct command' do
|
37
|
-
@ctags.send(:binary).should
|
37
|
+
@ctags.send(:binary).should == 'ctags -o out -e in'
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
data/spec/mactag/dsl_spec.rb
CHANGED
@@ -5,89 +5,221 @@ describe Mactag::Dsl do
|
|
5
5
|
@dsl = Mactag::Dsl.new(Mactag::Builder.new)
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
context 'deprecated API' do
|
9
|
+
before do
|
10
|
+
$stderr.stub(:puts)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
describe '#app' do
|
14
|
+
it '#index should receive :app when no arguments' do
|
15
|
+
@dsl.should_receive(:index).with(:app)
|
16
|
+
@dsl.app
|
17
|
+
end
|
18
|
+
|
19
|
+
it '#index should receive argument when single arguments' do
|
20
|
+
@dsl.should_receive(:index).with('foo.rb')
|
21
|
+
@dsl.app('foo.rb')
|
22
|
+
end
|
23
|
+
|
24
|
+
it '#index should receive arguments when many arguments' do
|
25
|
+
@dsl.should_receive(:index).with('foo.rb', 'bar.rb')
|
26
|
+
@dsl.app('foo.rb', 'bar.rb')
|
27
|
+
end
|
15
28
|
end
|
16
29
|
|
17
|
-
|
18
|
-
|
30
|
+
describe '#gems' do
|
31
|
+
it '#index should receive :gems when no arguments' do
|
32
|
+
@dsl.should_receive(:index).with(:gems)
|
33
|
+
@dsl.gems
|
34
|
+
end
|
35
|
+
|
36
|
+
it '#index should receive gem name when single gem' do
|
37
|
+
@dsl.should_receive(:index).with('devise')
|
38
|
+
@dsl.gems('devise')
|
39
|
+
end
|
40
|
+
|
41
|
+
it '#index should receive gem name and version when single gem with version' do
|
42
|
+
@dsl.should_receive(:index).with('devise', '1.1.1')
|
43
|
+
@dsl.gems('devise', '1.1.1')
|
44
|
+
end
|
45
|
+
|
46
|
+
it '#index should receive gem names when multiple gems' do
|
47
|
+
@dsl.should_receive(:index).with('devise', 'simple_form')
|
48
|
+
@dsl.gems('devise', 'simple_form')
|
49
|
+
end
|
50
|
+
|
51
|
+
it '#index should receive gems and version when multiple gems and version' do
|
52
|
+
@dsl.should_receive(:index).with('devise', 'simple_form', { :version => '1.1.1' })
|
53
|
+
@dsl.gems('devise', 'simple_form', :version => '1.1.1')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#rails' do
|
58
|
+
it '#index should receive :rails when no options' do
|
59
|
+
@dsl.should_receive(:index).with(:rails)
|
60
|
+
@dsl.rails
|
61
|
+
end
|
62
|
+
|
63
|
+
it '#index should receive version when version' do
|
64
|
+
@dsl.should_receive(:index).with({ :version => '3.0.0' })
|
65
|
+
@dsl.rails(:version => '3.0.0')
|
66
|
+
end
|
67
|
+
|
68
|
+
it '#index should receive package when only and single package' do
|
69
|
+
@dsl.should_receive(:index).with({ :only => 'activerecord' })
|
70
|
+
@dsl.rails(:only => 'activerecord')
|
71
|
+
end
|
72
|
+
|
73
|
+
it '#index should receive packages when only and many package' do
|
74
|
+
@dsl.should_receive(:index).with({ :only => ['activerecord', 'activemodel'] })
|
75
|
+
@dsl.rails(:only => ['activerecord', 'activemodel'])
|
76
|
+
end
|
77
|
+
|
78
|
+
it '#index should receive package when except and single package' do
|
79
|
+
@dsl.should_receive(:index).with({ :except => 'activerecord' })
|
80
|
+
@dsl.rails(:except => 'activerecord')
|
81
|
+
end
|
82
|
+
|
83
|
+
it '#index should receive packages when except and many package' do
|
84
|
+
@dsl.should_receive(:index).with({ :except => ['activerecord', 'activemodel'] })
|
85
|
+
@dsl.rails(:except => ['activerecord', 'activemodel'])
|
86
|
+
end
|
87
|
+
|
88
|
+
it '#index should receive options when mix' do
|
89
|
+
@dsl.should_receive(:index).with({ :only => ['activerecord', 'activemodel'], :version => '3.0.0' })
|
90
|
+
@dsl.rails(:only => ['activerecord', 'activemodel'], :version => '3.0.0')
|
91
|
+
end
|
19
92
|
end
|
20
93
|
end
|
21
94
|
|
22
|
-
describe '#
|
23
|
-
|
24
|
-
@dsl.
|
95
|
+
describe '#app' do
|
96
|
+
it 'should index default when :app' do
|
97
|
+
@dsl.index(:app)
|
98
|
+
@dsl.should have_app_index(*Mactag::Indexer::App::PATTERNS)
|
25
99
|
end
|
26
100
|
|
27
|
-
|
28
|
-
@dsl.
|
101
|
+
it 'should index argument' do
|
102
|
+
@dsl.index('lib/foo.rb')
|
103
|
+
@dsl.should have_app_index('lib/foo.rb')
|
29
104
|
end
|
30
105
|
|
31
|
-
|
32
|
-
@dsl.
|
106
|
+
it 'should index arguments' do
|
107
|
+
@dsl.index('lib/foo.rb', 'app/models/*.rb')
|
108
|
+
@dsl.should have_app_index('lib/foo.rb', 'app/models/*.rb')
|
33
109
|
end
|
34
110
|
end
|
35
111
|
|
36
|
-
describe '#
|
37
|
-
|
38
|
-
|
112
|
+
describe '#gems' do
|
113
|
+
it 'should index all gems when :gems' do
|
114
|
+
Mactag::Indexer::Gem.stub(:all) do
|
115
|
+
[
|
116
|
+
Mactag::Indexer::Gem.new('devise', '1.1.1'),
|
117
|
+
Mactag::Indexer::Gem.new('simple_form', '1.5.4')
|
118
|
+
]
|
119
|
+
end
|
120
|
+
|
121
|
+
@dsl.index(:gems)
|
122
|
+
@dsl.should have_gem_index('devise', '1.1.1')
|
123
|
+
@dsl.should have_gem_index('simple_form', '1.5.4')
|
39
124
|
end
|
40
125
|
|
41
|
-
|
42
|
-
|
43
|
-
@dsl.gem('devise')
|
44
|
-
end
|
126
|
+
it 'should index single gem without version' do
|
127
|
+
Mactag::Indexer::Gem.stub(:exist?) { true }
|
45
128
|
|
46
|
-
|
47
|
-
|
48
|
-
end
|
129
|
+
@dsl.index('devise')
|
130
|
+
@dsl.should have_gem_index('devise')
|
49
131
|
end
|
50
132
|
|
51
|
-
|
52
|
-
|
53
|
-
@dsl.gems('devise', 'rack')
|
54
|
-
end
|
133
|
+
it 'should index single gem with version' do
|
134
|
+
Mactag::Indexer::Gem.stub(:exist?) { true }
|
55
135
|
|
56
|
-
|
57
|
-
|
58
|
-
|
136
|
+
@dsl.index('devise', :version => '1.1.1')
|
137
|
+
@dsl.should have_gem_index('devise', '1.1.1')
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should index multiple gems' do
|
141
|
+
Mactag::Indexer::Gem.stub(:exist?) { true }
|
142
|
+
|
143
|
+
@dsl.index('devise', 'simple_form')
|
144
|
+
@dsl.should have_gem_index('devise')
|
145
|
+
@dsl.should have_gem_index('simple_form')
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'should index when mix' do
|
149
|
+
Mactag::Indexer::Gem.stub(:exist?) { true }
|
150
|
+
|
151
|
+
@dsl.index('devise', :version => '1.1.1')
|
152
|
+
@dsl.index('simple_form')
|
153
|
+
@dsl.should have_gem_index('devise', '1.1.1')
|
154
|
+
@dsl.should have_gem_index('simple_form')
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'should raise exception when more than one gem specified with version' do
|
158
|
+
proc {
|
159
|
+
@dsl.index('devise', 'simple_form', :version => '1.1.1')
|
160
|
+
}.should raise_exception(ArgumentError)
|
59
161
|
end
|
60
162
|
end
|
61
163
|
|
62
164
|
describe '#rails' do
|
63
|
-
|
64
|
-
@dsl.rails
|
165
|
+
it 'should index when no options' do
|
166
|
+
@dsl.index(:rails)
|
167
|
+
@dsl.should have_rails_index('actionmailer', 'actionpack', 'activemodel', 'activerecord', 'activeresource', 'activesupport', 'railties')
|
65
168
|
end
|
66
169
|
|
67
|
-
|
68
|
-
@dsl.
|
170
|
+
it 'should index when version' do
|
171
|
+
@dsl.index(:rails, :version => '3.0.0')
|
172
|
+
@dsl.should have_rails_index('actionmailer', 'actionpack', 'activemodel', 'activerecord', 'activeresource', 'activesupport', 'railties', :version => '3.0.0')
|
69
173
|
end
|
70
174
|
|
71
|
-
|
72
|
-
@dsl.
|
175
|
+
it 'should index when only and single package' do
|
176
|
+
@dsl.index(:rails, :only => 'activemodel')
|
177
|
+
@dsl.should have_rails_index('activemodel')
|
73
178
|
end
|
74
179
|
|
75
|
-
|
76
|
-
|
77
|
-
|
180
|
+
it 'should index when only and many packages' do
|
181
|
+
@dsl.index(:rails, :only => ['activerecord', 'activemodel'])
|
182
|
+
@dsl.should have_rails_index('activerecord', 'activemodel')
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should index when except and single package' do
|
186
|
+
@dsl.index(:rails, :except => 'activemodel')
|
187
|
+
@dsl.should have_rails_index('actionmailer', 'actionpack', 'activerecord', 'activeresource', 'activesupport', 'railties')
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should index when except and many packages' do
|
191
|
+
@dsl.index(:rails, :except => ['activerecord', 'activemodel'])
|
192
|
+
@dsl.should have_rails_index('actionmailer', 'actionpack', 'activeresource', 'activesupport', 'railties')
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'should index when mix' do
|
196
|
+
@dsl.index(:rails, :only => ['activerecord', 'activemodel'], :version => '3.0.0')
|
197
|
+
@dsl.should have_rails_index('activerecord', 'activemodel', :version => '3.0.0')
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
context 'deprecated' do
|
202
|
+
describe '#plugin' do
|
203
|
+
before do
|
204
|
+
Mactag::Indexer::Plugin.stub(:all) do
|
205
|
+
[Mactag::Indexer::Plugin.new('devise')]
|
206
|
+
end
|
78
207
|
end
|
79
208
|
|
80
|
-
|
81
|
-
@dsl.
|
209
|
+
it 'should index without arguments' do
|
210
|
+
@dsl.send(:plugin_private)
|
211
|
+
@dsl.should have_plugin_index('devise')
|
82
212
|
end
|
83
213
|
|
84
|
-
|
85
|
-
@dsl.
|
214
|
+
it 'should index with single argument' do
|
215
|
+
@dsl.send(:plugin_private, 'devise')
|
216
|
+
@dsl.should have_plugin_index('devise')
|
86
217
|
end
|
87
|
-
end
|
88
218
|
|
89
|
-
|
90
|
-
|
219
|
+
it 'should index with many arguments' do
|
220
|
+
@dsl.send(:plugin_private, 'devise', 'rack')
|
221
|
+
@dsl.should have_plugin_index('devise', 'rack')
|
222
|
+
end
|
91
223
|
end
|
92
224
|
end
|
93
225
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mactag::Indexer::App do
|
4
|
+
subject do
|
5
|
+
Mactag::Indexer::App.new('app')
|
6
|
+
end
|
7
|
+
|
8
|
+
it_should_behave_like 'indexer'
|
9
|
+
|
10
|
+
context 'self#all' do
|
11
|
+
it 'should return all files' do
|
12
|
+
all = Mactag::Indexer::App.all
|
13
|
+
all.map(&:tag).should =~ Mactag::Indexer::App::PATTERNS
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have ruby files in app and lib as default pattern' do
|
18
|
+
Mactag::Indexer::App::PATTERNS.should =~ ['app/**/*.rb', 'lib/**/*.rb']
|
19
|
+
end
|
20
|
+
end
|