tagrity 0.1.10 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tagrity_config.yml +38 -0
- data/.travis.yml +6 -1
- data/Gemfile.lock +4 -2
- data/README.md +94 -30
- data/lib/tagrity/commands/start.rb +2 -1
- data/lib/tagrity/commands/status.rb +17 -2
- data/lib/tagrity/commands/stop.rb +3 -2
- data/lib/tagrity/config_file.rb +40 -19
- data/lib/tagrity/helper.rb +2 -2
- data/lib/tagrity/pid_file.rb +2 -2
- data/lib/tagrity/provider.rb +2 -1
- data/lib/tagrity/tag_generator.rb +11 -23
- data/lib/tagrity/version.rb +1 -1
- data/sample_config.yml +14 -7
- data/tagrity.gemspec +1 -0
- data/test_files/.gitignore +1 -0
- data/test_files/.tagrity_config.yml +37 -0
- data/test_files/barbaz.c +7 -0
- data/test_files/expected_after_delete +6 -0
- data/test_files/expected_genall_git_tags +6 -0
- data/test_files/expected_genall_nongit_tags +10 -0
- data/test_files/foo/barbaz.rb +5 -0
- data/test_files/foo/foobar.c +7 -0
- metadata +27 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20de67060444a9805be57457f42fbead18066cf3f65c7a51f6262328f86381c6
|
4
|
+
data.tar.gz: b342a4934b3d604f5fadc98d559a9863346d35e984641606fe6f3697a1829787
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 227ecdbf6ea0faa4b24b5ec2b6238285ef1cb8c585e42abef2aa82baeaf6a1b65d403e34dd42aafff3acf1ac7eaeec798f87ec7c318e416f7b1acc897eeaf5ba
|
7
|
+
data.tar.gz: 16c33ed46225a24a24bd090661d88866c5a760ef5ee373e718f2ae93f97cbd221142e1634ddeb83362645c203ae9001c38e9e2161d9684addb48b92997f6ce64
|
data/.tagrity_config.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# which command to use to generate tags for a specific file extension
|
2
|
+
# overrides default_command
|
3
|
+
# DEFAULT: empty
|
4
|
+
extension_commands:
|
5
|
+
rb: ripper-tags
|
6
|
+
c: ctags
|
7
|
+
|
8
|
+
# default command to generate tags
|
9
|
+
# DEFAULT: ctags
|
10
|
+
default_command: ctags
|
11
|
+
|
12
|
+
# filename (relative to pwd) to generate tags into
|
13
|
+
# DEFAULT: tags
|
14
|
+
tagf: tags
|
15
|
+
|
16
|
+
# list of extensions to exclusively generate tags for
|
17
|
+
# this will take precendence over extensions_blacklist if it is non-empty
|
18
|
+
# DEFAULT: []
|
19
|
+
extensions_whitelist: [rb]
|
20
|
+
|
21
|
+
# list of extensions to not generate tags for
|
22
|
+
# this can will be ignored if extensions_whitelist is non-empty
|
23
|
+
# DEFAULT: []
|
24
|
+
# extensions_blacklist: [erb, html, txt]
|
25
|
+
|
26
|
+
# how to integrate with git
|
27
|
+
# git_strategy: TRACKED | IGNORED | NA
|
28
|
+
# TRACKED: only index files tracked by git
|
29
|
+
# IGNORED: don't index files which are ignored by git
|
30
|
+
# NA: don't use git, index all files under pwd
|
31
|
+
# DEFAULT: TRACKED
|
32
|
+
git_strategy: TRACKED
|
33
|
+
|
34
|
+
# which paths (relative to pwd) to ignore
|
35
|
+
# It's usually better to avoid this since tagrity integrates with git by
|
36
|
+
# default using the strategy specified by git_strategy
|
37
|
+
# DEFAULT: []
|
38
|
+
excluded_paths: [test_files]
|
data/.travis.yml
CHANGED
@@ -4,4 +4,9 @@ language: ruby
|
|
4
4
|
cache: bundler
|
5
5
|
rvm:
|
6
6
|
- 2.6.3
|
7
|
-
before_install:
|
7
|
+
before_install:
|
8
|
+
- gem install bundler -v 2.0.2
|
9
|
+
- gem install ripper-tags -v 0.8.1
|
10
|
+
- brew unlink python@2
|
11
|
+
- brew install --HEAD universal-ctags/universal-ctags/universal-ctags
|
12
|
+
os: osx
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tagrity (0.
|
4
|
+
tagrity (0.2.0)
|
5
|
+
cli-ui (~> 1.3.0)
|
5
6
|
listen (~> 3.0)
|
6
7
|
pry (~> 0.9.9)
|
7
8
|
thor (~> 0.20)
|
@@ -9,6 +10,7 @@ PATH
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
13
|
+
cli-ui (1.3.0)
|
12
14
|
coderay (1.1.2)
|
13
15
|
diff-lcs (1.3)
|
14
16
|
ffi (1.11.3)
|
@@ -22,7 +24,7 @@ GEM
|
|
22
24
|
slop (~> 3.4)
|
23
25
|
rake (10.5.0)
|
24
26
|
rb-fsevent (0.10.3)
|
25
|
-
rb-inotify (0.10.
|
27
|
+
rb-inotify (0.10.1)
|
26
28
|
ffi (~> 1.0)
|
27
29
|
ripper-tags (0.8.0)
|
28
30
|
rspec (3.9.0)
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Tagrity
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.com/RRethy/tagrity.svg?branch=master)](https://travis-ci.com/RRethy/tagrity)
|
4
|
+
|
3
5
|
Automatically regenerate tags on file changes.
|
4
6
|
|
5
7
|
## Installation
|
@@ -14,16 +16,88 @@ $ gem install tagrity
|
|
14
16
|
tagrity start
|
15
17
|
```
|
16
18
|
|
17
|
-
That's it!
|
19
|
+
That's it! It will monitor pwd and by default only index files tracked by git.
|
20
|
+
|
21
|
+
To stop watching pwd, use
|
22
|
+
|
23
|
+
```sh
|
24
|
+
tagrity stop
|
25
|
+
```
|
26
|
+
|
27
|
+
To view directories being watched, use
|
28
|
+
|
29
|
+
```sh
|
30
|
+
tagrity status
|
31
|
+
```
|
32
|
+
|
33
|
+
## Configuration
|
34
|
+
|
35
|
+
Configuration can be done through use of a `tagrity_config.yml` file that looks like the following:
|
36
|
+
|
37
|
+
[`tagrity_config.yml`](https://github.com/RRethy/tagrity/blob/master/sample_config.yml)
|
38
|
+
|
39
|
+
```yaml
|
40
|
+
# which command to use to generate tags for a specific file extension
|
41
|
+
# overrides default_command
|
42
|
+
# commands must support --append, -f, -L
|
43
|
+
#
|
44
|
+
# Default: empty
|
45
|
+
extension_commands:
|
46
|
+
rb: ripper-tags
|
47
|
+
c: ctags
|
48
|
+
go: gotags
|
49
|
+
|
50
|
+
# default command to generate tags
|
51
|
+
# command must support --append, -f, -L
|
52
|
+
#
|
53
|
+
# Default: ctags
|
54
|
+
default_command: ctags
|
55
|
+
|
56
|
+
# filename (relative to pwd) to generate tags into
|
57
|
+
#
|
58
|
+
# Default: tags
|
59
|
+
tagf: tags
|
60
|
+
|
61
|
+
# list of extensions to exclusively generate tags for
|
62
|
+
# this will take precendence over extensions_blacklist if it is non-empty
|
63
|
+
#
|
64
|
+
# Default: []
|
65
|
+
extensions_whitelist: [rb, c, h, js]
|
66
|
+
|
67
|
+
# list of extensions to not generate tags for
|
68
|
+
# this can will be ignored if extensions_whitelist is non-empty
|
69
|
+
#
|
70
|
+
# Default: []
|
71
|
+
extensions_blacklist: [erb, html, txt]
|
72
|
+
|
73
|
+
# how to integrate with git
|
74
|
+
# git_strategy: TRACKED | IGNORED | NA
|
75
|
+
# TRACKED: only index files tracked by git
|
76
|
+
# IGNORED: don't index files which are ignored by git
|
77
|
+
# NA: don't use git, index all files under pwd
|
78
|
+
#
|
79
|
+
# Default: TRACKED
|
80
|
+
git_strategy: TRACKED
|
81
|
+
|
82
|
+
# which paths (relative to pwd) to ignore
|
83
|
+
# It's usually better to avoid this since tagrity integrates with git by
|
84
|
+
# default using the strategy specified by git_strategy
|
85
|
+
#
|
86
|
+
# Default: []
|
87
|
+
excluded_paths: [vendor, node_modules]
|
88
|
+
```
|
89
|
+
|
90
|
+
Tagrity will look for a global config file at `$XDG_CONFIG_HOME/tagrity/tagrity_config.yml` (usually this will be `~/.config/tagrity/tagrity_config.yml`). This can be overridden by a local config file by the same name under pwd.
|
18
91
|
|
19
92
|
## Usage
|
20
93
|
|
21
94
|
```
|
22
95
|
Commands:
|
23
96
|
tagrity help [COMMAND] # Describe available commands or one specific command
|
24
|
-
tagrity
|
97
|
+
tagrity logs # Print the logs for pwd
|
98
|
+
tagrity start # Start watching pwd
|
25
99
|
tagrity status # List running tagrity processes and the directories being watched
|
26
|
-
tagrity stop # Stop watching
|
100
|
+
tagrity stop # Stop watching pwd
|
27
101
|
```
|
28
102
|
|
29
103
|
### start
|
@@ -33,15 +107,10 @@ Usage:
|
|
33
107
|
tagrity start
|
34
108
|
|
35
109
|
Options:
|
36
|
-
[--
|
37
|
-
[--
|
38
|
-
|
39
|
-
|
40
|
-
[--default-cmd=DEFAULT_CMD]
|
41
|
-
[--excluded-exts=one two three]
|
42
|
-
[--excluded-paths=one two three]
|
43
|
-
|
44
|
-
Start watching a directory (default to pwd)
|
110
|
+
[--fg], [--no-fg] # keep the tagrity process running in the foreground
|
111
|
+
[--fresh], [--no-fresh] # index the whole codebase before watching the file system. This will be slow if the codebase is large.
|
112
|
+
|
113
|
+
Start watching pwd
|
45
114
|
```
|
46
115
|
|
47
116
|
### stop
|
@@ -50,10 +119,7 @@ Start watching a directory (default to pwd)
|
|
50
119
|
Usage:
|
51
120
|
tagrity stop
|
52
121
|
|
53
|
-
|
54
|
-
[--dir=DIR]
|
55
|
-
|
56
|
-
Stop watching a directory (default to pwd)
|
122
|
+
Stop watching pwd
|
57
123
|
```
|
58
124
|
|
59
125
|
### status
|
@@ -65,15 +131,22 @@ Usage:
|
|
65
131
|
List running tagrity processes and the directories being watched
|
66
132
|
```
|
67
133
|
|
68
|
-
|
134
|
+
### logs
|
135
|
+
|
136
|
+
```
|
137
|
+
Usage:
|
138
|
+
tagrity logs
|
69
139
|
|
70
|
-
|
140
|
+
Options:
|
141
|
+
[-n=N] # the number of log lines to print
|
142
|
+
# Default: 10
|
71
143
|
|
72
|
-
|
144
|
+
Print the logs for pwd
|
145
|
+
```
|
73
146
|
|
74
147
|
## Contributing
|
75
148
|
|
76
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
149
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/RRethy/tagrity. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
77
150
|
|
78
151
|
## License
|
79
152
|
|
@@ -81,13 +154,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
81
154
|
|
82
155
|
## Code of Conduct
|
83
156
|
|
84
|
-
Everyone interacting in the Tagrity project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
tagrity config to use (default to ~/.config/tagrity/config.yml if available).
|
90
|
-
A config file is a yaml file with the following possible values.
|
91
|
-
Some of these can be overridden with options, however the configfile
|
92
|
-
provided via --configfile will override the global config file in
|
93
|
-
~/.config/tagrity/config.yml
|
157
|
+
Everyone interacting in the Tagrity project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/RRethy/tagrity/blob/master/CODE_OF_CONDUCT.md).
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'listen'
|
2
|
+
require 'cli/ui'
|
2
3
|
require 'tagrity/pid_file'
|
3
4
|
require 'tagrity/helper'
|
4
5
|
require 'tagrity/provider'
|
@@ -47,7 +48,7 @@ module Tagrity
|
|
47
48
|
listener.start
|
48
49
|
sleep
|
49
50
|
rescue ErrorProcessAlreadyRunning => e
|
50
|
-
puts e.message
|
51
|
+
puts ::CLI::UI.fmt "{{red:#{e.message}}}"
|
51
52
|
logger.error(e.message)
|
52
53
|
rescue Interrupt => e
|
53
54
|
logger.info("Process interrupted. Killing #{Process.pid}")
|
@@ -1,10 +1,25 @@
|
|
1
|
+
require 'cli/ui'
|
2
|
+
|
1
3
|
module Tagrity
|
2
4
|
module Command
|
3
5
|
class Status
|
4
6
|
class << self
|
5
7
|
def call
|
6
|
-
PidFile.alive_pid_files.each do |pid_file|
|
7
|
-
|
8
|
+
pid_files = PidFile.alive_pid_files.each do |pid_file|
|
9
|
+
pid_file
|
10
|
+
end
|
11
|
+
|
12
|
+
return if pid_files.empty?
|
13
|
+
|
14
|
+
max_pid_len = pid_files.max do |a, b|
|
15
|
+
a.pid.digits.count <=> b.pid.digits.count
|
16
|
+
end.pid.digits.count
|
17
|
+
max_dir_len = pid_files.max do |a, b|
|
18
|
+
a.dir.length <=> b.dir.length
|
19
|
+
end.dir.length
|
20
|
+
|
21
|
+
pid_files.each do |pid_file|
|
22
|
+
puts ::CLI::UI.fmt "{{cyan:#{pid_file.pid.to_s.ljust(max_pid_len)}}} {{green:#{pid_file.dir.ljust(max_dir_len)}}}"
|
8
23
|
end
|
9
24
|
end
|
10
25
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'cli/ui'
|
1
2
|
require 'tagrity/tlogger'
|
2
3
|
|
3
4
|
module Tagrity
|
@@ -8,11 +9,11 @@ module Tagrity
|
|
8
9
|
dir = Dir.pwd
|
9
10
|
pid_files = PidFile.alive_pid_files(dir: dir)
|
10
11
|
if pid_files.empty?
|
11
|
-
puts "😕 tagrity doesn't seem to be watching #{dir}"
|
12
|
+
puts ::CLI::UI.fmt "{{red:#{"😕 tagrity doesn't seem to be watching #{dir}"}}}"
|
12
13
|
else
|
13
14
|
pid_files.each do |pid_file|
|
14
15
|
pid_file.delete
|
15
|
-
puts "Successfully killed #{pid_file.pid}"
|
16
|
+
puts ::CLI::UI.fmt "{{green:#{"Successfully killed #{pid_file.pid}"}}}"
|
16
17
|
Tlogger.instance.info("Successfully killed #{pid_file.pid}")
|
17
18
|
end
|
18
19
|
end
|
data/lib/tagrity/config_file.rb
CHANGED
@@ -12,18 +12,16 @@ module Tagrity
|
|
12
12
|
LOCAL_CONFIG_PATH = File.expand_path("./.#{CONFIG_FNAME}")
|
13
13
|
GLOBAL_CONFIG_PATH = File.expand_path("#{ENV['XDG_CONFIG_HOME'] || "#{ENV['HOME']}/.config"}/tagrity/#{CONFIG_FNAME}")
|
14
14
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
ensure_git_strategy
|
22
|
-
ensure_excluded_paths
|
15
|
+
def reload_local
|
16
|
+
read_config(fname: local_config_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def reload_global
|
20
|
+
read_config(fname: global_config_path)
|
23
21
|
end
|
24
22
|
|
25
23
|
def command_for_extension(extension)
|
26
|
-
cmd = extension_commands[extension]
|
24
|
+
cmd = extension_commands[extension.to_s]
|
27
25
|
if cmd.nil?
|
28
26
|
default_command
|
29
27
|
else
|
@@ -33,14 +31,14 @@ module Tagrity
|
|
33
31
|
|
34
32
|
def ignore_extension?(extension)
|
35
33
|
unless extensions_whitelist.empty?
|
36
|
-
return !extensions_whitelist.include?(extension)
|
34
|
+
return !extensions_whitelist.include?(extension.to_s)
|
37
35
|
end
|
38
36
|
|
39
|
-
extensions_blacklist.include?(extension)
|
37
|
+
extensions_blacklist.include?(extension.to_s)
|
40
38
|
end
|
41
39
|
|
42
40
|
def path_ignored?(path)
|
43
|
-
excluded_paths.any? { |pat|
|
41
|
+
excluded_paths.any? { |pat| !(/^#{pat}/ =~ path.to_s).nil? }
|
44
42
|
end
|
45
43
|
|
46
44
|
def respect_git?
|
@@ -81,6 +79,16 @@ module Tagrity
|
|
81
79
|
|
82
80
|
private
|
83
81
|
|
82
|
+
def init
|
83
|
+
ensure_extension_commands
|
84
|
+
ensure_default_command
|
85
|
+
ensure_tagf
|
86
|
+
ensure_extensions_whitelist
|
87
|
+
ensure_extensions_blacklist
|
88
|
+
ensure_git_strategy
|
89
|
+
ensure_excluded_paths
|
90
|
+
end
|
91
|
+
|
84
92
|
def ensure_extension_commands
|
85
93
|
ensure_option('extension_commands', {})
|
86
94
|
end
|
@@ -109,7 +117,7 @@ module Tagrity
|
|
109
117
|
end
|
110
118
|
|
111
119
|
def ensure_excluded_paths
|
112
|
-
ensure_option('
|
120
|
+
ensure_option('excluded_paths', [])
|
113
121
|
end
|
114
122
|
|
115
123
|
def ensure_option(name, default)
|
@@ -122,14 +130,27 @@ module Tagrity
|
|
122
130
|
@config ||= read_config
|
123
131
|
end
|
124
132
|
|
125
|
-
def read_config
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
133
|
+
def read_config(fname: nil)
|
134
|
+
@config = {}
|
135
|
+
if fname.nil?
|
136
|
+
if File.readable?(local_config_path)
|
137
|
+
read_config(fname: local_config_path)
|
138
|
+
elsif File.readable?(global_config_path)
|
139
|
+
read_config(fname: global_config_path)
|
140
|
+
end
|
130
141
|
else
|
131
|
-
@config =
|
142
|
+
@config = YAML.load_file(fname)
|
132
143
|
end
|
144
|
+
init
|
145
|
+
@config
|
146
|
+
end
|
147
|
+
|
148
|
+
def global_config_path
|
149
|
+
File.expand_path("#{ENV['XDG_CONFIG_HOME'] || "#{ENV['HOME']}/.config"}/tagrity/#{CONFIG_FNAME}")
|
150
|
+
end
|
151
|
+
|
152
|
+
def local_config_path
|
153
|
+
File.expand_path("./.#{CONFIG_FNAME}")
|
133
154
|
end
|
134
155
|
end
|
135
156
|
end
|
data/lib/tagrity/helper.rb
CHANGED
@@ -15,7 +15,7 @@ module Tagrity
|
|
15
15
|
LOG_DIR
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def executable?(cmd)
|
19
19
|
!%x{command -v #{cmd}}.empty?
|
20
20
|
end
|
21
21
|
|
@@ -32,7 +32,7 @@ module Tagrity
|
|
32
32
|
true
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
35
|
+
def git_dir?
|
36
36
|
`git rev-parse --git-dir &> /dev/null`
|
37
37
|
$?.exitstatus == 0
|
38
38
|
end
|
data/lib/tagrity/pid_file.rb
CHANGED
@@ -24,7 +24,7 @@ module Tagrity
|
|
24
24
|
pid = pid_from_path(path)
|
25
25
|
pid_file_dir = File.read(path)
|
26
26
|
|
27
|
-
if dir.nil? ||
|
27
|
+
if dir.nil? || same_dirs?(pid_file_dir, dir)
|
28
28
|
if Helper.alive?(pid)
|
29
29
|
pid_files << PidFile.new(pid_file_dir, pid)
|
30
30
|
else
|
@@ -38,7 +38,7 @@ module Tagrity
|
|
38
38
|
|
39
39
|
private
|
40
40
|
|
41
|
-
def
|
41
|
+
def same_dirs?(dir1, dir2)
|
42
42
|
File.realdirpath(dir1) == File.realdirpath(dir2)
|
43
43
|
end
|
44
44
|
|
data/lib/tagrity/provider.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'tagrity/config_file'
|
2
2
|
require 'tagrity/tag_generator'
|
3
|
+
require 'tagrity/tlogger'
|
3
4
|
|
4
5
|
module Tagrity
|
5
6
|
class Provider
|
@@ -12,7 +13,7 @@ module Tagrity
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def provide_tag_generator
|
15
|
-
TagGenerator.new
|
16
|
+
TagGenerator.new(ConfigFile.instance, Tlogger.instance)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
@@ -2,15 +2,15 @@ require 'tmpdir'
|
|
2
2
|
require 'tempfile'
|
3
3
|
require 'fileutils'
|
4
4
|
require 'tagrity/helper'
|
5
|
-
require '
|
5
|
+
require 'pry'
|
6
6
|
|
7
7
|
module Tagrity
|
8
8
|
class TagGenerator
|
9
9
|
class ExecutableNonExist < StandardError; end
|
10
10
|
|
11
|
-
def initialize
|
12
|
-
|
13
|
-
@
|
11
|
+
def initialize(config, logger)
|
12
|
+
@config = config
|
13
|
+
@logger = logger
|
14
14
|
end
|
15
15
|
|
16
16
|
def generate_all
|
@@ -26,7 +26,7 @@ module Tagrity
|
|
26
26
|
if $?.exitstatus == 0
|
27
27
|
generate(files)
|
28
28
|
else
|
29
|
-
logger.error("Failed to get a listing of all files under pwd for use with --fresh. Used #{cmd}.")
|
29
|
+
@logger.error("Failed to get a listing of all files under pwd for use with --fresh. Used #{cmd}.")
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -40,9 +40,9 @@ module Tagrity
|
|
40
40
|
IO::write(tmpf.path, fnames.join("\n"))
|
41
41
|
system(cmd, '-f', tagf, '--append', '-L', tmpf.path, out: File::NULL)
|
42
42
|
if $?.exitstatus == 0
|
43
|
-
logger.info("{#{cmd}} generated tags for #{fnames} into #{tagf}")
|
43
|
+
@logger.info("{#{cmd}} generated tags for #{fnames} into #{tagf}")
|
44
44
|
else
|
45
|
-
logger.info("{#{cmd}} failed to generate tags for #{fnames} into #{tagf}")
|
45
|
+
@logger.info("{#{cmd}} failed to generate tags for #{fnames} into #{tagf}")
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -60,7 +60,7 @@ module Tagrity
|
|
60
60
|
end
|
61
61
|
tmpf.rewind
|
62
62
|
FileUtils.mv(tmpf.path, tagf, force: true)
|
63
|
-
logger.info("Deleted tags for #{files} from #{tagf}")
|
63
|
+
@logger.info("Deleted tags for #{files} from #{tagf}")
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -71,7 +71,7 @@ module Tagrity
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def indexable?(file)
|
74
|
-
file != tagf && !
|
74
|
+
file != tagf && !file_excluded?(file) && File.readable?(file)
|
75
75
|
end
|
76
76
|
|
77
77
|
def copacetic_with_git?(file)
|
@@ -87,27 +87,15 @@ module Tagrity
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def check_git?
|
90
|
-
@config.respect_git? && Helper.
|
90
|
+
@check_git ||= @config.respect_git? && Helper.git_dir?
|
91
91
|
end
|
92
92
|
|
93
|
-
def
|
93
|
+
def file_excluded?(fname)
|
94
94
|
@config.ignore_extension?(fname.partition('.').last) || @config.path_ignored?(fname)
|
95
95
|
end
|
96
96
|
|
97
|
-
def assert_executables
|
98
|
-
%w(cat grep mv).each do |exe|
|
99
|
-
if !Helper.is_executable?(exe)
|
100
|
-
raise ExecutableNonExist, "tagrity depends on the executable #{exe}"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
97
|
def tagf
|
106
98
|
@config.tagf
|
107
99
|
end
|
108
|
-
|
109
|
-
def logger
|
110
|
-
Tlogger.instance
|
111
|
-
end
|
112
100
|
end
|
113
101
|
end
|
data/lib/tagrity/version.rb
CHANGED
data/sample_config.yml
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# which command to use to generate tags for a specific file extension
|
2
2
|
# overrides default_command
|
3
3
|
# commands must support --append, -f, -L
|
4
|
-
#
|
4
|
+
#
|
5
|
+
# Default: empty
|
5
6
|
extension_commands:
|
6
7
|
rb: ripper-tags
|
7
8
|
c: ctags
|
@@ -9,21 +10,25 @@ extension_commands:
|
|
9
10
|
|
10
11
|
# default command to generate tags
|
11
12
|
# command must support --append, -f, -L
|
12
|
-
#
|
13
|
+
#
|
14
|
+
# Default: ctags
|
13
15
|
default_command: ctags
|
14
16
|
|
15
17
|
# filename (relative to pwd) to generate tags into
|
16
|
-
#
|
18
|
+
#
|
19
|
+
# Default: tags
|
17
20
|
tagf: tags
|
18
21
|
|
19
22
|
# list of extensions to exclusively generate tags for
|
20
23
|
# this will take precendence over extensions_blacklist if it is non-empty
|
21
|
-
#
|
24
|
+
#
|
25
|
+
# Default: []
|
22
26
|
extensions_whitelist: [rb, c, h, js]
|
23
27
|
|
24
28
|
# list of extensions to not generate tags for
|
25
29
|
# this can will be ignored if extensions_whitelist is non-empty
|
26
|
-
#
|
30
|
+
#
|
31
|
+
# Default: []
|
27
32
|
extensions_blacklist: [erb, html, txt]
|
28
33
|
|
29
34
|
# how to integrate with git
|
@@ -31,11 +36,13 @@ extensions_blacklist: [erb, html, txt]
|
|
31
36
|
# TRACKED: only index files tracked by git
|
32
37
|
# IGNORED: don't index files which are ignored by git
|
33
38
|
# NA: don't use git, index all files under pwd
|
34
|
-
#
|
39
|
+
#
|
40
|
+
# Default: TRACKED
|
35
41
|
git_strategy: TRACKED
|
36
42
|
|
37
43
|
# which paths (relative to pwd) to ignore
|
38
44
|
# It's usually better to avoid this since tagrity integrates with git by
|
39
45
|
# default using the strategy specified by git_strategy
|
40
|
-
#
|
46
|
+
#
|
47
|
+
# Default: []
|
41
48
|
excluded_paths: [vendor, node_modules]
|
data/tagrity.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
|
29
29
|
spec.add_dependency 'thor', '~> 0.20'
|
30
30
|
spec.add_dependency 'listen', '~> 3.0'
|
31
|
+
spec.add_dependency 'cli-ui', '~> 1.3.0'
|
31
32
|
|
32
33
|
spec.add_development_dependency "bundler", "~> 2.0"
|
33
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -0,0 +1 @@
|
|
1
|
+
foobar.rb
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# which command to use to generate tags for a specific file extension
|
2
|
+
# overrides default_command
|
3
|
+
# DEFAULT: empty
|
4
|
+
extension_commands:
|
5
|
+
rb: ripper-tags
|
6
|
+
|
7
|
+
# default command to generate tags
|
8
|
+
# DEFAULT: ctags
|
9
|
+
default_command: ctags
|
10
|
+
|
11
|
+
# filename (relative to pwd) to generate tags into
|
12
|
+
# DEFAULT: tags
|
13
|
+
tagf: tags
|
14
|
+
|
15
|
+
# list of extensions to exclusively generate tags for
|
16
|
+
# this will take precendence over extensions_blacklist if it is non-empty
|
17
|
+
# DEFAULT: []
|
18
|
+
extensions_whitelist: [rb, c, vim]
|
19
|
+
|
20
|
+
# list of extensions to not generate tags for
|
21
|
+
# this can will be ignored if extensions_whitelist is non-empty
|
22
|
+
# DEFAULT: []
|
23
|
+
# extensions_blacklist: [erb, html, txt]
|
24
|
+
|
25
|
+
# how to integrate with git
|
26
|
+
# git_strategy: TRACKED | IGNORED | NA
|
27
|
+
# TRACKED: only index files tracked by git
|
28
|
+
# IGNORED: don't index files which are ignored by git
|
29
|
+
# NA: don't use git, index all files under pwd
|
30
|
+
# DEFAULT: TRACKED
|
31
|
+
git_strategy: IGNORED
|
32
|
+
|
33
|
+
# which paths (relative to pwd) to ignore
|
34
|
+
# It's usually better to avoid this since tagrity integrates with git by
|
35
|
+
# default using the strategy specified by git_strategy
|
36
|
+
# DEFAULT: []
|
37
|
+
excluded_paths: [vendor, node_modules]
|
data/test_files/barbaz.c
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
barbaz_fun_one foo/barbaz.rb /^def barbaz_fun_one$/;" f class:Object
|
2
|
+
barbaz_fun_two foo/barbaz.rb /^def barbaz_fun_two$/;" f class:Object
|
3
|
+
barbaz_one barbaz.c /^int barbaz_one() {$/;" f typeref:typename:int
|
4
|
+
barbaz_two barbaz.c /^int barbaz_two() {$/;" f typeref:typename:int
|
5
|
+
foobar_fun_one foo/foobar.rb /^def foobar_fun_one$/;" f class:Object
|
6
|
+
foobar_fun_two foo/foobar.rb /^def foobar_fun_two$/;" f class:Object
|
@@ -0,0 +1,6 @@
|
|
1
|
+
barbaz_fun_one foo/barbaz.rb /^def barbaz_fun_one$/;" f class:Object
|
2
|
+
barbaz_fun_two foo/barbaz.rb /^def barbaz_fun_two$/;" f class:Object
|
3
|
+
barbaz_one barbaz.c /^int barbaz_one() {$/;" f typeref:typename:int
|
4
|
+
barbaz_one foo/foobar.c /^int barbaz_one() {$/;" f typeref:typename:int
|
5
|
+
barbaz_two barbaz.c /^int barbaz_two() {$/;" f typeref:typename:int
|
6
|
+
barbaz_two foo/foobar.c /^int barbaz_two() {$/;" f typeref:typename:int
|
@@ -0,0 +1,10 @@
|
|
1
|
+
barbaz_fun_one foo/barbaz.rb /^def barbaz_fun_one$/;" f class:Object
|
2
|
+
barbaz_fun_two foo/barbaz.rb /^def barbaz_fun_two$/;" f class:Object
|
3
|
+
barbaz_one barbaz.c /^int barbaz_one() {$/;" f typeref:typename:int
|
4
|
+
barbaz_one foo/foobar.c /^int barbaz_one() {$/;" f typeref:typename:int
|
5
|
+
barbaz_two barbaz.c /^int barbaz_two() {$/;" f typeref:typename:int
|
6
|
+
barbaz_two foo/foobar.c /^int barbaz_two() {$/;" f typeref:typename:int
|
7
|
+
foobar_fun_one foo/foobar.rb /^def foobar_fun_one$/;" f class:Object
|
8
|
+
foobar_fun_one foobar.rb /^def foobar_fun_one$/;" f class:Object
|
9
|
+
foobar_fun_two foo/foobar.rb /^def foobar_fun_two$/;" f class:Object
|
10
|
+
foobar_fun_two foobar.rb /^def foobar_fun_two$/;" f class:Object
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagrity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam P. Regasz-Rethy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cli-ui
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,6 +132,7 @@ extra_rdoc_files: []
|
|
118
132
|
files:
|
119
133
|
- ".gitignore"
|
120
134
|
- ".rspec"
|
135
|
+
- ".tagrity_config.yml"
|
121
136
|
- ".travis.yml"
|
122
137
|
- CODE_OF_CONDUCT.md
|
123
138
|
- Gemfile
|
@@ -143,6 +158,16 @@ files:
|
|
143
158
|
- lib/tagrity/version.rb
|
144
159
|
- sample_config.yml
|
145
160
|
- tagrity.gemspec
|
161
|
+
- test_files/.gitignore
|
162
|
+
- test_files/.tagrity_config.yml
|
163
|
+
- test_files/barbaz.c
|
164
|
+
- test_files/expected_after_delete
|
165
|
+
- test_files/expected_genall_git_tags
|
166
|
+
- test_files/expected_genall_nongit_tags
|
167
|
+
- test_files/foo/barbaz.rb
|
168
|
+
- test_files/foo/foobar.c
|
169
|
+
- test_files/foo/foobar.rb
|
170
|
+
- test_files/foobar.rb
|
146
171
|
homepage: https://github.com/RRethy/tagrity
|
147
172
|
licenses:
|
148
173
|
- MIT
|