tagrity 0.2.6 → 0.2.7
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 +1 -1
- 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 +28 -17
- data/lib/tagrity/provider.rb +7 -5
- data/lib/tagrity/tlogger.rb +4 -0
- data/lib/tagrity/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3cedab5e7b5b37fbf717a23c623e66214ef3a541ab873dc9e7bceffb9b356e0
|
4
|
+
data.tar.gz: 7348028ac723e7bdfbd21a5364147229baf1cd73099bfe8b120cf045d33d410d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58747973850cfd2def6c51670594f7a44dbb067bf0a63746cbee4da07cdfebdb1f3a778982720202bce082885880f3e32dd4a998573ab1028ab2e2a6c4b9ca22
|
7
|
+
data.tar.gz: a3b4f43a3a3515611875348aafe1b7336920fe3f6e9743296312f55db82b85aed05ac802dae8f5ffde716eb0baaa0525f972818a6dbeee6cdc60c3615f580259
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
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
|
@@ -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
|
data/lib/tagrity/tlogger.rb
CHANGED
data/lib/tagrity/version.rb
CHANGED
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.7
|
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-01-
|
11
|
+
date: 2020-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|