tagrity 0.2.6 → 0.2.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7abbd36d4074d7f610bbbed3e71d903568893a67164ed0e80ba3f08ec02dd421
4
- data.tar.gz: e353956fd28322c2683f56ce2fc7859e0e52ec2463e4c7e003d4798048fa8210
3
+ metadata.gz: a3cedab5e7b5b37fbf717a23c623e66214ef3a541ab873dc9e7bceffb9b356e0
4
+ data.tar.gz: 7348028ac723e7bdfbd21a5364147229baf1cd73099bfe8b120cf045d33d410d
5
5
  SHA512:
6
- metadata.gz: 42589ff58a766a2cf3704320dd28d3f22c18e63ef65f5790191165cd33f6aa1d39b0e39eccf6fd58a78b09ea3b30557a3a07a7e62c588a13115371d553a239cb
7
- data.tar.gz: f3842c9081dcf17c74f8651b504a1c4af4d416e54bdca36b2a466272dd0fcb3b5dee5db9a0e677c99f849a934942d7986247960cda2130a32a8c1364d7039c6b
6
+ metadata.gz: 58747973850cfd2def6c51670594f7a44dbb067bf0a63746cbee4da07cdfebdb1f3a778982720202bce082885880f3e32dd4a998573ab1028ab2e2a6c4b9ca22
7
+ data.tar.gz: a3b4f43a3a3515611875348aafe1b7336920fe3f6e9743296312f55db82b85aed05ac802dae8f5ffde716eb0baaa0525f972818a6dbeee6cdc60c3615f580259
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  .rspec_status
12
12
 
13
13
  /var/
14
+ lib/tagrity/var/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tagrity (0.2.6)
4
+ tagrity (0.2.7)
5
5
  cli-ui (~> 1.3.0)
6
6
  listen (~> 3.0)
7
7
  pry (~> 0.9.9)
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
- puts `cat #{logf} | tail -n #{Integer(n)}`.split("\n")
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
- Tlogger.instance.logf
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 ||= Tlogger.instance
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
- Tlogger.instance.info("Successfully killed #{pid_file.pid}")
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
@@ -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? || !config[name].is_a?(default.class)
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
- read_config(fname: local_config_path)
140
+ config_fname = local_config_path
141
+ @config = YAML.load_file(local_config_path)
136
142
  elsif File.readable?(global_config_path)
137
- read_config(fname: global_config_path)
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
@@ -8,13 +8,15 @@ module Tagrity
8
8
  def provide(want)
9
9
  case want
10
10
  when :tag_generator
11
- provide_tag_generator
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
@@ -16,6 +16,10 @@ module Tagrity
16
16
  logger.error(msg)
17
17
  end
18
18
 
19
+ def debug(msg)
20
+ logger.debug(msg)
21
+ end
22
+
19
23
  def logf
20
24
  # TODO this can cause duplicates, unlikely tho
21
25
  "#{Helper.log_dir}/#{Dir.pwd.gsub(/\//, '--')}.log"
@@ -1,3 +1,3 @@
1
1
  module Tagrity
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
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.6
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-08 00:00:00.000000000 Z
11
+ date: 2020-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor