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.
@@ -0,0 +1,180 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mactag::Indexer::Gem do
4
+ subject do
5
+ Mactag::Indexer::Gem.new('devise')
6
+ end
7
+
8
+ it_should_behave_like 'indexer'
9
+
10
+ before do
11
+ @gem = Mactag::Indexer::Gem.new('devise')
12
+
13
+ Mactag::Config.stub(:gem_home) { 'GEM_HOME' }
14
+ end
15
+
16
+ describe '#tag' do
17
+ context 'when gem exists' do
18
+ before do
19
+ @gem.stub(:exist?) { true }
20
+ end
21
+
22
+ context 'without version' do
23
+ before do
24
+ @gem.stub(:most_recent) { '1.1.1' }
25
+ end
26
+
27
+ it 'returns path to gem' do
28
+ @gem.tag.should == 'GEM_HOME/devise-1.1.1/lib/**/*.rb'
29
+ end
30
+ end
31
+
32
+ context 'with version' do
33
+ before do
34
+ @gem.stub(:version) { '1.1.1' }
35
+ end
36
+
37
+ it 'returns path to gem' do
38
+ @gem.tag.should == 'GEM_HOME/devise-1.1.1/lib/**/*.rb'
39
+ end
40
+ end
41
+ end
42
+
43
+ context 'when gem does not exist' do
44
+ before do
45
+ @gem.stub(:exist?) { false }
46
+ end
47
+
48
+ it 'raises exception' do
49
+ proc {
50
+ @gem.tag
51
+ }.should raise_exception(Mactag::GemNotFoundError)
52
+ end
53
+ end
54
+ end
55
+
56
+ describe '#exist?' do
57
+ it 'exists when single version of gem exists' do
58
+ @gem.stub(:dirs) { ['GEM_HOME/devise-1.1.1/lib/**/*.rb'] }
59
+ @gem.should exist
60
+ end
61
+
62
+ it 'exists when more than one version of gem exists' do
63
+ @gem.stub(:dirs) {
64
+ [
65
+ 'GEM_HOME/devise-1.1.0/lib/**/*.rb',
66
+ 'GEM_HOME/devise-1.1.1/lib/**/*.rb'
67
+ ]
68
+ }
69
+ @gem.should exist
70
+ end
71
+
72
+ it 'does not exist when no gem exist' do
73
+ @gem.stub(:dirs) { [] }
74
+ @gem.should_not exist
75
+ end
76
+ end
77
+
78
+ describe '#version' do
79
+ it 'should return version when specified' do
80
+ gem = Mactag::Indexer::Gem.new('devise', '1.1.1')
81
+ gem.version.should == '1.1.1'
82
+ end
83
+
84
+ it 'should return most recent version when not specified' do
85
+ gem = Mactag::Indexer::Gem.new('devise')
86
+ gem.stub(:most_recent) { '1.1.1' }
87
+ gem.version.should == '1.1.1'
88
+ end
89
+ end
90
+
91
+ describe '#most_recent' do
92
+ context 'when no gems exists' do
93
+ before do
94
+ @gem.stub(:dirs) { [] }
95
+ end
96
+
97
+ it 'should be nil' do
98
+ @gem.most_recent.should be_nil
99
+ end
100
+ end
101
+
102
+ context 'when single version of gem exist' do
103
+ before do
104
+ @gem.stub(:dirs) { ['GEM_HOME/devise-1.1.1/lib/**/*.rb'] }
105
+ end
106
+
107
+ it 'should extract version' do
108
+ @gem.most_recent.should == '1.1.1'
109
+ end
110
+ end
111
+
112
+ context 'when multiple versions of gem exist' do
113
+ before do
114
+ @gem.stub(:dirs) {
115
+ [
116
+ 'GEM_HOME/devise-1.1.0/lib/**/*.rb',
117
+ 'GEM_HOME/devise-1.1.1/lib/**/*.rb'
118
+ ]
119
+ }
120
+ end
121
+
122
+ it 'should extract the most recent version' do
123
+ @gem.most_recent.should == '1.1.1'
124
+ end
125
+ end
126
+
127
+ context 'when gem name includes regex keywords' do
128
+ before do
129
+ @gem = Mactag::Indexer::Gem.new('foo+bar')
130
+ @gem.stub(:dirs) { ['GEM_HOME/foo+bar-0.0.1/lib/**/*.rb'] }
131
+ end
132
+
133
+ it 'should extract version' do
134
+ @gem.most_recent.should == '0.0.1'
135
+ end
136
+ end
137
+
138
+ context 'when gem version is not on the form MAJOR.MINOR.PATCH' do
139
+ before do
140
+ @gem.stub(:dirs) { ['GEM_HOME/devise-2.0.0.rc/lib/**/*.rb'] }
141
+ end
142
+
143
+ it 'should extract version' do
144
+ @gem.most_recent.should == '2.0.0.rc'
145
+ end
146
+ end
147
+
148
+ context 'when the path contains other version numbers' do
149
+ before do
150
+ @gem.stub(:dirs) { ['/Users/user/.rvm/gems/ree-1.8.7-2011.03@project/gems/devise-1.1.2'] }
151
+ end
152
+
153
+ it 'should extract version' do
154
+ @gem.most_recent.should == '1.1.2'
155
+ end
156
+ end
157
+ end
158
+
159
+ context '#dirs' do
160
+ it 'should escape gem name' do
161
+ Dir.should_receive(:glob).with('GEM_HOME/devise-*')
162
+
163
+ @gem.dirs
164
+ end
165
+ end
166
+
167
+ context 'self#all' do
168
+ before do
169
+ Mactag::Bundler.stub(:gems) { [['devise', '1.1.1']] }
170
+ end
171
+
172
+ it 'should return all as gems' do
173
+ all = Mactag::Indexer::Gem.all
174
+
175
+ gem = all.first
176
+ gem.name.should == 'devise'
177
+ gem.version.should == '1.1.1'
178
+ end
179
+ end
180
+ end
@@ -1,68 +1,77 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Mactag::Tag::Plugin do
3
+ describe Mactag::Indexer::Plugin do
4
4
  subject do
