guard-ctags-bundler 0.1.4 → 0.1.5

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.
data/.gitignore CHANGED
@@ -3,5 +3,9 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  /vendor/ruby
6
+ /vendor/rbx
6
7
  /test/test_project/tags
7
8
  /test/test_project/gems.tags
9
+ /.vagrant
10
+ /Vagrantfile
11
+ /.rbx
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ before_install:
2
+ - gem install bundler
3
+ - sudo apt-get install exuberant-ctags
4
+ rvm:
5
+ - 1.8.7
6
+ - 1.9.2
7
+ - 1.9.3
8
+ - jruby
9
+ - rbx-18mode
10
+ - rbx-19mode
11
+ notifications:
12
+ email: ivalkeen@gmail.com
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
- ###### Guard-CTags-Bundler
2
- =
1
+ # Guard-CTags-Bundler
2
+
3
+ [![Build Status](https://secure.travis-ci.org/ivalkeen/guard-ctags-bundler.png)](http://travis-ci.org/ivalkeen/guard-ctags-bundler)
3
4
 
4
5
  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.
5
6
 
@@ -36,6 +37,7 @@ Please, read [Guard usage doc](https://github.com/guard/guard#readme)
36
37
  ``` ruby
37
38
  :src_path => ".", # source path to be scanned for tags (default .)
38
39
  :emacs => false, # run ctags in emacs mode and merge tags and gems.tags into TAGS file
40
+ :stdlib => true, # run ctags for core and stdlib, generating stdlib.tags (default false)
39
41
  ```
40
42
 
41
43
  For a typical Rails application, `Guardfile` can look like this (default):
@@ -1,3 +1,7 @@
1
+ require 'rbconfig'
2
+ require 'bundler'
3
+ require 'bundler/runtime'
4
+
1
5
  module Guard
2
6
  class CtagsBundler
3
7
  class CtagsGenerator
@@ -6,7 +10,7 @@ module Guard
6
10
  end
7
11
 
8
12
  def generate_project_tags
9
- generate_tags(@opts[:src_path] || ".", "tags")
13
+ generate_tags(@opts[:src_path] || ".", custom_path_for("tags"))
10
14
  end
11
15
 
12
16
  def generate_bundler_tags
@@ -14,7 +18,11 @@ module Guard
14
18
  definition = ::Bundler::Definition.build("Gemfile", "Gemfile.lock", nil)
15
19
  runtime = ::Bundler::Runtime.new(Dir.pwd, definition)
16
20
  paths = runtime.requested_specs.map(&:full_gem_path)
17
- generate_tags(paths, "gems.tags")
21
+ generate_tags(paths, custom_path_for("gems.tags") )
22
+ end
23
+
24
+ def generate_stdlib_tags
25
+ generate_tags(stdlib_path, custom_path_for("stdlib.tags"))
18
26
  end
19
27
 
20
28
  private
@@ -23,11 +31,34 @@ module Guard
23
31
  if path.instance_of?(Array)
24
32
  path = path.join(' ').strip
25
33
  end
26
-
34
+ system("mkdir -p ./#{@opts[:custom_path]}") if @opts[:custom_path]
27
35
  cmd = "find #{path} -type f -name \\*.rb | ctags -f #{tag_file} -L -"
28
36
  cmd << " -e" if @opts[:emacs]
29
37
  system(cmd)
30
- system("cat tags gems.tags > TAGS") if @opts[:emacs]
38
+ if @opts[:emacs]
39
+ if @opts[:stdlib]
40
+ system("cat #{custom_path_for("tags")} #{custom_path_for("gems.tags")} #{custom_path_for("stdlib.tags")} > TAGS")
41
+ else
42
+ system("cat #{custom_path_for("tags")} #{custom_path_for("gems.tags")} > TAGS")
43
+ end
44
+ end
45
+ end
46
+
47
+ def custom_path_for(file)
48
+ if @opts[:custom_path]
49
+ return "./#{@opts[:custom_path]}/#{file}"
50
+ else
51
+ return file
52
+ end
53
+ end
54
+
55
+ def stdlib_path
56
+ # hack for rubinius, as it breaks MRI and JRuby directory structure
57
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
58
+ RbConfig::CONFIG['libdir']
59
+ else
60
+ RbConfig::CONFIG['rubylibdir']
61
+ end
31
62
  end
32
63
  end
33
64
  end
@@ -1,7 +1,7 @@
1
1
  module Guard
2
2
  module Ctags
3
3
  module Bundler
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,6 @@
1
+ require 'rubygems'
1
2
  require 'guard'
2
3
  require 'guard/guard'
3
- require 'bundler'
4
- require 'bundler/runtime'
5
4
 
6
5
  module Guard
7
6
  class CtagsBundler < Guard
@@ -16,6 +15,7 @@ module Guard
16
15
  UI.info 'Guard::CtagsBundler is running!'
17
16
  @ctags_generator.generate_bundler_tags
18
17
  @ctags_generator.generate_project_tags
18
+ @ctags_generator.generate_stdlib_tags if options[:stdlib]
19
19
  end
20
20
 
21
21
  def run_on_changes(paths)
@@ -4,34 +4,60 @@ require 'guard/ctags-bundler/ctags_generator'
4
4
 
5
5
  class CtagsGeneratorTest < MiniTest::Unit::TestCase
6
6
  def setup
7
- clean_tags
7
+ @oldpath = Dir.pwd
8
8
  Dir.chdir(test_project_path)
9
9
  end
10
10
 
11
+ def teardown
12
+ Dir.chdir(@oldpath)
13
+ clean_tags
14
+ end
15
+
11
16
  def test_generate_project_tags
12
17
  generator.generate_project_tags
13
18
  assert File.exists?(test_tags_file)
14
19
  end
15
20
 
16
21
  def test_generate_project_tags_for_src_path_only
17
- generator(src_path: ["app", "lib"]).generate_project_tags
22
+ generator(:src_path => ["app", "lib"]).generate_project_tags
18
23
  result = File.read(test_tags_file)
19
24
  assert_match("method_of_class_1", result)
20
25
  assert_match("method_of_class_2", result)
21
26
  refute_match("method_of_class_3", result)
22
- refute_match("Rake", result)
27
+ refute_match(/\bGuard\b/, result)
23
28
  end
24
29
 
25
30
  def test_generate_bundler_tags
26
31
  generator.generate_bundler_tags
27
32
  assert File.exists?(test_gems_tags_file)
28
33
  result = File.read(test_gems_tags_file)
29
- assert_match("Rake", result)
34
+ assert_match(/\bGuard\b/, result)
30
35
  refute_match("method_of_class_1", result)
31
36
  refute_match("method_of_class_2", result)
32
37
  refute_match("method_of_class_3", result)
33
38
  end
34
39
 
40
+ def test_generate_stdlib_tags
41
+ generator.generate_stdlib_tags
42
+ assert File.exists?(test_stdlib_tags_file)
43
+ result = File.read(test_stdlib_tags_file)
44
+ assert_match("DateTime", result)
45
+ assert_match("YAML", result)
46
+ refute_match(/\bGuard\b/, result)
47
+ refute_match("method_of_class_1", result)
48
+ refute_match("method_of_class_2", result)
49
+ refute_match("method_of_class_3", result)
50
+ end
51
+
52
+ def test_generate_project_tags_for_custom_path
53
+ generator(:custom_path => "custom").generate_project_tags
54
+ result = File.read(custom_path_file)
55
+ assert_match("method_of_class_1", result)
56
+ assert_match("method_of_class_2", result)
57
+ assert_match("method_of_class_3", result)
58
+ refute_match("Rake", result)
59
+ end
60
+
35
61
  private
36
62
 
37
63
  def generator(opts = {})
data/test/test_helper.rb CHANGED
@@ -1,8 +1,9 @@
1
+ require 'rubygems'
1
2
  require 'minitest/autorun'
2
3
  require 'purdytest'
3
4
 
4
5
  def test_project_path
5
- File.expand_path("test_project", File.dirname(__FILE__))
6
+ @cached ||= File.expand_path("test_project", File.dirname(__FILE__))
6
7
  end
7
8
 
8
9
  def test_tags_file
@@ -13,8 +14,20 @@ def test_gems_tags_file
13
14
  File.join(test_project_path, "gems.tags")
14
15
  end
15
16
 
17
+ def custom_path_file
18
+ File.join(test_project_path, "custom", "tags")
19
+ end
20
+
21
+ def test_stdlib_tags_file
22
+ File.join(test_project_path, "stdlib.tags")
23
+ end
24
+
16
25
  def clean_tags
17
- [test_tags_file, test_gems_tags_file].each do |file|
26
+ [test_tags_file, test_gems_tags_file, test_stdlib_tags_file, custom_path_file].each do |file|
18
27
  File.delete(file) if File.exists?(file)
19
28
  end
29
+
30
+ if File.exists?(File.join(test_project_path, 'custom'))
31
+ system("rmdir #{File.join(test_project_path, 'custom')}")
32
+ end
20
33
  end
@@ -1,3 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rake", :require => false
3
+ gem "guard", :require => false
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.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-23 00:00:00.000000000 Z
12
+ date: 2012-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
@@ -101,6 +101,7 @@ extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
103
  - .gitignore
104
+ - .travis.yml
104
105
  - Gemfile
105
106
  - LICENSE
106
107
  - README.md
@@ -130,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
131
  version: '0'
131
132
  segments:
132
133
  - 0
133
- hash: 4269814697447651255
134
+ hash: 610861147332230790
134
135
  required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  none: false
136
137
  requirements:
@@ -139,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
140
  version: '0'
140
141
  segments:
141
142
  - 0
142
- hash: 4269814697447651255
143
+ hash: 610861147332230790
143
144
  requirements: []
144
145
  rubyforge_project: guard-ctags-bundler
145
146
  rubygems_version: 1.8.24