tagmatic 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/README.md +5 -1
- data/Rakefile +5 -0
- data/bin/tagmatic +1 -1
- data/lib/tagmatic.rb +59 -54
- data/spec/lib/tagmatic_spec.rb +7 -0
- data/tagmatic.gemspec +3 -2
- metadata +22 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cfcfec342fcb923bacdad4c9ff248f1e4912b91
|
4
|
+
data.tar.gz: 405aa7f3b5f14592d3a59e3996c3e8329b356491
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b8747af2b30f6de999fb6c4bbdc6f6f02a3076ad625dd6d64f0561e17080adf2de14ec71bca4d306e7ea53e2dcae9f7021536b10805eecaec47a2e3a1054ea5
|
7
|
+
data.tar.gz: be4ffe48419de5dac81425cb6641dd3538053e2021fa5ad6fc6a5620f95ce911241e0d41cc52e3c78c62adabba9526dfd211268526782fa3ad79f1356635e30a
|
data/.rspec
ADDED
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# TagMatic
|
2
2
|
|
3
|
-
Automates regenerating the tags file by using Git's post hook functionality.
|
3
|
+
Automates regenerating the tags (ctags) file by using Git's post hook functionality.
|
4
|
+
|
5
|
+
## Dependencies
|
6
|
+
|
7
|
+
Tagmatic depends on Ctags. Search for `Installing ctags` for your operating system.
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
data/Rakefile
CHANGED
data/bin/tagmatic
CHANGED
data/lib/tagmatic.rb
CHANGED
@@ -1,63 +1,80 @@
|
|
1
1
|
class TagMatic
|
2
|
-
VERSION =
|
2
|
+
VERSION = '0.0.2'
|
3
3
|
|
4
|
-
HASH_BANG
|
5
|
-
TAGS_FILE_NAME = "tags"
|
6
|
-
TAGMATIC_BIN = 'tagmatic'
|
4
|
+
HASH_BANG = '#!/bin/bash'
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
APP_DIRECTORIES = %w/
|
7
|
+
app
|
8
|
+
config
|
9
|
+
lib
|
10
|
+
src
|
11
|
+
/
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
'config',
|
17
|
-
'lib'
|
18
|
-
]
|
13
|
+
IGNORE_FILES = %w/
|
14
|
+
javascript
|
15
|
+
sql
|
16
|
+
/
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
HOOKS_FILES = %w/
|
19
|
+
post-checkout
|
20
|
+
post-merge
|
21
|
+
/
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
HELP
|
23
|
+
HOOK_TEMPLATE = 'tagmatic generate-tags .'
|
24
|
+
HELP = 'Run `tagmatic install` to setup the hooks that regenerate your "tags" file.'
|
28
25
|
|
29
26
|
attr_accessor :current_dir
|
30
27
|
|
31
|
-
def initialize
|
28
|
+
def initialize(*argv)
|
32
29
|
command = argv.shift
|
33
30
|
command = command.tr('-', '_') if command
|
34
31
|
|
35
|
-
if command && respond_to?(
|
36
|
-
send(
|
32
|
+
if command && respond_to?(command) && argv.any?
|
33
|
+
send(command, argv)
|
34
|
+
elsif command && respond_to?(command)
|
35
|
+
send(command)
|
37
36
|
else
|
38
|
-
|
37
|
+
puts 'Command not found'
|
38
|
+
help
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
42
|
+
def install
|
43
|
+
HOOKS_FILES.each do |file_name|
|
44
|
+
append(File.join(git_dir, 'hooks', file_name), 0777) do |body, f|
|
45
|
+
[HASH_BANG, HOOK_TEMPLATE].each do |text|
|
46
|
+
f.puts(text) unless body && body.include?(text)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
puts 'all tagged up'
|
45
51
|
end
|
46
52
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
53
|
+
def generate_tags(dir_path)
|
54
|
+
raise ArgumentError.new('missing directory') if dir_path.empty?
|
55
|
+
puts 'Regenerating tags...'
|
56
|
+
self.current_dir = File.expand_path(dir_path.pop)
|
57
|
+
remove_tags_file(dir_path)
|
58
|
+
APP_DIRECTORIES.each do |path|
|
59
|
+
result = `ctags -Ra #{ignore} #{path}` if File.exists?(path)
|
60
|
+
unless $CHILD_STATUS.to_i == 0
|
61
|
+
raise RuntimeError, result
|
62
|
+
end
|
51
63
|
end
|
52
|
-
puts 'all tagged up'
|
53
64
|
end
|
54
65
|
|
55
|
-
def
|
66
|
+
def help
|
56
67
|
puts HELP
|
57
68
|
end
|
58
69
|
|
59
|
-
def
|
60
|
-
|
70
|
+
def __version
|
71
|
+
puts VERSION
|
72
|
+
end
|
73
|
+
|
74
|
+
protected
|
75
|
+
|
76
|
+
def git_dir
|
77
|
+
@git_dir ||= %x[git rev-parse --git-dir].chomp
|
61
78
|
end
|
62
79
|
|
63
80
|
def append(file, *args)
|
@@ -68,17 +85,12 @@ HELP
|
|
68
85
|
end
|
69
86
|
end
|
70
87
|
|
71
|
-
def
|
72
|
-
|
73
|
-
self.current_dir = File.expand_path( dir_path.pop )
|
74
|
-
remove_tags_file( dir_path )
|
75
|
-
APP_DIRECTORIES.each do |path|
|
76
|
-
result = `#{CTAGS_CMD} #{ignore} #{path}` if File.exists?( path )
|
77
|
-
end
|
88
|
+
def remove_tags_file(dir_path)
|
89
|
+
File.delete(tags_path) if File.exists?(tags_path)
|
78
90
|
end
|
79
91
|
|
80
|
-
def
|
81
|
-
|
92
|
+
def tags_file_name
|
93
|
+
'tags'
|
82
94
|
end
|
83
95
|
|
84
96
|
def tags_path
|
@@ -86,17 +98,10 @@ HELP
|
|
86
98
|
end
|
87
99
|
|
88
100
|
def ignore
|
89
|
-
"
|
101
|
+
"--languages=#{ignore_file_types}" if ignore_file_types
|
90
102
|
end
|
91
103
|
|
92
104
|
def ignore_file_types
|
93
|
-
|
94
|
-
IGNORE_FILES.each do |ft|
|
95
|
-
langs << "," unless langs.empty?
|
96
|
-
langs << "-#{ft}"
|
97
|
-
end
|
98
|
-
langs
|
105
|
+
IGNORE_FILES.join(',-').prepend('-') if IGNORE_FILES.any?
|
99
106
|
end
|
100
|
-
|
101
|
-
protected :append
|
102
107
|
end
|
data/tagmatic.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = TagMatic::VERSION
|
9
9
|
spec.authors = ["Adan Alvarado"]
|
10
10
|
spec.email = ["adan.alvarado7@gmail.com"]
|
11
|
-
spec.description = %q{Automatically regenarate
|
12
|
-
spec.summary = %q{Tagmatic will recreate the tags file for you whenever your HEAD changes}
|
11
|
+
spec.description = %q{Automatically regenarate ctags files with Git hooks}
|
12
|
+
spec.summary = %q{Tagmatic will recreate the tags (ctags) file for you whenever your HEAD changes}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
23
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagmatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adan Alvarado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,7 +38,21 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Automatically regenarate ctags files with Git hooks
|
42
56
|
email:
|
43
57
|
- adan.alvarado7@gmail.com
|
44
58
|
executables:
|
@@ -47,12 +61,14 @@ extensions: []
|
|
47
61
|
extra_rdoc_files: []
|
48
62
|
files:
|
49
63
|
- .gitignore
|
64
|
+
- .rspec
|
50
65
|
- Gemfile
|
51
66
|
- LICENSE.txt
|
52
67
|
- README.md
|
53
68
|
- Rakefile
|
54
69
|
- bin/tagmatic
|
55
70
|
- lib/tagmatic.rb
|
71
|
+
- spec/lib/tagmatic_spec.rb
|
56
72
|
- tagmatic.gemspec
|
57
73
|
homepage: ''
|
58
74
|
licenses:
|
@@ -77,5 +93,6 @@ rubyforge_project:
|
|
77
93
|
rubygems_version: 2.0.5
|
78
94
|
signing_key:
|
79
95
|
specification_version: 4
|
80
|
-
summary: Tagmatic will recreate the tags file for you whenever your HEAD changes
|
81
|
-
test_files:
|
96
|
+
summary: Tagmatic will recreate the tags (ctags) file for you whenever your HEAD changes
|
97
|
+
test_files:
|
98
|
+
- spec/lib/tagmatic_spec.rb
|