guard-ctags-bundler 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/README.md +21 -5
- data/Rakefile +10 -0
- data/guard-ctags-bundler.gemspec +4 -2
- data/lib/guard/ctags-bundler.rb +9 -22
- data/lib/guard/ctags-bundler/ctags_generator.rb +29 -0
- data/lib/guard/ctags-bundler/templates/Guardfile +2 -2
- data/lib/guard/ctags-bundler/version.rb +1 -1
- data/test/ctags-bundler/ctags_generator_test.rb +40 -0
- data/test/test_helper.rb +20 -0
- data/test/test_project/Gemfile +3 -0
- data/test/test_project/app/class1.rb +4 -0
- data/test/test_project/lib/class2.rb +4 -0
- data/test/test_project/vendor/class3.rb +4 -0
- metadata +56 -6
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Guard-CTags-Bundler
|
1
|
+
###### Guard-CTags-Bundler
|
2
2
|
=
|
3
3
|
|
4
4
|
Guard-CTags-Bundler generates [ctags](http://ctags.sourceforge.net) for your project and for gems in your bundle. For project tags file `tags` is generated, for gems tags file `gems.tags` is generated.
|
@@ -27,6 +27,23 @@ And then add a basic setup to your `Guardfile`:
|
|
27
27
|
|
28
28
|
$ guard init ctags-bundler
|
29
29
|
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
Please, read [Guard usage doc](https://github.com/guard/guard#readme)
|
33
|
+
|
34
|
+
## Guardfile Options
|
35
|
+
|
36
|
+
``` ruby
|
37
|
+
:src_path => ".", # source path to be scanned for tags (default .)
|
38
|
+
:emacs => false, # run ctags in emacs mode and merge tags and gems.tags into TAGS file
|
39
|
+
```
|
40
|
+
|
41
|
+
For a typical Rails application, `Guardfile` can look like this (default):
|
42
|
+
|
43
|
+
guard 'ctags-bundler', :src_path => ["app", "lib", "spec/support"] do
|
44
|
+
watch(/^(app|lib|spec\/support)\/.*\.rb$/)
|
45
|
+
watch('Gemfile.lock')
|
46
|
+
end
|
30
47
|
|
31
48
|
## CTags
|
32
49
|
|
@@ -42,14 +59,13 @@ Vim supports ctags by default. All you need to do is add your `gems.tags` file t
|
|
42
59
|
|
43
60
|
set tags+=gems.tags
|
44
61
|
|
45
|
-
|
46
62
|
## Emacs
|
47
63
|
|
48
64
|
Ctags can be used with emacs too. Add `:emacs => true` option to your Guardfile and ctags will be generated with `-e` option:
|
49
65
|
|
50
|
-
guard 'ctags-bundler', :emacs => true do
|
51
|
-
watch(
|
66
|
+
guard 'ctags-bundler', :emacs => true, :src_path => ["app", "lib", "spec/support"] do
|
67
|
+
watch(/^(app|lib|spec\/support)\/.*\.rb$/)
|
52
68
|
watch('Gemfile.lock')
|
53
69
|
end
|
54
70
|
|
55
|
-
Thanks to [Jorge Dias](https://github.com/diasjorge) for
|
71
|
+
Thanks to [Jorge Dias](https://github.com/diasjorge) and [Antono Vasiljev](https://github.com/antono) for emacs support.
|
data/Rakefile
CHANGED
data/guard-ctags-bundler.gemspec
CHANGED
@@ -19,8 +19,10 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
# specify any dependencies here; for example:
|
22
|
-
s.add_dependency 'guard', '>= 0.
|
22
|
+
s.add_dependency 'guard', '>= 1.0.0'
|
23
|
+
|
24
|
+
s.add_development_dependency "minitest"
|
25
|
+
s.add_development_dependency "purdytest"
|
23
26
|
|
24
|
-
# s.add_development_dependency "rspec"
|
25
27
|
# s.add_runtime_dependency "rest-client"
|
26
28
|
end
|
data/lib/guard/ctags-bundler.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "guard/ctags-bundler/version"
|
2
|
+
require "guard/ctags-bundler/ctags_generator"
|
2
3
|
require 'guard'
|
3
4
|
require 'guard/guard'
|
4
5
|
require 'bundler'
|
@@ -8,41 +9,27 @@ module Guard
|
|
8
9
|
class CtagsBundler < Guard
|
9
10
|
def initialize(watchers = [], options = {})
|
10
11
|
super(watchers, options)
|
12
|
+
@ctags_generator = ::Guard::Ctags::Bundler::CtagsGenerator.new(options)
|
11
13
|
end
|
12
14
|
|
13
15
|
def start
|
14
16
|
UI.info 'Guard::CtagsBundler is running!'
|
17
|
+
@ctags_generator.generate_bundler_tags
|
18
|
+
@ctags_generator.generate_project_tags
|
15
19
|
end
|
16
20
|
|
17
|
-
def
|
21
|
+
def run_on_changes(paths)
|
18
22
|
if paths.include?('Gemfile.lock')
|
19
23
|
UI.info "regenerating bundler tags..."
|
20
|
-
generate_bundler_tags
|
24
|
+
@ctags_generator.generate_bundler_tags
|
21
25
|
end
|
26
|
+
|
22
27
|
ruby_files = paths.reject {|f| f == 'Gemfile.lock'}
|
28
|
+
|
23
29
|
if ruby_files.any?
|
24
30
|
UI.info "regenerating project tags..."
|
25
|
-
generate_project_tags
|
31
|
+
@ctags_generator.generate_project_tags
|
26
32
|
end
|
27
33
|
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def generate_project_tags(paths)
|
32
|
-
generate_tags(paths, "tags")
|
33
|
-
end
|
34
|
-
|
35
|
-
def generate_bundler_tags
|
36
|
-
runtime = ::Bundler::Runtime.new Dir.pwd, ::Bundler.definition
|
37
|
-
paths = runtime.specs.map(&:full_gem_path)
|
38
|
-
generate_tags(paths, "gems.tags")
|
39
|
-
end
|
40
|
-
|
41
|
-
def generate_tags(paths, tag_file)
|
42
|
-
paths = paths.join(' ').strip
|
43
|
-
cmd = "find #{paths} -type f -name \\*.rb | ctags -f #{tag_file} -L -"
|
44
|
-
cmd << " -e" if options[:emacs]
|
45
|
-
system(cmd)
|
46
|
-
end
|
47
34
|
end
|
48
35
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Guard::Ctags::Bundler::CtagsGenerator
|
2
|
+
def initialize(opts = {})
|
3
|
+
@opts = opts
|
4
|
+
end
|
5
|
+
|
6
|
+
def generate_project_tags
|
7
|
+
generate_tags(@opts[:src_path] || ".", "tags")
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate_bundler_tags
|
11
|
+
definition = Bundler::Definition.build("Gemfile", "Gemfile.lock", nil)
|
12
|
+
runtime = Bundler::Runtime.new(Dir.pwd, definition)
|
13
|
+
paths = runtime.requested_specs.map(&:full_gem_path)
|
14
|
+
generate_tags(paths, "gems.tags")
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def generate_tags(path, tag_file)
|
20
|
+
if path.instance_of?(Array)
|
21
|
+
path = path.join(' ').strip
|
22
|
+
end
|
23
|
+
|
24
|
+
cmd = "find #{path} -type f -name \\*.rb | ctags -f #{tag_file} -L -"
|
25
|
+
cmd << " -e" if @opts[:emacs]
|
26
|
+
system(cmd)
|
27
|
+
system("cat tags gems.tags > TAGS") if @opts[:emacs]
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require 'guard/ctags-bundler/ctags_generator'
|
4
|
+
|
5
|
+
class CtagsGeneratorTest < MiniTest::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
clean_tags
|
8
|
+
Dir.chdir(test_project_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_generate_project_tags
|
12
|
+
generator.generate_project_tags
|
13
|
+
assert File.exists?(test_tags_file)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_generate_project_tags_for_src_path_only
|
17
|
+
generator(src_path: ["app", "lib"]).generate_project_tags
|
18
|
+
result = File.read(test_tags_file)
|
19
|
+
assert_match("method_of_class_1", result)
|
20
|
+
assert_match("method_of_class_2", result)
|
21
|
+
refute_match("method_of_class_3", result)
|
22
|
+
refute_match("Rake", result)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_generate_bundler_tags
|
26
|
+
generator.generate_bundler_tags
|
27
|
+
assert File.exists?(test_gems_tags_file)
|
28
|
+
result = File.read(test_gems_tags_file)
|
29
|
+
assert_match("Rake", result)
|
30
|
+
refute_match("method_of_class_1", result)
|
31
|
+
refute_match("method_of_class_2", result)
|
32
|
+
refute_match("method_of_class_3", result)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def generator(opts = {})
|
38
|
+
Guard::Ctags::Bundler::CtagsGenerator.new(opts)
|
39
|
+
end
|
40
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'purdytest'
|
3
|
+
|
4
|
+
def test_project_path
|
5
|
+
File.expand_path("test_project", File.dirname(__FILE__))
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_tags_file
|
9
|
+
File.join(test_project_path, "tags")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_gems_tags_file
|
13
|
+
File.join(test_project_path, "gems.tags")
|
14
|
+
end
|
15
|
+
|
16
|
+
def clean_tags
|
17
|
+
[test_tags_file, test_gems_tags_file].each do |file|
|
18
|
+
File.delete(file) if File.exists?(file)
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-ctags-bundler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,19 +9,56 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: minitest
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: purdytest
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
25
62
|
description: ! 'Guard::CtagsBundler uses ctags utility and generates 2 files: tags
|
26
63
|
-- with tags generated from project''s source tree and gems.tags -- with tags generated
|
27
64
|
from rubygems from project''s bundle.'
|
@@ -38,8 +75,15 @@ files:
|
|
38
75
|
- Rakefile
|
39
76
|
- guard-ctags-bundler.gemspec
|
40
77
|
- lib/guard/ctags-bundler.rb
|
78
|
+
- lib/guard/ctags-bundler/ctags_generator.rb
|
41
79
|
- lib/guard/ctags-bundler/templates/Guardfile
|
42
80
|
- lib/guard/ctags-bundler/version.rb
|
81
|
+
- test/ctags-bundler/ctags_generator_test.rb
|
82
|
+
- test/test_helper.rb
|
83
|
+
- test/test_project/Gemfile
|
84
|
+
- test/test_project/app/class1.rb
|
85
|
+
- test/test_project/lib/class2.rb
|
86
|
+
- test/test_project/vendor/class3.rb
|
43
87
|
homepage: https://github.com/ivalkeen/guard-ctags-bundler
|
44
88
|
licenses: []
|
45
89
|
post_install_message:
|
@@ -52,15 +96,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
96
|
- - ! '>='
|
53
97
|
- !ruby/object:Gem::Version
|
54
98
|
version: '0'
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
hash: 974875642901378133
|
55
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
103
|
none: false
|
57
104
|
requirements:
|
58
105
|
- - ! '>='
|
59
106
|
- !ruby/object:Gem::Version
|
60
107
|
version: '0'
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
hash: 974875642901378133
|
61
111
|
requirements: []
|
62
112
|
rubyforge_project: guard-ctags-bundler
|
63
|
-
rubygems_version: 1.8.
|
113
|
+
rubygems_version: 1.8.23
|
64
114
|
signing_key:
|
65
115
|
specification_version: 3
|
66
116
|
summary: Guard gem for generating ctags for project files and gems from project's
|