tagrity 0.1.6 → 0.1.11

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: 0bbba0199d2e4305cc015fc1bf2151892628224fdb31ad0a1b2fe0e08b2a5b8b
4
- data.tar.gz: b2910418b53ce0d188c03048ca4554988e1833269ed385a041291dd0427a4499
3
+ metadata.gz: 676b3812ea21f514554472122fca65107c27a5c1998b9868ce5da719fca8b584
4
+ data.tar.gz: 29b26f0ca85cfbd6dcac1af677f298ea31687a793cfbb224d6dfa0f140a23d81
5
5
  SHA512:
6
- metadata.gz: d103e833875ab1d827dc26857a78c9795092ccf1fd8d346fa506fcf3586b6581d5842a6d5a30b9ea470643997a97722e9df922b83cdbd8a1607b222261eaa114
7
- data.tar.gz: 24eef3ae46b97b8e56802013a60217e9c8749f81846e4beff6f056f33166e9f2d4935cc4a12f6c8005d5b93d29db9d5803fef18e586f5cd3a8d82faf5b0a7392
6
+ metadata.gz: 360d9552c208f658a465a590a438a8d09f4f6ea2ca39be206ba643fec3e060eedd2e02232b7b8aa3c9b17786f43c677ce86bec1e5e54024ea45a8b62653d0e08
7
+ data.tar.gz: dd53f1bf80a33e857c93c317ffb960559939ce81627221415291b11630ca9239b8f673f8f2cfd1e4bc743d8369634cfc38a6a28bddf05347b809adb9025c4754
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tagrity (0.1.6)
4
+ tagrity (0.1.11)
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.0)
27
+ rb-inotify (0.10.1)
26
28
  ffi (~> 1.0)
27
29
  ripper-tags (0.8.0)
28
30
  rspec (3.9.0)
@@ -2,29 +2,20 @@ require 'thor'
2
2
  require 'tagrity/commands/start'
3
3
  require 'tagrity/commands/stop'
4
4
  require 'tagrity/commands/status'
5
+ require 'tagrity/commands/logs'
5
6
 
6
7
  module Tagrity
7
8
  class CLI < Thor
8
- desc "start", "Start watching a directory (default to pwd)"
9
- option :dir, desc: "directory to watch (omit to use pwd)"
10
- option :tagf, desc: "filename (relative) to generate tags into (default: 'tags')."
11
- option :fg, type: :boolean, desc: "keep the tagrity process running in the foreground"
9
+ desc "start", "Start watching pwd"
10
+ option :fg, type: :boolean, default: false, desc: "keep the tagrity process running in the foreground"
12
11
  option :fresh, type: :boolean, default: false, desc: "index the whole codebase before watching the file system. This will be slow if the codebase is large."
13
- option :git, type: :boolean, default: true, desc: "only index files which are being tracked by git"
14
- option :configfile, desc: "See README for more info."
15
- option :ext_cmds, type: :hash, desc: "which <command> to use to generate tags based on the file extension. <command> must support -f and --append"
16
- option :default_cmd, desc: "the default <command> to be used to generate tags (default: 'ctags'). <command> must support -f and --append"
17
- option :excluded_exts, type: :array, desc: "which file extensions to not generate tags for."
18
- option :excluded_paths, type: :array, desc: "which paths to ignore. Usually better to ignore this since by default only file tracked by git are indexed."
19
12
  def start()
20
- setup_config
21
- Command::Start::call(dir, fg?, fresh?)
13
+ Command::Start::call(options['fg'], options['fresh'])
22
14
  end
23
15
 
24
- desc "stop", "Stop watching a directory (default to pwd)"
25
- option :dir
16
+ desc "stop", "Stop watching pwd"
26
17
  def stop()
27
- Command::Stop::call(dir)
18
+ Command::Stop::call
28
19
  end
29
20
 
30
21
  desc "status", "List running tagrity processes and the directories being watched"
@@ -32,32 +23,10 @@ module Tagrity
32
23
  Command::Status::call
33
24
  end
34
25
 
35
- private
36
-
37
- def dir
38
- dir = options[:dir] || Dir.pwd
39
- raise Errno::ENOENT, "No such directory - #{dir}" unless Dir.exists?(dir)
40
- dir
41
- end
42
-
43
- def fg?
44
- options[:fg]
45
- end
46
-
47
- def fresh?
48
- options[:fresh]
49
- end
50
-
51
- def setup_config
52
- ConfigFile.instance.init(
53
- configfile: options[:configfile],
54
- default_cmd: options[:default_cmd],
55
- tagf: options[:tagf],
56
- ext_cmds: options[:ext_cmds],
57
- excluded_exts: options[:excluded_exts],
58
- excluded_paths: options[:excluded_paths],
59
- git: options[:git]
60
- )
26
+ desc "logs", "Print the logs for pwd"
27
+ option :n, type: :numeric, default: 10, desc: "the number of log lines to print"
28
+ def logs
29
+ Command::Logs::call(options['n'])
61
30
  end
62
31
  end
63
32
  end
@@ -0,0 +1,23 @@
1
+ require 'tagrity/tlogger'
2
+
3
+ module Tagrity
4
+ module Command
5
+ class Logs
6
+ class << self
7
+ def call(n)
8
+ if File.readable?(logf)
9
+ puts `cat #{logf} | tail -n #{Integer(n)}`.split("\n")
10
+ else
11
+ puts "Error: There doesn't seem to be a log file for #{Dir.pwd}"
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def logf
18
+ Tlogger.instance.logf
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,8 +1,9 @@
1
1
  require 'listen'
2
+ require 'cli/ui'
2
3
  require 'tagrity/pid_file'
3
4
  require 'tagrity/helper'
4
- require 'tagrity/file_callbacks'
5
5
  require 'tagrity/provider'
6
+ require 'tagrity/tlogger'
6
7
 
7
8
  module Tagrity
8
9
  module Command
@@ -10,32 +11,47 @@ module Tagrity
10
11
  class ErrorProcessAlreadyRunning < StandardError; end
11
12
 
12
13
  class << self
13
- def call(dir, fg, fresh)
14
+ def call(fg, fresh)
15
+ dir = Dir.pwd
14
16
  assert_not_running(dir)
15
17
 
16
18
  Process.daemon(nochdir: true) unless fg
17
19
 
18
- callbacks = Provider.provide(:file_callbacks)
20
+ tag_generator = Provider.provide(:tag_generator)
19
21
  PidFile.write(PidFile.new(dir, Process.pid))
20
22
 
21
- callbacks.on_fresh if fresh
23
+ logger.fg = fg
24
+ logger.info("Watching #{dir} with process pid #{Process.pid}")
25
+
26
+ if fresh
27
+ logger.info("Generating tags fresh for #{dir}")
28
+ tag_generator.generate_all
29
+ end
22
30
 
23
31
  listener = Listen.to(
24
32
  dir,
25
33
  relative: true,
26
34
  ) do |modified, added, removed|
27
- puts "modified absolute path: #{modified}"
28
- puts "added absolute path: #{added}"
29
- puts "removed absolute path: #{removed}"
30
- callbacks.on_files_modified(modified)
31
- callbacks.on_files_added(added)
32
- callbacks.on_files_removed(removed)
35
+ unless modified.empty?
36
+ logger.info("modified absolute path: #{modified}")
37
+ tag_generator.generate(modified)
38
+ end
39
+ unless added.empty?
40
+ logger.info("added absolute path: #{added}")
41
+ tag_generator.generate(added)
42
+ end
43
+ unless removed.empty?
44
+ logger.info("removed absolute path: #{removed}")
45
+ tag_generator.delete_files_tags(removed)
46
+ end
33
47
  end
34
48
  listener.start
35
49
  sleep
36
50
  rescue ErrorProcessAlreadyRunning => e
37
- puts e.message
51
+ puts ::CLI::UI.fmt "{{red:#{e.message}}}"
52
+ logger.error(e.message)
38
53
  rescue Interrupt => e
54
+ logger.info("Process interrupted. Killing #{Process.pid}")
39
55
  PidFile.delete(dir)
40
56
  end
41
57
 
