mactag 0.4.0 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,94 +1,105 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Mactag::Tag::Rails do
4
- it 'should have correct packages' do
5
- Mactag::Tag::Rails::PACKAGES.should =~ [:actionmailer, :actionpack, :activemodel, :activerecord, :activeresource, :railties, :activesupport]
4
+ subject do
5
+ Mactag::Tag::Rails.new({})
6
+ end
7
+
8
+ it_should_behave_like 'tagger'
9
+
10
+ before do
11
+ @rails = Mactag::Tag::Rails.new({})
12
+ end
13
+
14
+ it 'has correct default packages' do
15
+ Mactag::Tag::Rails::PACKAGES.should eq(['actionmailer', 'actionpack', 'activemodel', 'activerecord', 'activeresource', 'activesupport', 'railties'])
6
16
  end
7
17
 
8
18
  describe '#tag' do
9
19
  before do
10
- @rails = Mactag::Tag::Rails.new({})
20
+ Mactag::Tag::Gem.stub(:new) { mock(:tag => 'tag') }
11
21
  end
12
22
 
13
- it 'return empty array if no packages' do
14
- @rails.stub!(:packages).and_return([])
23
+ it 'returns empty array if no packages' do
24
+ @rails.stub(:packages) { [] }
15
25
 
16
- @rails.tag.should be_empty
26
+ @rails.tag.should eq([])
17
27
  end
18
28
 
19
- it 'should return array with gem tags when packages' do
20
- @rails.stub!(:packages).and_return([:activemodel, :activerecord])
29
+ it 'returns array with gem tags when packages' do
30
+ @rails.stub(:packages) { ['activemodel', 'activerecord'] }
21
31
 
22
- o = Object.new
23
- def o.tag
24
- 'tag'
25
- end
26
-
27
- Mactag::Tag::Gem.stub!(:new).and_return(o)
28
-
29
- @rails.tag.should =~ ['tag', 'tag']
32
+ @rails.tag.should eq(['tag', 'tag'])
30
33
  end
31
34
  end
32
35
 
33
36
  describe '#packages' do
34
- it 'should return all packages when no arguments' do
35
- @rails = Mactag::Tag::Rails.new({})
36
-
37
- @rails.send(:packages).should =~ Mactag::Tag::Rails::PACKAGES
37
+ it 'returns all packages unless only and except' do
38
+ @rails.packages.should eq(Mactag::Tag::Rails::PACKAGES)
38
39
  end
39
40
 
40
- it 'should return some packages when only specified' do
41
+ it 'returns some packages when only specified' do
41
42
  @rails = Mactag::Tag::Rails.new(:only => [:active_support, :activerecord])
42
43
 
43
- @rails.send(:packages).should =~ [:activesupport, :activerecord]
44
+ @rails.packages.should eq(['activesupport', 'activerecord'])
44
45
  end
45
46
 
46
- it 'return some packages when except specified' do
47
+ it 'returns some packages when except specified' do
47
48
  @rails = Mactag::Tag::Rails.new(:except => [:active_support, :activerecord])
48
49
 
49
- @rails.send(:packages).should =~ (Mactag::Tag::Rails::PACKAGES - [:activesupport, :activerecord])
50
+ @rails.packages.should eq(['actionmailer', 'actionpack', 'activemodel', 'activeresource', 'railties'])
50
51
  end
51
52
  end
52
53
 
53
54
  describe '#packagize' do
54
- before do
55
- @rails = Mactag::Tag::Rails.new({})
55
+ it 'returns empty array when no packages' do
56
+ @rails.send(:packagize, []).should be_nil
56
57
  end
57
58
 
58
59
  context 'single package' do
59
- before do
60
- @packagized = @rails.send(:packagize!, 'active_record')
60
+ it 'packagizes when symbol' do
61
+ @rails.send(:packagize, [:activerecord]).should eq(['activerecord'])
62
+ end
63
+
64
+ it 'packagizes when string' do
65
+ @rails.send(:packagize, ['activerecord']).should eq(['activerecord'])
61
66
  end
62
67
 
63
- it 'should return package packagized' do
64
- @packagized.should =~ [:activerecord]
68
+ it 'packagizes when underscore' do
69
+ @rails.send(:packagize, [:active_record]).should eq(['activerecord'])
65
70
  end
66
71
  end
67
72
 
68
- context 'multiple packages' do
69
- before do
70
- @packagized = @rails.send(:packagize!, ['_active_support_', :action_view])
73
+ context 'multiples packages' do
74
+ it 'packagizes when symbols' do
75
+ @rails.send(:packagize, [:activerecord, :activemodel]).should eq(['activerecord', 'activemodel'])
76
+ end
77
+
78
+ it 'packagizes when string' do
79
+ @rails.send(:packagize, ['activerecord', 'activemodel']).should eq(['activerecord', 'activemodel'])
80
+ end
81
+
82
+ it 'packagizes when underscore' do
83
+ @rails.send(:packagize, [:active_record, :active_model]).should eq(['activerecord', 'activemodel'])
71
84
  end
72
85
 
73
- it 'should return packages packagized' do
74
- @packagized.should =~ [:activesupport, :actionview]
86
+ it 'packagizes when mixed' do
87
+ @rails.send(:packagize, [:active_record, 'activemodel']).should eq(['activerecord', 'activemodel'])
75
88
  end
76
89
  end
77
90
  end
78
91
 
79
92
  describe '#version' do
80
- it 'should pick specified version when given' do
81
- @rails = Mactag::Tag::Rails.new({ :version => '3.0.0.rc' })
93
+ it 'returns specified version when version option' do
94
+ @rails = Mactag::Tag::Rails.new(:version => '3.0.0')
82
95
 
83
- @rails.send(:version).should == '3.0.0.rc'
96
+ @rails.send(:version).should eq('3.0.0')
84
97
  end
85
98
 
86
- it 'pick same rails version as application when not specified version' do
87
- Rails.stub!(:version).and_return('3.0.0.beta3')
88
-
89
- @rails = Mactag::Tag::Rails.new({})
99
+ it 'returns same version as rails application when version option is not specified' do
100
+ Rails.stub(:version) { '3.0.0' }
90
101
 
91
- @rails.send(:version).should == '3.0.0.beta3'
102
+ @rails.send(:version).should eq('3.0.0')
92
103
  end
93
104
  end
94
105
  end
@@ -0,0 +1,5 @@
1
+ describe 'Tag' do
2
+ it 'does not pollute the global namespace' do
3
+ Object.const_defined?(:Tag).should be_false
4
+ end
5
+ 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: 15
5
- prerelease: false
4
+ hash: 13
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 0
10
- version: 0.4.0
8
+ - 5
9
+ - 3
10
+ version: 0.5.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Johan Andersson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-13 00:00:00 +02:00
18
+ date: 2011-02-06 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,17 +26,16 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: -1848230019
29
+ hash: 7
30
30
  segments:
31
31
  - 3
32
32
  - 0
33
33
  - 0
34
- - beta1
35
- version: 3.0.0.beta1
34
+ version: 3.0.0
36
35
  type: :runtime
37
36
  version_requirements: *id001
38
37
  - !ruby/object:Gem::Dependency
39
- name: bundler
38
+ name: rspec
40
39
  prerelease: false
41
40
  requirement: &id002 !ruby/object:Gem::Requirement
42
41
  none: false
@@ -45,31 +44,13 @@ dependencies:
45
44
  - !ruby/object:Gem::Version
46
45
  hash: 15
47
46
  segments:
48
- - 0
49
- - 9
50
- - 26
51
- version: 0.9.26
52
- type: :runtime
53
- version_requirements: *id002
54
- - !ruby/object:Gem::Dependency
55
- name: rspec
56
- prerelease: false
57
- requirement: &id003 !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- hash: 62196421
63
- segments:
64
47
  - 2
