ripper-tags 0.2.1 → 0.3.0
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 +4 -4
- data/lib/ripper-tags.rb +1 -1
- data/lib/ripper-tags/data_reader.rb +26 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d472bb663bdcfad6fc036ad754053b5836a59b58
|
4
|
+
data.tar.gz: e02b4cc630471c544b14d83fffae62562cc6d814
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3349ce8680e14d37b98c4d771a4e1d3426b5f8ded4e3ee9efb15e8d4117c2058a8384de47537ef057c36dbb05b97fa5524dfccd16b1eefb1f19f18022c1c72cd
|
7
|
+
data.tar.gz: 77effbe07be672bca0881d3b4ad7176b41a567b060f1ad601c520365964955266a4bd5aa8b9e4dae3ea16e2370521b9d138e2ce7b93f18754d433bdae23a3072
|
data/lib/ripper-tags.rb
CHANGED
@@ -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 =~
|
43
|
+
(options.all_files || file =~ RE_RUBY) && !exclude_file?(file)
|
39
44
|
end
|
40
45
|
|
41
|
-
def
|
42
|
-
|
43
|
-
if
|
44
|
-
|
45
|
-
|
46
|
-
File.join(file, name)
|
47
|
-
|
48
|
-
|
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
|
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
|
-
|
69
|
+
options.files.each do |file|
|
70
|
+
resolve_file(file, &block)
|
71
|
+
end
|
59
72
|
end
|
60
73
|
end
|
61
74
|
|