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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 785afdc87a9645ad5b28e986751ef260572d8b79
4
- data.tar.gz: b11c03bee8bd38b9c8047a01e8ef0023e5efb03f
3
+ metadata.gz: 9737f2ffe3116e23bfcc57021b402e0ef01dd580
4
+ data.tar.gz: 71d0b9a2044217d12c978473c19843ede5759988
5
5
  SHA512:
6
- metadata.gz: f47c3728b82e73489fc7574533c343882528f5bf1364e37c8b6f2fa033bc1f077c6d51286b8c5be999e53b8edcf0af016096f6be6305dd4a1d8a056a86b5406a
7
- data.tar.gz: 3f8a6fd4904254a6bebb1a73f8791fd03d2d7fe4b3e7e896eb55acd2b2e88152b7264c279380f58eb6cd7974e07f631af6bfbf4821ecb1c020ddffd4d95b468a
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 'ptools'
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(File.join(@dir, '**/*'), File::FNM_DOTMATCH)
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.select { |f| !File.directory?(f) && !File.binary?(f) }.map do |file|
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
@@ -25,5 +25,5 @@
25
25
  # Copyright:: Copyright (c) 2014-2017 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module PDD
28
- VERSION = '0.17.2'.freeze
28
+ VERSION = '0.17.3'.freeze
29
29
  end
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
@@ -20,6 +20,8 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
+ STDOUT.sync = true
24
+
23
25
  require 'simplecov'
24
26
  require 'pdd'
25
27
  require 'minitest/autorun'
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
- skip
42
- in_temp(['c']) do |dir|
43
- FileUtils.cp(File.join(Dir.pwd, '.git/index'), dir)
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.2
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-06 00:00:00.000000000 Z
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