win32-file 0.5.4 → 0.5.5

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.
data/CHANGES CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.5.5 - 22-Nov-2007
2
+ * Fixed a bug in the File.dirname method with regards to relative paths.
3
+ Thanks go to an Laust Rud for the spot.
4
+ * Removed the install.rb file. Use the 'rake install' task instead.
5
+ * Added more tests to ensure the File.dirname method works properly and
6
+ did some test refactoring in general.
7
+
1
8
  == 0.5.4 - 8-Apr-2007
2
9
  * Now runs -w clean.
3
10
  * Added a Rakefile. Manual installation and testing should now be handled
data/MANIFEST CHANGED
@@ -2,7 +2,6 @@
2
2
  * MANIFEST
3
3
  * Rakefile
4
4
  * README
5
- * install.rb
6
5
  * win32-file.gemspec
7
6
  * lib/win32/file.rb
8
7
  * test/sometestfile.txt
@@ -11,5 +10,4 @@
11
10
  * test/tc_file_encryption.rb
12
11
  * test/tc_file_path.rb
13
12
  * test/tc_file_security.rb
14
- * test/tc_file_stat.rb
15
- * test/ts_all.rb
13
+ * test/tc_file_stat.rb
data/Rakefile CHANGED
@@ -1,13 +1,20 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
+ require 'rbconfig'
4
+ include Config
3
5
 
4
6
  task :clean do
5
7
  rm 'sometestfile.txt' if File.exists? 'sometestfile.txt'
6
8
  end
7
9
 
8
10
  desc 'Install the win32-file package (non-gem)'
9
- task :install => [:clean] do
10
- ruby 'install.rb'
11
+ task :install do
12
+ sitelibdir = CONFIG['sitelibdir']
13
+ installdir = File.join(sitelibdir, 'win32')
14
+ file = 'lib\win32\file.rb'
15
+
16
+ Dir.mkdir(installdir) unless File.exists?(installdir)
17
+ FileUtils.cp(file, installdir, :verbose => true)
11
18
  end
12
19
 
13
20
  desc 'Install the win32-file package as a gem'
@@ -21,11 +28,10 @@ Rake::TestTask.new("test") do |t|
21
28
  t.libs << 'test'
22
29
  t.verbose = true
23
30
  t.warning = true
24
- t.test_files = FileList['test/ts_all.rb']
31
+ t.test_files = FileList['test/tc*']
25
32
  end
26
33
 
27
34
  Rake::TestTask.new("test_attributes") do |t|
28
- cp('test/sometestfile.txt', '.')
29
35
  t.verbose = true
30
36
  t.warning = true
31
37
  t.test_files = FileList['test/tc_file_attributes.rb']
@@ -38,28 +44,24 @@ Rake::TestTask.new("test_constants") do |t|
38
44
  end
39
45
 
40
46
  Rake::TestTask.new("test_encryption") do |t|
41
- cp('test/sometestfile.txt', '.')
42
47
  t.verbose = true
43
48
  t.warning = true
44
49
  t.test_files = FileList['test/tc_file_encryption.rb']
45
50
  end
46
51
 
47
52
  Rake::TestTask.new("test_path") do |t|
48
- cp('test/sometestfile.txt', '.')
49
53
  t.verbose = true
50
54
  t.warning = true
51
55
  t.test_files = FileList['test/tc_file_path.rb']
52
56
  end
53
57
 
54
58
  Rake::TestTask.new("test_security") do |t|
55
- cp('test/sometestfile.txt', '.')
56
59
  t.verbose = true
57
60
  t.warning = true
58
61
  t.test_files = FileList['test/tc_file_security.rb']
59
62
  end
60
63
 
61
64
  Rake::TestTask.new("test_stat") do |t|
62
- cp('test/sometestfile.txt', '.')
63
65
  t.verbose = true
64
66
  t.warning = true
65
67
  t.test_files = FileList['test/tc_file_stat.rb']
