ripper-tags 0.2.1 → 0.3.0

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: af64b5310db2c8944c8a3af1bbbf3514b71f003e
4
- data.tar.gz: 249c8b6dc4dc5d53cbe6d1c3505d5cc6110912c6
3
+ metadata.gz: d472bb663bdcfad6fc036ad754053b5836a59b58
4
+ data.tar.gz: e02b4cc630471c544b14d83fffae62562cc6d814
5
5
  SHA512:
6
- metadata.gz: bc5ba6f2d1789d1bf02f849e7c0536cf1b3c99c8a3b58fcd3395994ac25223f4134908e1203ae91e2c99694d2cdd0921343b44a094893b8865baa09c941ce939
7
- data.tar.gz: 74c81007636f8cdb8ed8c3243cc090a8a538a0319d157699e40e8d93490cdf814f73ab1c234118e14d3c7189f60643accd99d0c581448b1bc2604101f8f4c782
6
+ metadata.gz: 3349ce8680e14d37b98c4d771a4e1d3426b5f8ded4e3ee9efb15e8d4117c2058a8384de47537ef057c36dbb05b97fa5524dfccd16b1eefb1f19f18022c1c72cd
7
+ data.tar.gz: 77effbe07be672bca0881d3b4ad7176b41a567b060f1ad601c520365964955266a4bd5aa8b9e4dae3ea16e2370521b9d138e2ce7b93f18754d433bdae23a3072
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.2.1" end
12
+ def self.version() "0.3.0" end
13
13
 
14
14
  FatalError = Class.new(RuntimeError)
15
15
 
@@ -1,10 +1,15 @@
1
1
  require 'pp'
2
+ require 'pathname'
2
3
  require 'ripper-tags/parser'
3
4
 
4
5
  module RipperTags
5
6
  class FileFinder
6
7
  attr_reader :options
7
8
 
9
+ RE_RUBY = /\.rb\z/
10
+ DIR_CURRENT = '.'.freeze
11
+ DIR_PARENT = '..'.freeze
12
+
8
13
  def initialize(options)
9
14
  @options = options
10
15
  end
@@ -35,27 +40,35 @@ module RipperTags
35
40
  end
36
41
 
37
42
  def include_file?(file)
38
- (options.all_files || file =~ /\.rb\z/) && !exclude_file?(file)
43
+ (options.all_files || file =~ RE_RUBY) && !exclude_file?(file)
39
44
  end
40
45
 
41
- def find_files(list, depth = 0)
42
- list.each do |file|
43
- if File.directory?(file)
44
- if options.recursive
45
- files = Dir.entries(file).map { |name|
46
- File.join(file, name) unless '.' == name || '..' == name
47
- }.compact
48
- find_files(files, depth + 1) {|f| yield f }
46
+ def resolve_file(file, depth = 0, &block)
47
+ if File.directory?(file)
48
+ if options.recursive
49
+ Dir.entries(file).each do |name|
50
+ if name != DIR_CURRENT && name != DIR_PARENT
51
+ subfile = File.join(file, name)
52
+ subfile = clean_path(subfile) if depth == 0
53
+ resolve_file(subfile, depth + 1, &block)
54
+ end
49
55
  end
50
- else
51
- yield file if include_file?(file)
52
56
  end
57
+ else
58
+ file = clean_path(file) if depth == 0
59
+ yield file if include_file?(file)
53
60
  end
54
61
  end
55
62
 
56
- def each_file
63
+ def clean_path(file)
64
+ Pathname.new(file).cleanpath.to_s
65
+ end
66
+
67
+ def each_file(&block)
57
68
  return to_enum(__method__) unless block_given?
58
- find_files(options.files) {|f| yield f }
69
+ options.files.each do |file|
70
+ resolve_file(file, &block)
71
+ end
59
72
  end
60
73
  end
61
74
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ripper-tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aman Gupta