@@ -48,6 +64,10 @@ module Tagrity
48
64
  raise ErrorProcessAlreadyRunning, "Error: tagrity is already watching #{dir} with process #{pids}"
49
65
  end
50
66
  end
67
+
68
+ def logger
69
+ @logger ||= Tlogger.instance
70
+ end
51
71
  end
52
72
  end
53
73
  end
@@ -1,10 +1,23 @@
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
- puts "#{pid_file.pid} #{pid_file.dir}"
8
+ pid_files = PidFile.alive_pid_files.each do |pid_file|
9
+ pid_file
10
+ end
11
+
12
+ max_pid_len = pid_files.max do |a, b|
13
+ a.pid.digits.count <=> b.pid.digits.count
14
+ end.pid.digits.count
15
+ max_dir_len = pid_files.max do |a, b|
16
+ a.dir.length <=> b.dir.length
17
+ end.dir.length
18
+
19
+ pid_files.each do |pid_file|
20
+ puts ::CLI::UI.fmt "{{cyan:#{pid_file.pid.to_s.ljust(max_pid_len)}}} {{green:#{pid_file.dir.ljust(max_dir_len)}}}"
8
21
  end
9
22
  end
10
23
  end
@@ -1,15 +1,20 @@
1
+ require 'cli/ui'
2
+ require 'tagrity/tlogger'
3
+
1
4
  module Tagrity
2
5
  module Command
3
6
  class Stop
4
7
  class << self
5
- def call(dir)
8
+ def call
9
+ dir = Dir.pwd
6
10
  pid_files = PidFile.alive_pid_files(dir: dir)
7
11
  if pid_files.empty?
8
- puts "😕 tagrity doesn't seem to be watching #{dir}"
12
+ puts ::CLI::UI.fmt "{{red:#{"😕 tagrity doesn't seem to be watching #{dir}"}}}"
9
13
  else
10
14
  pid_files.each do |pid_file|
11
15
  pid_file.delete
12
- puts "Successfully killed #{pid_file.pid}"
16
+ puts ::CLI::UI.fmt "{{green:#{"Successfully killed #{pid_file.pid}"}}}"
17
+ Tlogger.instance.info("Successfully killed #{pid_file.pid}")
13
18
  end
14
19
  end
15
20
  end
@@ -7,105 +7,129 @@ module Tagrity
7
7
  include Singleton
8
8
 
9
9
  class ErrorTagFileNotWritable < StandardError; end
10
- class ErrorGitNotExecutable < StandardError; end
11
10
 
12
- def init(
13
- configfile:,
14
- default_cmd:,
15
- tagf:,
16
- ext_cmds:,
17
- excluded_exts:,
18
- excluded_paths:,
19
- git:
20
- )
21
- fname = config_file_name(configfile)
22
- @config = if fname.nil? then {} else YAML.load_file(fname) end
23
- ensure_ext_cmds(ext_cmds)
24
- ensure_default_cmd(default_cmd)
25
- ensure_tagf(tagf)
26
- ensure_excluded_exts(excluded_exts)
27
- ensure_excluded_paths(excluded_paths)
28
- ensure_git(git)
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
+
15
+ def init
16
+ ensure_extension_commands
17
+ ensure_default_command
18
+ ensure_tagf
19
+ ensure_extensions_whitelist
20
+ ensure_extensions_blacklist
21
+ ensure_git_strategy
22
+ ensure_excluded_paths
23
+ end
24
+
25
+ def command_for_extension(extension)
26
+ cmd = extension_commands[extension]
27
+ if cmd.nil?
28
+ default_command
29
+ else
30
+ cmd
31
+ end
32
+ end
33
+
34
+ def ignore_extension?(extension)
35
+ unless extensions_whitelist.empty?
36
+ return !extensions_whitelist.include?(extension)
37
+ end
38
+
39
+ extensions_blacklist.include?(extension)
29
40
  end
30
41
 
