ptools 1.4.1-universal-mingw32 → 1.4.2-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
  SHA256:
3
- metadata.gz: daf33ac7c6c26eb73262fde47054dfdee711c306995c67a7ead5dd7c64f41984
4
- data.tar.gz: 53af13a0aa13df74392375e21d91014d71c3c55b01f183faed53fee52332ceb8
3
+ metadata.gz: 9694f9c933387b24ebb3d67fd25dd3f317d1f770fb3a60cf6dad28d4f377d478
4
+ data.tar.gz: 1cc7c6ac40de18d9d1681399b15d6a911a19e0ae546f7e350824c18358e706fb
5
5
  SHA512:
6
- metadata.gz: 302d30c2b116019561aeacc3c116697230456f2baa958e8dc22d2de69f2b453a3cbfd24353c07ce16f83ad781405a3559fb743d00d5ebdedf4a57697e90b4b60
7
- data.tar.gz: 2418dd67eaa224bf83fca03ccee8a7851a0434ac4ce7adc99620910e6dd454516e5a99c58661007134fa8d2aa446aace208bb014e50219c9fdf12cac8a24620f
6
+ metadata.gz: 4af9fe9d5e99b81958b6bc50c45fa0deb8a0fd9362c8dbe9aafb157a9d5054519827d2f912521ee5b7e8d40fe17838d72e800b1ae9d7f2218f1ba21c87feb23f
7
+ data.tar.gz: 48e8ea182f3b809bb1c732082274f0568593f720964566718ea4bd61f7302e57b3917e6700fc0504b14b377a78fd77c25e97abf5ffdc19550b63bbabee311846
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 1.4.2 - 6-Jan-2021
2
+ * Fixed a private access modifier that wasn't actually working as intended.
3
+ * Two Windows constants that were never meant for public consumption have been marked private.
4
+ * Minor tweak to one of the touch specs.
5
+ * The Gemfile now just uses the gemspec.
6
+ * The image? singleton method was effectively ignoring filename extensions. This
7
+ has been fixed, though with the option to disable that check if desired.
8
+
1
9
  ## 1.4.1 - 29-Dec-2020
2
10
  * Switch from rdoc to markdown since github is not rendering rdoc properly.
3
11
  * Added metadata to gemspec.
data/Gemfile CHANGED
@@ -1,12 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'structured_warnings'
4
-
5
- group :production do
6
- gem 'win32-file' if File::ALT_SEPARATOR
7
- end
8
-
9
- group :test do
10
- gem 'rake'
11
- gem 'rspec'
12
- end
3
+ gemspec
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.4.1'.freeze
6
+ PTOOLS_VERSION = '1.4.2'.freeze
7
7
 
8
8
  # :stopdoc:
9
9
 
@@ -19,17 +19,26 @@ class File
19
19
  MSWINDOWS = false
20
20
  end
21
21
 
22
- IMAGE_EXT = %w[.bmp .gif .jpg .jpeg .png]
22
+ if File::ALT_SEPARATOR
23
+ private_constant :WIN32EXTS
24
+ private_constant :MSWINDOWS
25
+ end
26
+
27
+ IMAGE_EXT = %w[.bmp .gif .jpg .jpeg .png .ico]
23
28
 
24
29
  # :startdoc:
25
30
 
26
31
  # Returns whether or not the file is an image. Only JPEG, PNG, BMP,
27
32
  # GIF, and ICO are checked against.
28
33
  #
29
- # This method does some simple read and extension checks. For a version
34
+ # This reads and checks the first few bytes of the file. For a version
30
35
  # that is more robust, but which depends on a 3rd party C library (and is
31
36
  # difficult to build on MS Windows), see the 'filemagic' library.
32
37
  #
38
+ # By default the filename extension is also checked. You can disable this
39
+ # by passing false as the second argument, in which case only the contents
40
+ # are checked.
41
+ #
33
42
  # Examples:
34
43
  #
35
44
  # File.image?('somefile.jpg') # => true
@@ -38,9 +47,13 @@ class File
38
47
  # The approach I used here is based on information found at
39
48
  # http://en.wikipedia.org/wiki/Magic_number_(programming)
40
49
  #
41
- def self.image?(file)
42
- bool = IMAGE_EXT.include?(File.extname(file).downcase)
50
+ def self.image?(file, check_file_extension = true)
43
51
  bool = bmp?(file) || jpg?(file) || png?(file) || gif?(file) || tiff?(file) || ico?(file)
52
+
53
+ if check_file_extension
54
+ bool = bool && IMAGE_EXT.include?(File.extname(file).downcase)
55
+ end
56
+
44
57
  bool
45
58
  end
46
59
 
@@ -402,8 +415,6 @@ class File
402
415
  end
403
416
  end
404
417
 
405
- private
406
-
407
418
  # Returns whether or not the given +text+ contains a BOM marker.
