mactag 0.4.0 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/README.markdown +36 -65
- data/Rakefile +12 -0
- data/VERSION +1 -1
- data/lib/generators/mactag/templates/mactag.rb +43 -19
- data/lib/mactag.rb +2 -8
- data/lib/mactag/builder.rb +24 -22
- data/lib/mactag/bundler.rb +36 -0
- data/lib/mactag/config.rb +6 -13
- data/lib/mactag/ctags.rb +2 -2
- data/lib/mactag/dsl.rb +16 -4
- data/lib/mactag/errors.rb +32 -0
- data/lib/mactag/tag.rb +3 -1
- data/lib/mactag/tag/app.rb +3 -3
- data/lib/mactag/tag/gem.rb +33 -33
- data/lib/mactag/tag/plugin.rb +21 -15
- data/lib/mactag/tag/rails.rb +22 -29
- data/lib/tasks/mactag.rake +3 -16
- data/spec/mactag/builder_spec.rb +68 -49
- data/spec/mactag/bundler_spec.rb +4 -0
- data/spec/mactag/config_spec.rb +13 -19
- data/spec/mactag/ctags_spec.rb +11 -11
- data/spec/mactag/dsl_spec.rb +46 -19
- data/spec/mactag/tag/app_spec.rb +4 -9
- data/spec/mactag/tag/gem_spec.rb +61 -65
- data/spec/mactag/tag/plugin_spec.rb +42 -31
- data/spec/mactag/tag/rails_spec.rb +54 -43
- data/spec/mactag/tag_spec.rb +5 -0
- metadata +23 -41
- data/lib/mactag/event_handler.rb +0 -22
- data/lib/mactag/server.rb +0 -48
- data/lib/mactag/tags_file.rb +0 -31
- data/spec/mactag/server_spec.rb +0 -4
- data/spec/mactag/tags_file_spec.rb +0 -39
data/spec/mactag/config_spec.rb
CHANGED
@@ -2,49 +2,43 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Mactag::Config do
|
4
4
|
describe '#binary' do
|
5
|
-
it '
|
6
|
-
Mactag::Config.binary.should
|
5
|
+
it 'is correct command' do
|
6
|
+
Mactag::Config.binary.should eq('ctags -o {OUTPUT} -e {INPUT}')
|
7
7
|
end
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
describe '#tags_file' do
|
11
|
-
it '
|
12
|
-
Mactag::Config.tags_file.should
|
11
|
+
it 'is correct name' do
|
12
|
+
Mactag::Config.tags_file.should eq('TAGS')
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
describe '#gem_home' do
|
17
17
|
context 'when using RVM' do
|
18
18
|
before do
|
19
|
-
Mactag::Config.stub
|
20
|
-
File.stub
|
19
|
+
Mactag::Config.stub(:rvm) { true }
|
20
|
+
File.stub(:join) { '/path/to/rvm/gems' }
|
21
21
|
end
|
22
22
|
|
23
|
-
it '
|
24
|
-
Mactag::Config.gem_home.should
|
23
|
+
it 'is the correct gems path' do
|
24
|
+
Mactag::Config.gem_home.should eq('/path/to/rvm/gems')
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
context 'when not using RVM' do
|
29
29
|
before do
|
30
|
-
Mactag::Config.stub
|
30
|
+
Mactag::Config.stub(:rvm) { false }
|
31
31
|
end
|
32
32
|
|
33
|
-
it '
|
34
|
-
Mactag::Config.gem_home.should
|
33
|
+
it 'is the default gem path' do
|
34
|
+
Mactag::Config.gem_home.should eq('/Library/Ruby/Gems/1.8/gems')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe '#rvm' do
|
40
|
-
it '
|
40
|
+
it 'is true by default' do
|
41
41
|
Mactag::Config.rvm.should be_true
|
42
42
|
end
|
43
43
|
end
|
44
|
-
|
45
|
-
describe '#tags_dir' do
|
46
|
-
it 'should have correct name' do
|
47
|
-
Mactag::Config.tags_dir.should == '.tags'
|
48
|
-
end
|
49
|
-
end
|
50
44
|
end
|
data/spec/mactag/ctags_spec.rb
CHANGED
@@ -6,35 +6,35 @@ describe Mactag::Ctags do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
describe '#initialize' do
|
9
|
-
it '
|
9
|
+
it 'handles a single file' do
|
10
10
|
@ctags = Mactag::Ctags.new('in', 'out')
|
11
|
-
@ctags.instance_variable_get('@input').should
|
11
|
+
@ctags.instance_variable_get('@input').should eq(['in'])
|
12
12
|
end
|
13
13
|
|
14
|
-
it '
|
14
|
+
it 'handles multiple files' do
|
15
15
|
@ctags = Mactag::Ctags.new(['in_1', 'in_2'], 'out')
|
16
|
-
@ctags.instance_variable_get('@input').should
|
16
|
+
@ctags.instance_variable_get('@input').should eq(['in_1', 'in_2'])
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe '#command' do
|
21
21
|
before do
|
22
|
-
Rails.stub
|
23
|
-
@ctags.stub
|
22
|
+
Rails.stub(:root) { 'root' }
|
23
|
+
@ctags.stub(:binary) { 'binary' }
|
24
24
|
end
|
25
25
|
|
26
|
-
it '
|
27
|
-
@ctags.send(:command).should
|
26
|
+
it 'is correct command' do
|
27
|
+
@ctags.send(:command).should eq('cd root && binary')
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
describe '#binary' do
|
32
32
|
before do
|
33
|
-
Mactag::Config.stub
|
33
|
+
Mactag::Config.stub(:binary) { 'ctags -o {OUTPUT} -e {INPUT}' }
|
34
34
|
end
|
35
35
|
|
36
|
-
it '
|
37
|
-
@ctags.send(:binary).should
|
36
|
+
it 'returns correct command' do
|
37
|
+
@ctags.send(:binary).should eq('ctags -o out -e in')
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
data/spec/mactag/dsl_spec.rb
CHANGED
@@ -2,65 +2,92 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Mactag::Dsl do
|
4
4
|
before do
|
5
|
-
@
|
6
|
-
@dsl = Mactag::Dsl.new(@builder)
|
5
|
+
@dsl = Mactag::Dsl.new(Mactag::Builder.new)
|
7
6
|
end
|
8
7
|
|
9
8
|
describe '#app' do
|
10
|
-
|
9
|
+
it_does_not_support_dsl 'without arguments' do
|
10
|
+
@dsl.app
|
11
|
+
end
|
12
|
+
|
13
|
+
it_supports_dsl 'with single argument' do
|
11
14
|
@dsl.app('lib/**/*.rb')
|
12
15
|
end
|
16
|
+
|
17
|
+
it_supports_dsl 'with multiple arguments' do
|
18
|
+
@dsl.app('lib/**/*.rb', 'app/**/*.rb')
|
19
|
+
end
|
13
20
|
end
|
14
21
|
|
15
22
|
describe '#plugin' do
|
16
|
-
|
23
|
+
it_supports_dsl 'without arguments' do
|
17
24
|
@dsl.plugin
|
18
25
|
end
|
19
26
|
|
20
|
-
|
27
|
+
it_supports_dsl 'with single argument' do
|
21
28
|
@dsl.plugin('devise')
|
22
29
|
end
|
23
30
|
|
24
|
-
|
31
|
+
it_supports_dsl 'with multiple arguments' do
|
25
32
|
@dsl.plugins('devise', 'rack')
|
26
33
|
end
|
27
34
|
end
|
28
35
|
|
29
36
|
describe '#gem' do
|
30
|
-
|
37
|
+
it_supports_dsl 'without arguments' do
|
31
38
|
@dsl.gem
|
32
39
|
end
|
33
40
|
|
34
|
-
context 'single argument' do
|
35
|
-
|
36
|
-
@dsl.gem('devise'
|
41
|
+
context 'with single argument' do
|
42
|
+
it_supports_dsl 'without version' do
|
43
|
+
@dsl.gem('devise')
|
37
44
|
end
|
38
45
|
|
39
|
-
|
40
|
-
@dsl.gem('devise')
|
46
|
+
it_supports_dsl 'with version' do
|
47
|
+
@dsl.gem('devise', :version => '1.1.1')
|
41
48
|
end
|
42
49
|
end
|
43
50
|
|
44
|
-
|
45
|
-
|
51
|
+
context 'with multiple arguments' do
|
52
|
+
it_supports_dsl 'without version' do
|
53
|
+
@dsl.gems('devise', 'rack')
|
54
|
+
end
|
55
|
+
|
56
|
+
it_does_not_support_dsl 'with version' do
|
57
|
+
@dsl.gems('devise', 'rack', :version => '1.1.1')
|
58
|
+
end
|
46
59
|
end
|
47
60
|
end
|
48
61
|
|
49
62
|
describe '#rails' do
|
50
|
-
|
63
|
+
it_supports_dsl 'without arguments' do
|
51
64
|
@dsl.rails
|
52
65
|
end
|
53
66
|
|
54
|
-
|
67
|
+
it_supports_dsl 'with packages only' do
|
55
68
|
@dsl.rails(:only => [])
|
56
69
|
end
|
57
70
|
|
58
|
-
|
71
|
+
it_supports_dsl 'with packages except' do
|
59
72
|
@dsl.rails(:except => [])
|
60
73
|
end
|
61
74
|
|
62
|
-
|
63
|
-
|
75
|
+
context 'with version' do
|
76
|
+
it_supports_dsl do
|
77
|
+
@dsl.rails(:version => '3.0.0')
|
78
|
+
end
|
79
|
+
|
80
|
+
it_supports_dsl 'with only' do
|
81
|
+
@dsl.rails(:version => '3.0.0', :only => [])
|
82
|
+
end
|
83
|
+
|
84
|
+
it_supports_dsl 'with except' do
|
85
|
+
@dsl.rails(:version => '3.0.0', :except => [])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it_does_not_support_dsl 'with only and except' do
|
90
|
+
@dsl.rails(:only => [], :except => [])
|
64
91
|
end
|
65
92
|
end
|
66
93
|
end
|
data/spec/mactag/tag/app_spec.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Mactag::Tag::App do
|
4
|
-
|
5
|
-
|
6
|
-
@tag = 'app/**/*.rb'
|
7
|
-
@app = Mactag::Tag::App.new(@tag)
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should set the tag' do
|
11
|
-
@app.tag.should == @tag
|
12
|
-
end
|
4
|
+
subject do
|
5
|
+
Mactag::Tag::App.new('app')
|
13
6
|
end
|
7
|
+
|
8
|
+
it_should_behave_like 'tagger'
|
14
9
|
end
|
data/spec/mactag/tag/gem_spec.rb
CHANGED
@@ -1,110 +1,106 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Mactag::Tag::Gem do
|
4
|
+
subject do
|
5
|
+
Mactag::Tag::Gem.new('devise')
|
6
|
+
end
|
7
|
+
|
8
|
+
it_should_behave_like 'tagger'
|
9
|
+
|
4
10
|
before do
|
5
|
-
Mactag::Config.stub
|
11
|
+
Mactag::Config.stub(:gem_home) { 'GEM_HOME' }
|
12
|
+
|
13
|
+
@gem = Mactag::Tag::Gem.new('devise')
|
6
14
|
end
|
7
15
|
|
8
16
|
describe '#tag' do
|
9
|
-
context '
|
10
|
-
|
11
|
-
|
12
|
-
|
17
|
+
context 'when gem exists' do
|
18
|
+
before do
|
19
|
+
@gem.stub(:exists?) { true }
|
20
|
+
end
|
13
21
|
|
14
|
-
|
15
|
-
|
22
|
+
context 'without version' do
|
23
|
+
before do
|
24
|
+
Mactag::Tag::Gem.stub(:last) { '1.1.1' }
|
16
25
|
end
|
17
26
|
|
18
|
-
it '
|
19
|
-
@gem.tag.should
|
27
|
+
it 'returns path to gem' do
|
28
|
+
@gem.tag.should eq('GEM_HOME/devise-1.1.1/lib/**/*.rb')
|
20
29
|
end
|
21
30
|
end
|
22
31
|
|
23
|
-
context 'with
|
32
|
+
context 'with version' do
|
24
33
|
before do
|
25
|
-
@gem
|
26
|
-
@gem.stub!(:exists?).and_return(true)
|
34
|
+
@gem.stub(:version) { '1.1.1' }
|
27
35
|
end
|
28
36
|
|
29
|
-
it '
|
30
|
-
@gem.tag.should
|
37
|
+
it 'returns path to gem' do
|
38
|
+
@gem.tag.should eq('GEM_HOME/devise-1.1.1/lib/**/*.rb')
|
31
39
|
end
|
32
40
|
end
|
33
41
|
end
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
43
|
+
context 'when gem does not exist' do
|
44
|
+
before do
|
45
|
+
@gem.stub(:exists?) { false }
|
46
|
+
end
|
38
47
|
|
39
|
-
|
48
|
+
it 'raises exception' do
|
49
|
+
proc {
|
50
|
+
@gem.tag
|
51
|
+
}.should raise_exception(Mactag::GemNotFoundError)
|
52
|
+
end
|
40
53
|
end
|
41
54
|
end
|
42
55
|
|
43
|
-
describe '#
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
it 'should return only gem if only one version of same gem exists' do
|
51
|
-
Dir.stub!(:glob).and_return(['vendor/plugins/devise-1.1.1'])
|
52
|
-
|
53
|
-
Mactag::Tag::Gem.most_recent('devise').should == 'devise-1.1.1'
|
54
|
-
end
|
56
|
+
describe '#exists?' do
|
57
|
+
context 'without version' do
|
58
|
+
it 'is true when single version of gem exists' do
|
59
|
+
Dir.stub(:glob) { ['devise-1.1.1'] }
|
60
|
+
@gem.exists?.should be_true
|
61
|
+
end
|
55
62
|
|
56
|
-
|
57
|
-
|
63
|
+
it 'is true when multiple versions of gem exists' do
|
64
|
+
Dir.stub(:glob) { %w(devise-1.1.0 devise-1.1.1) }
|
65
|
+
@gem.exists?.should be_true
|
66
|
+
end
|
58
67
|
|
59
|
-
|
68
|
+
it 'is false when gem does not exist' do
|
69
|
+
Dir.stub(:glob) { [] }
|
70
|
+
@gem.exists?.should be_false
|
71
|
+
end
|
60
72
|
end
|
61
73
|
end
|
62
74
|
|
63
|
-
describe '#
|
64
|
-
context '
|
75
|
+
describe '#last' do
|
76
|
+
context 'when no gems exists' do
|
65
77
|
before do
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should be true when gem exist' do
|
70
|
-
File.stub!(:directory?).and_return(true)
|
71
|
-
|
72
|
-
@gem.send(:exists?).should be_true
|
78
|
+
Mactag::Tag::Gem.stub(:dirs) { [] }
|
73
79
|
end
|
74
80
|
|
75
|
-
it '
|
76
|
-
|
77
|
-
|
78
|
-
@gem.send(:exists?).should be_false
|
81
|
+
it 'returns nil' do
|
82
|
+
Mactag::Tag::Gem.last('devise').should be_nil
|
79
83
|
end
|
80
84
|
end
|
81
85
|
|
82
|
-
context '
|
86
|
+
context 'when single version of gem exist' do
|
83
87
|
before do
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'should be true when gem exists' do
|
88
|
-
Mactag::Tag::Gem.stub!(:most_recent).and_return('devise-1.1.1')
|
89
|
-
|
90
|
-
@gem.send(:exists?).should be_true
|
88
|
+
Mactag::Tag::Gem.stub(:dirs) { ['devise-1.1.1'] }
|
91
89
|
end
|
92
90
|
|
93
|
-
it '
|
94
|
-
Mactag::Tag::Gem.
|
95
|
-
|
96
|
-
@gem.send(:exists?).should be_false
|
91
|
+
it 'returns nil' do
|
92
|
+
Mactag::Tag::Gem.last('devise').should eq('1.1.1')
|
97
93
|
end
|
98
94
|
end
|
99
|
-
end
|
100
95
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
96
|
+
context 'when multiple versions of gem exist' do
|
97
|
+
before do
|
98
|
+
Mactag::Tag::Gem.stub(:dirs) { ['devise-1.1.0', 'devise-1.1.1'] }
|
99
|
+
end
|
105
100
|
|
106
|
-
|
107
|
-
|
101
|
+
it 'returns nil' do
|
102
|
+
Mactag::Tag::Gem.last('devise').should eq('1.1.1')
|
103
|
+
end
|
108
104
|
end
|
109
105
|
end
|
110
106
|
end
|
@@ -1,57 +1,68 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Mactag::Tag::Plugin do
|
4
|
-
|
5
|
-
Mactag::Tag::Plugin
|
4
|
+
subject do
|
5
|
+
Mactag::Tag::Plugin.new('devise')
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@plugin = Mactag::Tag::Plugin.new('devise')
|
6
10
|
end
|
7
11
|
|
8
|
-
|
9
|
-
before do
|
10
|
-
@plugin = Mactag::Tag::Plugin.new('devise')
|
11
|
-
end
|
12
|
+
it_should_behave_like 'tagger'
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
it 'has correct plugin path' do
|
15
|
+
Mactag::Tag::Plugin::PLUGIN_PATH.should eq(['vendor', 'plugins'])
|
16
|
+
end
|
15
17
|
|
16
|
-
|
18
|
+
describe '#tag' do
|
19
|
+
it 'returns path to plugin when plugin exists' do
|
20
|
+
@plugin.stub(:exists?) { true }
|
21
|
+
@plugin.tag.should eq('vendor/plugins/devise/lib/**/*.rb')
|
17
22
|
end
|
18
23
|
|
19
|
-
it '
|
20
|
-
@plugin.stub
|
21
|
-
|
22
|
-
|
24
|
+
it 'raises exception when plugin does not exist' do
|
25
|
+
@plugin.stub(:exists?) { false }
|
26
|
+
proc {
|
27
|
+
@plugin.tag
|
28
|
+
}.should raise_exception(Mactag::PluginNotFoundError)
|
23
29
|
end
|
24
30
|
end
|
25
31
|
|
26
|
-
describe '#
|
27
|
-
|
28
|
-
@plugin
|
32
|
+
describe '#path' do
|
33
|
+
it 'return path to plugin' do
|
34
|
+
@plugin.path.should eq('vendor/plugins/devise')
|
29
35
|
end
|
36
|
+
end
|
30
37
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
@plugin.
|
38
|
+
describe '#exists?' do
|
39
|
+
it 'is true when plugin directory exists' do
|
40
|
+
File.stub(:directory?) { true }
|
41
|
+
@plugin.exists?.should be_true
|
35
42
|
end
|
36
43
|
|
37
|
-
it '
|
38
|
-
File.stub
|
39
|
-
|
40
|
-
@plugin.send(:exists?).should be_false
|
44
|
+
it 'is false when plugin directory does not exist' do
|
45
|
+
File.stub(:directory?) { false }
|
46
|
+
@plugin.exists?.should be_false
|
41
47
|
end
|
42
48
|
end
|
43
49
|
|
44
50
|
describe '#all' do
|
45
|
-
it '
|
46
|
-
Dir.stub
|
47
|
-
|
48
|
-
Mactag::Tag::Plugin.all.should =~ ['one', 'two']
|
51
|
+
it 'returns empty array when no plugins' do
|
52
|
+
Dir.stub(:glob) { [] }
|
53
|
+
Mactag::Tag::Plugin.all.should be_empty
|
49
54
|
end
|
50
55
|
|
51
|
-
it '
|
52
|
-
Dir.stub
|
56
|
+
it 'returns plugin name when single plugin' do
|
57
|
+
Dir.stub(:glob) { ['vendor/plugins/devise'] }
|
58
|
+
Mactag::Tag::Plugin.all.should eq(['devise'])
|
59
|
+
end
|
53
60
|
|
54
|
-
|
61
|
+
it 'returns plugin names when multiple plugins' do
|
62
|
+
Dir.stub(:glob) {
|
63
|
+
['vendor/plugins/devise', 'vendor/plugins/simple_form']
|
64
|
+
}
|
65
|
+
Mactag::Tag::Plugin.all.should eq(['devise', 'simple_form'])
|
55
66
|
end
|
56
67
|
end
|
57
68
|
end
|