win32-file-stat 1.4.1 → 1.4.2

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: 8bd37a04637609ed685cbbcc71a621b2660169e4
4
- data.tar.gz: 9123576b418e37ecfe320c96e35c42b6c60f9bba
3
+ metadata.gz: f4a8344517f65f38afc25399ed53ba90e4042790
4
+ data.tar.gz: 082ee54ef5f8683133ac1a6debd4100aa689dbd2
5
5
  SHA512:
6
- metadata.gz: 715f01129adafd4c12b71ba8db1ea9c52f6a45e566cfad6427df6ed74c453f5cd43905c3cd2a044ec454dafbc2a8741c6d414a8bde2e2e1f8e46ffb9a6869685
7
- data.tar.gz: 6f5b6e59efa693919ad1268cdc01acd8e978d9a82b36263d4c73a58049bed44cdcd98ef080ab14c860411eb8ef6d9b7bb80f4a308a45ed403de7a6bc6b130b7b
6
+ metadata.gz: c739e1e16beb1130f1cba2c27dcb94e53758a6df15dc9bf8eea30789da0626ae1cec9a9481bd811437603583353974df7bb18b792e7e09ad5160c33d218c801f
7
+ data.tar.gz: 73012b9bd897383edf5208ebd42b163350f7bdef8acc9c44ff9eac56eb041d99754e92a2e55ea5156a08e1c771a5694ad3faff4e1e2f3f52940c473620e850d5
data/CHANGES CHANGED
@@ -1,5 +1,9 @@
1
+ == 1.4.2 - 28-Apr-2014
2
+ * Allow the File::Stat.new method to accept objects that respond to to_str
3
+ or to_path to mimic MRI.
4
+
1
5
  == 1.4.1 - 12-Feb-2014
2
- * The #writable and #writable_real methods now always return fals if the file
6
+ * The #writable and #writable_real methods now always return false if the file
3
7
  has been marked readonly.
4
8
  * Fixed an rdev test and added a writable test.
5
9
 
@@ -55,7 +55,7 @@ class File::Stat
55
55
  attr_reader :dev_major, :dev_minor, :rdev_major, :rdev_minor
56
56
 
57
57
  # The version of the win32-file-stat library
58
- WIN32_FILE_STAT_VERSION = '1.4.1'
58
+ WIN32_FILE_STAT_VERSION = '1.4.2'
59
59
 
60
60
  # Creates and returns a File::Stat object, which encapsulate common status
61
61
  # information for File objects on MS Windows sytems. The information is
@@ -63,7 +63,7 @@ class File::Stat
63
63
  # the file after that point will not be reflected.
64
64
  #
65
65
  def initialize(file)
66
- raise TypeError unless file.is_a?(String)
66
+ file = string_check(file)
67
67
 
68
68
  path = file.tr('/', "\\")
69
69
  @path = path
@@ -554,6 +554,14 @@ class File::Stat
554
554
 
555
555
  private
556
556
 
557
+ # Allow stringy arguments
558
+ def string_check(arg)
559
+ return arg if arg.is_a?(String)
560
+ return arg.send(:to_str) if arg.respond_to?(:to_str, true) # MRI honors private to_str
561
+ return arg.to_path if arg.respond_to?(:to_path)
562
+ raise TypeError
563
+ end
564
+
557
565
  # This is based on fileattr_to_unixmode in win32.c
558
566
  #
559
567
  def get_mode
@@ -9,6 +9,7 @@ require 'ffi'
9
9
  require 'test-unit'
10
10
  require 'win32/file/stat'
11
11
  require 'win32/security'
12
+ require 'pathname'
12
13
 
13
14
  class TC_Win32_File_Stat < Test::Unit::TestCase
14
15
  extend FFI::Library
@@ -53,7 +54,7 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
53
54
  end
54
55
 
55
56
  test "version is set to expected value" do
56
- assert_equal('1.4.1', File::Stat::WIN32_FILE_STAT_VERSION)
57
+ assert_equal('1.4.2', File::Stat::WIN32_FILE_STAT_VERSION)
57
58
  end
58
59
 
59
60
  test "constructor does not modify argument" do
@@ -62,6 +63,10 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
62
63
  assert_equal(expected, @@txt_file)
63
64
  end
64
65
 
66
+ test "constructor allows arguments that implement to_path" do
67
+ assert_nothing_raised{ File::Stat.new(Pathname.new(Dir.pwd)) }
68
+ end
69
+
65
70
  test "archive? method basic functionality" do
66
71
  assert_respond_to(@stat, :archive?)
67
72
  assert_nothing_raised{ @stat.archive? }
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'win32-file-stat'
3
- spec.version = '1.4.1'
3
+ spec.version = '1.4.2'
4
4
  spec.authors = ['Daniel J. Berger', 'Park Heesob']
5
5
  spec.license = 'Artistic 2.0'
6
6
  spec.email = 'djberg96@gmail.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-file-stat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-12 00:00:00.000000000 Z
12
+ date: 2014-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi