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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e02cd80599f10c1542303ca9ea7853c5065971f
4
- data.tar.gz: 4fe8daa3aee4f6e616f5f3aeb58ff13aa132f1fa
3
+ metadata.gz: 0cfcfec342fcb923bacdad4c9ff248f1e4912b91
4
+ data.tar.gz: 405aa7f3b5f14592d3a59e3996c3e8329b356491
5
5
  SHA512:
6
- metadata.gz: a57f33282554bc93218c98da0b7189098cdcf403411460880a402b211f76964afaef58c6192363a917d0aee49ad74a88840064cdda4e49f1d36ad0b0929dc016
7
- data.tar.gz: 0380955ef1418e75ae2922412d4f27221f931be11370173abe8fcbf1b36e665431fd3ac381eda8384c23faf426b823a032e137dbc708a397b03e0e358df013c7
6
+ metadata.gz: 3b8747af2b30f6de999fb6c4bbdc6f6f02a3076ad625dd6d64f0561e17080adf2de14ec71bca4d306e7ea53e2dcae9f7021536b10805eecaec47a2e3a1054ea5
7
+ data.tar.gz: be4ffe48419de5dac81425cb6641dd3538053e2021fa5ad6fc6a5620f95ce911241e0d41cc52e3c78c62adabba9526dfd211268526782fa3ad79f1356635e30a
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
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
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ task :default => :spec
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- $: << File.expand_path("../../lib", __FILE__)
2
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
3
3
  require 'tagmatic'
4
4
  TagMatic.new(*ARGV)
@@ -1,63 +1,80 @@
1
1
  class TagMatic
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
 
4
- HASH_BANG = "#!/bin/bash"
5
- TAGS_FILE_NAME = "tags"
6
- TAGMATIC_BIN = 'tagmatic'
4
+ HASH_BANG = '#!/bin/bash'
7
5
 
8
- TEMPLATE = <<-TMPL
9
- #{TAGMATIC_BIN} generate-tags .
10
- TMPL
6
+ APP_DIRECTORIES = %w/
7
+ app
8
+ config
9
+ lib
10
+ src
11
+ /
11
12
 
12
- CTAGS_CMD = 'ctags -Ra'
13
- LANGUAGES_FLAGS = '--languages='
14
- APP_DIRECTORIES = [
15
- 'app',
16
- 'config',
17
- 'lib'
18
- ]
13
+ IGNORE_FILES = %w/
14
+ javascript
15
+ sql
16
+ /
19
17
 
20
- IGNORE_FILES = [
21
- 'javascript',
22
- 'sql'
23
- ]
18
+ HOOKS_FILES = %w/
19
+ post-checkout
20
+ post-merge
21
+ /
24
22
 
25
- HELP = <<-HELP
26
- run install to install to hooks to regenerate your tags file
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 *argv
28
+ def initialize(*argv)
32
29
  command = argv.shift
33
30
  command = command.tr('-', '_') if command
34
31
 
35
- if command && respond_to?( command )
36
- send( command, argv )
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
- display_help
37
+ puts 'Command not found'
38
+ help
39
39
  end
40
40
  end
41
41
 
42
- def git_dir
43
- @git_dir = %x[git rev-parse --git-dir].chomp
44
- @git_dir
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 install *argv
48
- append(File.join(git_dir, 'hooks', 'post-checkout'), 0777) do |body, f|
49
- f.puts HASH_BANG unless body
50
- f.puts TEMPLATE
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 display_help
66
+ def help
56
67
  puts HELP
57
68
  end
58
69
 
59
- def tags_file_name
60
- TAGS_FILE_NAME
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 generate_tags dir_path
72
- puts 'Regenerating tags...'
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 remove_tags_file dir_path
81
- File.delete( tags_path ) if File.exists?( tags_path )
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
- "#{LANGUAGES_FLAGS}#{ignore_file_types}" if ignore_file_types
101
+ "--languages=#{ignore_file_types}" if ignore_file_types
90
102
  end
91
103
 
92
104
  def ignore_file_types
93
- langs = ''
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
@@ -0,0 +1,7 @@
1
+ require 'rspec'
2
+ require 'tagmatic'
3
+
4
+ describe TagMatic do
5
+ let( :tagmatic ) { TagMatic.new }
6
+ it { tagmatic.should be_an_instance_of(TagMatic) }
7
+ end
@@ -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 tags files with Git hooks}
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.1
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-07-22 00:00:00.000000000 Z
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
- description: Automatically regenarate tags files with Git hooks
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