data/lib/win32/file.rb CHANGED
@@ -16,7 +16,7 @@ class File
16
16
  extend Windows::MSVCRT::Buffer
17
17
  extend Windows::Limits
18
18
 
19
- VERSION = '0.5.4'
19
+ VERSION = '0.5.5'
20
20
  MAX_PATH = 260
21
21
 
22
22
  # Abbreviated attribute constants for convenience
@@ -68,37 +68,37 @@ class File
68
68
  # permission constants as possible values. The possible constant values
69
69
  # are:
70
70
  #
71
- # FILE_READ_DATA
72
- # FILE_WRITE_DATA
73
- # FILE_APPEND_DATA
74
- # FILE_READ_EA
75
- # FILE_WRITE_EA
76
- # FILE_EXECUTE
77
- # FILE_DELETE_CHILD
78
- # FILE_READ_ATTRIBUTES
79
- # FILE_WRITE_ATTRIBUTES
80
- # STANDARD_RIGHTS_ALL
81
- # FULL
82
- # READ
83
- # ADD
84
- # CHANGE
85
- # DELETE
86
- # READ_CONTROL
87
- # WRITE_DAC
88
- # WRITE_OWNER
89
- # SYNCHRONIZE
90
- # STANDARD_RIGHTS_REQUIRED
91
- # STANDARD_RIGHTS_READ
92
- # STANDARD_RIGHTS_WRITE
93
- # STANDARD_RIGHTS_EXECUTE
94
- # STANDARD_RIGHTS_ALL
95
- # SPECIFIC_RIGHTS_ALL
96
- # ACCESS_SYSTEM_SECURITY
97
- # MAXIMUM_ALLOWED
98
- # GENERIC_READ
99
- # GENERIC_WRITE
100
- # GENERIC_EXECUTE
101
- # GENERIC_ALL
71
+ # * FILE_READ_DATA
72
+ # * FILE_WRITE_DATA
73
+ # * FILE_APPEND_DATA
74
+ # * FILE_READ_EA
75
+ # * FILE_WRITE_EA
76
+ # * FILE_EXECUTE
77
+ # * FILE_DELETE_CHILD
78
+ # * FILE_READ_ATTRIBUTES
79
+ # * FILE_WRITE_ATTRIBUTES
80
+ # * STANDARD_RIGHTS_ALL
81
+ # * FULL
82
+ # * READ
83
+ # * ADD
84
+ # * CHANGE
85
+ # * DELETE
86
+ # * READ_CONTROL
87
+ # * WRITE_DAC
88
+ # * WRITE_OWNER
89
+ # * SYNCHRONIZE
90
+ # * STANDARD_RIGHTS_REQUIRED
91
+ # * STANDARD_RIGHTS_READ
92
+ # * STANDARD_RIGHTS_WRITE
93
+ # * STANDARD_RIGHTS_EXECUTE
94
+ # * STANDARD_RIGHTS_ALL
95
+ # * SPECIFIC_RIGHTS_ALL
96
+ # * ACCESS_SYSTEM_SECURITY
97
+ # * MAXIMUM_ALLOWED
98
+ # * GENERIC_READ
99
+ # * GENERIC_WRITE
100
+ # * GENERIC_EXECUTE
101
+ # * GENERIC_ALL
102
102
  #
103
103
  def set_permissions(file, perms)
104
104
  raise TypeError unless perms.kind_of?(Hash)
@@ -398,9 +398,11 @@ class File
398
398
  # paths properly, i.e. it should not return anything less than the root.
399
399
  # In all other respects it is identical to the current implementation.
400
400
  #
401
- # File.basename("C:\\foo\\bar.txt") -> "bar.txt"
402
- # File.basename("C:\\foo\\bar.txt", ".txt") -> "bar"
403
- # File.basename("\\\\foo\\bar") -> "\\\\foo\\bar"
401
+ # Examples:
402
+ #
403
+ # File.basename("C:\\foo\\bar.txt") -> "bar.txt"
404
+ # File.basename("C:\\foo\\bar.txt", ".txt") -> "bar"
405
+ # File.basename("\\\\foo\\bar") -> "\\\\foo\\bar"
404
406
  #
