-
Notifications
You must be signed in to change notification settings - Fork 2
/
dot_tags_reporter.rb
executable file
·94 lines (63 loc) · 1.64 KB
/
dot_tags_reporter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env ruby
# encoding: utf-8
# frozen_string_literal: true
# warn_indent: true
##########################################################
###
## File: dot_tags_reporter.rb
## Desc: Report on the contents of a .tags file
## By: Dewayne VanHoozer ([email protected])
#
require 'amazing_print'
require 'debug_me'
include DebugMe
require 'cli_helper'
include CliHelper
configatron.version = '0.0.1'
HELP = <<EOHELP
Important:
Put important stuff here.
EOHELP
cli_helper("Report on the contents of a .tags file") do |o|
end
# Display the usage info
if ARGV.empty?
configatron.target_dir = Pathname.pwd
else
configatron.target_dir = Pathname.new(ARGV.shift)
end
# Error check your stuff; use error('some message') and warning('some message')
unless configatron.target_dir.exist?
error "No such directory exists: #{configatron.target_dir}"
else
configatron.tags_path = configatron.target_dir + '.tags'
unless configatron.tags_path.exist?
error "No such file exists: #{configatron.target_dir}"
end
end
abort_if_errors
######################################################
# Local methods
######################################################
# Main
at_exit do
puts
puts "Done."
puts
end
ap configatron.to_h if verbose? || debug?
configatron.tags_path.each_line do |a_line|
next if a_line.start_with?('!')
a_line.gsub!(';"','')
parts = a_line.chomp.split("\t")
if parts.size > 4
reference_key = parts[4].gsub('class:','').gsub('.','::')
if 'f' == parts[3]
reference_key += '#' + parts[0]
else
reference_key += '::' + parts[0]
end
parts[4] = reference_key
end
ap parts
end