win32-dir 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.3.4 - 5-May-2009
2
+ * Redefined the Dir.getwd (and the Dir.pwd alias) to always return a
3
+ normalized path.
4
+ * Some gemspec updates.
5
+
1
6
  == 0.3.3 - 30-Mar-2009
2
7
  * Virtual folders like Dir::CONTROL, which were previously almost always nil,
3
8
  are now set to their display name.
data/README CHANGED
@@ -261,7 +261,7 @@ Dir::TEMPLATES
261
261
  Ruby's
262
262
 
263
263
  == Copyright
264
- (C) 2003-2008 Daniel J. Berger, All Rights Reserved
264
+ (C) 2003-2009 Daniel J. Berger, All Rights Reserved
265
265
 
266
266
  == Warranty
267
267
  This package is provided "as is" and without any express or
data/lib/win32/dir.rb CHANGED
@@ -29,7 +29,8 @@ class Dir
29
29
  extend Windows::Limits
30
30
  extend Windows::SystemInfo
31
31
 
32
- VERSION = '0.3.3'
32
+ # The version of the win32-dir library.
33
+ VERSION = '0.3.4'
33
34
 
34
35
  # Dynamically set each of the CSIDL_ constants
35
36
  constants.grep(/CSIDL/).each{ |constant|
@@ -59,10 +60,42 @@ class Dir
59
60
 
60
61
  # Set Dir::MYDOCUMENTS to the same as Dir::PERSONAL if undefined
61
62
  unless defined? MYDOCUMENTS
63
+ # Same as Dir::PERSONAL
62
64
  MYDOCUMENTS = PERSONAL
63
65
  end
66
+
67
+ class << self
68
+ remove_method :getwd
69
+ end
70
+
71
+ # Returns the present working directory. Unlike MRI, this method always
72
+ # normalizes the path.
73
+ #
74
+ # Examples:
75
+ #
76
+ # Dir.chdir("C:/Progra~1")
77
+ # Dir.getwd # => C:\Program Files
78
+ #
79
+ # Dir.chdir("C:/PROGRAM FILES")
80
+ # Dir.getwd # => C:\Program Files
81
+ #
82
+ def self.getwd
83
+ path1 = 0.chr * MAXPATH
84
+ path2 = 0.chr * MAXPATH
85
+ path3 = 0.chr * MAXPATH
86
+
87
+ GetCurrentDirectory(MAXPATH, path1)
88
+ GetShortPathName(path1, path2, MAXPATH)
89
+ GetLongPathName(path2, path3, MAXPATH)
90
+
91
+ path3[/^[^\0]*/]
92
+ end
93
+
94
+ class << self
95
+ alias :pwd :getwd
96
+ end
64
97
 
65
- # Creates the symlink +to+, linked to the existing directory +from+. If the
98
+ # Creates the symlink +to+, linked to the existing directory +from+. If the
66
99
  # +to+ directory already exists, it must be empty or an error is raised.
67
100
  #
68
101
  def self.create_junction(to, from)
data/test/test_dir.rb CHANGED
@@ -13,11 +13,13 @@ require 'fileutils'
13
13
 
14
14
  class TC_Win32_Dir < Test::Unit::TestCase
15
15
  def self.startup
16
- Dir.chdir('test') unless File.basename(Dir.pwd) == 'test'
17
- @@from = File.join(Dir.pwd, "test_from_directory")
16
+ @@test_home = File.dirname(File.expand_path(__FILE__))
18
17
  end
19
18
 
20
19
  def setup
20
+ Dir.chdir(@@test_home) unless File.basename(Dir.pwd) == 'test'
21
+ @@from = File.join(Dir.pwd, "test_from_directory")
22
+
21
23
  @ascii_to = "test_to_directory"
22
24
  @unicode_to = "Ελλάσ" # Greek - the word is 'Hellas'
23
25
  @test_file = File.join(@@from, "test.txt")
@@ -25,7 +27,7 @@ class TC_Win32_Dir < Test::Unit::TestCase
25
27
  end
26
28
 
27
29
  def test_version
28
- assert_equal('0.3.3', Dir::VERSION)
30
+ assert_equal('0.3.4', Dir::VERSION)
29
31
  end
30
32
 
31
33
  def test_create_junction_basic
@@ -62,6 +64,36 @@ class TC_Win32_Dir < Test::Unit::TestCase
62
64
  assert_equal(true, Dir.empty?(@@from))
63
65
  end
64
66
 
67
+ def test_pwd_basic
68
+ assert_respond_to(Dir, :pwd)
69
+ assert_nothing_raised{ Dir.pwd }
70
+ assert_kind_of(String, Dir.pwd)
71
+ end
72
+
73
+ def test_pwd_short_path
74
+ Dir.chdir("C:\\Progra~1")
75
+ assert_equal("C:\\Program Files", Dir.pwd)
76
+ end
77
+
78
+ def test_pwd_long_path
79
+ Dir.chdir("C:\\Program Files")
80
+ assert_equal("C:\\Program Files", Dir.pwd)
81
+ end
82
+
83
+ def test_pwd_caps
84
+ Dir.chdir("C:\\PROGRAM FILES")
85
+ assert_equal("C:\\Program Files", Dir.pwd)
86
+ end
87
+
88
+ def test_pwd_forward_slash
89
+ Dir.chdir("C:/Program Files")
90
+ assert_equal("C:\\Program Files", Dir.pwd)
91
+ end
92
+
93
+ def test_pwd_is_proper_alias
94
+ assert_true(Dir.method(:getwd) == Dir.method(:pwd))
95
+ end
96
+
65
97
  def test_admintools
66
98
  assert_not_nil(Dir::ADMINTOOLS)
67
99
  assert_kind_of(String, Dir::ADMINTOOLS)
data/win32-dir.gemspec CHANGED
@@ -1,25 +1,31 @@
1
1
  require "rubygems"
2
2
 
3
3
  spec = Gem::Specification.new do |gem|
4
- gem.name = "win32-dir"
5
- gem.version = "0.3.3"
6
- gem.authors = ["Daniel J. Berger", "Park Heesob"]
7
- gem.email = "djberg96@gmail.com"
8
- gem.homepage = "http://www.rubyforge.org/projects/win32utils"
9
- gem.platform = Gem::Platform::RUBY
10
- gem.summary = "Extra constants and methods for the Dir class on Windows."
11
- gem.description = "Extra constants and methods for the Dir class on Windows."
12
- gem.test_file = "test/test_dir.rb"
13
- gem.has_rdoc = true
14
- gem.files = Dir["lib/win32/*.rb"] + Dir["test/*"] + Dir["[A-Z]*"]
15
- gem.files.reject! { |fn| fn.include? "CVS" }
16
- gem.require_path = "lib"
17
- gem.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
18
- gem.add_dependency("windows-pr", ">= 0.9.3")
19
- gem.rubyforge_project = "win32utils"
4
+ gem.name = 'win32-dir'
5
+ gem.version = '0.3.4'
6
+ gem.authors = ['Daniel J. Berger', 'Park Heesob']
7
+ gem.email = 'djberg96@gmail.com'
8
+ gem.homepage = 'http://www.rubyforge.org/projects/win32utils'
9
+ gem.platform = Gem::Platform::RUBY
10
+ gem.summary = 'Extra constants and methods for the Dir class on Windows.'
11
+ gem.test_file = 'test/test_dir.rb'
12
+ gem.files = Dir["lib/win32/*.rb"] + Dir["test/*"] + Dir["[A-Z]*"]
13
+
14
+ gem.rubyforge_project = 'win32utils'
15
+ gem.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
16
+
17
+ gem.add_dependency('windows-pr', '>= 0.9.3')
18
+
19
+ gem.files.reject!{ |fn| fn.include? "CVS" }
20
+
21
+ gem.description = "The win32-dir library provides extra methods and
22
+ constants for the builtin Dir class. The constants provide a convenient
23
+ way to identify certain directories across all versions of Windows. Some
24
+ methods have been added, such as the ability to create junctions. Others
25
+ have been modified to provide a more consistent result for MS Windows.".gsub(/\s+/, ' ')
20
26
  end
21
27
 
22
- if $0 == __FILE__
28
+ if $0 == __FILE__
23
29
  Gem.manage_gems if Gem::RubyGemsVersion.to_f < 1.0
24
30
  Gem::Builder.new(spec).build
25
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-dir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-03-30 00:00:00 -06:00
13
+ date: 2009-05-19 00:00:00 -06:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -23,7 +23,7 @@ dependencies:
23
23
  - !ruby/object:Gem::Version
24
24
  version: 0.9.3
25
25
  version:
26
- description: Extra constants and methods for the Dir class on Windows.
26
+ description: The win32-dir library provides extra methods and constants for the builtin Dir class. The constants provide a convenient way to identify certain directories across all versions of Windows. Some methods have been added, such as the ability to create junctions. Others have been modified to provide a more consistent result for MS Windows.
27
27
  email: djberg96@gmail.com
28
28
  executables: []
29
29
 
@@ -37,15 +37,14 @@ files:
37
37
  - lib/win32/dir.rb
38
38
  - test/test_dir.rb
39
39
  - CHANGES
40
- - examples
41
- - lib
42
40
  - MANIFEST
43
41
  - Rakefile
44
42
  - README
45
- - test
46
43
  - win32-dir.gemspec
47
44
  has_rdoc: true
48
45
  homepage: http://www.rubyforge.org/projects/win32utils
46
+ licenses: []
47
+
49
48
  post_install_message:
50
49
  rdoc_options: []
51
50
 
@@ -66,9 +65,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
65
  requirements: []
67
66
 
68
67
  rubyforge_project: win32utils
69
- rubygems_version: 1.3.1
68
+ rubygems_version: 1.3.3
70
69
  signing_key:
71
- specification_version: 2
70
+ specification_version: 3
72
71
  summary: Extra constants and methods for the Dir class on Windows.
73
72
  test_files:
74
73
  - test/test_dir.rb