405
407
  def basename(file, suffix = nil)
406
408
  fpath = false
@@ -453,10 +455,12 @@ class File
453
455
  # paths properly, i.e. it should not return anything less than the root.
454
456
  # In all other respects it is identical to the current implementation.
455
457
  #
456
- # File.dirname("C:\\foo\\bar\\baz.txt") -> "C:\\foo\\bar"
457
- # File.dirname("\\\\foo\\bar") -> "\\\\foo\\bar"
458
+ # Examples:
459
+ #
460
+ # File.dirname("C:\\foo\\bar\\baz.txt") -> "C:\\foo\\bar"
461
+ # File.dirname("\\\\foo\\bar") -> "\\\\foo\\bar"
458
462
  #
459
- def dirname(file)
463
+ def dirname(file)
460
464
  fpath = false
461
465
  file = file.dup
462
466
 
@@ -465,10 +469,6 @@ class File
465
469
  fpath = true
466
470
  end
467
471
 
468
- if PathIsRelative(file)
469
- return '.'
470
- end
471
-
472
472
  if PathIsRoot(file)
473
473
  file.tr!("\\", '/') if fpath
474
474
  return file
@@ -476,6 +476,12 @@ class File
476
476
 
477
477
  PathRemoveFileSpec(file)
478
478
  file = file.split(0.chr).first
479
+
480
+ # Empty paths, short relative paths
481
+ if file.nil? || (file && file.empty?)
482
+ return '.'
483
+ end
484
+
479
485
  PathRemoveBackslash(file)
480
486
 
481
487
  file.tr!("\\", '/') if fpath
@@ -10,13 +10,14 @@ require 'win32/file'
10
10
  class TC_Win32_File_Attributes < Test::Unit::TestCase
11
11
  include Windows::File
12
12
  def setup
13
- @file = 'sometestfile.txt'
13
+ @dir = File.dirname(File.expand_path(__FILE__))
14
+ @file = File.join(@dir, 'sometestfile.txt')
14
15
  @fh = File.open(@file)
15
16
  @attr = GetFileAttributes(@file)
16
17
  end
17
18
 
18
19
  def test_version
19
- assert_equal('0.5.4', File::VERSION)
20
+ assert_equal('0.5.5', File::VERSION)
20
21
  end
21
22
 
22
23
  def test_temporary
@@ -241,6 +242,7 @@ class TC_Win32_File_Attributes < Test::Unit::TestCase
241
242
  def teardown
242
243
  SetFileAttributes(@file, @attr)
243
244
  @file = nil
245
+ @dir = nil
244
246
  @fh.close
245
247
  end
246
248
  end
@@ -11,8 +11,9 @@ require 'win32/file'
11
11
 
12
12
  class TC_Win32_File_Encryption < Test::Unit::TestCase
13
13
  def setup
14
- @file = 'sometestfile.txt'
15
- @msg = 'IGNORE - may not work due to security setup of your system'
14
+ @dir = File.dirname(File.expand_path(__FILE__))
15
+ @file = File.join(@dir, 'sometestfile.txt')
16
+ @msg = '=> Ignore. May not work due to security setup of your system.'
16
17
  end
17
18
 
18
19
  def test_encrypt
@@ -27,5 +28,6 @@ class TC_Win32_File_Encryption < Test::Unit::TestCase
27
28
 
28
29
  def teardown
29
30
  @file = nil
31
+ @dir = nil
30
32
  end
31
33
  end
data/test/tc_file_path.rb CHANGED
@@ -9,8 +9,9 @@ require 'win32/file'
9
9
 
10
10
  class TC_Win32_File_Path < Test::Unit::TestCase
11
11
  def setup
12
- @short_file = 'SOMETE~1.TXT'
13
- @long_file = 'sometestfile.txt'
12
+ @dir = File.dirname(File.expand_path(__FILE__))
13
+ @long_file = File.join(@dir, 'sometestfile.txt')
14
+ @short_file = File.join(@dir, 'SOMETE~1.TXT')
14
15
  end
15
16
 
16
17
  def test_basename
@@ -98,11 +99,14 @@ class TC_Win32_File_Path < Test::Unit::TestCase
98
99
  assert_equal("//foo/bar", File.dirname("//foo/bar"))
99
100
  assert_equal("//foo", File.dirname("//foo"))
100
101
  assert_equal("//", File.dirname("//"))
102
+ assert_equal(".", File.dirname("./foo"))
103
+ assert_equal("./foo", File.dirname("./foo/bar"))
101
104
 
102
105
  # Edge cases
103
106
  assert_equal(".", File.dirname(""))
104
107
  assert_equal(".", File.dirname("."))
105
108
  assert_equal(".", File.dirname("."))
109
+ assert_equal(".", File.dirname("./"))
106
110
  assert_raises(TypeError){ File.dirname(nil) }
107
111
 
108
112
  # Ensure original path not modified
@@ -148,17 +152,18 @@ class TC_Win32_File_Path < Test::Unit::TestCase
148
152
  def test_long_path
149
153
  assert_respond_to(File, :long_path)
150
154
  assert_equal('sometestfile.txt', File.long_path(@short_file))
151
- assert_equal('SOMETE~1.TXT', @short_file)
155
+ assert_equal('SOMETE~1.TXT', File.basename(@short_file))
152
156
  end
153
157
 
154
158
  def test_short_path
155
159
  assert_respond_to(File, :short_path)
156
160
  assert_equal('SOMETE~1.TXT', File.short_path(@long_file))
157
- assert_equal('sometestfile.txt', @long_file)
161
+ assert_equal('sometestfile.txt', File.basename(@long_file))
158
162
  end
159
163
 
160
164
  def teardown
161
165
  @short_file = nil
162
166
  @long_file = nil
167
+ @dir = nil
163
168
  end
164
169
  end
@@ -11,7 +11,8 @@ require 'socket'
11
11
  class TC_Win32_File_Security < Test::Unit::TestCase
12
12
  def setup
13
13
  @host = Socket.gethostname
14
- @file = 'sometestfile.txt'
14
+ @dir = File.dirname(File.expand_path(__FILE__))
15
+ @file = File.join(@dir, 'sometestfile.txt')
15
16
  @perms = nil
16
17
  end
17
18
 
@@ -45,5 +46,6 @@ class TC_Win32_File_Security < Test::Unit::TestCase
45
46
  @file = nil
46
47
  @host = nil
47
48
  @perms = nil
49
+ @dir = nil
48
50
  end
49
51
  end
data/test/tc_file_stat.rb CHANGED
@@ -9,7 +9,8 @@ require 'win32/file'
9
9
 
10
10
  class TC_Win32_File_Stat < Test::Unit::TestCase
11
11
  def setup
12
- @file = 'sometestfile.txt'
12
+ @dir = File.dirname(File.expand_path(__FILE__))
13
+ @file = File.join(@dir, 'sometestfile.txt')
13
14
  end
14
15
 
15
16
  # Although I don't perform a test against a file > 2gb here (since I
@@ -86,5 +87,6 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
86
87
 
87
88
  def teardown
88
89
  @file = nil
90
+ @dir = nil
89
91
  end
90
92
  end
data/win32-file.gemspec CHANGED
@@ -2,14 +2,14 @@ require "rubygems"
2
2
 
3
3
  spec = Gem::Specification.new do |gem|
4
4
  gem.name = "win32-file"
5
- gem.version = "0.5.4"
5
+ gem.version = "0.5.5"
6
6
  gem.author = "Daniel J. Berger"
7
7
  gem.email = "djberg96@gmail.com"
8
8
  gem.homepage = "http://www.rubyforge.org/projects/win32utils"
9
9
  gem.platform = Gem::Platform::RUBY
10
10
  gem.summary = "Extra or redefined methods for the File class on Windows."
11
11
  gem.description = "Extra or redefined methods for the File class on Windows."
12
- gem.test_file = "test/ts_all.rb"
12
+ gem.test_files = Dir["test/tc*"]
13
13
  gem.has_rdoc = true
14
14
  gem.files = Dir["lib/win32/*.rb"] + Dir["test/*"] + Dir["[A-Z]*"]
15
15
  gem.files.reject! { |fn| fn.include? "CVS" }
metadata CHANGED
@@ -1,33 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0.8
3
- specification_version: 1
4
2
  name: win32-file
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.5.4
7
- date: 2007-04-08 00:00:00 -06:00
8
- summary: Extra or redefined methods for the File class on Windows.
9
- require_paths:
10
- - lib
11
- email: djberg96@gmail.com
12
- homepage: http://www.rubyforge.org/projects/win32utils
13
- rubyforge_project:
14
- description: Extra or redefined methods for the File class on Windows.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.5.5
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Daniel J. Berger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2007-11-22 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: win32-file-stat
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.2.0
23
+ version:
24
+ description: Extra or redefined methods for the File class on Windows.
25
+ email: djberg96@gmail.com
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - README
32
+ - CHANGES
31
33
  files:
32
34
  - lib/win32/file.rb
33
35
  - test/CVS
@@ -38,36 +40,44 @@ files:
38
40
  - test/tc_file_path.rb
39
41
  - test/tc_file_security.rb
40
42
  - test/tc_file_stat.rb
41
- - test/ts_all.rb
42
43
  - CHANGES
43
44
  - CVS
44
- - install.rb
45
45
  - lib
46
46
  - MANIFEST
47
47
  - Rakefile
48
48
  - README
49
49
  - test
50
50
  - win32-file.gemspec
51
- test_files:
52
- - test/ts_all.rb
51
+ has_rdoc: true
52
+ homepage: http://www.rubyforge.org/projects/win32utils
53
+ post_install_message:
53
54
  rdoc_options: []
54
55
 
55
- extra_rdoc_files:
56
- - README
57
- - CHANGES
58
- executables: []
59
-
60
- extensions: []
61
-
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
62
70
  requirements: []
63
71
 
64
- dependencies:
65
- - !ruby/object:Gem::Dependency
66
- name: win32-file-stat
67
- version_requirement:
68
- version_requirements: !ruby/object:Gem::Version::Requirement
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 1.2.0
73
- version:
72
+ rubyforge_project:
73
+ rubygems_version: 0.9.5
74
+ signing_key:
75
+ specification_version: 2
76
+ summary: Extra or redefined methods for the File class on Windows.
77
+ test_files:
78
+ - test/tc_file_attributes.rb
79
+ - test/tc_file_constants.rb
80
+ - test/tc_file_encryption.rb
81
+ - test/tc_file_path.rb
82
+ - test/tc_file_security.rb
83
+ - test/tc_file_stat.rb
data/install.rb DELETED
@@ -1,11 +0,0 @@
1
- # For those who don't like gems...
2
- require 'rbconfig'
3
- require 'ftools'
4
- include Config
5
-
6
- sitelibdir = CONFIG['sitelibdir']
7
- installdir = sitelibdir + '/win32'
8
- file = 'lib\win32\file.rb'
9
-
10
- Dir.mkdir(installdir) unless File.exists?(installdir)
11
- File.copy(file, installdir, true)
data/test/ts_all.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'tc_file_encryption'
2
- require 'tc_file_path'
3
- require 'tc_file_stat'
4
- require 'tc_file_attributes'
5
- require 'tc_file_security'
6
- require 'tc_file_constants'