tagrity 0.1.5 → 0.1.6

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: a68befc5bd00a195bc6767e46c5f9c32dacf7ea2771bc2f2d85c7f4ce1c8251e
4
- data.tar.gz: e4dd17c87a1ea0b66a32647dcff90d4091a546f14111809d99730554a915274d
3
+ metadata.gz: 0bbba0199d2e4305cc015fc1bf2151892628224fdb31ad0a1b2fe0e08b2a5b8b
4
+ data.tar.gz: b2910418b53ce0d188c03048ca4554988e1833269ed385a041291dd0427a4499
5
5
  SHA512:
6
- metadata.gz: 3612f8c0df254ceadbbb200f24cf9fe38b1c62a9cd82c6d3ef28d8be6297a49d309499548287e0a42a903bcf694d43da50d24330efee0934dab70d2188207b99
7
- data.tar.gz: fe81fc0f1076e64c1c78c07b5455c5287e1dae663359ebb9451a973c7740bbea9d4a4421de0abaa5e16c6d198eb642222c67dd69306c129a308e11d9a075a7bf
6
+ metadata.gz: d103e833875ab1d827dc26857a78c9795092ccf1fd8d346fa506fcf3586b6581d5842a6d5a30b9ea470643997a97722e9df922b83cdbd8a1607b222261eaa114
7
+ data.tar.gz: 24eef3ae46b97b8e56802013a60217e9c8749f81846e4beff6f056f33166e9f2d4935cc4a12f6c8005d5b93d29db9d5803fef18e586f5cd3a8d82faf5b0a7392
@@ -0,0 +1,4 @@
1
+ continue
2
+ n
3
+ next
4
+ ls
@@ -1,18 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tagrity (0.1.3)
4
+ tagrity (0.1.6)
5
5
  listen (~> 3.0)
6
+ pry (~> 0.9.9)
6
7
  thor (~> 0.20)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
12
+ coderay (1.1.2)
11
13
  diff-lcs (1.3)
12
14
  ffi (1.11.3)
13
- listen (3.2.0)
15
+ listen (3.2.1)
14
16
  rb-fsevent (~> 0.10, >= 0.10.3)
15
17
  rb-inotify (~> 0.9, >= 0.9.10)
18
+ method_source (0.9.2)
19
+ pry (0.9.12.6)
20
+ coderay (~> 1.0)
21
+ method_source (~> 0.8)
22
+ slop (~> 3.4)
16
23
  rake (10.5.0)
17
24
  rb-fsevent (0.10.3)
18
25
  rb-inotify (0.10.0)
@@ -31,6 +38,7 @@ GEM
31
38
  diff-lcs (>= 1.2.0, < 2.0)
32
39
  rspec-support (~> 3.9.0)
33
40
  rspec-support (3.9.0)
41
+ slop (3.6.0)
34
42
  thor (0.20.3)
35
43
 
36
44
  PLATFORMS
data/README.md CHANGED
@@ -4,19 +4,17 @@ Automatically regenerate tags on file changes.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'tagrity'
7
+ ```sh
8
+ $ gem install tagrity
11
9
  ```
12
10
 
13
- And then execute:
14
-
15
- $ bundle
11
+ ## Quick Start
16
12
 
17
- Or install it yourself as:
13
+ ```sh
14
+ tagrity start
15
+ ```
18
16
 
19
- $ gem install tagrity
17
+ That's it! By default, tagrity will only index files tracked by git. You may wish to al
20
18
 
21
19
  ## Usage
22
20
 
@@ -93,35 +91,3 @@ A config file is a yaml file with the following possible values.
93
91
  Some of these can be overridden with options, however the configfile
94
92
  provided via --configfile will override the global config file in
95
93
  ~/.config/tagrity/config.yml
96
- ```
97
- # ext_cmds allows different tag generators to be used depending on the file extension.
98
- # Multiple extensions does not work, *.html.erb files will be picked up as erb.
99
- # ext_cmds:
100
- # <file extension>: <command to use to generate tags for this file extension>
101
- # DEFAULT: empty
102
- ext_cmds:
103
- rb: ripper-tags
104
- c: ctags
105
- go: gotags
106
-
107
- # default_cmd specifies the default command to be used to generate tags
108
- # default_cmd: <command>
109
- # DEFAULT: ctags
110
- default_cmd: ctags
111
-
112
- # tagf is the filename (relative) to generate tags into
113
- # tagf: <filename>
114
- # DEFAULT: tags
115
- tagf: tags
116
-
117
- # excluded_exts specifies which file extensions to not generate tags for.
118
- # excluded_exts: [<file extension>, ...]
119
- # DEFAULT: []
120
- excluded_exts: [rb, h, js]
121
-
122
- # excluded_paths specifies which paths to ignore.
123
- # It's usually better to avoid this since by default tagrity will only look
124
- # at files which are tracked by git.
125
- # excluded_paths: [<path>, ...]
126
- # DEFAULT: []
127
- excluded_paths: [vendor, node_modules]
@@ -7,12 +7,13 @@ module Tagrity
7
7
  class CLI < Thor
8
8
  desc "start", "Start watching a directory (default to pwd)"
9
9
  option :dir, desc: "directory to watch (omit to use pwd)"
10
- option :fresh, type: :boolean, default: false, desc: "index the whole codebase before watching the file system."
11
10
  option :tagf, desc: "filename (relative) to generate tags into (default: 'tags')."
12
- option :git, type: :boolean, default: true, desc: "only index files which are being tracked by git"
13
11
  option :fg, type: :boolean, desc: "keep the tagrity process running in the foreground"
12
+ 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
14
  option :configfile, desc: "See README for more info."
15
- option :default_cmd, desc: "the default command to be used to generate tags (default: 'ctags')"
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"
16
17
  option :excluded_exts, type: :array, desc: "which file extensions to not generate tags for."
17
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."
18
19
  def start()
@@ -52,6 +53,7 @@ module Tagrity
52
53
  configfile: options[:configfile],
53
54
  default_cmd: options[:default_cmd],
54
55
  tagf: options[:tagf],
56
+ ext_cmds: options[:ext_cmds],
55
57
  excluded_exts: options[:excluded_exts],
56
58
  excluded_paths: options[:excluded_paths],
57
59
  git: options[:git]
@@ -24,6 +24,9 @@ module Tagrity
24
24
  dir,
25
25
  relative: true,
26
26
  ) do |modified, added, removed|
27
+ puts "modified absolute path: #{modified}"
28
+ puts "added absolute path: #{added}"
29
+ puts "removed absolute path: #{removed}"
27
30
  callbacks.on_files_modified(modified)
28
31
  callbacks.on_files_added(added)
29
32
  callbacks.on_files_removed(removed)
@@ -13,13 +13,14 @@ module Tagrity
13
13
  configfile:,
14
14
  default_cmd:,
15
15
  tagf:,
16
+ ext_cmds:,
16
17
  excluded_exts:,
17
18
  excluded_paths:,
18
19
  git:
19
20
  )
20
21
  fname = config_file_name(configfile)
21
22
  @config = if fname.nil? then {} else YAML.load_file(fname) end
22
- ensure_ext_cmds
23
+ ensure_ext_cmds(ext_cmds)
23
24
  ensure_default_cmd(default_cmd)
24
25
  ensure_tagf(tagf)
25
26
  ensure_excluded_exts(excluded_exts)
@@ -55,8 +56,8 @@ module Tagrity
55
56
 
56
57
  private
57
58
 
58
- def ensure_ext_cmds
59
- set_option('ext_cmds', nil, {})
59
+ def ensure_ext_cmds(ext_cmds)
60
+ set_option('ext_cmds', ext_cmds, {})
60
61
  end
61
62
 
62
63
  def ensure_default_cmd(default_cmd)
@@ -1,4 +1,7 @@
1
1
  require 'tmpdir'
2
+ require 'tempfile'
3
+ require 'fileutils'
4
+ require 'pry'
2
5
  require 'tagrity/helper'
3
6
 
4
7
  module Tagrity
@@ -32,24 +35,32 @@ module Tagrity
32
35
  .select { |file| generate_tags?(file) }
33
36
  .group_by { |file| @config.ft_to_cmd(file.partition('.').last) }
34
37
  .each do |cmd, fnames|
35
- `#{cmd} -f #{tagf} --append #{fnames.join(' ')} &> /dev/null`
36
- if $?.exitstatus == 0
37
- puts "{#{cmd}} generated tags for #{fnames} into #{tagf}"
38
- else
39
- puts "{#{cmd}} failed to generate tags for #{fnames} into #{tagf}"
38
+ Tempfile.create do |tmpf|
39
+ IO::write(tmpf.path, fnames.join("\n"))
40
+ system(cmd, '-f', tagf, '--append', '-L', tmpf.path, out: File::NULL)
41
+ if $?.exitstatus == 0
42
+ puts "{#{cmd}} generated tags for #{fnames} into #{tagf}"
43
+ else
44
+ puts "{#{cmd}} failed to generate tags for #{fnames} into #{tagf}"
45
+ end
40
46
  end
41
47
  end
42
48
  end
43
49
 
44
50
  def delete_files_tags(files)
45
51
  return if files.empty?
46
- `cat #{tagf} | grep -v -F #{files.map { |f| " -e \" #{f} \""}.join(' ')} > #{tmp_file} 2> /dev/null`
47
- if $?.exitstatus == 0
48
- `mv -f #{tmp_file} #{tagf}`
49
- puts "Deleted tags for #{files} from #{tagf}"
50
- else
51
- puts "Failed to delete tags for #{files} from #{tagf}"
52
+ Tempfile.create do |tmpf|
53
+ File.open(tagf) do |f|
54
+ f.each_line do |line|
55
+ unless files.any? { |fname| line.include?("\t#{fname}\t") }
56
+ tmpf.write line
57
+ end
58
+ end
52
59
  end
60
+ tmpf.rewind
61
+ FileUtils.mv(tmpf.path, tagf, force: true)
62
+ puts "Deleted tags for #{files} from #{tagf}"
63
+ end
53
64
  end
54
65
 
55
66
  private
@@ -1,3 +1,3 @@
1
1
  module Tagrity
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -0,0 +1,31 @@
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>
5
+ # DEFAULT: empty
6
+ ext_cmds:
7
+ rb: ripper-tags
8
+ c: ctags
9
+ go: gotags
10
+
11
+ # default_cmd specifies the default command to be used to generate tags
12
+ # default_cmd: <command>
13
+ # DEFAULT: ctags
14
+ default_cmd: ctags
15
+
16
+ # tagf is the filename (relative) to generate tags into
17
+ # tagf: <filename>
18
+ # DEFAULT: tags
19
+ tagf: tags
20
+
21
+ # excluded_exts specifies which file extensions to not generate tags for.
22
+ # excluded_exts: [<file extension>, ...]
23
+ # DEFAULT: []
24
+ excluded_exts: [rb, h, js]
25
+
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>, ...]
30
+ # DEFAULT: []
31
+ excluded_paths: [vendor, node_modules]
@@ -33,4 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "rake", "~> 10.0"
34
34
  spec.add_development_dependency "rspec", "~> 3.0"
35
35
  spec.add_development_dependency "ripper-tags", "~> 0.8.0"
36
+ spec.add_dependency "pry", "~> 0.9.9"
36
37
  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.1.5
4
+ version: 0.1.6
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-13 00:00:00.000000000 Z
11
+ date: 2019-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.8.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.9.9
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.9.9
97
111
  description: Ditto
98
112
  email:
99
113
  - rethy.spud@gmail.com
@@ -102,6 +116,7 @@ executables:
102
116
  extensions: []
103
117
  extra_rdoc_files: []
104
118
  files:
119
+ - ".byebug_history"
105
120
  - ".gitignore"
106
121
  - ".rspec"
107
122
  - ".travis.yml"
@@ -114,7 +129,6 @@ files:
114
129
  - bin/console
115
130
  - bin/setup
116
131
  - exe/tagrity
117
- - foobar.rb
118
132
  - lib/tagrity.rb
119
133
  - lib/tagrity/cli.rb
120
134
  - lib/tagrity/commands/start.rb
@@ -127,6 +141,7 @@ files:
127
141
  - lib/tagrity/provider.rb
128
142
  - lib/tagrity/tag_generator.rb
129
143
  - lib/tagrity/version.rb
144
+ - sample_config.yml
130
145
  - tagrity.gemspec
131
146
  homepage: https://github.com/RRethy/tagrity
132
147
  licenses:
@@ -150,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
165
  - !ruby/object:Gem::Version
151
166
  version: '0'
152
167
  requirements: []
153
- rubygems_version: 3.0.3
168
+ rubygems_version: 3.0.6
154
169
  signing_key:
155
170
  specification_version: 4
156
171
  summary: Regenerate tags on file changes.
data/foobar.rb DELETED
File without changes