mactag 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +35 -30
- data/Rakefile +10 -8
- data/VERSION +1 -1
- data/lib/generators/mactag/templates/mactag.rb +26 -85
- data/lib/mactag.rb +7 -1
- data/lib/mactag/builder.rb +4 -6
- data/lib/mactag/bundler.rb +21 -19
- data/lib/mactag/config.rb +22 -16
- data/lib/mactag/ctags.rb +2 -0
- data/lib/mactag/dsl.rb +197 -32
- data/lib/mactag/indexer.rb +9 -0
- data/lib/mactag/indexer/app.rb +22 -0
- data/lib/mactag/indexer/gem.rb +72 -0
- data/lib/mactag/{tag → indexer}/plugin.rb +10 -9
- data/lib/mactag/indexer/rails.rb +46 -0
- data/spec/mactag/builder_spec.rb +11 -11
- data/spec/mactag/config_spec.rb +24 -29
- data/spec/mactag/ctags_spec.rb +4 -4
- data/spec/mactag/dsl_spec.rb +179 -47
- data/spec/mactag/indexer/app_spec.rb +20 -0
- data/spec/mactag/indexer/gem_spec.rb +180 -0
- data/spec/mactag/{tag → indexer}/plugin_spec.rb +32 -23
- data/spec/mactag/indexer/rails_spec.rb +112 -0
- data/spec/spec_helper.rb +18 -0
- metadata +53 -28
- data/.gemtest +0 -0
- data/lib/mactag/tag.rb +0 -9
- data/lib/mactag/tag/app.rb +0 -30
- data/lib/mactag/tag/gem.rb +0 -80
- data/lib/mactag/tag/rails.rb +0 -86
- data/spec/mactag/tag/app_spec.rb +0 -9
- data/spec/mactag/tag/gem_spec.rb +0 -117
- data/spec/mactag/tag/rails_spec.rb +0 -105
- data/spec/mactag/tag_spec.rb +0 -5
data/README.markdown
CHANGED
@@ -7,23 +7,21 @@ their definitions.
|
|
7
7
|
|
8
8
|
|
9
9
|
# Exuberant Ctags
|
10
|
+
|
10
11
|
First off, you must install [Ctags](http://ctags.sourceforge.net/).
|
11
|
-
Some systems comes with a
|
12
|
+
Some systems comes with a `ctags` binary already. If you have the
|
12
13
|
ctags executable, but have problems creating the tags file. Then make
|
13
14
|
sure that you are using **Exuberant Ctags** and not some other version.
|
14
15
|
|
15
16
|
|
16
17
|
# Installation
|
17
18
|
|
18
|
-
## Plugin
|
19
|
-
Install the plugin:
|
20
|
-
$ rails plugin install git://github.com/rejeep/mactag.git
|
21
|
-
|
22
|
-
## Gem
|
23
19
|
Install the gem:
|
20
|
+
|
24
21
|
$ gem install mactag
|
25
22
|
|
26
|
-
Add mactag to the
|
23
|
+
Add `mactag` to the `Gemfile`:
|
24
|
+
|
27
25
|
group :development do
|
28
26
|
gem 'mactag'
|
29
27
|
end
|
@@ -31,55 +29,62 @@ Add mactag to the **Gemfile**:
|
|
31
29
|
|
32
30
|
# Configuration
|
33
31
|
|
34
|
-
To generate
|
35
|
-
|
36
|
-
|
32
|
+
To generate the configuration file `config/mactag.rb`, use the
|
33
|
+
`mactag` generator. The generated file contains a basic setup and some
|
34
|
+
examples of how to configure Mactag.
|
35
|
+
|
37
36
|
$ rails generate mactag
|
38
37
|
|
39
38
|
## Example mactag.rb file
|
40
39
|
|
41
|
-
Mactag
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
Mactag.configure do |config|
|
41
|
+
# Do not use RVM
|
42
|
+
config.rvm = false
|
43
|
+
config.gem_home = '/usr/lib/ruby/gems/1.8/gems'
|
44
|
+
|
45
|
+
# Binary when installing ctags from Homebrew
|
46
|
+
config.binary = '/usr/local/Cellar/ctags/5.8/bin/ctags -e -o {OUTPUT} {INPUT}'
|
47
|
+
|
48
|
+
# Change name of output file
|
49
|
+
config.tags_file = 'DA-TAGS'
|
50
|
+
end
|
45
51
|
|
46
52
|
Mactag do
|
47
|
-
|
48
|
-
|
49
|
-
|
53
|
+
index 'app/models/*.rb'
|
54
|
+
|
55
|
+
index 'carrerwave', 'simple_form'
|
56
|
+
index 'redcarpet', :version => '1.17.2'
|
50
57
|
|
51
|
-
|
52
|
-
gem 'formtastic', :version => '0.9.7'
|
53
|
-
|
54
|
-
rails :except => :actionmailer, :version => '2.3.5'
|
58
|
+
index :rails, :except => :actionmailer, :version => '3.1.3'
|
55
59
|
end
|
56
60
|
|
57
|
-
## Options
|
61
|
+
## Configuration Options
|
58
62
|
The available configuration options are described below.
|
59
63
|
|
60
|
-
###
|
64
|
+
### rvm
|
61
65
|
If true, use [Rvm](http://rvm.beginrescueend.com/) when indexing gems.
|
62
66
|
Defaults to: `true`
|
63
67
|
|
64
|
-
###
|
65
|
-
Path to gems. No need to set this when using
|
68
|
+
### gem_home
|
69
|
+
Path to gems. No need to set this when using `rvm`.
|
66
70
|
Defaults to: `/Library/Ruby/Gems/1.8/gems`
|
67
71
|
|
68
|
-
###
|
69
|
-
The command to run when creating the TAGS-file.
|
70
|
-
replaced with the value of
|
72
|
+
### binary
|
73
|
+
The command to run when creating the TAGS-file. `{OUTPUT}` will be
|
74
|
+
replaced with the value of `tags_file` configuration option. `{INPUT}`
|
71
75
|
will be replaced with all files to index.
|
72
76
|
Defaults to: `ctags -o {OUTPUT} -e {INPUT}`
|
73
77
|
|
74
|
-
###
|
78
|
+
### tags_file
|
75
79
|
Name of the output tags file.
|
76
80
|
Defaults to: `TAGS`
|
77
81
|
|
78
82
|
|
79
83
|
# Usage
|
80
84
|
To create the TAGS file, simply run:
|
85
|
+
|
81
86
|
$ rake mactag
|
82
87
|
|
83
88
|
|
84
89
|
# License
|
85
|
-
Copyright (c) 2010 Johan Andersson, released under the MIT license
|
90
|
+
Copyright (c) 2010-2012 Johan Andersson, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require '
|
3
|
-
|
4
|
-
Rake::TestTask.new(:spec) do |t|
|
5
|
-
t.libs << 'lib'
|
6
|
-
t.libs << 'spec'
|
7
|
-
t.pattern = 'spec/**/*_spec.rb'
|
8
|
-
t.verbose = true
|
9
|
-
end
|
2
|
+
require 'yard'
|
3
|
+
require 'rspec/core/rake_task'
|
10
4
|
|
11
5
|
task :default => :spec
|
12
6
|
task :test => :spec
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
9
|
+
t.rspec_opts = %w[--color]
|
10
|
+
end
|
11
|
+
|
12
|
+
YARD::Rake::YardocTask.new do |t|
|
13
|
+
t.files = ['lib/**/*.rb']
|
14
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
@@ -1,98 +1,39 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Defaults to: true
|
6
|
-
#
|
7
|
-
# Example:
|
8
|
-
# Mactag::Config.rvm = false
|
9
|
-
#
|
1
|
+
Mactag.configure do |config|
|
2
|
+
# Use RVM to locate project gems.
|
3
|
+
# config.rvm = false
|
10
4
|
|
11
|
-
|
12
|
-
#
|
13
|
-
# Path to gems.
|
14
|
-
#
|
15
|
-
# Change to whatever your system is using, if not the default. Most
|
16
|
-
# GNU/Linux systems use: /usr/lib/ruby/gems/1.8/gems
|
17
|
-
#
|
18
|
-
# (You don't need to set this when Mactag::Config.rvm is true)
|
19
|
-
#
|
20
|
-
# Defaults to: '/Library/Ruby/Gems/1.8/gems'
|
21
|
-
#
|
22
|
-
# Example:
|
23
|
-
# Mactag::Config.gem_home = '/usr/lib/ruby/gems/1.8/gems'
|
24
|
-
#
|
5
|
+
# Path to gems. No need to set this when RVM is used!
|
6
|
+
# config.gem_home = '/Library/Ruby/Gems/1.8/gems'
|
25
7
|
|
26
|
-
|
27
|
-
#
|
28
|
-
# Name of tags file.
|
29
|
-
#
|
30
|
-
# Defaults to: 'TAGS'
|
31
|
-
#
|
32
|
-
# Example:
|
33
|
-
# Mactag::Config.tags_file = '.tags'
|
34
|
-
#
|
8
|
+
# Name of tags file to create.
|
9
|
+
# config.tags_file = '.tags'
|
35
10
|
|
36
|
-
|
37
|
-
#
|
38
|
-
|
39
|
-
#
|
40
|
-
# The command must specify:
|
41
|
-
# {INPUT} - replaced by the input files to tag
|
42
|
-
# {OUTPUT} - replaced by Mactag::Config.tags_file
|
43
|
-
#
|
44
|
-
# Defaults to: 'ctags -o {OUTPUT} -e {INPUT}'
|
45
|
-
#
|
46
|
-
# Example:
|
47
|
-
# Mactag::Config.binary = '/usr/local/Cellar/ctags/5.8/bin/ctags -e -o {OUTPUT} {INPUT}'
|
48
|
-
#
|
11
|
+
# Command used to create the tags table. {INPUT} and {OUTPUT} are required!
|
12
|
+
# config.binary = '/usr/local/Cellar/ctags/5.8/bin/ctags -e -o {OUTPUT} {INPUT}'
|
13
|
+
end
|
49
14
|
|
50
15
|
Mactag do
|
51
|
-
|
52
|
-
#
|
53
|
-
# Index all ruby files in app recursive and all ruby files directly under lib.
|
54
|
-
# app 'app/**/*.rb', 'lib/*.rb'
|
55
|
-
#
|
16
|
+
# Index current project.
|
17
|
+
# index :app
|
56
18
|
|
57
|
-
|
58
|
-
#
|
59
|
-
# Index the plugins thinking-sphinx and formtastic.
|
60
|
-
# plugins 'thinking-sphinx', 'formtastic'
|
61
|
-
#
|
19
|
+
# Index all models and helpers.
|
20
|
+
# index 'app/models/*.rb', 'app/helpers/*.rb'
|
62
21
|
|
63
|
-
|
64
|
-
#
|
65
|
-
# Index the gems paperclip and authlogic.
|
66
|
-
# gems 'paperclip', 'authlogic'
|
67
|
-
#
|
22
|
+
# Index the gems carrierwave and redcarpet.
|
23
|
+
# index 'carrierwave', 'redcarpet'
|
68
24
|
|
69
|
-
|
70
|
-
#
|
71
|
-
# Index the gem formtastic version 0.9.7.
|
72
|
-
# gem 'formtastic', :version => '0.9.7'
|
73
|
-
#
|
25
|
+
# Index the gem simple_form version 1.5.2.
|
26
|
+
# index 'simple_form', :version => '1.5.2'
|
74
27
|
|
75
|
-
|
76
|
-
#
|
77
|
-
# Index all rails packages, except actionmailer.
|
78
|
-
# rails :except => :actionmailer
|
79
|
-
#
|
28
|
+
# Index rails.
|
29
|
+
# index :rails
|
80
30
|
|
81
|
-
|
82
|
-
#
|
83
|
-
# Index only rails packages activerecord and activesupport.
|
84
|
-
# rails :only => [:activerecord, :active_support]
|
85
|
-
#
|
31
|
+
# Index rails except action mailer.
|
32
|
+
# index :rails, :except => :actionmailer
|
86
33
|
|
87
|
-
|
88
|
-
#
|
89
|
-
# Index all rails packages, version 3.0.0.
|
90
|
-
# rails :version => '3.0.0'
|
91
|
-
#
|
34
|
+
# Index only rails packages activerecord and activesupport.
|
35
|
+
# index :rails, :only => %w(activerecord activesupport)
|
92
36
|
|
93
|
-
|
94
|
-
#
|
95
|
-
# Index all rails packages, same version as current application.
|
96
|
-
# rails
|
97
|
-
#
|
37
|
+
# Index rails, version 3.1.3.
|
38
|
+
# index :rails, :version => '3.1.3'
|
98
39
|
end
|
data/lib/mactag.rb
CHANGED
@@ -2,7 +2,7 @@ require 'mactag/railtie'
|
|
2
2
|
require 'mactag/config'
|
3
3
|
require 'mactag/builder'
|
4
4
|
require 'mactag/dsl'
|
5
|
-
require 'mactag/
|
5
|
+
require 'mactag/indexer'
|
6
6
|
require 'mactag/ctags'
|
7
7
|
require 'mactag/bundler'
|
8
8
|
require 'mactag/errors'
|
@@ -10,6 +10,12 @@ require 'mactag/errors'
|
|
10
10
|
module Mactag
|
11
11
|
autoload :Bundler, 'bundler'
|
12
12
|
autoload :Rails, 'rails'
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def configure(&block)
|
16
|
+
Mactag::Config.configure(&block)
|
17
|
+
end
|
18
|
+
end
|
13
19
|
end
|
14
20
|
|
15
21
|
def Mactag(&block)
|
data/lib/mactag/builder.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
module Mactag
|
2
|
-
##
|
3
|
-
#
|
4
|
-
# Tag builder.
|
5
|
-
#
|
6
2
|
class Builder
|
3
|
+
attr_reader :tags
|
4
|
+
|
7
5
|
def initialize
|
8
6
|
@tags = []
|
9
7
|
end
|
@@ -39,13 +37,13 @@ module Mactag
|
|
39
37
|
class << self
|
40
38
|
def create
|
41
39
|
unless gem_home_exists?
|
42
|
-
raise Mactag::MactagError.new("
|
40
|
+
raise Mactag::MactagError.new("Gem home directory '#{Mactag::Config.gem_home}' does not exist")
|
43
41
|
end
|
44
42
|
|
45
43
|
if builder.has_gems?
|
46
44
|
Mactag::Ctags.new(@builder.files, Mactag::Config.tags_file).create
|
47
45
|
|
48
|
-
puts
|
46
|
+
puts "Successfully generated #{Mactag::Config.tags_file} file"
|
49
47
|
else
|
50
48
|
raise Mactag::MactagError.new('Nothing to tag')
|
51
49
|
end
|
data/lib/mactag/bundler.rb
CHANGED
@@ -5,32 +5,34 @@ module Mactag
|
|
5
5
|
# used.
|
6
6
|
#
|
7
7
|
class Bundler
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
class << self
|
9
|
+
def gems
|
10
|
+
dependencies.map do |dependency|
|
11
|
+
[dependency, specs[dependency]]
|
12
|
+
end
|
11
13
|
end
|
12
|
-
end
|
13
14
|
|
14
15
|
|
15
|
-
|
16
|
+
private
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
def specs
|
19
|
+
@specs ||= runtime.specs.inject({}) do |hash, spec|
|
20
|
+
hash[spec.name] = spec.version.to_s
|
21
|
+
hash
|
22
|
+
end
|
21
23
|
end
|
22
|
-
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
def dependencies
|
26
|
+
default = runtime.dependencies.select { |dependency|
|
27
|
+
dependency.groups.include?(:default)
|
28
|
+
}.map(&:name)
|
29
|
+
default.delete('rails')
|
30
|
+
default
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
def runtime
|
34
|
+
@runtime ||= ::Bundler.load
|
35
|
+
end
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
data/lib/mactag/config.rb
CHANGED
@@ -2,20 +2,16 @@ module Mactag
|
|
2
2
|
class Config
|
3
3
|
##
|
4
4
|
#
|
5
|
-
# The command to run (replacing {OUTPUT} with
|
6
|
-
# and {INPUT} with the input files) when creating the
|
7
|
-
#
|
8
|
-
# Mactag::Config.binary = 'etags -o {OUTPUT} {INPUT}'
|
5
|
+
# The command to run (replacing <tt>{OUTPUT}</tt> with <tt>tags_file</tt>
|
6
|
+
# and <tt>{INPUT}</tt> with the input files) when creating the tags file.
|
9
7
|
#
|
10
8
|
@@binary = 'ctags -o {OUTPUT} -e {INPUT}'
|
11
|
-
|
9
|
+
cattr_reader :binary
|
12
10
|
|
13
11
|
##
|
14
12
|
#
|
15
13
|
# Name of the output tags file.
|
16
14
|
#
|
17
|
-
# Mactag::Config.binary = 'TAGS_FILE'
|
18
|
-
#
|
19
15
|
@@tags_file = 'TAGS'
|
20
16
|
cattr_accessor :tags_file
|
21
17
|
|
@@ -24,8 +20,6 @@ module Mactag
|
|
24
20
|
# If using Ruby Version Manager (RVM), setting this option to true
|
25
21
|
# will enable Mactag to find out the gem path automatically.
|
26
22
|
#
|
27
|
-
# Mactag::Config.rvm = false
|
28
|
-
#
|
29
23
|
@@rvm = true
|
30
24
|
cattr_accessor :rvm
|
31
25
|
|
@@ -33,16 +27,28 @@ module Mactag
|
|
33
27
|
#
|
34
28
|
# The system folder where the gems are located.
|
35
29
|
#
|
36
|
-
# Mactag::Config.gem_home = '/Library/Ruby/Gems/1.8/gems'
|
37
|
-
#
|
38
30
|
@@gem_home = '/Library/Ruby/Gems/1.8/gems'
|
39
31
|
cattr_writer :gem_home
|
40
32
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
33
|
+
class << self
|
34
|
+
def binary=(binary)
|
35
|
+
if binary.include?('{INPUT}') && binary.include?('{OUTPUT}')
|
36
|
+
@@binary = binary
|
37
|
+
else
|
38
|
+
raise Mactag::MactagError.new("Binary command must include '{INPUT}' and '{OUTPUT}'")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def gem_home
|
43
|
+
if rvm
|
44
|
+
File.join(ENV['GEM_HOME'], 'gems')
|
45
|
+
else
|
46
|
+
@@gem_home
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def configure(&block)
|
51
|
+
yield self
|
46
52
|
end
|
47
53
|
end
|
48
54
|
end
|