408
419
  # If present, we can generally assume it's a text file.
409
420
  #
@@ -418,6 +429,10 @@ class File
418
429
  bool
419
430
  end
420
431
 
432
+ private_class_method :check_bom?
433
+
434
+ # Returns the newline characters for the given platform.
435
+ #
421
436
  def self.nl_for_platform(platform)
422
437
  platform = RbConfig::CONFIG["host_os"] if platform == 'local'
423
438
 
@@ -433,22 +448,32 @@ class File
433
448
  end
434
449
  end
435
450
 
451
+ # Is the file a bitmap file?
452
+ #
436
453
  def self.bmp?(file)
437
454
  IO.read(file, 3) == "BM6"
438
455
  end
439
456
 
457
+ # Is the file a jpeg file?
458
+ #
440
459
  def self.jpg?(file)
441
460
  IO.read(file, 10, nil, :encoding => 'binary') == "\377\330\377\340\000\020JFIF".force_encoding(Encoding::BINARY)
442
461
  end
443
462
 
463
+ # Is the file a png file?
464
+ #
444
465
  def self.png?(file)
445
466
  IO.read(file, 4, nil, :encoding => 'binary') == "\211PNG".force_encoding(Encoding::BINARY)
446
467
  end
447
468
 
469
+ # Is the file a gif?
470
+ #
448
471
  def self.gif?(file)
449
472
  ['GIF89a', 'GIF97a'].include?(IO.read(file, 6))
450
473
  end
451
474
 
475
+ # Is the file a tiff?
476
+ #
452
477
  def self.tiff?(file)
453
478
  return false if File.size(file) < 12
454
479
 
@@ -470,6 +495,8 @@ class File
470
495
  true
471
496
  end
472
497
 
498
+ # Is the file an ico file?
499
+ #
473
500
  def self.ico?(file)
474
501
  ["\000\000\001\000", "\000\000\002\000"].include?(IO.read(file, 4, nil, :encoding => 'binary'))
475
502
  end
data/ptools.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rbconfig'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'ptools'
5
- spec.version = '1.4.1'
5
+ spec.version = '1.4.2'
6
6
  spec.license = 'Artistic-2.0'
7
7
  spec.author = 'Daniel J. Berger'
8
8
  spec.email = 'djberg96@gmail.com'
@@ -13,21 +13,11 @@ RSpec.describe File, :constants do
13
13
  let(:windows) { File::ALT_SEPARATOR }
14
14
 
15
15
  example "PTOOLS_VERSION constant is set to expected value" do
16
- expect(File::PTOOLS_VERSION).to eq('1.4.1')
16
+ expect(File::PTOOLS_VERSION).to eq('1.4.2')
17
17
  expect(File::PTOOLS_VERSION.frozen?).to be true
18
18
  end
19
19
 
20
20
  example "IMAGE_EXT constant is set to array of values" do
21
- expect(File::IMAGE_EXT.sort).to eq(%w[.bmp .gif .jpeg .jpg .png])
22
- end
23
-
24
- example "WINDOWS constant is defined on MS Windows" do
25
- skip "skipped unless MS Windows" unless windows
26
- expect(File::MSWINDOWS).not_to be_nil
27
- end
28
-
29
- example "WIN32EXTS constant is defined on MS Windows" do
30
- skip "skipped unless MS Windows" unless windows
31
- expect(File::WIN32EXTS).not_to be_nil
21
+ expect(File::IMAGE_EXT).to match_array(%w[.bmp .gif .ico .jpeg .jpg .png])
32
22
  end
33
23
  end
data/spec/touch_spec.rb CHANGED
@@ -30,7 +30,7 @@ RSpec.describe File, :touch do
30
30
 
31
31
  example "touch an existing file returns expected results" do
32
32
  stat = File.stat(xfile)
33
- sleep 0.5
33
+ sleep 1
34
34
  expect{ File.touch(xfile) }.not_to raise_error
35
35
  expect(File.size(xfile) == stat.size).to be true
36
36
  expect(File.mtime(xfile) == stat.mtime).to be false
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ptools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Daniel J. Berger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2020-12-29 00:00:00.000000000 Z
38
+ date: 2021-05-22 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rake
@@ -125,7 +125,7 @@ metadata:
125
125
  documentation_uri: https://github.com/djberg96/ptools/wiki
126
126
  source_code_uri: https://github.com/djberg96/ptools
127
127
  wiki_uri: https://github.com/djberg96/ptools/wiki
128
- post_install_message:
128
+ post_install_message:
129
129
  rdoc_options: []
130
130
  require_paths:
131
131
  - lib
@@ -140,8 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.0.3
144
- signing_key:
143
+ rubygems_version: 3.1.4
144
+ signing_key:
145
145
  specification_version: 4
146
146
  summary: Extra methods for the File class
147
147
  test_files: []
metadata.gz.sig CHANGED
Binary file