pdd 0.17.2 → 0.17.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pdd/sources.rb +22 -4
- data/lib/pdd/version.rb +1 -1
- data/pdd.gemspec +0 -1
- data/test/test__helper.rb +2 -0
- data/test/test_sources.rb +13 -4
- data/test_assets/aladdin.jpg +0 -0
- data/test_assets/article.pdf +0 -0
- data/test_assets/cambria.woff +0 -0
- data/test_assets/elegant-objects.png +0 -0
- data/test_assets/favicon.ico +0 -0
- metadata +7 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9737f2ffe3116e23bfcc57021b402e0ef01dd580
|
4
|
+
data.tar.gz: 71d0b9a2044217d12c978473c19843ede5759988
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df79e23a678a56d0623496d7fde7cf5ba3782ae868ddf854919bfa5d93952e1e03a77c84bdb46f395352a082eccf24af666e6b425e08b70b5bfbf98f00eea9a8
|
7
|
+
data.tar.gz: bb5703913a301601dee492be977948950e19e6515398cbc4ecd4958a227c0da9edd713cb71df709c92cca1ceaa7b1726f888e6901618a5f1a5755d94c292e458
|
data/lib/pdd/sources.rb
CHANGED
@@ -20,8 +20,10 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
-
require '
|
23
|
+
require 'pdd'
|
24
24
|
require 'pdd/source'
|
25
|
+
require 'shellwords'
|
26
|
+
require 'English'
|
25
27
|
|
26
28
|
module PDD
|
27
29
|
# Code base abstraction
|
@@ -35,14 +37,18 @@ module PDD
|
|
35
37
|
|
36
38
|
# Fetch all sources.
|
37
39
|
def fetch
|
38
|
-
files = Dir.glob(
|
40
|
+
files = Dir.glob(
|
41
|
+
File.join(@dir, '**/*'), File::FNM_DOTMATCH
|
42
|
+
).reject { |f| File.directory?(f) }
|
43
|
+
excluded = 0
|
39
44
|
@exclude.each do |ptn|
|
40
45
|
Dir.glob(File.join(@dir, ptn), File::FNM_DOTMATCH) do |f|
|
41
46
|
files.delete_if { |i| i == f }
|
47
|
+
excluded += 1
|
42
48
|
end
|
43
49
|
end
|
44
|
-
PDD.log.info "#{files.size} file(s) found"
|
45
|
-
files.
|
50
|
+
PDD.log.info "#{files.size} file(s) found, #{excluded} excluded"
|
51
|
+
files.reject { |f| binary?(f) }.map do |file|
|
46
52
|
VerboseSource.new(
|
47
53
|
file,
|
48
54
|
Source.new(file, file[@dir.length + 1, file.length])
|
@@ -53,5 +59,17 @@ module PDD
|
|
53
59
|
def exclude(ptn)
|
54
60
|
Sources.new(@dir, @exclude.push(ptn))
|
55
61
|
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def binary?(f)
|
66
|
+
`grep -qI '.' #{Shellwords.escape(f)}`
|
67
|
+
if $CHILD_STATUS.success?
|
68
|
+
false
|
69
|
+
else
|
70
|
+
PDD.log.info "#{f} is a binary file (#{File.size(f)} bytes)"
|
71
|
+
true
|
72
|
+
end
|
73
|
+
end
|
56
74
|
end
|
57
75
|
end
|
data/lib/pdd/version.rb
CHANGED
data/pdd.gemspec
CHANGED
@@ -45,7 +45,6 @@ Gem::Specification.new do |s|
|
|
45
45
|
s.rdoc_options = ['--charset=UTF-8']
|
46
46
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
47
47
|
s.add_runtime_dependency 'nokogiri', '~>1.6'
|
48
|
-
s.add_runtime_dependency 'ptools', '~>1.3'
|
49
48
|
s.add_runtime_dependency 'slop', '~>3.6'
|
50
49
|
s.add_development_dependency 'rake', '10.5.0'
|
51
50
|
s.add_development_dependency 'coveralls', '0.7.2'
|
data/test/test__helper.rb
CHANGED
data/test/test_sources.rb
CHANGED
@@ -21,9 +21,11 @@
|
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
23
|
require 'minitest/autorun'
|
24
|
-
require 'pdd/sources'
|
25
24
|
require 'fileutils'
|
26
25
|
require 'tmpdir'
|
26
|
+
require 'pdd/sources'
|
27
|
+
|
28
|
+
require_relative '../test/test__helper'
|
27
29
|
|
28
30
|
# Sources test.
|
29
31
|
# Author:: Yegor Bugayenko (yegor@teamed.io)
|
@@ -38,9 +40,16 @@ class TestSources < Minitest::Test
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def test_ignores_binary_files
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
in_temp([]) do |dir|
|
44
|
+
[
|
45
|
+
'README.md',
|
46
|
+
'.git/index',
|
47
|
+
'test_assets/elegant-objects.png',
|
48
|
+
'test_assets/aladdin.jpg',
|
49
|
+
'test_assets/article.pdf',
|
50
|
+
'test_assets/cambria.woff',
|
51
|
+
'test_assets/favicon.ico'
|
52
|
+
].each { |f| FileUtils.cp(File.join(Dir.pwd, f), dir) }
|
44
53
|
list = PDD::Sources.new(dir).fetch
|
45
54
|
assert_equal 1, list.size
|
46
55
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: ptools
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.3'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.3'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: slop
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,6 +207,11 @@ files:
|
|
221
207
|
- test/test_source.rb
|
222
208
|
- test/test_sources.rb
|
223
209
|
- test/test_text.rb
|
210
|
+
- test_assets/aladdin.jpg
|
211
|
+
- test_assets/article.pdf
|
212
|
+
- test_assets/cambria.woff
|
213
|
+
- test_assets/elegant-objects.png
|
214
|
+
- test_assets/favicon.ico
|
224
215
|
homepage: http://github.com/yegor256/pdd
|
225
216
|
licenses:
|
226
217
|
- MIT
|