tagrity 0.1.10 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.tagrity_config.yml +38 -0
- data/.travis.yml +6 -1
- data/Gemfile.lock +4 -2
- data/README.md +96 -31
- data/lib/tagrity/commands/start.rb +2 -1
- data/lib/tagrity/commands/status.rb +3 -1
- data/lib/tagrity/commands/stop.rb +3 -2
- data/lib/tagrity/config_file.rb +40 -21
- 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 +16 -8
- 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: a857a7e4ba200bc8058e9e862098e3de1b7e1058b5098f2e745a076e4ad04f57
|
4
|
+
data.tar.gz: 153d10c351c435f5cc518b851376e5c0b4d4720e00aabc64cd30ad26ec4272b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fb823c4f06d08641055876347f0d1f8c79ff825ecd91e2f885acecff79ee5e181faf57dfea5b3eab464fe4d0852353ae99271e485cea1a8e73a803a4307774c
|
7
|
+
data.tar.gz: ca2dae1f92bc9a6430435436574a1fb61b45ad4d881ca240fde79f77cf94867ad0488ff062b46d526d232c4f42f5f62581d88eaf1befb8dbd01178f9070a81d7
|
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.1
|
4
|
+
tagrity (0.2.1)
|
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,6 +1,8 @@
|
|
1
1
|
# Tagrity
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.com/RRethy/tagrity)
|
4
|
+
|
5
|
+
Automatically regenerate your tags on file changes.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -14,16 +16,89 @@ $ 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
|
+
**NOTE:** 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 in the current directory under the name `.tagrity_config.yml`.
|
38
|
+
|
39
|
+
[`tagrity_config.yml`](https://github.com/RRethy/tagrity/blob/master/sample_config.yml)
|
40
|
+
|
41
|
+
```yaml
|
42
|
+
# which command to use to generate tags for a specific file extension
|
43
|
+
# overrides default_command
|
44
|
+
# tag generation commands must support --append, -f, -L
|
45
|
+
# NOTE: Exuberant-ctags does NOT satisfy this, instead use Universal-ctags
|
46
|
+
#
|
47
|
+
# Default: empty
|
48
|
+
extension_commands:
|
49
|
+
rb: ripper-tags
|
50
|
+
c: ctags
|
51
|
+
go: gotags
|
52
|
+
|
53
|
+
# default command to generate tags
|
54
|
+
# command must support --append, -f, -L
|
55
|
+
#
|
56
|
+
# Default: ctags
|
57
|
+
default_command: ctags
|
58
|
+
|
59
|
+
# filename (relative to pwd) to generate tags into
|
60
|
+
#
|
61
|
+
# Default: tags
|
62
|
+
tagf: tags
|
63
|
+
|
64
|
+
# list of extensions to exclusively generate tags for
|
65
|
+
# this will take precendence over extensions_blacklist if it is non-empty
|
66
|
+
#
|
67
|
+
# Default: []
|
68
|
+
extensions_whitelist: [rb, c, h, js]
|
69
|
+
|
70
|
+
# list of extensions to not generate tags for
|
71
|
+
# this can will be ignored if extensions_whitelist is non-empty
|
72
|
+
#
|
73
|
+
# Default: []
|
74
|
+
extensions_blacklist: [erb, html, txt]
|
75
|
+
|
76
|
+
# how to integrate with git
|
77
|
+
# git_strategy: TRACKED | IGNORED | NA
|
78
|
+
# TRACKED: only index files tracked by git
|
79
|
+
# IGNORED: don't index files which are ignored by git
|
80
|
+
# NA: don't use git, index all files under pwd
|
81
|
+
#
|
82
|
+
# Default: TRACKED
|
83
|
+
git_strategy: TRACKED
|
84
|
+
|
85
|
+
# which paths (relative to pwd) to ignore
|
86
|
+
# It's usually better to avoid this since tagrity integrates with git by
|
87
|
+
# default using the strategy specified by git_strategy
|
88
|
+
#
|
89
|
+
# Default: []
|
90
|
+
excluded_paths: [vendor, node_modules]
|
91
|
+
```
|
18
92
|
|
19
93
|
## Usage
|
20
94
|
|
21
95
|
```
|
22
96
|
Commands:
|
23
97
|
tagrity help [COMMAND] # Describe available commands or one specific command
|
24
|
-
tagrity
|
98
|
+
tagrity logs # Print the logs for pwd
|
99
|
+
tagrity start # Start watching pwd
|
25
100
|
tagrity status # List running tagrity processes and the directories being watched
|
26
|
-
tagrity stop # Stop watching
|
101
|
+
tagrity stop # Stop watching pwd
|
27
102
|
```
|
28
103
|
|
29
104
|
### start
|
@@ -33,15 +108,10 @@ Usage:
|
|
33
108
|
tagrity start
|
34
109
|
|
35
110
|
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)
|
111
|
+
[--fg], [--no-fg] # keep the tagrity process running in the foreground
|
112
|
+
[--fresh], [--no-fresh] # index the whole codebase before watching the file system. This will be slow if the codebase is large.
|
113
|
+
|
114
|
+
Start watching pwd
|
45
115
|
```
|
46
116
|
|
47
117
|
### stop
|
@@ -50,10 +120,7 @@ Start watching a directory (default to pwd)
|
|
50
120
|
Usage:
|
51
121
|
tagrity stop
|
52
122
|
|
53
|
-
|
54
|
-
[--dir=DIR]
|
55
|
-
|
56
|
-
Stop watching a directory (default to pwd)
|
123
|
+
Stop watching pwd
|
57
124
|
```
|
58
125
|
|
59
126
|
### status
|
@@ -65,15 +132,22 @@ Usage:
|
|
65
132
|
List running tagrity processes and the directories being watched
|
66
133
|
```
|
67
134
|
|
68
|
-
|
135
|
+
### logs
|
69
136
|
|
70
|
-
|
137
|
+
```
|
138
|
+
Usage:
|
139
|
+
tagrity logs
|
71
140
|
|
72
|
-
|
141
|
+
Options:
|
142
|
+
[-n=N] # the number of log lines to print
|
143
|
+
# Default: 10
|
144
|
+
|
145
|
+
Print the logs for pwd
|
146
|
+
```
|
73
147
|
|
74
148
|
## Contributing
|
75
149
|
|
76
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
150
|
+
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
151
|
|
78
152
|
## License
|
79
153
|
|
@@ -81,13 +155,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
81
155
|
|
82
156
|
## Code of Conduct
|
83
157
|
|
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
|
158
|
+
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,12 @@
|
|
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
8
|
PidFile.alive_pid_files.each do |pid_file|
|
7
|
-
puts "
|
9
|
+
puts ::CLI::UI.fmt "{{cyan:#{pid_file.pid}}} {{green:#{pid_file.dir}}}"
|
8
10
|
end
|
9
11
|
end
|
10
12
|
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
@@ -9,21 +9,17 @@ module Tagrity
|
|
9
9
|
class ErrorTagFileNotWritable < StandardError; end
|
10
10
|
|
11
11
|
CONFIG_FNAME = 'tagrity_config.yml'
|
12
|
-
LOCAL_CONFIG_PATH = File.expand_path("./.#{CONFIG_FNAME}")
|
13
|
-
GLOBAL_CONFIG_PATH = File.expand_path("#{ENV['XDG_CONFIG_HOME'] || "#{ENV['HOME']}/.config"}/tagrity/#{CONFIG_FNAME}")
|
14
12
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
ensure_git_strategy
|
22
|
-
ensure_excluded_paths
|
13
|
+
def reload_local
|
14
|
+
read_config(fname: local_config_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def reload_global
|
18
|
+
read_config(fname: global_config_path)
|
23
19
|
end
|
24
20
|
|
25
21
|
def command_for_extension(extension)
|
26
|
-
cmd = extension_commands[extension]
|
22
|
+
cmd = extension_commands[extension.to_s]
|
27
23
|
if cmd.nil?
|
28
24
|
default_command
|
29
25
|
else
|
@@ -33,14 +29,14 @@ module Tagrity
|
|
33
29
|
|
34
30
|
def ignore_extension?(extension)
|
35
31
|
unless extensions_whitelist.empty?
|
36
|
-
return !extensions_whitelist.include?(extension)
|
32
|
+
return !extensions_whitelist.include?(extension.to_s)
|
37
33
|
end
|
38
34
|
|
39
|
-
extensions_blacklist.include?(extension)
|
35
|
+
extensions_blacklist.include?(extension.to_s)
|
40
36
|
end
|
41
37
|
|
42
38
|
def path_ignored?(path)
|
43
|
-
excluded_paths.any? { |pat|
|
39
|
+
excluded_paths.any? { |pat| !(/^#{pat}/ =~ path.to_s).nil? }
|
44
40
|
end
|
45
41
|
|
46
42
|
def respect_git?
|
@@ -81,6 +77,16 @@ module Tagrity
|
|
81
77
|
|
82
78
|
private
|
83
79
|
|
80
|
+
def init
|
81
|
+
ensure_extension_commands
|
82
|
+
ensure_default_command
|
83
|
+
ensure_tagf
|
84
|
+
ensure_extensions_whitelist
|
85
|
+
ensure_extensions_blacklist
|
86
|
+
ensure_git_strategy
|
87
|
+
ensure_excluded_paths
|
88
|
+
end
|
89
|
+
|
84
90
|
def ensure_extension_commands
|
85
91
|
ensure_option('extension_commands', {})
|
86
92
|
end
|
@@ -109,7 +115,7 @@ module Tagrity
|
|
109
115
|
end
|
110
116
|
|
111
117
|
def ensure_excluded_paths
|
112
|
-
ensure_option('
|
118
|
+
ensure_option('excluded_paths', [])
|
113
119
|
end
|
114
120
|
|
115
121
|
def ensure_option(name, default)
|
@@ -122,14 +128,27 @@ module Tagrity
|
|
122
128
|
@config ||= read_config
|
123
129
|
end
|
124
130
|
|
125
|
-
def read_config
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
131
|
+
def read_config(fname: nil)
|
132
|
+
@config = {}
|
133
|
+
if fname.nil?
|
134
|
+
if File.readable?(local_config_path)
|
135
|
+
read_config(fname: local_config_path)
|
136
|
+
elsif File.readable?(global_config_path)
|
137
|
+
read_config(fname: global_config_path)
|
138
|
+
end
|
130
139
|
else
|
131
|
-
@config =
|
140
|
+
@config = YAML.load_file(fname)
|
132
141
|
end
|
142
|
+
init
|
143
|
+
@config
|
144
|
+
end
|
145
|
+
|
146
|
+
def global_config_path
|
147
|
+
File.expand_path("#{ENV['XDG_CONFIG_HOME'] || "#{ENV['HOME']}/.config"}/tagrity/#{CONFIG_FNAME}")
|
148
|
+
end
|
149
|
+
|
150
|
+
def local_config_path
|
151
|
+
File.expand_path("./.#{CONFIG_FNAME}")
|
133
152
|
end
|
134
153
|
end
|
135
154
|
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,9 @@
|
|
1
1
|
# which command to use to generate tags for a specific file extension
|
2
2
|
# overrides default_command
|
3
|
-
# commands must support --append, -f, -L
|
4
|
-
#
|
3
|
+
# tag generation commands must support --append, -f, -L
|
4
|
+
# NOTE: Exuberant-ctags does NOT satisfy this, instead use Universal-ctags
|
5
|
+
#
|
6
|
+
# Default: empty
|
5
7
|
extension_commands:
|
6
8
|
rb: ripper-tags
|
7
9
|
c: ctags
|
@@ -9,21 +11,25 @@ extension_commands:
|
|
9
11
|
|
10
12
|
# default command to generate tags
|
11
13
|
# command must support --append, -f, -L
|
12
|
-
#
|
14
|
+
#
|
15
|
+
# Default: ctags
|
13
16
|
default_command: ctags
|
14
17
|
|
15
18
|
# filename (relative to pwd) to generate tags into
|
16
|
-
#
|
19
|
+
#
|
20
|
+
# Default: tags
|
17
21
|
tagf: tags
|
18
22
|
|
19
23
|
# list of extensions to exclusively generate tags for
|
20
24
|
# this will take precendence over extensions_blacklist if it is non-empty
|
21
|
-
#
|
25
|
+
#
|
26
|
+
# Default: []
|
22
27
|
extensions_whitelist: [rb, c, h, js]
|
23
28
|
|
24
29
|
# list of extensions to not generate tags for
|
25
30
|
# this can will be ignored if extensions_whitelist is non-empty
|
26
|
-
#
|
31
|
+
#
|
32
|
+
# Default: []
|
27
33
|
extensions_blacklist: [erb, html, txt]
|
28
34
|
|
29
35
|
# how to integrate with git
|
@@ -31,11 +37,13 @@ extensions_blacklist: [erb, html, txt]
|
|
31
37
|
# TRACKED: only index files tracked by git
|
32
38
|
# IGNORED: don't index files which are ignored by git
|
33
39
|
# NA: don't use git, index all files under pwd
|
34
|
-
#
|
40
|
+
#
|
41
|
+
# Default: TRACKED
|
35
42
|
git_strategy: TRACKED
|
36
43
|
|
37
44
|
# which paths (relative to pwd) to ignore
|
38
45
|
# It's usually better to avoid this since tagrity integrates with git by
|
39
46
|
# default using the strategy specified by git_strategy
|
40
|
-
#
|
47
|
+
#
|
48
|
+
# Default: []
|
41
49
|
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.1
|
4
|
+
version: 0.2.1
|
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
|