guard-ctags-composer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ /vendor/ruby
6
+ /test/test_project/tags
7
+ /test/test_project/gems.tags
data/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2011 Ivan Tkalin
4
+ 2012 Konstantin Kudryashov
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+ ###### Guard-CTags-Composer
2
+ =
3
+
4
+ Guard-CTags-Composer generates [ctags](http://ctags.sourceforge.net) for your PHP project and for `vendor` libs.
5
+ For project tags file `tags` is generated, for vendor tags file `gems.tags` is generated.
6
+
7
+ Features
8
+ -
9
+
10
+ * When you run `composer install` in your project, `vendor.tags` file is automatically is generated or updated.
11
+ * When you save one of you project's php files, `tags` file is automatically generated or updated.
12
+
13
+ ## Install
14
+
15
+ Make sure you have [Guard](http://github.com/guard/guard) installed.
16
+
17
+ Install the gem:
18
+
19
+ $ gem install guard-ctags-composer
20
+
21
+ Add a basic setup to your `Guardfile`:
22
+
23
+ $ guard init ctags-composer
24
+
25
+ ## Usage
26
+
27
+ Please, read [Guard usage doc](https://github.com/guard/guard#readme)
28
+
29
+ ## Guardfile Options
30
+
31
+ ``` ruby
32
+ :src_path => ".", # source path to be scanned for tags (default `src`)
33
+ :vendor_path => ".", # source path to be scanned for vendor tags (default `vendor`)
34
+ :emacs => false, # run ctags in emacs mode and merge tags and gems.tags into TAGS file
35
+ ```
36
+
37
+ For a typical Rails application, `Guardfile` can look like this (default):
38
+
39
+ guard 'ctags-composer', :src_path => ["src"], :vendor_path => ["vendor"] do
40
+ watch(/^(src)\/.*\.php/)
41
+ watch('composer.lock')
42
+ end
43
+
44
+ ## CTags
45
+
46
+ [Ctags](http://ctags.sourceforge.net) generates an index (or tag) file of language objects found in
47
+ source files that allows these items to be quickly and easily located by a text editor or other utility.
48
+ A tag signifies a language object for which an index entry is available (or, alternatively, the index
49
+ entry created for that object).
50
+
51
+ In ubuntu you can install ctags by running
52
+
53
+ $ sudo apt-get install exuberant-ctags
54
+
55
+ ## Vim
56
+
57
+ Vim supports ctags by default. All you need to do is add your `gems.tags` file to the Vim's tag stack.
58
+
59
+ set tags+=vendor.tags
60
+
61
+ ## Emacs
62
+
63
+ Ctags can be used with emacs too. Add `:emacs => true` option to your Guardfile and ctags will be generated with `-e` option:
64
+
65
+ guard 'ctags-composer', :emacs => true do
66
+ watch(/^(src)\/.*\.php/)
67
+ watch('composer.lock')
68
+ end
69
+
70
+ ## Fork
71
+
72
+ This version is a forked edition of `guard-ctags-bundler` gem.
@@ -0,0 +1,20 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "guard-ctags-composer"
3
+ s.version = "0.0.1"
4
+ s.authors = ["Konstantin Kudryashov"]
5
+ s.email = ["ever.zet@gmail.com"]
6
+ s.homepage = "https://github.com/everzet/guard-ctags-composer"
7
+ s.summary = %q{Guard gem for generating ctags for project files and vendor libraries.}
8
+ s.description = %q{Guard::CtagsComposer uses ctags utility and generates 2 files: tags -- with tags generated from project's source tree and vendor.tags -- with tags generated from vendor folder.}
9
+
10
+ s.files = `git ls-files`.split("\n")
11
+ s.test_files = `git ls-files -- {test}/*`.split("\n")
12
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
13
+ s.require_paths = ["lib"]
14
+
15
+ # specify any dependencies here; for example:
16
+ s.add_dependency 'guard', '>= 1.0.0'
17
+
18
+ s.add_development_dependency "minitest"
19
+ s.add_development_dependency "purdytest"
20
+ end
@@ -0,0 +1,32 @@
1
+ module Guard
2
+ module Ctags
3
+ module Composer
4
+ class CtagsGenerator
5
+ def initialize(opts = {})
6
+ @opts = opts
7
+ end
8
+
9
+ def generate_project_tags
10
+ generate_tags(@opts[:src_path] || "src", "tags")
11
+ end
12
+
13
+ def generate_vendor_tags
14
+ generate_tags(@opts[:vendor_path] || "vendor", "vendor.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 \\*.php | ctags -f #{tag_file} -L -"
25
+ cmd << " -e" if @opts[:emacs]
26
+ system(cmd)
27
+ system("cat tags vendor.tags > TAGS") if @opts[:emacs]
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,4 @@
1
+ guard 'ctags-composer', :src_path => ["src"], :vendor_path => ["vendor"] do
2
+ watch(/^(src|tests)\/.*\.php$/)
3
+ watch('composer.lock')
4
+ end
@@ -0,0 +1,32 @@
1
+ require "guard/ctags-composer/ctags_generator"
2
+ require 'guard'
3
+ require 'guard/guard'
4
+
5
+ module Guard
6
+ class CtagsComposer < Guard
7
+ def initialize(watchers = [], options = {})
8
+ super(watchers, options)
9
+ @ctags_generator = ::Guard::Ctags::Composer::CtagsGenerator.new(options)
10
+ end
11
+
12
+ def start
13
+ UI.info 'Guard::CtagsComposer is running!'
14
+ @ctags_generator.generate_vendor_tags
15
+ @ctags_generator.generate_project_tags
16
+ end
17
+
18
+ def run_on_changes(paths)
19
+ if paths.include?('composer.lock')
20
+ UI.info "regenerating vendor tags..."
21
+ @ctags_generator.generate_vendor_tags
22
+ end
23
+
24
+ ruby_files = paths.reject {|f| f == 'composer.lock'}
25
+
26
+ if ruby_files.any?
27
+ UI.info "regenerating project tags..."
28
+ @ctags_generator.generate_project_tags
29
+ end
30
+ end
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-ctags-composer
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Konstantin Kudryashov
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2012-07-06 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: guard
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ - 0
31
+ version: 1.0.0
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: minitest
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :development
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: purdytest
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ type: :development
57
+ version_requirements: *id003
58
+ description: "Guard::CtagsComposer uses ctags utility and generates 2 files: tags -- with tags generated from project's source tree and vendor.tags -- with tags generated from vendor folder."
59
+ email:
60
+ - ever.zet@gmail.com
61
+ executables: []
62
+
63
+ extensions: []
64
+
65
+ extra_rdoc_files: []
66
+
67
+ files:
68
+ - .gitignore
69
+ - LICENSE
70
+ - README.md
71
+ - guard-ctags-composer.gemspec
72
+ - lib/guard/ctags-composer.rb
73
+ - lib/guard/ctags-composer/ctags_generator.rb
74
+ - lib/guard/ctags-composer/templates/Guardfile
75
+ has_rdoc: true
76
+ homepage: https://github.com/everzet/guard-ctags-composer
77
+ licenses: []
78
+
79
+ post_install_message:
80
+ rdoc_options: []
81
+
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ requirements: []
99
+
100
+ rubyforge_project:
101
+ rubygems_version: 1.3.6
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Guard gem for generating ctags for project files and vendor libraries.
105
+ test_files: []
106
+