65
48
  - 0
66
49
  - 0
67
- - beta
68
- - 19
69
- version: 2.0.0.beta.19
50
+ version: 2.0.0
70
51
  type: :development
71
- version_requirements: *id003
72
- description: Mactag is DSL in ruby for creating a Ctags-file for Rails projects
52
+ version_requirements: *id002
53
+ description: Mactag is a Ctags DSL for Rails
73
54
  email: johan.rejeep@gmail.com
74
55
  executables: []
75
56
 
@@ -78,43 +59,44 @@ extensions: []
78
59
  extra_rdoc_files:
79
60
  - README.markdown
80
61
  files:
62
+ - .gemtest
81
63
  - README.markdown
64
+ - Rakefile
82
65
  - VERSION
83
66
  - lib/generators/mactag/mactag_generator.rb
84
67
  - lib/generators/mactag/templates/mactag.rb
85
68
  - lib/mactag.rb
86
69
  - lib/mactag/builder.rb
70
+ - lib/mactag/bundler.rb
87
71
  - lib/mactag/config.rb
88
72
  - lib/mactag/ctags.rb
89
73
  - lib/mactag/dsl.rb
90
- - lib/mactag/event_handler.rb
74
+ - lib/mactag/errors.rb
91
75
  - lib/mactag/railtie.rb
92
- - lib/mactag/server.rb
93
76
  - lib/mactag/tag.rb
94
77
  - lib/mactag/tag/app.rb
95
78
  - lib/mactag/tag/gem.rb
96
79
  - lib/mactag/tag/plugin.rb
97
80
  - lib/mactag/tag/rails.rb
98
- - lib/mactag/tags_file.rb
99
81
  - lib/tasks/mactag.rake
100
82
  - spec/mactag/builder_spec.rb
83
+ - spec/mactag/bundler_spec.rb
101
84
  - spec/mactag/config_spec.rb
102
85
  - spec/mactag/ctags_spec.rb
103
86
  - spec/mactag/dsl_spec.rb
104
- - spec/mactag/server_spec.rb
105
87
  - spec/mactag/tag/app_spec.rb
106
88
  - spec/mactag/tag/gem_spec.rb
107
89
  - spec/mactag/tag/plugin_spec.rb
108
90
  - spec/mactag/tag/rails_spec.rb
109
- - spec/mactag/tags_file_spec.rb
91
+ - spec/mactag/tag_spec.rb
110
92
  - spec/mactag_spec.rb
111
93
  has_rdoc: true
112
94
  homepage: http://github.com/rejeep/mactag
113
95
  licenses: []
114
96
 
115
97
  post_install_message:
116
- rdoc_options:
117
- - --charset=UTF-8
98
+ rdoc_options: []
99
+
118
100
  require_paths:
119
101
  - lib
120
102
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -138,19 +120,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
120
  requirements: []
139
121
 
140
122
  rubyforge_project:
141
- rubygems_version: 1.3.7
123
+ rubygems_version: 1.5.0
142
124
  signing_key:
143
125
  specification_version: 3
144
126
  summary: Ctags for Rails
145
127
  test_files:
146
128
  - spec/mactag/builder_spec.rb
129
+ - spec/mactag/bundler_spec.rb
147
130
  - spec/mactag/config_spec.rb
148
131
  - spec/mactag/ctags_spec.rb
149
132
  - spec/mactag/dsl_spec.rb
150
- - spec/mactag/server_spec.rb
151
133
  - spec/mactag/tag/app_spec.rb
152
134
  - spec/mactag/tag/gem_spec.rb
153
135
  - spec/mactag/tag/plugin_spec.rb
154
136
  - spec/mactag/tag/rails_spec.rb
155
- - spec/mactag/tags_file_spec.rb
137
+ - spec/mactag/tag_spec.rb
156
138
  - spec/mactag_spec.rb
