pathname2 1.7.4 → 1.8.0

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: 84212bcc430946a16d891b581e2542f0612a2fb8
4
- data.tar.gz: 29523654aa88c6c8457a4e340aaf6fbcb793bee3
3
+ metadata.gz: 113b69a61947d4b98d3c4a44c1a030d2a49e193e
4
+ data.tar.gz: 03c39ef8fdfbf343c04ce7ab3da048af9f5da3db
5
5
  SHA512:
6
- metadata.gz: f533ba4680d65321f23d14353f81d181fbaf9afb04008ea84c21f53c9262a0bb66a73750f349de344522824966845c0d6f3d1eb5e405cd8b7a77b6444323352e
7
- data.tar.gz: 929e7cabf8112de8e7093323296ef4549354b652eef8ec53fef925529d4926f6cfa224ae58d91d06fe1dee1d783001559cbea6ac59a5c12601b819f0d746cf2e
6
+ metadata.gz: fec8d35e327db644ea24c8777288df0690c6e8e6d85627b7646aae83d99266bbeb0ef8c256727afd77342c89ed5cf36ca9923c444aa4c01edcb00a3d435cc98d
7
+ data.tar.gz: 80eadfb04099f368725d206f487ab3195515819053bb365173a90b7ee64a1c136e3a0cbb36bd18622174ae9d582ee125b84cf5f2b3918ecb58adadd5eb0ee72a
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGES CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.8.0 - 19-Jun-2016
2
+ * Changed license to Apache 2.0.
3
+ * Some cleanup and updates to the Rakefile and benchmarks.
4
+ * Refactored some realpath tests so they're not touching system files like
5
+ /dev/stdin any more. Thanks go to Michael R. Crusoe for pointing out the
6
+ potential pitfalls of doing that.
7
+
1
8
  == 1.7.4 - 7-Sep-2015
2
9
  * This gem is now signed.
3
10
  * Rakefile now assumes Rubygems 2.x for some tasks.
data/README CHANGED
@@ -72,21 +72,20 @@
72
72
  method that is used by the pathname2 library.
73
73
 
74
74
  == Known Issues
75
- In Ruby 1.8.3 and 1.8.4 you will see a failure in the test suite regarding
76
- 'fu_world_writable?' from FileUtils. You can ignore this. That method is
77
- supposed to be private. See ruby-core:7383.
75
+ On MS Windows, some methods may not work on pathnames greater than 260
76
+ characters because of internal function limitations.
78
77
 
79
- Any other issues should be reported on the project page at
78
+ Any issues you find should be reported on the project page at
80
79
  https://github.com/djberg96/pathname2
81
80
 
82
81
  == Future Plans
83
82
  Suggestions welcome.
84
83
 
85
84
  == License
86
- Artistic 2.0
85
+ Apache 2.0
87
86
 
88
87
  == Copyright
89
- (C) 2003-2015 Daniel J. Berger
88
+ (C) 2003-2016 Daniel J. Berger
90
89
  All rights reserved.
91
90
 
92
91
  == Warranty
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ namespace :gem do
10
10
  require 'rubygems/package'
11
11
  spec = eval(IO.read('pathname2.gemspec'))
12
12
  spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
13
- Gem::Package.build(spec)
13
+ Gem::Package.build(spec, true)
14
14
  end
15
15
 
16
16
  desc "Install the pathname2 gem"
@@ -12,7 +12,7 @@ require 'benchmark'
12
12
  require 'pathname2'
13
13
  require 'rbconfig'
14
14
 
15
- if Config::CONFIG['host_os'].match("mswin")
15
+ if RbConfig::CONFIG['host_os'] =~ /mingw|mswin/i
16
16
  path1 = Pathname.new("C:\\Program Files\\Windows NT")
17
17
  path2 = Pathname.new("Accessories")
18
18
  path3 = Pathname.new("C:\\Program Files\\..\\.\\Windows NT")
@@ -26,102 +26,102 @@ end
26
26
  MAX = 10000
27
27
 
28
28
  Benchmark.bm(25) do |bench|
29
- bench.report("Pathname.new(path)"){
30
- MAX.times{ Pathname.new("/usr/local/bin") }
31
- }
32
-
33
- bench.report("Pathname#+(Pathname)"){
34
- MAX.times{ path1 + path2 }
35
- }
36
-
37
- bench.report("Pathname#+(String)"){
38
- MAX.times{ path1 + path2 }
39
- }
40
-
41
- bench.report("Pathname#children"){
42
- MAX.times{ path1.children }
43
- }
44
-
45
- bench.report("Pathname#pstrip"){
46
- MAX.times{ path1.pstrip }
47
- }
48
-
49
- bench.report("Pathname#pstrip!"){
50
- MAX.times{ path1.pstrip! }
51
- }
52
-
53
- bench.report("Pathname#to_a"){
54
- MAX.times{ path1.to_a }
55
- }
56
-
57
- bench.report("Pathname#descend"){
58
- MAX.times{ path1.descend{} }
59
- }
60
-
61
- bench.report("Pathname#ascend"){
62
- MAX.times{ path1.ascend{} }
63
- }
64
-
65
- bench.report("Pathname#root"){
66
- MAX.times{ path1.root }
67
- }
68
-
69
- bench.report("Pathname#root?"){
70
- MAX.times{ path1.root? }
71
- }
72
-
73
- bench.report("Pathname#<=>"){
74
- MAX.times{ path1 <=> path2 }
75
- }
76
-
77
- bench.report("Pathname#absolute?"){
78
- MAX.times{ path1.absolute? }
79
- }
80
-
81
- bench.report("Pathname#relative?"){
82
- MAX.times{ path1.relative? }
83
- }
84
-
85
- bench.report("Pathname#clean"){
86
- MAX.times{ path3.clean }
87
- }
88
-
89
- bench.report("Pathname#clean!"){
90
- MAX.times{ path3.clean! }
91
- }
92
-
93
- # Platform specific tests
94
- if Config::CONFIG['host_os'].match("mswin")
95
- bench.report("Pathname.new(file_url)"){
96
- MAX.times{ Pathname.new("file:///C:/usr/local/bin") }
97
- }
98
-
99
- bench.report("Pathname#drive_number"){
100
- MAX.times{ path1.drive_number }
101
- }
102
-
103
- bench.report("Pathname#unc?"){
104
- MAX.times{ path1.unc? }
105
- }
106
-
107
- bench.report("Pathname#undecorate"){
108
- MAX.times{ path1.undecorate }
109
- }
110
-
111
- bench.report("Pathname#undecorate!"){
112
- MAX.times{ path1.undecorate! }
113
- }
114
-
115
- bench.report("Pathname#short_path"){
116
- MAX.times{ path1.short_path }
117
- }
118
-
119
- bench.report("Pathname#long_path"){
120
- MAX.times{ path1.long_path }
121
- }
122
- else
123
- bench.report("Pathname#realpath"){
124
- MAX.times{ path4.realpath }
125
- }
126
- end
29
+ bench.report("Pathname.new(path)"){
30
+ MAX.times{ Pathname.new("/usr/local/bin") }
31
+ }
32
+
33
+ bench.report("Pathname#+(Pathname)"){
34
+ MAX.times{ path1 + path2 }
35
+ }
36
+
37
+ bench.report("Pathname#+(String)"){
38
+ MAX.times{ path1 + path2 }
39
+ }
40
+
41
+ bench.report("Pathname#children"){
42
+ MAX.times{ path1.children }
43
+ }
44
+
45
+ bench.report("Pathname#pstrip"){
46
+ MAX.times{ path1.pstrip }
47
+ }
48
+
49
+ bench.report("Pathname#pstrip!"){
50
+ MAX.times{ path1.pstrip! }
51
+ }
52
+
53
+ bench.report("Pathname#to_a"){
54
+ MAX.times{ path1.to_a }
55
+ }
56
+
57
+ bench.report("Pathname#descend"){
58
+ MAX.times{ path1.descend{} }
59
+ }
60
+
61
+ bench.report("Pathname#ascend"){
62
+ MAX.times{ path1.ascend{} }
63
+ }
64
+
65
+ bench.report("Pathname#root"){
66
+ MAX.times{ path1.root }
67
+ }
68
+
69
+ bench.report("Pathname#root?"){
70
+ MAX.times{ path1.root? }
71
+ }
72
+
73
+ bench.report("Pathname#<=>"){
74
+ MAX.times{ path1 <=> path2 }
75
+ }
76
+
77
+ bench.report("Pathname#absolute?"){
78
+ MAX.times{ path1.absolute? }
79
+ }
80
+
81
+ bench.report("Pathname#relative?"){
82
+ MAX.times{ path1.relative? }
83
+ }
84
+
85
+ bench.report("Pathname#clean"){
86
+ MAX.times{ path3.clean }
87
+ }
88
+
89
+ bench.report("Pathname#clean!"){
90
+ MAX.times{ path3.clean! }
91
+ }
92
+
93
+ # Platform specific tests
94
+ if RbConfig::CONFIG['host_os'] =~ /mingw|mswin/i
95
+ bench.report("Pathname.new(file_url)"){
96
+ MAX.times{ Pathname.new("file:///C:/usr/local/bin") }
97
+ }
98
+
99
+ bench.report("Pathname#drive_number"){
100
+ MAX.times{ path1.drive_number }
101
+ }
102
+
103
+ bench.report("Pathname#unc?"){
104
+ MAX.times{ path1.unc? }
105
+ }
106
+
107
+ bench.report("Pathname#undecorate"){
108
+ MAX.times{ path1.undecorate }
109
+ }
110
+
111
+ bench.report("Pathname#undecorate!"){
112
+ MAX.times{ path1.undecorate! }
113
+ }
114
+
115
+ bench.report("Pathname#short_path"){
116
+ MAX.times{ path1.short_path }
117
+ }
118
+
119
+ bench.report("Pathname#long_path"){
120
+ MAX.times{ path1.long_path }
121
+ }
122
+ else
123
+ bench.report("Pathname#realpath"){
124
+ MAX.times{ path4.realpath }
125
+ }
126
+ end
127
127
  end
@@ -93,7 +93,7 @@ class Pathname < String
93
93
  public
94
94
 
95
95
  # The version of the pathname2 library
96
- VERSION = '1.7.4'
96
+ VERSION = '1.8.0'
97
97
 
98
98
  # The maximum length of a path
99
99
  MAXPATH = 1024 unless defined? MAXPATH # Yes, I willfully violate POSIX
@@ -2,9 +2,9 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'pathname2'
5
- spec.version = '1.7.4'
5
+ spec.version = '1.8.0'
6
6
  spec.author = 'Daniel J. Berger'
7
- spec.license = 'Artistic 2.0'
7
+ spec.license = 'Apache 2.0'
8
8
  spec.email = 'djberg96@gmail.com'
9
9
  spec.homepage = 'https://github.com/djberg96/pathname2'
10
10
  spec.summary = 'An alternate implementation of the Pathname class'
@@ -5,6 +5,7 @@
5
5
  # should be run via the test rake task.
6
6
  ##############################################################################
7
7
  require 'pathname2'
8
+ require 'fileutils'
8
9
  require 'rbconfig'
9
10
  require 'test-unit'
10
11
  include RbConfig
@@ -30,6 +31,10 @@ class TC_Pathname < Test::Unit::TestCase
30
31
  @rel_array = []
31
32
 
32
33
  @mypath = MyPathname.new('/usr/bin')
34
+
35
+ @test_file = 'realpath_test.txt'
36
+ @link_file = 'realpath_symlink.txt'
37
+ @link_file2 = 'realpath_symlink2.txt'
33
38
  end
34
39
 
35
40
  # Convenience method to verify that the receiver was not modified
@@ -62,41 +67,30 @@ class TC_Pathname < Test::Unit::TestCase
62
67
 
63
68
  # Convenience method for test_relative_path_from_expected_errors
64
69
  def assert_relpath_err(to, from)
65
- assert_raise(ArgumentError) {
66
- Pathname.new(to).relative_path_from(from)
67
- }
70
+ assert_raise(ArgumentError) { Pathname.new(to).relative_path_from(from) }
68
71
  end
69
72
 
70
- def test_file_url_path
73
+ test "url_path returns expected result" do
71
74
  assert_equal('/foo bar/baz', @url_path)
72
75
  end
73
76
 
74
- def test_realpath
77
+ test "realpath basic functionality" do
78
+ FileUtils.touch(@test_file) && File.symlink(@test_file, @link_file)
75
79
  assert_respond_to(@abs_path, :realpath)
76
80
  assert_equal(@@pwd, Pathname.new('.').realpath)
77
- assert_kind_of(Pathname, Pathname.new('/dev/stdin').realpath)
78
- assert(Pathname.new('/dev/stdin') != Pathname.new('/dev/stdin').realpath)
79
- if CONFIG['host_os'] =~ /bsd|darwin|mac/i
80
- assert_raises(Errno::ENOENT){ Pathname.new('../blahblah/bogus').realpath }
81
- else
82
- assert_raises(Errno::ENOENT){ Pathname.new('../bogus').realpath }
83
- end
84
- end
85
-
86
- def test_realpath_platform
87
- case CONFIG['host_os']
88
- when /linux/i
89
- path1 = '/dev/stdin'
90
- assert_true(['/dev/pts/0', '/dev/proc/self/fd/0'].include?(Pathname.new(path1).realpath))
91
- when /sunos|solaris/i
92
- path1 = '/dev/null'
93
- path2 = '/dev/stdin'
94
- path3 = '/dev/fd0' # Multiple symlinks
95
-
96
- assert_equal('/devices/pseudo/mm@0:null', Pathname.new(path1).realpath)
97
- assert_equal('/dev/fd/0', Pathname.new(path2).realpath)
98
- assert_equal('/devices/pci@1f,0/isa@7/dma@0,0/floppy@0,3f0:c', Pathname.new(path3).realpath)
99
- end
81
+ assert_kind_of(Pathname, Pathname.new(@link_file).realpath)
82
+ end
83
+
84
+ test "realpath returns expected result for simple symlink" do
85
+ FileUtils.touch(@test_file) && File.symlink(@test_file, @link_file)
86
+ assert_true(Pathname.new(@link_file) != Pathname.new(@link_file).realpath)
87
+ assert_raises(Errno::ENOENT){ Pathname.new('../bogus').realpath }
88
+ end
89
+
90
+ test "realpath returns expected result for nested symlink" do
91
+ FileUtils.touch(@test_file) && File.symlink(@test_file, @link_file) && File.symlink(@link_file, @link_file2)
92
+ assert_true(Pathname.new(@link_file) != Pathname.new(@link_file2).realpath)
93
+ assert_equal(Pathname.new(@link_file).realpath, Pathname.new(@link_file2).realpath)
100
94
  end
101
95
 
102
96
  # These tests taken directly from Tanaka's pathname.rb. The one failure
@@ -476,6 +470,14 @@ class TC_Pathname < Test::Unit::TestCase
476
470
  @mypath = nil
477
471
  @abs_array.clear
478
472
  @rel_array.clear
473
+
474
+ File.delete(@link_file2) if File.exist?(@link_file2)
475
+ File.delete(@link_file) if File.exist?(@link_file)
476
+ File.delete(@test_file) if File.exist?(@test_file)
477
+
478
+ @link_file2 = nil
479
+ @link_file = nil
480
+ @test_file = nil
479
481
  end
480
482
 
481
483
  def self.shutdown
@@ -8,6 +8,6 @@ require 'test-unit'
8
8
 
9
9
  class TC_Pathname_Version < Test::Unit::TestCase
10
10
  test "version is set to expected value" do
11
- assert_equal('1.7.4', Pathname::VERSION)
11
+ assert_equal('1.8.0', Pathname::VERSION)
12
12
  end
13
13
  end
@@ -51,11 +51,11 @@ class TC_Pathname_Facade < Test::Unit::TestCase
51
51
  assert_respond_to(@path, :sysopen)
52
52
  end
53
53
 
54
- test "exists? facade works as expected" do
55
- assert_respond_to(@path, :exists?)
56
- assert_nothing_raised{ @path.exists? }
57
- assert_true(Pathname.new("C:\\").exists?)
58
- assert_false(Pathname.new("X:\\foo\\bar\\baz").exists?)
54
+ test "exist? facade works as expected" do
55
+ assert_respond_to(@path, :exist?)
56
+ assert_nothing_raised{ @path.exist? }
57
+ assert_true(Pathname.new("C:\\").exist?)
58
+ assert_false(Pathname.new("X:\\foo\\bar\\baz").exist?)
59
59
  end
60
60
 
61
61
  def teardown
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pathname2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.4
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -30,7 +30,7 @@ cert_chain:
30
30
  EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
31
31
  tGSHgAmcLlkdGgan182qsE/4kKM=
32
32
  -----END CERTIFICATE-----
33
- date: 2015-09-07 00:00:00.000000000 Z
33
+ date: 2016-06-19 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: facade
@@ -90,18 +90,24 @@ extra_rdoc_files:
90
90
  - CHANGES
91
91
  - MANIFEST
92
92
  files:
93
- - CHANGES
94
- - MANIFEST
95
- - README
96
- - Rakefile
93
+ - benchmarks
97
94
  - benchmarks/bench_pathname.rb
98
95
  - benchmarks/bench_plus.rb
96
+ - certs
99
97
  - certs/djberg96_pub.pem
98
+ - CHANGES
99
+ - examples
100
100
  - examples/example_pathname.rb
101
+ - lib
101
102
  - lib/pathname2.rb
103
+ - MANIFEST
102
104
  - pathname2.gemspec
105
+ - Rakefile
106
+ - README
107
+ - test
103
108
  - test/test_pathname.rb
104
109
  - test/test_version.rb
110
+ - test/windows
105
111
  - test/windows/test_append.rb
106
112
  - test/windows/test_aref.rb
107
113
  - test/windows/test_ascend.rb
@@ -132,7 +138,7 @@ files:
132
138
  - test/windows/test_undecorate_bang.rb
133
139
  homepage: https://github.com/djberg96/pathname2
134
140
  licenses:
135
- - Artistic 2.0
141
+ - Apache 2.0
136
142
  metadata: {}
137
143
  post_install_message:
138
144
  rdoc_options: []
@@ -150,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
156
  version: '0'
151
157
  requirements: []
152
158
  rubyforge_project:
153
- rubygems_version: 2.4.5
159
+ rubygems_version: 2.6.4
154
160
  signing_key:
155
161
  specification_version: 4
156
162
  summary: An alternate implementation of the Pathname class
metadata.gz.sig CHANGED
Binary file