mactag 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +3 -3
- data/VERSION +1 -1
- data/lib/generators/mactag/templates/mactag.rb +1 -1
- data/lib/mactag.rb +7 -1
- data/lib/mactag/builder.rb +90 -0
- data/lib/mactag/ctags.rb +23 -0
- data/lib/mactag/parser.rb +61 -0
- data/lib/mactag/tag.rb +0 -1
- data/lib/mactag/tag/app.rb +4 -4
- data/lib/mactag/tag/gem.rb +43 -38
- data/lib/mactag/tag/plugin.rb +19 -14
- data/lib/mactag/tag/rails.rb +3 -8
- data/lib/tasks/mactag.rake +1 -1
- data/test/mactag/builder_test.rb +77 -0
- data/test/mactag/config_test.rb +4 -8
- data/test/mactag/parser_test.rb +66 -0
- data/test/mactag/tag/app_test.rb +4 -4
- data/test/mactag/tag/gem_test.rb +100 -47
- data/test/mactag/tag/plugin_test.rb +28 -29
- data/test/mactag/tag/rails_test.rb +40 -28
- metadata +14 -71
- data/features/app.feature +0 -110
- data/features/gem.feature +0 -154
- data/features/plugin.feature +0 -115
- data/features/rails.feature +0 -6
- data/features/step_definitions/mactag_steps.rb +0 -43
- data/features/support/env.rb +0 -14
- data/features/support/rails_app.rb +0 -46
- data/features/support/tags_file.rb +0 -24
- data/lib/mactag/table.rb +0 -66
- data/lib/mactag/tag/parser.rb +0 -43
data/features/plugin.feature
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
Feature: Tag Plugins
|
2
|
-
In order to create a TAGS file
|
3
|
-
As a user
|
4
|
-
I want to tag application plugins
|
5
|
-
|
6
|
-
Background:
|
7
|
-
Given a Rails application
|
8
|
-
And mactag is installed
|
9
|
-
|
10
|
-
Scenario: Tag single plugin
|
11
|
-
Given the plugin "superduper" is installed
|
12
|
-
And file "vendor/plugins/superduper/lib/superduper.rb" with contents:
|
13
|
-
"""
|
14
|
-
class SuperDuper
|
15
|
-
def i_really_am
|
16
|
-
# ...
|
17
|
-
end
|
18
|
-
end
|
19
|
-
"""
|
20
|
-
And this mactag config file:
|
21
|
-
"""
|
22
|
-
Mactag::Table.generate do
|
23
|
-
plugin 'superduper'
|
24
|
-
end
|
25
|
-
"""
|
26
|
-
When I create the tags file
|
27
|
-
Then "i_really_am" should be tagged
|
28
|
-
|
29
|
-
Scenario: Tag multiple plugins different calls
|
30
|
-
Given the plugin "superduper" is installed
|
31
|
-
Given the plugin "dunder" is installed
|
32
|
-
And file "vendor/plugins/superduper/lib/superduper.rb" with contents:
|
33
|
-
"""
|
34
|
-
class SuperDuper
|
35
|
-
def i_really_am
|
36
|
-
# ...
|
37
|
-
end
|
38
|
-
end
|
39
|
-
"""
|
40
|
-
And file "vendor/plugins/dunder/lib/dunder.rb" with contents:
|
41
|
-
"""
|
42
|
-
class Dunder
|
43
|
-
def and_brak
|
44
|
-
# ...
|
45
|
-
end
|
46
|
-
end
|
47
|
-
"""
|
48
|
-
And this mactag config file:
|
49
|
-
"""
|
50
|
-
Mactag::Table.generate do
|
51
|
-
plugin 'superduper'
|
52
|
-
plugin 'dunder'
|
53
|
-
end
|
54
|
-
"""
|
55
|
-
When I create the tags file
|
56
|
-
Then "i_really_am" should be tagged
|
57
|
-
Then "and_brak" should be tagged
|
58
|
-
|
59
|
-
Scenario: Tag multiple plugins same call
|
60
|
-
Given the plugin "superduper" is installed
|
61
|
-
Given the plugin "dunder" is installed
|
62
|
-
And file "vendor/plugins/superduper/lib/superduper.rb" with contents:
|
63
|
-
"""
|
64
|
-
class SuperDuper
|
65
|
-
def i_really_am
|
66
|
-
# ...
|
67
|
-
end
|
68
|
-
end
|
69
|
-
"""
|
70
|
-
And file "vendor/plugins/dunder/lib/dunder.rb" with contents:
|
71
|
-
"""
|
72
|
-
class Dunder
|
73
|
-
def and_brak
|
74
|
-
# ...
|
75
|
-
end
|
76
|
-
end
|
77
|
-
"""
|
78
|
-
And this mactag config file:
|
79
|
-
"""
|
80
|
-
Mactag::Table.generate do
|
81
|
-
plugins 'superduper', 'dunder'
|
82
|
-
end
|
83
|
-
"""
|
84
|
-
When I create the tags file
|
85
|
-
Then "i_really_am" should be tagged
|
86
|
-
Then "and_brak" should be tagged
|
87
|
-
|
88
|
-
Scenario: Tag all plugins
|
89
|
-
Given the plugin "superduper" is installed
|
90
|
-
Given the plugin "dunder" is installed
|
91
|
-
And file "vendor/plugins/superduper/lib/superduper.rb" with contents:
|
92
|
-
"""
|
93
|
-
class SuperDuper
|
94
|
-
def i_really_am
|
95
|
-
# ...
|
96
|
-
end
|
97
|
-
end
|
98
|
-
"""
|
99
|
-
And file "vendor/plugins/dunder/lib/dunder.rb" with contents:
|
100
|
-
"""
|
101
|
-
class Dunder
|
102
|
-
def and_brak
|
103
|
-
# ...
|
104
|
-
end
|
105
|
-
end
|
106
|
-
"""
|
107
|
-
And this mactag config file:
|
108
|
-
"""
|
109
|
-
Mactag::Table.generate do
|
110
|
-
plugins
|
111
|
-
end
|
112
|
-
"""
|
113
|
-
When I create the tags file
|
114
|
-
Then "i_really_am" should be tagged
|
115
|
-
Then "and_brak" should be tagged
|
data/features/rails.feature
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
Given /^a Rails application$/ do
|
2
|
-
@app = RailsApp.new
|
3
|
-
end
|
4
|
-
|
5
|
-
Given /^mactag is installed$/ do
|
6
|
-
mactag = File.join(@app.root, "vendor", "plugins", "mactag")
|
7
|
-
|
8
|
-
FileUtils.mkdir_p(mactag)
|
9
|
-
|
10
|
-
[ "lib", "Rakefile", "init.rb" ].each do |file|
|
11
|
-
file = File.join(File.dirname(__FILE__), "..", "..", file)
|
12
|
-
|
13
|
-
FileUtils.cp_r(file, mactag)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
Given /^this mactag config file:$/ do |config|
|
18
|
-
@app.inject "config/mactag.rb", config
|
19
|
-
end
|
20
|
-
|
21
|
-
When /^I create the tags file$/ do
|
22
|
-
@tags = TagsFile.new(@app)
|
23
|
-
end
|
24
|
-
|
25
|
-
Then /^"([^"]*)" should be tagged$/ do |definition|
|
26
|
-
assert @tags.include?(definition)
|
27
|
-
end
|
28
|
-
|
29
|
-
Then /^"([^"]*)" should not be tagged$/ do |definition|
|
30
|
-
assert !@tags.include?(definition)
|
31
|
-
end
|
32
|
-
|
33
|
-
Given /^the plugin "([^"]*)" is installed$/ do |plugin|
|
34
|
-
@app.install_plugin(plugin)
|
35
|
-
end
|
36
|
-
|
37
|
-
Given /^the gem "([^"]*)" version "([^"]*)" is installed$/ do |gem, version|
|
38
|
-
@app.install_gem(gem, version)
|
39
|
-
end
|
40
|
-
|
41
|
-
Given /^file "([^"]*)" with contents:$/ do |file, contents|
|
42
|
-
@app.inject file, contents
|
43
|
-
end
|
data/features/support/env.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'active_support'
|
3
|
-
require 'active_support/test_case'
|
4
|
-
require 'active_support/core_ext'
|
5
|
-
require 'test/unit/assertions'
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
8
|
-
require 'mactag'
|
9
|
-
|
10
|
-
World(Test::Unit::Assertions)
|
11
|
-
|
12
|
-
After do
|
13
|
-
@app.destroy unless ENV['DEBUG'] == 'true'
|
14
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
class RailsApp
|
2
|
-
NAME = 'rails_app'
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
create
|
6
|
-
end
|
7
|
-
|
8
|
-
def root
|
9
|
-
@root ||= File.join(File.dirname(__FILE__), '..', '..', NAME)
|
10
|
-
end
|
11
|
-
|
12
|
-
def destroy
|
13
|
-
FileUtils.rm_rf(root)
|
14
|
-
end
|
15
|
-
|
16
|
-
def inject(file, contents)
|
17
|
-
to = File.join(root, file)
|
18
|
-
File.open(to, 'a') { |f| f.write("#{contents}\n") }
|
19
|
-
end
|
20
|
-
|
21
|
-
def install_plugin(plugin)
|
22
|
-
cmd = "cd #{root}"
|
23
|
-
cmd << " && rails generate plugin #{plugin}"
|
24
|
-
cmd << ' -q' unless ENV['DEBUG'] == 'true'
|
25
|
-
system cmd
|
26
|
-
end
|
27
|
-
|
28
|
-
def install_gem(gem, version)
|
29
|
-
install_plugin(gem)
|
30
|
-
|
31
|
-
plugins = File.join(root, 'vendor', 'plugins')
|
32
|
-
gems = File.join(root, 'vendor', 'gems')
|
33
|
-
|
34
|
-
FileUtils.mkdir_p(gems)
|
35
|
-
FileUtils.mv(File.join(plugins, gem), File.join(gems, "#{gem}-#{version}"))
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def create
|
42
|
-
cmd = "rails new #{NAME}"
|
43
|
-
cmd << ' -q' unless ENV['DEBUG'] == 'true'
|
44
|
-
system cmd
|
45
|
-
end
|
46
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
class TagsFile
|
2
|
-
def initialize(app)
|
3
|
-
@app = app
|
4
|
-
@file = File.join(@app.root, "TAGS")
|
5
|
-
|
6
|
-
create
|
7
|
-
end
|
8
|
-
|
9
|
-
def include?(definition)
|
10
|
-
File.open(@file) do |file|
|
11
|
-
return file.read =~ /#{definition}/
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def create
|
19
|
-
cmd = "cd #{@app.root}"
|
20
|
-
cmd << " && rake mactag"
|
21
|
-
cmd << " --trace" if ENV['DEBUG'] == 'true'
|
22
|
-
system cmd
|
23
|
-
end
|
24
|
-
end
|
data/lib/mactag/table.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
module Mactag
|
2
|
-
class Table
|
3
|
-
@@tags = []
|
4
|
-
|
5
|
-
class << self
|
6
|
-
##
|
7
|
-
#
|
8
|
-
# Generates the TAGS-table.
|
9
|
-
#
|
10
|
-
# ==== Example
|
11
|
-
# Mactag::Table.generate do
|
12
|
-
# app 'app/**/*.rb', 'lib/*.rb'
|
13
|
-
#
|
14
|
-
# plugins 'thinking-sphinx', 'whenever'
|
15
|
-
#
|
16
|
-
# gems 'paperclip', 'authlogic'
|
17
|
-
# gem 'formtastic', :version => '0.9.7'
|
18
|
-
#
|
19
|
-
# rails :except => :actionmailer, :version => '2.3.5'
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# See documentation for the methods *app*, *plugins*, *gems* and
|
23
|
-
# *rails* in respective tag class.
|
24
|
-
#
|
25
|
-
def generate(&block)
|
26
|
-
parser = Mactag::Tag::Parser.new(self)
|
27
|
-
parser.instance_eval(&block)
|
28
|
-
end
|
29
|
-
|
30
|
-
def <<(tag)
|
31
|
-
@@tags << tag
|
32
|
-
end
|
33
|
-
|
34
|
-
##
|
35
|
-
#
|
36
|
-
# Returns a string with all files that should be tagged. The
|
37
|
-
# files are separated with a whitespace.
|
38
|
-
#
|
39
|
-
def tags
|
40
|
-
@@tags.collect!(&:files)
|
41
|
-
@@tags.flatten!
|
42
|
-
@@tags.collect! { |file| File.expand_path(file) }
|
43
|
-
@@tags.collect! { |file| Dir.glob(file) }
|
44
|
-
@@tags.uniq!
|
45
|
-
@@tags.join(' ')
|
46
|
-
end
|
47
|
-
|
48
|
-
##
|
49
|
-
#
|
50
|
-
# Create the TAGS file.
|
51
|
-
#
|
52
|
-
def create
|
53
|
-
unless File.directory?(Mactag::Config.gem_home)
|
54
|
-
Mactag.warn 'Gem home path does not exist on your system'
|
55
|
-
end
|
56
|
-
|
57
|
-
if @@tags.collect(&:files).flatten.empty?
|
58
|
-
Mactag.warn 'You did not specify anything to tag'
|
59
|
-
else
|
60
|
-
system "cd #{Rails.root} && #{Mactag::Config.binary} #{Mactag::Table.tags}"
|
61
|
-
puts "Successfully generated TAGS file"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
data/lib/mactag/tag/parser.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
module Mactag
|
2
|
-
module Tag
|
3
|
-
class Parser
|
4
|
-
def initialize(table)
|
5
|
-
@table = table
|
6
|
-
end
|
7
|
-
|
8
|
-
##
|
9
|
-
#
|
10
|
-
# @see Mactag::Tag::App
|
11
|
-
#
|
12
|
-
def app(*files)
|
13
|
-
@table << Mactag::Tag::App.new(*files)
|
14
|
-
end
|
15
|
-
|
16
|
-
##
|
17
|
-
#
|
18
|
-
# @see Mactag::Tag::Plugin
|
19
|
-
#
|
20
|
-
def plugin(*plugins)
|
21
|
-
@table << Mactag::Tag::Plugin.new(*plugins)
|
22
|
-
end
|
23
|
-
alias_method :plugins, :plugin
|
24
|
-
|
25
|
-
##
|
26
|
-
#
|
27
|
-
# @see Mactag::Tag::Gem
|
28
|
-
#
|
29
|
-
def gem(*gems)
|
30
|
-
@table << Mactag::Tag::Gem.new(*gems)
|
31
|
-
end
|
32
|
-
alias_method :gems, :gem
|
33
|
-
|
34
|
-
##
|
35
|
-
#
|
36
|
-
# @see Mactag::Tag::Rails
|
37
|
-
#
|
38
|
-
def rails(options = {})
|
39
|
-
@table << Mactag::Tag::Rails.new(options)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|