Class: TagMatic
- Inherits:
-
Object
- Object
- TagMatic
- Defined in:
- lib/tagmatic.rb
Constant Summary collapse
- VERSION =
'0.0.3'- HASH_BANG =
'#!/bin/bash'- APP_DIRECTORIES =
%w/ app config lib src /
- IGNORE_FILES =
%w/ javascript sql /
- HOOKS_FILES =
%w/ post-checkout post-merge /
- HOOK_TEMPLATE =
'tagmatic generate-tags .'- HELP =
'Run `tagmatic install` to setup the hooks that regenerate your "tags" file.'
Instance Attribute Summary collapse
-
#current_dir ⇒ Object
Returns the value of attribute current_dir.
Instance Method Summary collapse
- #__version ⇒ Object
- #generate_tags(dir_path) ⇒ Object
- #help ⇒ Object
-
#initialize(*argv) ⇒ TagMatic
constructor
A new instance of TagMatic.
- #install ⇒ Object
Constructor Details
#initialize(*argv) ⇒ TagMatic
Returns a new instance of TagMatic.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tagmatic.rb', line 28 def initialize(*argv) command = argv.shift command = command.tr('-', '_') if command if command && respond_to?(command) && argv.any? send(command, argv) elsif command && respond_to?(command) send(command) else puts 'Command not found' help end end |
Instance Attribute Details
#current_dir ⇒ Object
Returns the value of attribute current_dir.
26 27 28 |
# File 'lib/tagmatic.rb', line 26 def current_dir @current_dir end |
Instance Method Details
#__version ⇒ Object
70 71 72 |
# File 'lib/tagmatic.rb', line 70 def __version puts VERSION end |
#generate_tags(dir_path) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/tagmatic.rb', line 53 def (dir_path) raise ArgumentError.new('missing directory') if dir_path.empty? puts 'Regenerating tags...' self.current_dir = File.(dir_path.pop) (dir_path) APP_DIRECTORIES.each do |path| result = `ctags -Ra #{ignore} #{path}` if File.exists?(path) unless $CHILD_STATUS.to_i == 0 raise RuntimeError, result end end end |
#help ⇒ Object
66 67 68 |
# File 'lib/tagmatic.rb', line 66 def help puts HELP end |
#install ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tagmatic.rb', line 42 def install HOOKS_FILES.each do |file_name| append(File.join(git_dir, 'hooks', file_name), 0777) do |body, f| [HASH_BANG, HOOK_TEMPLATE].each do |text| f.puts(text) unless body && body.include?(text) end end end puts 'all tagged up' end |