31
- def ft_to_cmd(ext)
32
- ft_cmd = @config['ext_cmds'][ext]
33
- return @config['default_cmd'] if ft_cmd.nil? || !Helper.is_executable?(ft_cmd)
34
- ft_cmd
42
+ def path_ignored?(path)
43
+ excluded_paths.any? { |pat| /#{pat}/ =~ path }
35
44
  end
36
45
 
37
- def is_ft_excluded(ext)
38
- @config['excluded_exts'].include?(ext)
46
+ def respect_git?
47
+ git_strategy != 'NA'
39
48
  end
40
49
 
41
- def is_path_excluded(path)
42
- @config['excluded_paths'].any? { |pat| /^(\.\/)?#{pat}.*/ =~ path }
50
+ def extension_commands
51
+ config['extension_commands']
52
+ end
53
+
54
+ def default_command
55
+ config['default_command']
43
56
  end
44
57
 
45
58
  def tagf
46
- @config['tagf']
59
+ config['tagf']
47
60
  end
48
61
 
49
- def respect_git?
50
- @config['git']
62
+ def extensions_whitelist
63
+ config['extensions_whitelist']
64
+ end
65
+
66
+ def extensions_blacklist
67
+ config['extensions_blacklist']
68
+ end
69
+
70
+ def git_strategy
71
+ config['git_strategy']
72
+ end
73
+
74
+ def excluded_paths
75
+ config['excluded_paths']
51
76
  end
52
77
 
53
78
  def to_s
54
- @config.to_s
79
+ config.to_s
55
80
  end
56
81
 
57
82
  private
58
83
 
59
- def ensure_ext_cmds(ext_cmds)
60
- set_option('ext_cmds', ext_cmds, {})
84
+ def ensure_extension_commands
85
+ ensure_option('extension_commands', {})
61
86
  end
62
87
 
63
- def ensure_default_cmd(default_cmd)
64
- set_option('default_cmd', default_cmd, 'ctags')
88
+ def ensure_default_command
89
+ ensure_option('default_command', 'ctags')
65
90
  end
66
91
 
67
- def ensure_excluded_exts(excluded_exts)
68
- set_option('excluded_exts', excluded_exts, [])
92
+ def ensure_tagf
93
+ ensure_option('tagf', 'tags')
94
+ if File.exists?(tagf) && !File.writable?(tagf)
95
+ raise ErrorTagFileNotWritable, "#{tagf} must be writable to be used as the tag file."
96
+ end
69
97
  end
70
98
 
71
- def ensure_excluded_paths(excluded_paths)
72
- set_option('excluded_paths', excluded_paths, [])
99
+ def ensure_extensions_whitelist
100
+ ensure_option('whitelist_extensions', [])
73
101
  end
74
102
 
75
- def ensure_tagf(tagf)
76
- set_option('tagf', tagf, 'tags')
77
- if File.exists?(@config['tagf']) && !File.writable?(@config['tagf'])
78
- raise ErrorTagFileNotWritable, "#{@config['tagf']} must be writable to be used as the tag file."
79
- end
103
+ def ensure_extensions_blacklist
104
+ ensure_option('blacklist_extensions', [])
80
105
  end
81
106
 
82
- def ensure_git(git)
83
- set_option('git', git, true)
84
- if @config['git'] && !Helper.is_executable?('git')
85
- raise ErrorGitNotExecutable, "'git' must be executable to use the --git option."
86
- end
107
+ def ensure_git_strategy
108
+ ensure_option('git_strategy', 'TRACKED')
87
109
  end
88
110
 
89
- def set_option(key, local_val, default)
90
- unless local_val.nil?
91
- @config[key] = local_val
92
- end
93
- return if @config.key?(key) && !@config[key].nil? && @config[key].is_a?(default.class)
94
- @config[key] = default
111
+ def ensure_excluded_paths
112
+ ensure_option('extension_commands', [])
95
113
  end
96
114
 
97
- def config_file_name(fname)
98
- return fname unless fname.nil?
99
- return global_config_file_name if File.file?(global_config_file_name)
100
- nil
115
+ def ensure_option(name, default)
116
+ if config[name].nil? || !config[name].is_a?(default.class)
117
+ config[name] = default
118
+ end
101
119
  end
102
120
 
103
- def global_config_file_name
104
- "#{global_config_dir_name}/config.yml"
121
+ def config
122
+ @config ||= read_config
105
123
  end
106
124
 
107
- def global_config_dir_name
108
- "#{ENV["HOME"]}/.config/tagrity"
125
+ def read_config
126
+ if File.readable?(LOCAL_CONFIG_PATH)
127
+ @config = YAML.load_file(LOCAL_CONFIG_PATH)
128
+ elsif File.readable?(GLOBAL_CONFIG_PATH)
129
+ @config = YAML.load_file(GLOBAL_CONFIG_PATH)
130
+ else
131
+ @config = {}
132
+ end
109
133
  end
110
134
  end
111
135
  end
@@ -10,6 +10,11 @@ module Tagrity
10
10
  RUN_DIR
11
11
  end
12
12
 
13
+ def log_dir
14
+ ensure_data_dirs
15
+ LOG_DIR
16
+ end
17
+
13
18
  def is_executable?(cmd)
14
19
  !%x{command -v #{cmd}}.empty?
15
20
  end
@@ -28,21 +33,16 @@ module Tagrity
28
33
  end
29
34
 
30
35
  def is_git_dir?
31
- return @is_git_dir unless @is_git_dir.nil?
32
36
  `git rev-parse --git-dir &> /dev/null`
33
- if $?.exitstatus == 0
34
- @is_git_dir = true
35
- else
36
- @is_git_dir = false
37
- end
37
+ $?.exitstatus == 0
38
38
  end
39
39
 
40
- def is_file_ignored?(file)
40
+ def file_ignored?(file)
41
41
  `git check-ignore -q #{file} &> /dev/null`
42
42
  $?.exitstatus == 0
43
43
  end
44
44
 
45
- def is_file_tracked?(file)
45
+ def file_tracked?(file)
46
46
  `git ls-files --error-unmatch #{file} &> /dev/null`
47
47
  $?.exitstatus == 0
48
48
  end
@@ -51,6 +51,7 @@ module Tagrity
51
51
 
52
52
  def ensure_data_dirs
53
53
  FileUtils.mkdir_p(RUN_DIR)
54
+ FileUtils.mkdir_p(LOG_DIR)
54
55
  end
55
56
  end
56
57
  end
@@ -1,4 +1,3 @@
1
- require 'tagrity/file_callbacks'
2
1
  require 'tagrity/config_file'
3
2
  require 'tagrity/tag_generator'
4
3
 
@@ -7,17 +6,11 @@ module Tagrity
7
6
  class << self
8
7
  def provide(want)
9
8
  case want
10
- when :file_callbacks
11
- provide_file_callbacks
12
9
  when :tag_generator
13
10
  provide_tag_generator
14
11
  end
15
12
  end
16
13
 
17
- def provide_file_callbacks
18
- FileCallbacks.new(provide(:tag_generator))
19
- end
20
-
21
14
  def provide_tag_generator
22
15
  TagGenerator.new
23
16
  end
@@ -1,8 +1,8 @@
1
1
  require 'tmpdir'
2
2
  require 'tempfile'
3
3
  require 'fileutils'
4
- require 'pry'
5
4
  require 'tagrity/helper'
5
+ require 'tagrity/tlogger'
6
6
 
7
7
  module Tagrity
8
8
  class TagGenerator
@@ -17,15 +17,16 @@ module Tagrity
17
17
  if File.exists?(tagf)
18
18
  File.delete(tagf)
19
19
  end
20
- if check_git?
21
- files = `git ls-files 2> /dev/null`.split
20
+ cmd = if check_git?
21
+ 'git ls-files 2> /dev/null'
22
22
  else
23
- files = `find * 2> /dev/null`.split
23
+ 'find * 2> /dev/null'
24
24
  end
25
+ files = `#{cmd}`.split("\n")
25
26
  if $?.exitstatus == 0
26
27
  generate(files)
27
28
  else
28
- puts "Failed to get a listing of all files under pwd for use with --fresh."
29
+ logger.error("Failed to get a listing of all files under pwd for use with --fresh. Used #{cmd}.")
29
30
  end
30
31
  end
31
32
 
@@ -33,15 +34,15 @@ module Tagrity
33
34
  return if files.empty?
34
35
  files
35
36
  .select { |file| generate_tags?(file) }
36
- .group_by { |file| @config.ft_to_cmd(file.partition('.').last) }
37
+ .group_by { |file| @config.command_for_extension(file.partition('.').last) }
37
38
  .each do |cmd, fnames|
38
39
  Tempfile.create do |tmpf|
39
40
  IO::write(tmpf.path, fnames.join("\n"))
40
41
  system(cmd, '-f', tagf, '--append', '-L', tmpf.path, out: File::NULL)
41
42
  if $?.exitstatus == 0
42
- puts "{#{cmd}} generated tags for #{fnames} into #{tagf}"
43
+ logger.info("{#{cmd}} generated tags for #{fnames} into #{tagf}")
43
44
  else
44
- puts "{#{cmd}} failed to generate tags for #{fnames} into #{tagf}"
45
+ logger.info("{#{cmd}} failed to generate tags for #{fnames} into #{tagf}")
45
46
  end
46
47
  end
47
48
  end
@@ -59,7 +60,7 @@ module Tagrity
59
60
  end
60
61
  tmpf.rewind
61
62
  FileUtils.mv(tmpf.path, tagf, force: true)
62
- puts "Deleted tags for #{files} from #{tagf}"
63
+ logger.info("Deleted tags for #{files} from #{tagf}")
63
64
  end
64
65
  end
65
66
 
@@ -74,7 +75,15 @@ module Tagrity
74
75
  end
75
76
 
76
77
  def copacetic_with_git?(file)
77
- !(check_git? && !Helper.is_file_tracked?(file))
78
+ return true if !check_git?
79
+ case @config.git_strategy
80
+ when 'TRACKED'
81
+ Helper.file_tracked?(file)
82
+ when 'IGNORED'
83
+ !Helper.file_ignored?(file)
84
+ else
85
+ false
86
+ end
78
87
  end
79
88
 
80
89
  def check_git?
@@ -82,7 +91,7 @@ module Tagrity
82
91
  end
83
92
 
84
93
  def is_file_excluded(fname)
85
- @config.is_ft_excluded(fname.partition('.').last) || @config.is_path_excluded(fname)
94
+ @config.ignore_extension?(fname.partition('.').last) || @config.path_ignored?(fname)
86
95
  end
87
96
 
88
97
  def assert_executables
@@ -97,10 +106,8 @@ module Tagrity
97
106
  @config.tagf
98
107
  end
99
108
 
100
- def tmp_file
101
- tmpdir = "#{Dir.tmpdir}/tagrity"
102
- FileUtils.mkdir_p(tmpdir)
103
- "#{tmpdir}/#{Process.pid}.tmptags"
109
+ def logger
110
+ Tlogger.instance
104
111
  end
105
112
  end
106
113
  end
@@ -0,0 +1,30 @@
1
+ require 'singleton'
2
+ require 'logger'
3
+ require 'tagrity/helper'
4
+
5
+ module Tagrity
6
+ class Tlogger
7
+ include Singleton
8
+
9
+ attr_writer :fg
10
+
11
+ def info(msg)
12
+ logger.info(msg)
13
+ end
14
+
15
+ def error(msg)
16
+ logger.error(msg)
17
+ end
18
+
19
+ def logf
20
+ # TODO this can cause duplicates, unlikely tho
21
+ "#{Helper.log_dir}/#{Dir.pwd.gsub(/\//, '--')}.log"
22
+ end
23
+
24
+ private
25
+
26
+ def logger
27
+ @logger ||= Logger.new(@fg ? STDOUT : logf, 'weekly')
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module Tagrity
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.11"
3
3
  end
@@ -1,31 +1,41 @@
1
- # ext_cmds allows different tag generators to be used depending on the file extension.
2
- # Multiple extensions does not work, *.html.erb files will be picked up as erb.
3
- # ext_cmds:
4
- # <file extension>: <command to use to generate tags for this file extension>
1
+ # which command to use to generate tags for a specific file extension
2
+ # overrides default_command
3
+ # commands must support --append, -f, -L
5
4
  # DEFAULT: empty
6
- ext_cmds:
5
+ extension_commands:
7
6
  rb: ripper-tags
8
7
  c: ctags
9
8
  go: gotags
10
9
 
11
- # default_cmd specifies the default command to be used to generate tags
12
- # default_cmd: <command>
10
+ # default command to generate tags
11
+ # command must support --append, -f, -L
13
12
  # DEFAULT: ctags
14
- default_cmd: ctags
13
+ default_command: ctags
15
14
 
16
- # tagf is the filename (relative) to generate tags into
17
- # tagf: <filename>
15
+ # filename (relative to pwd) to generate tags into
18
16
  # DEFAULT: tags
19
17
  tagf: tags
20
18
 
21
- # excluded_exts specifies which file extensions to not generate tags for.
22
- # excluded_exts: [<file extension>, ...]
19
+ # list of extensions to exclusively generate tags for
20
+ # this will take precendence over extensions_blacklist if it is non-empty
23
21
  # DEFAULT: []
24
- excluded_exts: [rb, h, js]
22
+ extensions_whitelist: [rb, c, h, js]
25
23
 
26
- # excluded_paths specifies which paths to ignore.
27
- # It's usually better to avoid this since by default tagrity will only look
28
- # at files which are tracked by git.
29
- # excluded_paths: [<path>, ...]
24
+ # list of extensions to not generate tags for
25
+ # this can will be ignored if extensions_whitelist is non-empty
26
+ # DEFAULT: []
27
+ extensions_blacklist: [erb, html, txt]
28
+
29
+ # how to integrate with git
30
+ # git_strategy: TRACKED | IGNORED | NA
31
+ # TRACKED: only index files tracked by git
32
+ # IGNORED: don't index files which are ignored by git
33
+ # NA: don't use git, index all files under pwd
34
+ # DEFAULT: TRACKED
35
+ git_strategy: TRACKED
36
+
37
+ # which paths (relative to pwd) to ignore
38
+ # It's usually better to avoid this since tagrity integrates with git by
39
+ # default using the strategy specified by git_strategy
30
40
  # DEFAULT: []
31
41
  excluded_paths: [vendor, node_modules]
@@ -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"
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.6
4
+ version: 0.1.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: 2019-12-17 00:00:00.000000000 Z
11
+ date: 2019-12-25 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
@@ -116,7 +130,6 @@ executables:
116
130
  extensions: []
117
131
  extra_rdoc_files: []
118
132
  files:
119
- - ".byebug_history"
120
133
  - ".gitignore"
121
134
  - ".rspec"
122
135
  - ".travis.yml"
@@ -131,15 +144,16 @@ files:
131
144
  - exe/tagrity
132
145
  - lib/tagrity.rb
133
146
  - lib/tagrity/cli.rb
147
+ - lib/tagrity/commands/logs.rb
134
148
  - lib/tagrity/commands/start.rb
135
149
  - lib/tagrity/commands/status.rb
136
150
  - lib/tagrity/commands/stop.rb
137
151
  - lib/tagrity/config_file.rb
138
- - lib/tagrity/file_callbacks.rb
139
152
  - lib/tagrity/helper.rb
140
153
  - lib/tagrity/pid_file.rb
141
154
  - lib/tagrity/provider.rb
142
155
  - lib/tagrity/tag_generator.rb
156
+ - lib/tagrity/tlogger.rb
143
157
  - lib/tagrity/version.rb
144
158
  - sample_config.yml
145
159
  - tagrity.gemspec
@@ -1,4 +0,0 @@
1
- continue
2
- n
3
- next
4
- ls
@@ -1,26 +0,0 @@
1
- require 'tagrity/tag_generator'
2
- require 'tagrity/config_file'
3
-
4
- module Tagrity
5
- class FileCallbacks
6
- def initialize(tag_generator)
7
- @tag_generator = tag_generator
8
- end
9
-
10
- def on_fresh
11
- @tag_generator.generate_all
12
- end
13
-
14
- def on_files_modified(files)
15
- @tag_generator.generate(files)
16
- end
17
-
18
- def on_files_added(files)
19
- @tag_generator.generate(files)
20
- end
21
-
22
- def on_files_removed(files)
23
- @tag_generator.delete_files_tags(files)
24
- end
25
- end
26
- end