5
- Mactag::Tag::Plugin.new('devise')
5
+ Mactag::Indexer::Plugin.new('devise')
6
6
  end
7
-
7
+
8
+ it_should_behave_like 'indexer'
9
+
8
10
  before do
9
- @plugin = Mactag::Tag::Plugin.new('devise')
11
+ @plugin = Mactag::Indexer::Plugin.new('devise')
10
12
  end
11
13
 
12
- it_should_behave_like 'tagger'
13
-
14
14
  it 'has correct plugin path' do
15
- Mactag::Tag::Plugin::PLUGIN_PATH.should eq(['vendor', 'plugins'])
15
+ Mactag::Indexer::Plugin::PLUGIN_PATH.should == ['vendor', 'plugins']
16
16
  end
17
17
 
18
18
  describe '#tag' do
19
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')
20
+ @plugin.stub(:exist?) { true }
21
+ @plugin.tag.should == 'vendor/plugins/devise/lib/**/*.rb'
22
22
  end
23
23
 
24
24
  it 'raises exception when plugin does not exist' do
25
- @plugin.stub(:exists?) { false }
25
+ @plugin.stub(:exist?) { false }
26
26
  proc {
27
27
  @plugin.tag
28
28
  }.should raise_exception(Mactag::PluginNotFoundError)
29
29
  end
30
30
  end
31
31
 
32
- describe '#path' do
33
- it 'return path to plugin' do
34
- @plugin.path.should eq('vendor/plugins/devise')
35
- end
36
- end
37
-
38
- describe '#exists?' do
32
+ describe '#exist?' do
39
33
  it 'is true when plugin directory exists' do
40
34
  File.stub(:directory?) { true }
41
- @plugin.exists?.should be_true
35
+ @plugin.should exist
42
36
  end
43
37
 
44
38
  it 'is false when plugin directory does not exist' do
45
39
  File.stub(:directory?) { false }
46
- @plugin.exists?.should be_false
40
+ @plugin.should_not exist
41
+ end
42
+ end
43
+
44
+ describe '#path' do
45
+ it 'return path to plugin' do
46
+ @plugin.path.should == 'vendor/plugins/devise'
47
47
  end
48
48
  end
49
49
 
50
50
  describe '#all' do
51
51
  it 'returns empty array when no plugins' do
52
52
  Dir.stub(:glob) { [] }
53
- Mactag::Tag::Plugin.all.should be_empty
53
+
54
+ all = Mactag::Indexer::Plugin.all
55
+ all.should be_empty
54
56
  end
55
57
 
56
58
  it 'returns plugin name when single plugin' do
57
59
  Dir.stub(:glob) { ['vendor/plugins/devise'] }
58
- Mactag::Tag::Plugin.all.should eq(['devise'])
60
+
61
+ all = Mactag::Indexer::Plugin.all
62
+ all.map(&:name).should == ['devise']
59
63
  end
60
64
 
61
65
  it 'returns plugin names when multiple plugins' do
62
66
  Dir.stub(:glob) {
63
- ['vendor/plugins/devise', 'vendor/plugins/simple_form']
67
+ [
68
+ 'vendor/plugins/devise',
69
+ 'vendor/plugins/simple_form'
70
+ ]
64
71
  }
65
- Mactag::Tag::Plugin.all.should eq(['devise', 'simple_form'])
72
+
73
+ all = Mactag::Indexer::Plugin.all
74
+ all.map(&:name).should =~ ['devise', 'simple_form']
66
75
  end
67
76
  end
68
77
  end
@@ -0,0 +1,112 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mactag::Indexer::Rails do
4
+ subject do
5
+ Mactag::Indexer::Rails.new({})
6
+ end
7
+
8
+ it_should_behave_like 'indexer'
9
+
10
+ before do
11
+ @rails = Mactag::Indexer::Rails.new({})
12
+ end
13
+
14
+ it 'should have correct default packages' do
15
+ Mactag::Indexer::Rails::PACKAGES.should == ['actionmailer', 'actionpack', 'activemodel', 'activerecord', 'activeresource', 'activesupport', 'railties']
16
+ end
17
+
18
+ context 'packagize' do
19
+ it 'should packagize only' do
20
+ @rails = Mactag::Indexer::Rails.new(:only => ['active_model'])
21
+ @rails.only.should == ['activemodel']
22
+ end
23
+
24
+ it 'should packagize except' do
25
+ @rails = Mactag::Indexer::Rails.new(:except => ['active_model', :action_pack])
26
+ @rails.except.should == ['activemodel', 'actionpack']
27
+ end
28
+ end
29
+
30
+ describe '#tag' do
31
+ before do
32
+ Mactag::Indexer::Gem.stub(:new) { mock(:tag => 'tag') }
33
+ end
34
+
35
+ it 'returns empty array when no packages' do
36
+ @rails.stub(:packages) { [] }
37
+ @rails.tag.should == []
38
+ end
39
+
40
+ it 'returns array with gem tags when packages' do
41
+ @rails.stub(:packages) { ['activemodel', 'activerecord'] }
42
+ @rails.tag.should == ['tag', 'tag']
43
+ end
44
+ end
45
+
46
+ describe '#packages' do
47
+ it 'should return all packages unless only and except' do
48
+ @rails.packages.should =~ Mactag::Indexer::Rails::PACKAGES
49
+ end
50
+
51
+ it 'should return some packages when only specified' do
52
+ @rails = Mactag::Indexer::Rails.new(:only => [:active_support, :activerecord])
53
+ @rails.packages.should =~ ['activesupport', 'activerecord']
54
+ end
55
+
56
+ it 'should return some packages when except specified' do
57
+ @rails = Mactag::Indexer::Rails.new(:except => [:active_support, :activerecord])
58
+ @rails.packages.should =~ ['actionmailer', 'actionpack', 'activemodel', 'activeresource', 'railties']
59
+ end
60
+ end
61
+
62
+ describe '#packagize' do
63
+ it 'returns empty array when no packages' do
64
+ @rails.send(:packagize, []).should be_nil
65
+ end
66
+
67
+ context 'single package' do
68
+ it 'packagizes when symbol' do
69
+ @rails.send(:packagize, [:activerecord]).should =~ ['activerecord']
70
+ end
71
+
72
+ it 'packagizes when string' do
73
+ @rails.send(:packagize, ['activerecord']).should =~ ['activerecord']
74
+ end
75
+
76
+ it 'packagizes when underscore' do
77
+ @rails.send(:packagize, [:active_record]).should =~ ['activerecord']
78
+ end
79
+ end
80
+
81
+ context 'multiples packages' do
82
+ it 'packagizes when symbols' do
83
+ @rails.send(:packagize, [:activerecord, :activemodel]).should =~ ['activerecord', 'activemodel']
84
+ end
85
+
86
+ it 'packagizes when string' do
87
+ @rails.send(:packagize, ['activerecord', 'activemodel']).should =~ ['activerecord', 'activemodel']
88
+ end
89
+
90
+ it 'packagizes when underscore' do
91
+ @rails.send(:packagize, [:active_record, :active_model]).should =~ ['activerecord', 'activemodel']
92
+ end
93
+
94
+ it 'packagizes when mixed' do
95
+ @rails.send(:packagize, [:active_record, 'activemodel']).should =~ ['activerecord', 'activemodel']
96
+ end
97
+ end
98
+ end
99
+
100
+ describe '#version' do
101
+ it 'returns specified version when version' do
102
+ @rails = Mactag::Indexer::Rails.new(:version => '3.0.0')
103
+ @rails.send(:version).should == '3.0.0'
104
+ end
105
+
106
+ it 'returns same version as app when version option is not specified' do
107
+ Rails.stub(:version) { '3.0.0' }
108
+
109
+ @rails.send(:version).should == '3.0.0'
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'rails'
3
+ require 'bundler'
4
+ require 'rspec'
5
+
6
+ require 'mactag'
7
+
8
+ require 'matcher'
9
+
10
+ RSpec.configure do |config|
11
+ config.include Matcher
12
+ end
13
+
14
+ shared_examples_for 'indexer' do
15
+ it 'responds to #tag' do
16
+ subject.should respond_to(:tag)
17
+ end
18
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mactag
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 5
9
- - 4
10
- version: 0.5.4
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Johan Andersson
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-06 00:00:00 +01:00
19
- default_executable:
18
+ date: 2011-02-06 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: rails
@@ -40,16 +39,43 @@ dependencies:
40
39
  requirement: &id002 !ruby/object:Gem::Requirement
