ptools 1.3.3-universal-mingw32 → 1.3.5-universal-mingw32

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 825f3067d1acabd589eb633c4307140008626138
4
- data.tar.gz: 2924015a89255311cb29ce3f26de584a81935288
3
+ metadata.gz: ee238a6835d5ed4a5dec58ed5eb35e88d8c6af6b
4
+ data.tar.gz: 96b5a663c8a6ef5c0dbedfbedaadbb399e735ca1
5
5
  SHA512:
6
- metadata.gz: 204eff0e8d7e2251793f0acf20ec16b113d35595a57012525700a343f917492d6ce2a5dee7504e6792f37f84f563bef421f232ea2e41776eafef49bc183a942a
7
- data.tar.gz: 6ea1e00173da43e41da1400af67369d68e68fa56582c480cc4b51be43f9f28553bcac286ee0a0d6b4945de6163582dc09bbe82bc4321c647a6800ec9de9beab3
6
+ metadata.gz: 9e5ef4db7f09c58cd4ee9e2b3343f1bcceb647abe07651a7ac2e308769c183b903d3729f9e444a64b85503b68a30b09601eb8bc1e3986868cbc3544f5c6f1f05
7
+ data.tar.gz: faa94b24f47fb46c74a723030eeebba3cf49fbfb34bfcb9a25064ad19cb10e82d638746bea0519f7e2209328dae4fb17b63e466e6f4a51edf9b4cf399244117d
checksums.yaml.gz.sig CHANGED
@@ -1 +1,3 @@
1
- 7,����o���f!�x(p��Q�e6M@y#�g>�"ξ��&�@Z�Q�"�|֋T2��-5�m���C��k��|b�^�z�Mʔ�F�&%u1��ʲK��� jeh�g���IGc��/�U�E����ͱ��B5.}K0�Ρ�o~2�ٍ��Pĉ��(g�ә�$z+�0����2g2�#-��MvF����n�������`�H)��hw��a"cgB�*�j9 �'KWc۝Zu�;�4+���=O"�A �?^���]ˢ
1
+ nWȴ� (���潂��� 2��_B�!�� [�EI�m=���sy��麜��c�H.���BlRS ��vx�$��v�����ʌ%?Ty���� (x�O
2
+ �����) ��Dؒq0�Z։k˽���x�����R���ݕ %����Hֵk����_���!aWE�{�
3
+ ��/�2�+B4+jk���Z�T���lb��k���IVT�L�������^�~R�Bn�H's�o3
data.tar.gz.sig CHANGED
Binary file
data/CHANGES CHANGED
@@ -1,3 +1,15 @@
1
+ == 1.3.5 - 3-Sep-2017
2
+ * The File.image? method now checks against .ico files.
3
+ * Eliminated Fixnum warning that showed up in Ruby 2.4.x.
4
+ * Updated cert.
5
+
6
+ == 1.3.4 - 4-Jul-2017
7
+ * The File.binary? method now lets you set your own percentage for the
8
+ internal heuristic as an optional second argument.
9
+ * The VERSION constant is now frozen.
10
+ * Minor updates to the Rakefile and gemspec.
11
+ * Updated cert file.
12
+
1
13
  == 1.3.3 - 25-Sep-2015
2
14
  * This gem is now signed.
3
15
  * The Rakefile tasks now assume Rubygems 2.x.
data/MANIFEST CHANGED
@@ -18,3 +18,4 @@
18
18
  * test/img/test.gif
19
19
  * test/img/test.jpg
20
20
  * test/img/test.png
21
+ * test/img/test.ico
data/Rakefile CHANGED
@@ -8,9 +8,9 @@ CLEAN.include("**/*.gem", "**/*.rbc", "**/*coverage*")
8
8
 
9
9
  desc 'Install the ptools package (non-gem)'
10
10
  task :install do
11
- sitelibdir = CONFIG["sitelibdir"]
12
- file = "lib/ptools.rb"
13
- FileUtils.cp(file, sitelibdir, :verbose => true)
11
+ sitelibdir = CONFIG["sitelibdir"]
12
+ file = "lib/ptools.rb"
13
+ FileUtils.cp(file, sitelibdir, :verbose => true)
14
14
  end
15
15
 
16
16
  namespace 'gem' do
@@ -19,7 +19,7 @@ namespace 'gem' do
19
19
  require 'rubygems/package'
20
20
  spec = eval(IO.read('ptools.gemspec'))
21
21
  spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
22
- Gem::Package.build(spec)
22
+ Gem::Package.build(spec, true)
23
23
  end
24
24
 
25
25
  desc 'Install the ptools gem'
@@ -1,21 +1,21 @@
1
1
  -----BEGIN CERTIFICATE-----
2
2
  MIIDcDCCAligA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C5FJeBdAiuw6lqHun
19
+ QLLepVJthIvwmfc8AU5TJGMawtVAUHIWiuQPoBBVVKOkeEhioO0cV8UabKsKMbE8
20
+ VpiARrgH+4lYiRFJ+gKpIbSEJvk=
21
21
  -----END CERTIFICATE-----
data/lib/ptools.rb CHANGED
@@ -3,7 +3,7 @@ require 'win32/file' if File::ALT_SEPARATOR
3
3
 
4
4
  class File
5
5
  # The version of the ptools library.
6
- PTOOLS_VERSION = '1.3.3'
6
+ PTOOLS_VERSION = '1.3.5'.freeze
7
7
 
8
8
  # :stopdoc:
9
9
 
@@ -23,8 +23,8 @@ class File
23
23
 
24
24
  # :startdoc:
25
25
 
26
- # Returns whether or not the file is an image. Only JPEG, PNG, BMP and
27
- # GIF are checked against.
26
+ # Returns whether or not the file is an image. Only JPEG, PNG, BMP,
27
+ # GIF, and ICO are checked against.
28
28
  #
29
29
  # This method does some simple read and extension checks. For a version
30
30
  # that is more robust, but which depends on a 3rd party C library (and is
@@ -39,8 +39,8 @@ class File
39
39
  # http://en.wikipedia.org/wiki/Magic_number_(programming)
40
40
  #
41
41
  def self.image?(file)
42
- bool = IMAGE_EXT.include?(File.extname(file).downcase) # Match ext
43
- bool = bmp?(file) || jpg?(file) || png?(file) || gif?(file) || tiff?(file) # Check data
42
+ bool = IMAGE_EXT.include?(File.extname(file).downcase)
43
+ bool = bmp?(file) || jpg?(file) || png?(file) || gif?(file) || tiff?(file) || ico?(file)
44
44
  bool
45
45
  end
46
46
 
@@ -79,6 +79,10 @@ class File
79
79
  # It performs a "best guess" based on a simple test of the first
80
80
  # +File.blksize+ characters, or 4096, whichever is smaller.
81
81
  #
82
+ # By default it will check to see if more than 30 percent of the characters
83
+ # are non-text characters. If so, the method returns true. You can configure
84
+ # this percentage by passing your own as a second argument.
85
+ #
82
86
  # Example:
83
87
  #
84
88
  # File.binary?('somefile.exe') # => true
@@ -87,13 +91,13 @@ class File
87
91
  # Based on code originally provided by Ryan Davis (which, in turn, is
88
92
  # based on Perl's -B switch).
89
93
  #
90
- def self.binary?(file)
94
+ def self.binary?(file, percentage = 0.30)
91
95
  return false if image?(file)
92
96
  bytes = File.stat(file).blksize
93
97
  bytes = 4096 if bytes > 4096
94
98
  s = (File.read(file, bytes) || "")
95
99
  s = s.encode('US-ASCII', :undef => :replace).split(//)
96
- ((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30
100
+ ((s.size - s.grep(" ".."~").size) / s.size.to_f) > percentage
97
101
  end
98
102
 
99
103
  # Looks for the first occurrence of +program+ within +path+.
@@ -479,4 +483,8 @@ class File
479
483
 
480
484
  true
481
485
  end
486
+
487
+ def self.ico?(file)
488
+ ["\000\000\001\000", "\000\000\002\000"].include?(IO.read(file, 4, nil, :encoding => 'binary'))
489
+ end
482
490
  end
data/ptools.gemspec CHANGED
@@ -3,14 +3,14 @@ require 'rbconfig'
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'ptools'
6
- spec.version = '1.3.3'
7
- spec.license = 'Artistic 2.0'
6
+ spec.version = '1.3.5'
7
+ spec.license = 'Artistic-2.0'
8
8
  spec.author = 'Daniel J. Berger'
9
9
  spec.email = 'djberg96@gmail.com'
10
10
  spec.homepage = 'https://github.com/djberg96/ptools'
11
11
  spec.summary = 'Extra methods for the File class'
12
12
  spec.test_files = Dir['test/test*']
13
- spec.files = Dir['**/*'] << '.gemtest'
13
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
14
14
  spec.cert_chain = ['certs/djberg96_pub.pem']
15
15
 
16
16
  spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
data/test/img/test.ico ADDED
Binary file
data/test/test_binary.rb CHANGED
@@ -47,6 +47,11 @@ class TC_Ptools_Binary < Test::Unit::TestCase
47
47
  assert_false(File.binary?(@gif_file))
48
48
  end
49
49
 
50
+ test "File.binary? accepts an optional percentage argument" do
51
+ assert_false(File.binary?(@txt_file, 0.50))
52
+ assert_true(File.binary?(@txt_file, 0.05))
53
+ end
54
+
50
55
  test "File.binary? raises an error if the file cannot be found" do
51
56
  assert_raise_kind_of(SystemCallError){ File.binary?('bogus') }
52
57
  end
@@ -15,7 +15,7 @@ class TC_Ptools_Constants < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  test "PTOOLS_VERSION constant is set to expected value" do
18
- assert_equal('1.3.3', File::PTOOLS_VERSION)
18
+ assert_equal('1.3.5', File::PTOOLS_VERSION)
19
19
  end
20
20
 
21
21
  test "IMAGE_EXT constant is set to array of values" do
data/test/test_image.rb CHANGED
@@ -18,6 +18,7 @@ class TC_Ptools_Image < Test::Unit::TestCase
18
18
  @jpg_file = File.join(Dir.pwd, 'img', 'test.jpg')
19
19
  @png_file = File.join(Dir.pwd, 'img', 'test.png')
20
20
  @gif_file = File.join(Dir.pwd, 'img', 'test.gif')
21
+ @ico_file = File.join(Dir.pwd, 'img', 'test.ico')
21
22
  end
22
23
 
23
24
  test "image? method basic functionality" do
@@ -43,6 +44,10 @@ class TC_Ptools_Image < Test::Unit::TestCase
43
44
  assert_true(File.image?(@png_file))
44
45
  end
45
46
 
47
+ test "image? method returns true for an ico" do
48
+ assert_true(File.image?(@ico_file))
49
+ end
50
+
46
51
  test "image? method raises an error if the file does not exist" do
47
52
  assert_raises(Errno::ENOENT, ArgumentError){ File.image?('bogus') }
48
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ptools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.5
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -12,25 +12,25 @@ cert_chain:
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
14
14
  cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
15
- MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTI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.000000000 Z
33
+ date: 2017-09-03 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: rake
@@ -86,16 +86,20 @@ extra_rdoc_files:
86
86
  - CHANGES
87
87
  - MANIFEST
88
88
  files:
89
- - ".gemtest"
89
+ - certs
90
+ - certs/djberg96_pub.pem
90
91
  - CHANGES
91
92
  - Gemfile
92
- - MANIFEST
93
- - README
94
- - Rakefile
95
- - certs/djberg96_pub.pem
93
+ - lib
96
94
  - lib/ptools.rb
95
+ - MANIFEST
97
96
  - ptools.gemspec
97
+ - Rakefile
98
+ - README
99
+ - test
100
+ - test/img
98
101
  - test/img/test.gif
102
+ - test/img/test.ico
99
103
  - test/img/test.jpg
100
104
  - test/img/test.png
101
105
  - test/test_binary.rb
@@ -110,11 +114,12 @@ files:
110
114
  - test/test_wc.rb
111
115
  - test/test_whereis.rb
112
116
  - test/test_which.rb
117
+ - test/txt
113
118
  - test/txt/english.txt
114
119
  - test/txt/korean.txt
115
120
  homepage: https://github.com/djberg96/ptools
116
121
  licenses:
117
- - Artistic 2.0
122
+ - Artistic-2.0
118
123
  metadata: {}
119
124
  post_install_message:
120
125
  rdoc_options: []
@@ -132,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
137
  version: '0'
133
138
  requirements: []
134
139
  rubyforge_project:
135
- rubygems_version: 2.4.8
140
+ rubygems_version: 2.6.12
136
141
  signing_key:
137
142
  specification_version: 4
138
143
  summary: Extra methods for the File class
metadata.gz.sig CHANGED
Binary file
data/.gemtest DELETED
File without changes