mactag 0.6.0 → 0.7.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 +64 -50
- data/bin/mactag +95 -0
- data/lib/mactag.rb +26 -4
- data/lib/mactag/builder.rb +1 -1
- data/lib/mactag/bundler.rb +9 -1
- data/lib/mactag/config.rb +51 -39
- data/lib/mactag/ctags.rb +1 -1
- data/lib/mactag/dsl.rb +62 -14
- data/lib/mactag/indexer.rb +1 -0
- data/lib/mactag/indexer/lib.rb +22 -0
- data/lib/mactag/indexer/rails.rb +7 -6
- data/spec/mactag/config_spec.rb +57 -10
- data/spec/mactag/ctags_spec.rb +2 -1
- data/spec/mactag/dsl_spec.rb +50 -0
- data/spec/mactag/indexer/lib_spec.rb +20 -0
- data/spec/mactag/indexer/rails_spec.rb +6 -6
- data/spec/mactag_spec.rb +15 -0
- data/spec/matcher.rb +8 -0
- data/spec/matcher/app.rb +32 -0
- data/spec/matcher/gem.rb +39 -0
- data/spec/matcher/lib.rb +31 -0
- data/spec/matcher/plugin.rb +32 -0
- data/spec/matcher/rails.rb +49 -0
- data/spec/spec_helper.rb +0 -2
- metadata +38 -27
- data/lib/generators/mactag/mactag_generator.rb +0 -11
- data/lib/generators/mactag/templates/mactag.rb +0 -39
- data/lib/tasks/mactag.rake +0 -8
data/lib/mactag/indexer.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Mactag
|
2
|
+
module Indexer
|
3
|
+
class Lib
|
4
|
+
attr_reader :tag
|
5
|
+
|
6
|
+
PATTERNS = ['lib/**/*.rb']
|
7
|
+
|
8
|
+
def initialize(tag)
|
9
|
+
@tag = tag
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def all
|
15
|
+
PATTERNS.map do |pattern|
|
16
|
+
new(pattern)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/mactag/indexer/rails.rb
CHANGED
@@ -28,17 +28,18 @@ module Mactag
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def version
|
31
|
-
@version || ::
|
31
|
+
@version || ::Mactag.rails_version
|
32
32
|
end
|
33
33
|
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
|
-
def packagize(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
def packagize(packages)
|
38
|
+
packages = Array(packages)
|
39
|
+
unless packages.empty?
|
40
|
+
packages.map do |package|
|
41
|
+
package.to_s.gsub(/[^a-z]/, '')
|
42
|
+
end
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
data/spec/mactag/config_spec.rb
CHANGED
@@ -1,39 +1,86 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Mactag::Config do
|
4
|
-
|
4
|
+
before(:all) do
|
5
|
+
@binary, @tags_file, @rvm, @gem_home =
|
6
|
+
%w(binary tags_file rvm gem_home).map do |option|
|
7
|
+
Mactag::Config.instance_variable_get("@#{option}")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
Mactag::Config.binary = @binary
|
13
|
+
Mactag::Config.tags_file = @tags_file
|
14
|
+
Mactag::Config.rvm = @rvm
|
15
|
+
Mactag::Config.gem_home = @gem_home
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.binary' do
|
5
19
|
it "should have option 'binary'" do
|
20
|
+
Mactag::Config.binary.should == @binary
|
6
21
|
Mactag::Config.should respond_to(:binary)
|
7
22
|
Mactag::Config.should respond_to(:binary=)
|
8
23
|
end
|
9
24
|
|
25
|
+
it "requires '{INPUT}' and '{OUTPUT}' to be present" do
|
26
|
+
proc {
|
27
|
+
Mactag::Config.binary = 'ctags -o {foo} -e {bar}'
|
28
|
+
}.should raise_exception
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context '.tags_file' do
|
10
33
|
it "should have option 'tags_file'" do
|
34
|
+
Mactag::Config.tags_file.should == @tags_file
|
11
35
|
Mactag::Config.should respond_to(:tags_file)
|
12
36
|
Mactag::Config.should respond_to(:tags_file=)
|
13
37
|
end
|
38
|
+
end
|
14
39
|
|
40
|
+
context '.rvm' do
|
15
41
|
it "should have option 'rvm'" do
|
42
|
+
Mactag::Config.rvm.should == true
|
16
43
|
Mactag::Config.should respond_to(:rvm)
|
17
44
|
Mactag::Config.should respond_to(:rvm=)
|
18
45
|
end
|
19
46
|
|
47
|
+
it "should be true or false" do
|
48
|
+
proc {
|
49
|
+
Mactag::Config.rvm = 'true'
|
50
|
+
}.should raise_exception
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context '.gem_home' do
|
20
55
|
it "should have option 'gem_home'" do
|
21
56
|
Mactag::Config.should respond_to(:gem_home)
|
22
57
|
Mactag::Config.should respond_to(:gem_home=)
|
23
58
|
end
|
59
|
+
|
60
|
+
it 'should be default when not using RVM' do
|
61
|
+
Mactag::Config.rvm = false
|
62
|
+
Mactag::Config.gem_home.should == @gem_home
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should be gem homet when using RVM' do
|
66
|
+
File.stub(:join) { 'GEM_HOME' }
|
67
|
+
|
68
|
+
Mactag::Config.rvm = true
|
69
|
+
Mactag::Config.gem_home.should == 'GEM_HOME'
|
70
|
+
end
|
24
71
|
end
|
25
72
|
|
26
|
-
it 'should be configurable' do
|
73
|
+
it 'should be configurable block style' do
|
27
74
|
Mactag.configure do |config|
|
28
|
-
config.
|
75
|
+
config.binary = 'binary {INPUT} {OUTPUT}'
|
76
|
+
config.tags_file = 'tags_file'
|
77
|
+
config.rvm = false
|
78
|
+
config.gem_home = 'gem_home'
|
29
79
|
end
|
30
|
-
end
|
31
80
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
}.should raise_exception
|
81
|
+
Mactag::Config.binary.should == 'binary {INPUT} {OUTPUT}'
|
82
|
+
Mactag::Config.tags_file.should == 'tags_file'
|
83
|
+
Mactag::Config.rvm.should == false
|
84
|
+
Mactag::Config.gem_home.should == 'gem_home'
|
38
85
|
end
|
39
86
|
end
|
data/spec/mactag/ctags_spec.rb
CHANGED
data/spec/mactag/dsl_spec.rb
CHANGED
@@ -92,7 +92,46 @@ describe Mactag::Dsl do
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
+
describe '#lib' do
|
96
|
+
before do
|
97
|
+
Mactag.stub(:rails_app?) { false }
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should raise exception when indexing :lib and in a Rails application' do
|
101
|
+
Mactag.stub(:rails_app?) { true }
|
102
|
+
proc {
|
103
|
+
@dsl.index(:lib)
|
104
|
+
}.should raise_exception
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should index default when :lib' do
|
108
|
+
@dsl.index(:lib)
|
109
|
+
@dsl.should have_lib_index(*Mactag::Indexer::Lib::PATTERNS)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should index argument' do
|
113
|
+
@dsl.index('lib/foo.rb')
|
114
|
+
@dsl.should have_lib_index('lib/foo.rb')
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should index arguments' do
|
118
|
+
@dsl.index('lib/foo.rb', 'lib/foo/*.rb')
|
119
|
+
@dsl.should have_lib_index('lib/foo.rb', 'lib/foo/*.rb')
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
95
123
|
describe '#app' do
|
124
|
+
before do
|
125
|
+
Mactag.stub(:rails_app?) { true }
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'should raise exception when indexing :app and not in a Rails application' do
|
129
|
+
Mactag.stub(:rails_app?) { false }
|
130
|
+
proc {
|
131
|
+
@dsl.index(:app)
|
132
|
+
}.should raise_exception
|
133
|
+
end
|
134
|
+
|
96
135
|
it 'should index default when :app' do
|
97
136
|
@dsl.index(:app)
|
98
137
|
@dsl.should have_app_index(*Mactag::Indexer::App::PATTERNS)
|
@@ -162,6 +201,17 @@ describe Mactag::Dsl do
|
|
162
201
|
end
|
163
202
|
|
164
203
|
describe '#rails' do
|
204
|
+
before do
|
205
|
+
Mactag.stub(:rails_app?) { true }
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'should raise exception when indexing :rails and not in a Rails application' do
|
209
|
+
Mactag.stub(:rails_app?) { false }
|
210
|
+
proc {
|
211
|
+
@dsl.index(:rails)
|
212
|
+
}.should raise_exception
|
213
|
+
end
|
214
|
+
|
165
215
|
it 'should index when no options' do
|
166
216
|
@dsl.index(:rails)
|
167
217
|
@dsl.should have_rails_index('actionmailer', 'actionpack', 'activemodel', 'activerecord', 'activeresource', 'activesupport', 'railties')
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mactag::Indexer::Lib do
|
4
|
+
subject do
|
5
|
+
Mactag::Indexer::Lib.new('lib')
|
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::Lib.all
|
13
|
+
all.map(&:tag).should =~ Mactag::Indexer::Lib::PATTERNS
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have ruby files in lib as default pattern' do
|
18
|
+
Mactag::Indexer::Lib::PATTERNS.should =~ ['lib/**/*.rb']
|
19
|
+
end
|
20
|
+
end
|
@@ -66,15 +66,15 @@ describe Mactag::Indexer::Rails do
|
|
66
66
|
|
67
67
|
context 'single package' do
|
68
68
|
it 'packagizes when symbol' do
|
69
|
-
@rails.send(:packagize,
|
69
|
+
@rails.send(:packagize, :activerecord).should =~ ['activerecord']
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'packagizes when string' do
|
73
|
-
@rails.send(:packagize,
|
73
|
+
@rails.send(:packagize, 'activerecord').should =~ ['activerecord']
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'packagizes when underscore' do
|
77
|
-
@rails.send(:packagize,
|
77
|
+
@rails.send(:packagize, :active_record).should =~ ['activerecord']
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -100,13 +100,13 @@ describe Mactag::Indexer::Rails do
|
|
100
100
|
describe '#version' do
|
101
101
|
it 'returns specified version when version' do
|
102
102
|
@rails = Mactag::Indexer::Rails.new(:version => '3.0.0')
|
103
|
-
@rails.
|
103
|
+
@rails.version.should == '3.0.0'
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'returns same version as app when version option is not specified' do
|
107
|
-
|
107
|
+
Mactag.stub(:rails_version) { '3.0.0' }
|
108
108
|
|
109
|
-
@rails.
|
109
|
+
@rails.version.should == '3.0.0'
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
data/spec/mactag_spec.rb
CHANGED
@@ -1,4 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Mactag do
|
4
|
+
it 'should respond to #rails_app?' do
|
5
|
+
Mactag.should respond_to(:rails_app?)
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should respond to #rails_version' do
|
9
|
+
Mactag.should respond_to(:rails_version)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should respond to #project_root' do
|
13
|
+
Mactag.should respond_to(:project_root)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should respond to #current_project' do
|
17
|
+
Mactag.should respond_to(:current_project)
|
18
|
+
end
|
4
19
|
end
|
data/spec/matcher.rb
ADDED
data/spec/matcher/app.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Matcher
|
2
|
+
class AppIndex
|
3
|
+
def initialize(paths)
|
4
|
+
@paths = paths
|
5
|
+
end
|
6
|
+
|
7
|
+
def matches?(dsl)
|
8
|
+
@tags = dsl.builder.tags
|
9
|
+
@actual = @tags.map(&:tag)
|
10
|
+
@actual - @paths == @paths - @actual && all_apps?
|
11
|
+
end
|
12
|
+
|
13
|
+
def failure_message
|
14
|
+
"expected '#{@paths.inspect}' but got '#{@actual.inspect}'"
|
15
|
+
end
|
16
|
+
|
17
|
+
def negative_failure_message
|
18
|
+
"expected something else then '#{@paths.inspect}' but got '#{@actual.inspect}'"
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def all_apps?
|
25
|
+
@tags.all? { |tag| tag.is_a?(Mactag::Indexer::App) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def have_app_index(*paths)
|
30
|
+
AppIndex.new(paths)
|
31
|
+
end
|
32
|
+
end
|
data/spec/matcher/gem.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Matcher
|
2
|
+
class GemIndex
|
3
|
+
def initialize(name, version)
|
4
|
+
@name = name
|
5
|
+
@version = version
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches?(dsl)
|
9
|
+
@actual = dsl.builder.tags
|
10
|
+
|
11
|
+
gem_exists? && all_gems?
|
12
|
+
end
|
13
|
+
|
14
|
+
def failure_message
|
15
|
+
"expected '#{@actual.inspect}' to include '#{@name}/#{@version}' but did not"
|
16
|
+
end
|
17
|
+
|
18
|
+
def negative_failure_message
|
19
|
+
"expected '#{@actual.inspect}' to not include '#{@name}/#{@version}' but did"
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def all_gems?
|
26
|
+
@actual.all? { |tag| tag.is_a?(Mactag::Indexer::Gem) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def gem_exists?
|
30
|
+
@actual.find do |gem|
|
31
|
+
gem.name == @name && gem.version == @version
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def have_gem_index(name, version = nil)
|
37
|
+
GemIndex.new(name, version)
|
38
|
+
end
|
39
|
+
end
|
data/spec/matcher/lib.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Matcher
|
2
|
+
class LibIndex
|
3
|
+
def initialize(paths)
|
4
|
+
@paths = paths
|
5
|
+
end
|
6
|
+
|
7
|
+
def matches?(dsl)
|
8
|
+
@tags = dsl.builder.tags
|
9
|
+
@actual = @tags.map(&:tag)
|
10
|
+
@actual - @paths == @paths - @actual
|
11
|
+
end
|
12
|
+
|
13
|
+
def failure_message
|
14
|
+
"expected '#{@paths.inspect}' but got '#{@actual.inspect}'"
|
15
|
+
end
|
16
|
+
|
17
|
+
def negative_failure_message
|
18
|
+
"expected something else then '#{@paths.inspect}' but got '#{@actual.inspect}'"
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def all_libs?
|
24
|
+
@tags.all? { |tag| tag.is_a?(Mactag::Indexer::Lib) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def have_lib_index(*paths)
|
29
|
+
LibIndex.new(paths)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Matcher
|
2
|
+
class PluginIndex
|
3
|
+
def initialize(*plugins)
|
4
|
+
@plugins = plugins
|
5
|
+
end
|
6
|
+
|
7
|
+
def matches?(dsl)
|
8
|
+
@tags = dsl.builder.tags
|
9
|
+
@actual = @tags.map(&:name)
|
10
|
+
@actual - @plugins == @plugins - @actual && all_plugins?
|
11
|
+
end
|
12
|
+
|
13
|
+
def failure_message
|
14
|
+
"expected '#{@actual.inspect}' to equal '#{@plugins}' but did not"
|
15
|
+
end
|
16
|
+
|
17
|
+
def negative_failure_message
|
18
|
+
"expected '#{@actual.inspect}' to not equal '#{@plugins}' but did"
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def all_plugins?
|
25
|
+
@tags.all? { |tag| tag.is_a?(Mactag::Indexer::Plugin) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def have_plugin_index(*plugins)
|
30
|
+
PluginIndex.new(*plugins)
|
31
|
+
end
|
32
|
+
end
|