41
40
  none: false
42
41
  requirements:
43
- - - ">="
42
+ - - ~>
44
43
  - !ruby/object:Gem::Version
45
- hash: 15
44
+ hash: 13
46
45
  segments:
47
46
  - 2
47
+ - 7
48
+ version: "2.7"
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: yard
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
48
61
  - 0
62
+ version: "0"
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: redcarpet
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
49
75
  - 0
50
- version: 2.0.0
76
+ version: "0"
51
77
  type: :development
52
- version_requirements: *id002
78
+ version_requirements: *id004
53
79
  description: Mactag is a Ctags DSL for Rails
54
80
  email: johan.rejeep@gmail.com
55
81
  executables: []
@@ -59,7 +85,6 @@ extensions: []
59
85
  extra_rdoc_files:
60
86
  - README.markdown
61
87
  files:
62
- - .gemtest
63
88
  - README.markdown
64
89
  - Rakefile
65
90
  - VERSION
@@ -73,24 +98,23 @@ files:
73
98
  - lib/mactag/dsl.rb
74
99
  - lib/mactag/errors.rb
75
100
  - lib/mactag/railtie.rb
76
- - lib/mactag/tag.rb
77
- - lib/mactag/tag/app.rb
78
- - lib/mactag/tag/gem.rb
79
- - lib/mactag/tag/plugin.rb
80
- - lib/mactag/tag/rails.rb
101
+ - lib/mactag/indexer.rb
102
+ - lib/mactag/indexer/app.rb
103
+ - lib/mactag/indexer/gem.rb
104
+ - lib/mactag/indexer/plugin.rb
105
+ - lib/mactag/indexer/rails.rb
81
106
  - lib/tasks/mactag.rake
82
107
  - spec/mactag/builder_spec.rb
83
108
  - spec/mactag/bundler_spec.rb
84
109
  - spec/mactag/config_spec.rb
85
110
  - spec/mactag/ctags_spec.rb
86
111
  - spec/mactag/dsl_spec.rb
87
- - spec/mactag/tag/app_spec.rb
88
- - spec/mactag/tag/gem_spec.rb
89
- - spec/mactag/tag/plugin_spec.rb
90
- - spec/mactag/tag/rails_spec.rb
91
- - spec/mactag/tag_spec.rb
112
+ - spec/mactag/indexer/app_spec.rb
113
+ - spec/mactag/indexer/gem_spec.rb
114
+ - spec/mactag/indexer/plugin_spec.rb
115
+ - spec/mactag/indexer/rails_spec.rb
92
116
  - spec/mactag_spec.rb
93
- has_rdoc: true
117
+ - spec/spec_helper.rb
94
118
  homepage: http://github.com/rejeep/mactag
95
119
  licenses: []
96
120
 
@@ -120,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
144
  requirements: []
121
145
 
122
146
  rubyforge_project:
123
- rubygems_version: 1.5.0
147
+ rubygems_version: 1.8.10
124
148
  signing_key:
125
149
  specification_version: 3
126
150
  summary: Ctags for Rails
@@ -130,9 +154,10 @@ test_files:
130
154
  - spec/mactag/config_spec.rb
131
155
  - spec/mactag/ctags_spec.rb
132
156
  - spec/mactag/dsl_spec.rb
133
- - spec/mactag/tag/app_spec.rb
134
- - spec/mactag/tag/gem_spec.rb
135
- - spec/mactag/tag/plugin_spec.rb
136
- - spec/mactag/tag/rails_spec.rb
137
- - spec/mactag/tag_spec.rb
157
+ - spec/mactag/indexer/app_spec.rb
158
+ - spec/mactag/indexer/gem_spec.rb
159
+ - spec/mactag/indexer/plugin_spec.rb
160
+ - spec/mactag/indexer/rails_spec.rb
138
161
  - spec/mactag_spec.rb
162
+ - spec/spec_helper.rb
163
+ has_rdoc: