ripper-tags 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d472bb663bdcfad6fc036ad754053b5836a59b58
4
- data.tar.gz: e02b4cc630471c544b14d83fffae62562cc6d814
3
+ metadata.gz: 290bd07700cddff930025f82db6f37b0bd964ae1
4
+ data.tar.gz: 3a7a292de4d1dc789a34d5b74a8f70cf0875d34d
5
5
  SHA512:
6
- metadata.gz: 3349ce8680e14d37b98c4d771a4e1d3426b5f8ded4e3ee9efb15e8d4117c2058a8384de47537ef057c36dbb05b97fa5524dfccd16b1eefb1f19f18022c1c72cd
7
- data.tar.gz: 77effbe07be672bca0881d3b4ad7176b41a567b060f1ad601c520365964955266a4bd5aa8b9e4dae3ea16e2370521b9d138e2ce7b93f18754d433bdae23a3072
6
+ metadata.gz: 79cf2b4df184edb33d7cae195666ece7cf22adbc9840349bd62dc0e6724a0060141f256a8e2562b1c360364dd0ebbe09228a415bc8f52c57fd437c5306f2f5fb
7
+ data.tar.gz: f40040c5fd7ad7085b1c250c8244dadaee5463237b7a2e2ab5a33a015e2472782edec9c1eb6c3b44e65d6a732c5f8a2bb82de75fd7a1b94bb0d39f58580ee5af
data/bin/ripper-tags CHANGED
@@ -2,7 +2,12 @@
2
2
  require 'ripper-tags'
3
3
 
4
4
  trap(:INT) { abort }
5
- trap(:PIPE) { abort }
5
+
6
+ begin
7
+ trap(:PIPE) { abort }
8
+ rescue ArgumentError
9
+ # SIGPIPE is unsupported on Windows
10
+ end
6
11
 
7
12
  program_name = File.basename($0)
8
13
 
@@ -10,4 +15,6 @@ begin
10
15
  RipperTags.process_args(ARGV)
11
16
  rescue Errno::ENOENT, OptionParser::InvalidOption => err
12
17
  abort "#{program_name}: #{err.message}"
18
+ rescue RipperTags::BrokenPipe
19
+ abort
13
20
  end
data/lib/ripper-tags.rb CHANGED
@@ -9,7 +9,7 @@ require 'ripper-tags/vim_formatter'
9
9
  require 'ripper-tags/json_formatter'
10
10
 
11
11
  module RipperTags
12
- def self.version() "0.3.0" end
12
+ def self.version() "0.3.1" end
13
13
 
14
14
  FatalError = Class.new(RuntimeError)
15
15
 
@@ -6,7 +6,7 @@ module RipperTags
6
6
  class FileFinder
7
7
  attr_reader :options
8
8
 
9
- RE_RUBY = /\.rb\z/
9
+ RUBY_EXT = '.rb'.freeze
10
10
  DIR_CURRENT = '.'.freeze
11
11
  DIR_PARENT = '..'.freeze
12
12
 
@@ -26,26 +26,36 @@ module RipperTags
26
26
 
27
27
  def exclude_file?(file)
28
28
  base = File.basename(file)
29
- exclude_patterns.any? {|ex|
29
+ match = exclude_patterns.find { |ex|
30
30
  case ex
31
31
  when Regexp then base =~ ex
32
32
  else base == ex
33
33
  end
34
- } || exclude_patterns.any? {|ex|
34
+ } || exclude_patterns.find { |ex|
35
35
  case ex
36
36
  when Regexp then file =~ ex
37
37
  else file.include?(ex)
38
38
  end
39
39
  }
40
+
41
+ if match && options.verbose
42
+ $stderr.puts "Ignoring %s because of exclude rule: %p" % [file, match]
43
+ end
44
+
45
+ match
46
+ end
47
+
48
+ def ruby_file?(file)
49
+ file.end_with?(RUBY_EXT)
40
50
  end
41
51
 
42
52
  def include_file?(file)
43
- (options.all_files || file =~ RE_RUBY) && !exclude_file?(file)
53
+ (options.all_files || ruby_file?(file)) && !exclude_file?(file)
44
54
  end
45
55
 
46
56
  def resolve_file(file, depth = 0, &block)
47
57
  if File.directory?(file)
48
- if options.recursive
58
+ if options.recursive && !exclude_file?(file)
49
59
  Dir.entries(file).each do |name|
50
60
  if name != DIR_CURRENT && name != DIR_PARENT
51
61
  subfile = File.join(file, name)
@@ -54,9 +64,14 @@ module RipperTags
54
64
  end
55
65
  end
56
66
  end
57
- else
67
+ elsif depth > 0 || File.exist?(file)
58
68
  file = clean_path(file) if depth == 0
59
69
  yield file if include_file?(file)
70
+ elsif
71
+ $stderr.puts "%s: %p: no such file or directory" % [
72
+ File.basename($0),
73
+ file
74
+ ]
60
75
  end
61
76
  end
62
77
 
@@ -2,6 +2,8 @@ require 'pathname'
2
2
  require 'set'
3
3
 
4
4
  module RipperTags
5
+ BrokenPipe = Class.new(RuntimeError)
6
+
5
7
  class DefaultFormatter
6
8
  attr_reader :options
7
9
 
@@ -31,7 +33,11 @@ module RipperTags
31
33
 
32
34
  def with_output
33
35
  if stdout?
34
- yield $stdout
36
+ begin
37
+ yield $stdout
38
+ rescue Errno::EINVAL
39
+ raise BrokenPipe
40
+ end
35
41
  else
36
42
  File.open(options.tag_file_name, 'w+') do |outfile|
37
43
  yield outfile
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ripper-tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aman Gupta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-26 00:00:00.000000000 Z
11
+ date: 2015-11-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: fast, accurate ctags generator for ruby source code using Ripper
14
14
  email: