tagrity 0.2.6 → 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +3 -3
- data/README.md +7 -6
- data/lib/tagrity/cli.rb +2 -1
- data/lib/tagrity/commands/logs.rb +10 -3
- data/lib/tagrity/commands/start.rb +2 -2
- data/lib/tagrity/commands/stop.rb +6 -1
- data/lib/tagrity/config_file.rb +31 -20
- data/lib/tagrity/provider.rb +7 -5
- data/lib/tagrity/tag_generator.rb +5 -5
- data/lib/tagrity/tlogger.rb +4 -0
- data/lib/tagrity/version.rb +1 -1
- data/sample_config.yml +3 -3
- data/tagrity.gemspec +1 -1
- data/test_files/barbaz.barbaz.c +7 -0
- data/test_files/expected_after_delete +2 -0
- data/test_files/expected_genall_git_tags +2 -0
- data/test_files/expected_genall_nongit_tags +2 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f61241e904a145f2f947f2577961fb622fb82293f1382ab91f5f461452e92de2
|
4
|
+
data.tar.gz: f0fa1c4fdea48600c548bc9deb5606ca2af9b73f45aad8d3fe74d67502204fdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9f47bbd86cf5daffbe74d3c5d1ba6ee0be97a6c73060de99d5f284a52b8f08e7ddacaf8158af97a7e365916777d94c117d50b1b6a77623edaeffd37ef3a2eb3
|
7
|
+
data.tar.gz: 6e7f2ce3a2249e1bb8c8b7535073617ac3ba4978e31aa4733cdbce61da7b828967eabf5c4442ef9e79ef746243c8f98a831aa125a278908a0041b72b3472bf35
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tagrity (0.2.
|
4
|
+
tagrity (0.2.10)
|
5
5
|
cli-ui (~> 1.3.0)
|
6
6
|
listen (~> 3.0)
|
7
7
|
pry (~> 0.9.9)
|
@@ -22,7 +22,7 @@ GEM
|
|
22
22
|
coderay (~> 1.0)
|
23
23
|
method_source (~> 0.8)
|
24
24
|
slop (~> 3.4)
|
25
|
-
rake (
|
25
|
+
rake (13.0.1)
|
26
26
|
rb-fsevent (0.10.3)
|
27
27
|
rb-inotify (0.10.1)
|
28
28
|
ffi (~> 1.0)
|
@@ -48,7 +48,7 @@ PLATFORMS
|
|
48
48
|
|
49
49
|
DEPENDENCIES
|
50
50
|
bundler (~> 2.0)
|
51
|
-
rake (~>
|
51
|
+
rake (~> 13.0)
|
52
52
|
ripper-tags (~> 0.8.0)
|
53
53
|
rspec (~> 3.0)
|
54
54
|
tagrity!
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ $ gem install tagrity
|
|
16
16
|
tagrity start
|
17
17
|
```
|
18
18
|
|
19
|
-
That's it! It will monitor pwd and
|
19
|
+
That's it! It will monitor pwd and index any files which change. Check out [Configuration](#configuration) to restrict which files get indexed.
|
20
20
|
|
21
21
|
To stop watching pwd, use
|
22
22
|
|
@@ -78,11 +78,11 @@ extensions_blacklist: [erb, html, txt]
|
|
78
78
|
# how to integrate with git
|
79
79
|
# git_strategy: TRACKED | IGNORED | NA
|
80
80
|
# TRACKED: only index files tracked by git
|
81
|
-
# IGNORED:
|
81
|
+
# IGNORED: only index files which are not ignored by git
|
82
82
|
# NA: don't use git, index all files under pwd
|
83
83
|
#
|
84
|
-
# Default:
|
85
|
-
git_strategy:
|
84
|
+
# Default: NA
|
85
|
+
git_strategy: IGNORED
|
86
86
|
|
87
87
|
# which paths (relative to pwd) to ignore
|
88
88
|
# It's usually better to avoid this since tagrity integrates with git by
|
@@ -141,8 +141,9 @@ Usage:
|
|
141
141
|
tagrity logs
|
142
142
|
|
143
143
|
Options:
|
144
|
-
[-n=N]
|
145
|
-
|
144
|
+
[-n=N] # the number of log lines to print
|
145
|
+
# Default: 10
|
146
|
+
[--debug], [--no-debug] # if debug logs be printed too
|
146
147
|
|
147
148
|
Print the logs for pwd
|
148
149
|
```
|
data/lib/tagrity/cli.rb
CHANGED
@@ -25,8 +25,9 @@ module Tagrity
|
|
25
25
|
|
26
26
|
desc "logs", "Print the logs for pwd"
|
27
27
|
option :n, type: :numeric, default: 10, desc: "the number of log lines to print"
|
28
|
+
option :debug, type: :boolean, default: false, desc: "if debug logs be printed too"
|
28
29
|
def logs
|
29
|
-
Command::Logs::call(options['n'])
|
30
|
+
Command::Logs::call(options['n'], options['debug'])
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'tagrity/tlogger'
|
2
|
+
require 'tagrity/provider'
|
2
3
|
|
3
4
|
module Tagrity
|
4
5
|
module Command
|
5
6
|
class Logs
|
6
7
|
class << self
|
7
|
-
def call(n)
|
8
|
+
def call(n, debug)
|
8
9
|
if File.readable?(logf)
|
9
|
-
|
10
|
+
system("cat #{logf} | grep -F #{log_levels(debug).map { |lvl| " -e '#{lvl}' " }.join} | tail -n #{Integer(n)}")
|
10
11
|
else
|
11
12
|
puts "Error: There doesn't seem to be a log file for #{Dir.pwd}"
|
12
13
|
end
|
@@ -14,8 +15,14 @@ module Tagrity
|
|
14
15
|
|
15
16
|
private
|
16
17
|
|
18
|
+
def log_levels(debug)
|
19
|
+
levels = ['INFO', 'WARN', 'ERROR', 'FATAL', 'UNKNOWN']
|
20
|
+
levels << 'DEBUG' if debug
|
21
|
+
levels
|
22
|
+
end
|
23
|
+
|
17
24
|
def logf
|
18
|
-
|
25
|
+
Provider.provide(:tlogger).logf
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
@@ -16,11 +16,11 @@ module Tagrity
|
|
16
16
|
assert_not_running(dir)
|
17
17
|
|
18
18
|
Process.daemon(nochdir: true) unless fg
|
19
|
+
logger.fg = fg
|
19
20
|
|
20
21
|
tag_generator = Provider.provide(:tag_generator)
|
21
22
|
PidFile.write(PidFile.new(dir, Process.pid))
|
22
23
|
|
23
|
-
logger.fg = fg
|
24
24
|
logger.info("Watching #{dir} with process pid #{Process.pid}")
|
25
25
|
|
26
26
|
if fresh
|
@@ -66,7 +66,7 @@ module Tagrity
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def logger
|
69
|
-
@logger ||=
|
69
|
+
@logger ||= Provider.provide(:tlogger)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'cli/ui'
|
2
2
|
require 'tagrity/tlogger'
|
3
|
+
require 'tagrity/provider'
|
3
4
|
|
4
5
|
module Tagrity
|
5
6
|
module Command
|
@@ -14,10 +15,14 @@ module Tagrity
|
|
14
15
|
pid_files.each do |pid_file|
|
15
16
|
pid_file.delete
|
16
17
|
puts ::CLI::UI.fmt "{{green:#{"Successfully killed #{pid_file.pid}"}}}"
|
17
|
-
|
18
|
+
logger.info("Successfully killed #{pid_file.pid}")
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
22
|
+
|
23
|
+
def logger
|
24
|
+
@logger ||= Provider.provide(:tlogger)
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
data/lib/tagrity/config_file.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'singleton'
|
3
3
|
require 'tagrity/helper'
|
4
|
+
require 'tagrity/tlogger'
|
5
|
+
require 'tagrity/provider'
|
4
6
|
|
5
7
|
module Tagrity
|
6
8
|
class ConfigFile
|
@@ -18,6 +20,12 @@ module Tagrity
|
|
18
20
|
read_config(fname: global_config_path)
|
19
21
|
end
|
20
22
|
|
23
|
+
def initial_load
|
24
|
+
if @config.nil?
|
25
|
+
read_config
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
21
29
|
def command_for_extension(extension)
|
22
30
|
cmd = extension_commands[extension.to_s]
|
23
31
|
if cmd.nil?
|
@@ -44,35 +52,35 @@ module Tagrity
|
|
44
52
|
end
|
45
53
|
|
46
54
|
def extension_commands
|
47
|
-
config['extension_commands']
|
55
|
+
@config['extension_commands']
|
48
56
|
end
|
49
57
|
|
50
58
|
def default_command
|
51
|
-
config['default_command']
|
59
|
+
@config['default_command']
|
52
60
|
end
|
53
61
|
|
54
62
|
def tagf
|
55
|
-
config['tagf']
|
63
|
+
@config['tagf']
|
56
64
|
end
|
57
65
|
|
58
66
|
def extensions_whitelist
|
59
|
-
config['extensions_whitelist']
|
67
|
+
@config['extensions_whitelist']
|
60
68
|
end
|
61
69
|
|
62
70
|
def extensions_blacklist
|
63
|
-
config['extensions_blacklist']
|
71
|
+
@config['extensions_blacklist']
|
64
72
|
end
|
65
73
|
|
66
74
|
def git_strategy
|
67
|
-
config['git_strategy']
|
75
|
+
@config['git_strategy']
|
68
76
|
end
|
69
77
|
|
70
78
|
def excluded_paths
|
71
|
-
config['excluded_paths']
|
79
|
+
@config['excluded_paths']
|
72
80
|
end
|
73
81
|
|
74
82
|
def to_s
|
75
|
-
config.to_s
|
83
|
+
@config.to_s
|
76
84
|
end
|
77
85
|
|
78
86
|
private
|
@@ -103,15 +111,15 @@ module Tagrity
|
|
103
111
|
end
|
104
112
|
|
105
113
|
def ensure_extensions_whitelist
|
106
|
-
ensure_option('
|
114
|
+
ensure_option('extensions_whitelist', [])
|
107
115
|
end
|
108
116
|
|
109
117
|
def ensure_extensions_blacklist
|
110
|
-
ensure_option('
|
118
|
+
ensure_option('extensions_blacklist', [])
|
111
119
|
end
|
112
120
|
|
113
121
|
def ensure_git_strategy
|
114
|
-
ensure_option('git_strategy', '
|
122
|
+
ensure_option('git_strategy', 'NA')
|
115
123
|
end
|
116
124
|
|
117
125
|
def ensure_excluded_paths
|
@@ -119,28 +127,27 @@ module Tagrity
|
|
119
127
|
end
|
120
128
|
|
121
129
|
def ensure_option(name, default)
|
122
|
-
if config[name].nil? ||
|
123
|
-
config[name] = default
|
130
|
+
if @config[name].nil? || !@config[name].is_a?(default.class)
|
131
|
+
@config[name] = default
|
124
132
|
end
|
125
133
|
end
|
126
134
|
|
127
|
-
def config
|
128
|
-
@config ||= read_config
|
129
|
-
end
|
130
|
-
|
131
135
|
def read_config(fname: nil)
|
132
136
|
@config = {}
|
137
|
+
config_fname = '{default configuration}'
|
133
138
|
if fname.nil?
|
134
139
|
if File.readable?(local_config_path)
|
135
|
-
|
140
|
+
config_fname = local_config_path
|
141
|
+
@config = YAML.load_file(local_config_path)
|
136
142
|
elsif File.readable?(global_config_path)
|
137
|
-
|
143
|
+
config_fname = global_config_path
|
144
|
+
@config = YAML.load_file(global_config_path)
|
138
145
|
end
|
139
146
|
else
|
140
147
|
@config = YAML.load_file(fname)
|
141
148
|
end
|
142
149
|
init
|
143
|
-
@config
|
150
|
+
logger.debug("Loaded config from #{config_fname} with settings #{@config.to_s}")
|
144
151
|
end
|
145
152
|
|
146
153
|
def global_config_path
|
@@ -150,5 +157,9 @@ module Tagrity
|
|
150
157
|
def local_config_path
|
151
158
|
File.expand_path("./.#{CONFIG_FNAME}")
|
152
159
|
end
|
160
|
+
|
161
|
+
def logger
|
162
|
+
@logger ||= Provider.provide(:tlogger)
|
163
|
+
end
|
153
164
|
end
|
154
165
|
end
|
data/lib/tagrity/provider.rb
CHANGED
@@ -8,13 +8,15 @@ module Tagrity
|
|
8
8
|
def provide(want)
|
9
9
|
case want
|
10
10
|
when :tag_generator
|
11
|
-
|
11
|
+
TagGenerator.new(provide(:config_file), provide(:tlogger))
|
12
|
+
when :tlogger
|
13
|
+
Tlogger.instance
|
14
|
+
when :config_file
|
15
|
+
config = ConfigFile.instance
|
16
|
+
config.initial_load
|
17
|
+
config
|
12
18
|
end
|
13
19
|
end
|
14
|
-
|
15
|
-
def provide_tag_generator
|
16
|
-
TagGenerator.new(ConfigFile.instance, Tlogger.instance)
|
17
|
-
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -20,7 +20,7 @@ module Tagrity
|
|
20
20
|
cmd = if check_git?
|
21
21
|
'git ls-files 2> /dev/null'
|
22
22
|
else
|
23
|
-
'find * 2> /dev/null'
|
23
|
+
'find * -type f 2> /dev/null'
|
24
24
|
end
|
25
25
|
files = `#{cmd}`.split("\n")
|
26
26
|
if $?.exitstatus == 0
|
@@ -33,12 +33,12 @@ module Tagrity
|
|
33
33
|
def generate(files)
|
34
34
|
return if files.empty?
|
35
35
|
files
|
36
|
-
.select { |file| generate_tags?(file)
|
37
|
-
.group_by { |file| @config.command_for_extension(file.
|
36
|
+
.select { |file| generate_tags?(file)}
|
37
|
+
.group_by { |file| @config.command_for_extension(file.split('.').last) }
|
38
38
|
.each do |cmd, fnames|
|
39
39
|
Tempfile.create do |tmpf|
|
40
40
|
IO::write(tmpf.path, fnames.join("\n"))
|
41
|
-
system(cmd, '-f', tagf, '--append', '-L', tmpf.path, out: File::NULL)
|
41
|
+
system(cmd, '-f', tagf, '--append', '-L', tmpf.path, out: File::NULL, err: File::NULL)
|
42
42
|
if $?.exitstatus == 0
|
43
43
|
@logger.info("{#{cmd}} generated tags for #{fnames} into #{tagf}")
|
44
44
|
else
|
@@ -91,7 +91,7 @@ module Tagrity
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def file_excluded?(fname)
|
94
|
-
@config.ignore_extension?(fname.
|
94
|
+
@config.ignore_extension?(fname.split('.').last) || @config.path_ignored?(fname)
|
95
95
|
end
|
96
96
|
|
97
97
|
def tagf
|
data/lib/tagrity/tlogger.rb
CHANGED
data/lib/tagrity/version.rb
CHANGED
data/sample_config.yml
CHANGED
@@ -35,11 +35,11 @@ extensions_blacklist: [erb, html, txt]
|
|
35
35
|
# how to integrate with git
|
36
36
|
# git_strategy: TRACKED | IGNORED | NA
|
37
37
|
# TRACKED: only index files tracked by git
|
38
|
-
# IGNORED:
|
38
|
+
# IGNORED: only index files which are not ignored by git
|
39
39
|
# NA: don't use git, index all files under pwd
|
40
40
|
#
|
41
|
-
# Default:
|
42
|
-
git_strategy:
|
41
|
+
# Default: NA
|
42
|
+
git_strategy: IGNORED
|
43
43
|
|
44
44
|
# which paths (relative to pwd) to ignore
|
45
45
|
# It's usually better to avoid this since tagrity integrates with git by
|
data/tagrity.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency 'cli-ui', '~> 1.3.0'
|
32
32
|
|
33
33
|
spec.add_development_dependency "bundler", "~> 2.0"
|
34
|
-
spec.add_development_dependency "rake", "~>
|
34
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
35
35
|
spec.add_development_dependency "rspec", "~> 3.0"
|
36
36
|
spec.add_development_dependency "ripper-tags", "~> 0.8.0"
|
37
37
|
spec.add_dependency "pry", "~> 0.9.9"
|
@@ -1,6 +1,8 @@
|
|
1
1
|
barbaz_fun_one foo/barbaz.rb /^def barbaz_fun_one$/;" f class:Object
|
2
2
|
barbaz_fun_two foo/barbaz.rb /^def barbaz_fun_two$/;" f class:Object
|
3
|
+
barbaz_one barbaz.barbaz.c /^int barbaz_one() {$/;" f typeref:typename:int
|
3
4
|
barbaz_one barbaz.c /^int barbaz_one() {$/;" f typeref:typename:int
|
5
|
+
barbaz_two barbaz.barbaz.c /^int barbaz_two() {$/;" f typeref:typename:int
|
4
6
|
barbaz_two barbaz.c /^int barbaz_two() {$/;" f typeref:typename:int
|
5
7
|
foobar_fun_one foo/foobar.rb /^def foobar_fun_one$/;" f class:Object
|
6
8
|
foobar_fun_two foo/foobar.rb /^def foobar_fun_two$/;" f class:Object
|
@@ -1,6 +1,8 @@
|
|
1
1
|
barbaz_fun_one foo/barbaz.rb /^def barbaz_fun_one$/;" f class:Object
|
2
2
|
barbaz_fun_two foo/barbaz.rb /^def barbaz_fun_two$/;" f class:Object
|
3
|
+
barbaz_one barbaz.barbaz.c /^int barbaz_one() {$/;" f typeref:typename:int
|
3
4
|
barbaz_one barbaz.c /^int barbaz_one() {$/;" f typeref:typename:int
|
4
5
|
barbaz_one foo/foobar.c /^int barbaz_one() {$/;" f typeref:typename:int
|
6
|
+
barbaz_two barbaz.barbaz.c /^int barbaz_two() {$/;" f typeref:typename:int
|
5
7
|
barbaz_two barbaz.c /^int barbaz_two() {$/;" f typeref:typename:int
|
6
8
|
barbaz_two foo/foobar.c /^int barbaz_two() {$/;" f typeref:typename:int
|
@@ -1,7 +1,9 @@
|
|
1
1
|
barbaz_fun_one foo/barbaz.rb /^def barbaz_fun_one$/;" f class:Object
|
2
2
|
barbaz_fun_two foo/barbaz.rb /^def barbaz_fun_two$/;" f class:Object
|
3
|
+
barbaz_one barbaz.barbaz.c /^int barbaz_one() {$/;" f typeref:typename:int
|
3
4
|
barbaz_one barbaz.c /^int barbaz_one() {$/;" f typeref:typename:int
|
4
5
|
barbaz_one foo/foobar.c /^int barbaz_one() {$/;" f typeref:typename:int
|
6
|
+
barbaz_two barbaz.barbaz.c /^int barbaz_two() {$/;" f typeref:typename:int
|
5
7
|
barbaz_two barbaz.c /^int barbaz_two() {$/;" f typeref:typename:int
|
6
8
|
barbaz_two foo/foobar.c /^int barbaz_two() {$/;" f typeref:typename:int
|
7
9
|
foobar_fun_one foo/foobar.rb /^def foobar_fun_one$/;" 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.2.
|
4
|
+
version: 0.2.11
|
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: 2020-
|
11
|
+
date: 2020-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '13.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '13.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- tagrity.gemspec
|
162
162
|
- test_files/.gitignore
|
163
163
|
- test_files/.tagrity_config.yml
|
164
|
+
- test_files/barbaz.barbaz.c
|
164
165
|
- test_files/barbaz.c
|
165
166
|
- test_files/expected_after_delete
|
166
167
|
- test_files/expected_genall_git_tags
|