@@ -1,22 +0,0 @@
1
- module Mactag
2
- class EventHandler
3
- def update(file)
4
- tags_file = Mactag::TagsFile.new(file)
5
- if tags_file.exist?
6
- tags_file.delete
7
- tags_file.create
8
- end
9
- end
10
-
11
- def delete(file)
12
- tags_file = Mactag::TagsFile.new(file)
13
- if tags_file.exist?
14
- tags_file.delete
15
- end
16
- end
17
-
18
- def create(file)
19
- Mactag::TagsFile.new(file).create
20
- end
21
- end
22
- end
@@ -1,48 +0,0 @@
1
- module Mactag
2
- class Server
3
- class << self
4
- def start
5
- create_tags_dir
6
- clear_tags
7
- init_tags
8
- init_monitor
9
- end
10
-
11
-
12
- private
13
-
14
- def create_tags_dir
15
- tags_dir = File.join(Rails.root, Mactag::Config.tags_dir)
16
- unless File.directory?(tags_dir)
17
- Dir.mkdir(tags_dir)
18
- end
19
- end
20
-
21
- def clear_tags
22
- tags_files = File.join(Rails.root, Mactag::Config.tags_dir, '*')
23
- Dir.glob(tags_files).each do |file|
24
- File.delete(file)
25
- end
26
- end
27
-
28
- def init_tags
29
- Mactag::Builder.builder.files.each do |file|
30
- Mactag::TagsFile.new(file).create
31
- end
32
- end
33
-
34
- def init_monitor
35
- event_handler = Mactag::EventHandler.new
36
- FSSM.monitor do
37
- Mactag::Builder.builder.directories.each do |directory|
38
- path(directory) do
39
- update { |base, relative| event_handler.update(File.join(base, relative)) }
40
- delete { |base, relative| event_handler.delete(File.join(base, relative)) }
41
- create { |base, relative| event_handler.create(File.join(base, relative)) }
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,31 +0,0 @@
1
- module Mactag
2
- class TagsFile
3
- def initialize(file)
4
- @input = file
5
- @output = output(file)
6
- end
7
-
8
- def create
9
- system "/usr/local/Cellar/ctags/5.8/bin/ctags -o #{@output} -e #{@input}"
10
- end
11
-
12
- def delete
13
- File.delete(@output)
14
- end
15
-
16
- def exist?
17
- File.exists?(@output)
18
- end
19
-
20
- private
21
-
22
- def output(file)
23
- basename = File.basename(file, '.*')
24
- dirname = File.dirname(file)
25
-
26
- filename = [dirname.gsub(/\//, '_'), basename].join('_')
27
-
28
- File.join(Rails.root, Mactag::Config.tags_dir, filename)
29
- end
30
- end
31
- end
@@ -1,4 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Mactag::Server do
4
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Mactag::TagsFile do
4
- before do
5
- File.stub!(:join).and_return('_path_to.file.rb')
6
-
7
- @tags_file = Mactag::TagsFile.new('file')
8
- end
9
-
10
- describe '#delete' do
11
- it 'should delete output file' do
12
- File.should_receive(:delete).with(@tags_file.instance_variable_get('@output'))
13
-
14
- @tags_file.delete
15
- end
16
- end
17
-
18
- describe 'exists?' do
19
- it 'should exist when file exists' do
20
- File.stub!(:exists?).and_return(true)
21
-
22
- @tags_file.exist?.should be_true
23
- end
24
-
25
- it 'should not exist when file does not exist' do
26
- File.stub!(:exists?).and_return(false)
27
-
28
- @tags_file.exist?.should be_false
29
- end
30
- end
31
-
32
- describe '#output' do
33
- it 'return correct output file' do
34
- File.stub!(:join).and_return { |*args| args.last }
35
-
36
- @tags_file.send(:output, '/path/to/file.rb').should == '_path_to_file'
37
- end
38
- end
39
- end