win32-xpath 1.1.0 → 1.2.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
- SHA1:
3
- metadata.gz: a356787d2a824c84435d4e0030d2332bc0e608c7
4
- data.tar.gz: aa3c03d68d1cf089ec4cf98e459305d1b23e5f83
2
+ SHA256:
3
+ metadata.gz: 3a5dc7b8cc4b32f0a194fd62a9c727ab8bed0eebf29b8923ff233de95230830a
4
+ data.tar.gz: 6259f5d6e3c91df4397946658d38a82c7dd3d3d862680819a15e87b0d3caffca
5
5
  SHA512:
6
- metadata.gz: 319c66c30e057d2b7dfdc0fd92146981939e8231dc8337d8d6e8232ccc9ec49678de0713ea7ebcd631e33ffa95839b2bd0773c0bf665c6d8a47dd20ef5b57f27
7
- data.tar.gz: 3d56bec08b78598926082214bed54e7631147c22e676d0f09fc794d5b05ef919d44263ad0d7a28e456dd426296a5e95c9419b831dcf8aecebce96dd1b09786c1
6
+ metadata.gz: babfea80ca48c92b191ec5179ebe3088a8f3a0a05b25191f67d1ea1f8ec4a29573dd347236e858ce7cd6a2515cc31729f19e38f4b944a7dba9b5ad93cca5ed81
7
+ data.tar.gz: 50468708592d798e43fb430eba9061ee40b8a9f01090eaa06095d2bd821fc931f62d09eb95515276bca79116d1509d87fbd719c2fd2d2bfcfdae674727169a98
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md ADDED
@@ -0,0 +1,40 @@
1
+ ## 1.2.0 - 9-Jul-2022
2
+ * Convert tests from test-unit to rspec, and update gemspec and Rakefile accordingly.
3
+
4
+ ## 1.1.2 - 8-Aug-2021
5
+ * The relative path directory argument now accepts anything that responds
6
+ to the to_path method.
7
+ * Now skips taint checking tests on Ruby 2.7+
8
+ * Added a .gitignore file.
9
+
10
+ ## 1.1.1 - 3-Mar-2019
11
+ * Switched RSTRING_PTR to StringValueCStr internally because apparently I
12
+ I didn't get the memo on null termination changes.
13
+ * Fixed a warning caused by rb_funcall by switching it to rb_funcall2.
14
+ * Fixed a bug where it would try to expand tildes for paths in 8.3 format.
15
+ Now tildes are only expanded if they are the first character in the path.
16
+ * Updated the cert.
17
+ * Updated the appveyor file to include Ruby 2.3, 2.4 and 2.5.
18
+ * Added a win32-xpath.rb file for convenience.
19
+
20
+ ## 1.1.0 - 11-Jun-2016
21
+ * Changed license to Apache 2.0.
22
+ * Use PathCchXXX functions wherever I could that had not already been
23
+ put into place.
24
+ * Removed the "futzing" directory and contents.
25
+ * Added an appveyor.yml file.
26
+
27
+ ## 1.0.4 - 26-Nov-2015
28
+ * This gem is now signed.
29
+
30
+ ## 1.0.3 - 3-Jul-2015
31
+ * Use PathCchXXX functions where available to improve long path handling.
32
+
33
+ ## 1.0.2 - 17-Jun-2015
34
+ * Deal with non-standard swprintf issues so that it works with mingw compiler.
35
+
36
+ ## 1.0.1 - 2-Apr-2015
37
+ * Altered internal handling of native C function failures.
38
+
39
+ ## 1.0.0 - 26-Feb-2015
40
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
data/MANIFEST.md ADDED
@@ -0,0 +1,14 @@
1
+ * appveyor.yml
2
+ * bench/bench_win32_xpath.rb
3
+ * CHANGES.md
4
+ * certs/djberg96_pub.pem
5
+ * ext/extconf.rb
6
+ * ext/win32/xpath.c
7
+ * Gemfile
8
+ * lib/win32-xpath.rb
9
+ * LICENSE
10
+ * MANIFEST.md
11
+ * Rakefile
12
+ * README.md
13
+ * test/test_win32_xpath.rb
14
+ * win32-xpath.gemspec
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ ## Description
2
+ A custom `File.expand_path` method for Ruby on Windows that's much faster and works better.
3
+
4
+ ## Installation
5
+ `gem install win32-xpath`
6
+
7
+ ## Adding the Trusted Cert
8
+ `gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/win32-xpath/main/certs/djberg96_pub.pem)`
9
+
10
+ ## Synopsis
11
+ ```ruby
12
+ require 'win32/xpath'
13
+
14
+ # That's it, you are now using this library when you call File.expand_path
15
+ ```
16
+
17
+ ## Features
18
+ * A 5x average performance boost over MRI's current method.
19
+ * Support for ~user expansion.
20
+
21
+ ## Known Issues
22
+ * This library does not support drive-current paths for the 2nd argument.
23
+ * This library does not support alt-stream name autocorrection.
24
+ * This library does not convert short paths to long paths.
25
+
26
+ It is very unlikely you will ever be affected by any of these things.
27
+ Drive-current paths are a relic of DOS 1.0, but even so this library
28
+ will handle them in the first argument.
29
+
30
+ I don't support alt-stream mangling because I don't believe it's the
31
+ job of this method to peform autocorrection. Even in MRI it only works
32
+ for the default $DATA stream, and then only for a certain type of
33
+ syntax error. I do not know when or why it was added.
34
+
35
+ Failure to convert short paths to long paths is irrelevant since that
36
+ has nothing to do with relative versus absolute paths.
37
+
38
+ One possible "real" issue is that on Windows 7 or earlier you will be
39
+ limited to 260 character paths. This is a limitation of the shlwapi.h
40
+ functions that I use internally.
41
+
42
+ If you discover any other issues, please report them on the project
43
+ page at https://github.com/djberg96/win32-xpath.
44
+
45
+ ## Mingw and Devkit
46
+ Make sure you have a recent version of the Devkit installed if you're
47
+ using the one-click installer. If you see this warning then you need
48
+ to upgrade your Devkit.
49
+
50
+ `"implicit declaration of function 'ConvertSidToStringSidW'"`
51
+
52
+ ## Acknowledgements
53
+ Park Heesob for encoding advice and help.
54
+
55
+ ## License
56
+ Apache-2.0
57
+
58
+ ## Copyright
59
+ (C) 2003-2022 Daniel J. Berger, All Rights Reserved
60
+
61
+ ## Warranty
62
+ This package is provided "as is" and without any express or
63
+ implied warranties, including, without limitation, the implied
64
+ warranties of merchantability and fitness for a particular purpose.
65
+
66
+ ## Author
67
+ Daniel Berger
data/Rakefile CHANGED
@@ -1,12 +1,13 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
- require 'rake/testtask'
4
3
  require 'rbconfig'
4
+ require 'rspec/core/rake_task'
5
5
  include RbConfig
6
6
 
7
7
  CLEAN.include(
8
8
  '**/*.gem', # Gem files
9
9
  '**/*.rbc', # Rubinius
10
+ '**/*.lock', # Bundler
10
11
  '**/*.o', # C object file
11
12
  '**/*.log', # Ruby extension build log
12
13
  '**/Makefile', # C Makefile
@@ -35,9 +36,9 @@ namespace :gem do
35
36
  desc "Build the win32-xpath gem"
36
37
  task :create => [:clean] do
37
38
  require 'rubygems/package'
38
- spec = eval(IO.read('win32-xpath.gemspec'))
39
+ spec = Gem::Specification.load('win32-xpath.gemspec')
39
40
  spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
40
- Gem::Package.build(spec, true)
41
+ Gem::Package.build(spec)
41
42
  end
42
43
 
43
44
  task "Install the win32-xpath gem"
@@ -47,15 +48,14 @@ namespace :gem do
47
48
  end
48
49
  end
49
50
 
50
- Rake::TestTask.new do |t|
51
- task :test => [:build]
52
- t.test_files = FileList['test/*']
53
- t.libs << 'ext'
54
- end
55
-
56
51
  desc "Run benchmarks"
57
52
  task :bench => [:build] do
58
53
  ruby "-Iext bench/bench_win32_xpath.rb"
59
54
  end
60
55
 
61
- task :default => :test
56
+ desc "Run the test suite"
57
+ RSpec::Core::RakeTask.new(:spec) do |t|
58
+ t.rspec_opts = '-Iext'
59
+ end
60
+
61
+ task :default => [:build, :spec]
data/appveyor.yml CHANGED
@@ -2,17 +2,18 @@ version: '{build}'
2
2
  branches:
3
3
  only:
4
4
  - master
5
+ - appveyor
5
6
  skip_tags: true
6
7
  environment:
7
8
  matrix:
8
- - ruby_version: 21
9
- ruby_dir: 2.1.0
10
- - ruby_version: 21-x64
11
- ruby_dir: 2.1.0
12
- - ruby_version: 22
13
- ruby_dir: 2.2.0
14
9
  - ruby_version: 22-x64
15
10
  ruby_dir: 2.2.0
11
+ - ruby_version: 23-x64
12
+ ruby_dir: 2.3.0
13
+ - ruby_version: 24-x64
14
+ ruby_dir: 2.4.0
15
+ - ruby_version: 25-x64
16
+ ruby_dir: 2.5.0
16
17
  install:
17
18
  - ps: >-
18
19
  $env:path = "C:\Ruby" + $env:ruby_version + "\bin;" + $env:path
@@ -25,10 +26,10 @@ install:
25
26
 
26
27
  if ((gem query -i test-unit -v ">= 3.0") -eq $False){ gem install test-unit --no-document }
27
28
  cache:
28
- - C:\Ruby21\lib\ruby\gems\2.1.0
29
- - C:\Ruby21-x64\lib\ruby\gems\2.1.0
30
- - C:\Ruby22\lib\ruby\gems\2.2.0
31
29
  - C:\Ruby22-x64\lib\ruby\gems\2.2.0
30
+ - C:\Ruby23-x64\lib\ruby\gems\2.3.0
31
+ - C:\Ruby24-x64\lib\ruby\gems\2.4.0
32
+ - C:\Ruby25-x64\lib\ruby\gems\2.5.0
32
33
  build: off
33
34
  test_script:
34
35
  - cmd: rake
@@ -1,6 +1,6 @@
1
1
  require 'benchmark'
2
2
 
3
- MAX = 100000
3
+ MAX = 400000
4
4
  puts "\nOld File.expand_path"
5
5
 
6
6
  Benchmark.bm(30) do |x|
@@ -1,21 +1,26 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
2
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
3
3
  cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
4
- MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTIwNDkxOFowPzERMA8GA1UEAwwIZGpi
4
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
5
5
  ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
6
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyTkvXqRp6hLs9eoJOS
7
- Hmi8kRYbq9Vkf15/hMxJpotYMgJVHHWrmDcC5Dye2PbnXjTkKf266Zw0PtT9h+lI
8
- S3ts9HO+vaCFSMwFFZmnWJSpQ3CNw2RcHxjWkk9yF7imEM8Kz9ojhiDXzBetdV6M
9
- gr0lV/alUr7TNVBDngbXEfTWscyXh1qd7xZ4EcOdsDktCe5G45N/o3662tPQvJsi
10
- FOF0CM/KuBsa/HL1/eoEmF4B3EKIRfTHrQ3hu20Kv3RJ88QM4ec2+0dd97uX693O
11
- zv6981fyEg+aXLkxrkViM/tz2qR2ZE0jPhHTREPYeMEgptRkTmWSKAuLVWrJEfgl
12
- DtkCAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFEwe
13
- nn6bfJADmuIDiMSOzedOrL+xMB0GA1UdEQQWMBSBEmRqYmVyZzk2QGdtYWlsLmNv
14
- bTAdBgNV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DAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
16
+ AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
17
+ YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
18
+ /3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
19
+ h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
20
+ 6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
21
+ ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
22
+ 1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
23
+ DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
24
+ ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
25
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
21
26
  -----END CERTIFICATE-----
data/ext/win32/xpath.c CHANGED
@@ -201,12 +201,16 @@ static VALUE rb_xpath(int argc, VALUE* argv, VALUE self){
201
201
  rb_scan_args(argc, argv, "11", &v_path_orig, &v_dir_orig);
202
202
 
203
203
  if (rb_respond_to(v_path_orig, rb_intern("to_path")))
204
- v_path_orig = rb_funcall(v_path_orig, rb_intern("to_path"), 0, NULL);
204
+ v_path_orig = rb_funcall2(v_path_orig, rb_intern("to_path"), 0, NULL);
205
205
 
206
206
  SafeStringValue(v_path_orig);
207
207
 
208
- if (!NIL_P(v_dir_orig))
208
+ if (!NIL_P(v_dir_orig)){
209
+ if (rb_respond_to(v_dir_orig, rb_intern("to_path")))
210
+ v_dir_orig = rb_funcall2(v_dir_orig, rb_intern("to_path"), 0, NULL);
211
+
209
212
  SafeStringValue(v_dir_orig);
213
+ }
210
214
 
211
215
  // Dup and prep string for modification
212
216
  path_encoding = rb_enc_get(v_path_orig);
@@ -223,10 +227,10 @@ static VALUE rb_xpath(int argc, VALUE* argv, VALUE self){
223
227
  rb_str_modify_expand(v_path, MAX_WPATH);
224
228
 
225
229
  // Make our path a wide string for later functions
226
- length = MultiByteToWideChar(CP_UTF8, 0, RSTRING_PTR(v_path), -1, NULL, 0);
230
+ length = MultiByteToWideChar(CP_UTF8, 0, StringValueCStr(v_path), -1, NULL, 0);
227
231
  path = (wchar_t*)ruby_xmalloc(length * sizeof(wchar_t));
228
232
 
229
- if(!MultiByteToWideChar(CP_UTF8, 0, RSTRING_PTR(v_path), -1, path, length)){
233
+ if(!MultiByteToWideChar(CP_UTF8, 0, StringValueCStr(v_path), -1, path, length)){
230
234
  ruby_xfree(path);
231
235
  rb_raise_syserr("MultibyteToWideChar", GetLastError());
232
236
  }
@@ -235,8 +239,8 @@ static VALUE rb_xpath(int argc, VALUE* argv, VALUE self){
235
239
  while(wcsstr(path, L"/"))
236
240
  path[wcscspn(path, L"/")] = L'\\';
237
241
 
238
- // Handle ~ expansion.
239
- if (ptr = wcschr(path, L'~')){
242
+ // Handle ~ expansion if first character.
243
+ if ( (ptr = wcschr(path, L'~')) && ((int)(ptr - path) == 0) ){
240
244
  wchar_t* home;
241
245
 
242
246
  // Handle both ~/user and ~user syntax
@@ -291,10 +295,10 @@ static VALUE rb_xpath(int argc, VALUE* argv, VALUE self){
291
295
  // Prep string for modification
292
296
  rb_str_modify_expand(v_dir, MAX_WPATH);
293
297
 
294
- length = MultiByteToWideChar(CP_UTF8, 0, RSTRING_PTR(v_dir), -1, NULL, 0);
298
+ length = MultiByteToWideChar(CP_UTF8, 0, StringValueCStr(v_dir), -1, NULL, 0);
295
299
  dir = (wchar_t*)ruby_xmalloc(MAX_WPATH * sizeof(wchar_t));
296
300
 
297
- if (!MultiByteToWideChar(CP_UTF8, 0, RSTRING_PTR(v_dir), -1, dir, length)){
301
+ if (!MultiByteToWideChar(CP_UTF8, 0, StringValueCStr(v_dir), -1, dir, length)){
298
302
  ruby_xfree(dir);
299
303
  rb_raise_syserr("MultibyteToWideChar", GetLastError());
300
304
  }
@@ -302,7 +306,8 @@ static VALUE rb_xpath(int argc, VALUE* argv, VALUE self){
302
306
  while (wcsstr(dir, L"/"))
303
307
  dir[wcscspn(dir, L"/")] = L'\\';
304
308
 
305
- if (ptr = wcschr(dir, L'~')){
309
+ // Check for tilde in first character
310
+ if ( (ptr = wcschr(dir, L'~')) && ((int)(ptr - dir) == 0) ){
306
311
  if (ptr[1] && ptr[1] != L'\\'){
307
312
  dir = find_user(++ptr);
308
313
  }
@@ -0,0 +1 @@
1
+ require 'win32/xpath'
@@ -0,0 +1,213 @@
1
+ require 'rspec'
2
+ require 'tmpdir'
3
+ require 'win32/xpath'
4
+ require 'etc'
5
+
6
+ RSpec.describe 'win32-xpath' do
7
+ let!(:login) { Etc.getlogin }
8
+ let!(:env){ ENV.to_h }
9
+
10
+ before do
11
+ @pwd = Dir.pwd
12
+ @tmp = 'C:/Temp'
13
+ @root = 'C:/'
14
+ @drive = env['HOMEDRIVE']
15
+ @home = env['HOME'].tr('\\', '/')
16
+ @unc = "//foo/bar"
17
+ ENV['HOME'] = env['USERPROFILE'] || Dir.home
18
+ end
19
+
20
+ after do
21
+ ENV.replace(env)
22
+ end
23
+
24
+ example "converts an empty pathname into absolute current pathname" do
25
+ expect(File.expand_path('')).to eq(@pwd)
26
+ end
27
+
28
+ example "converts '.' into absolute pathname using current directory" do
29
+ expect(File.expand_path('.')).to eq(@pwd)
30
+ end
31
+
32
+ example "converts relative path into absolute pathname using current directory" do
33
+ expect(File.expand_path('foo')).to eq(File.join(@pwd, 'foo'))
34
+ end
35
+
36
+ example "converts relative path into absolute pathname ignoring nil dir" do
37
+ expect(File.expand_path('foo', nil)).to eq(File.join(@pwd, 'foo'))
38
+ end
39
+
40
+ example "converts relative path and directory into the expected absolute pathname" do
41
+ expect(File.expand_path('foo', 'bar')).to eq(File.join(@pwd, 'bar', 'foo'))
42
+ end
43
+
44
+ example "converts relative edge case pathnames into absolute pathnames" do
45
+ expect(File.expand_path('a.')).to eq(File.join(@pwd, 'a'))
46
+ expect(File.expand_path('.a')).to eq(File.join(@pwd, '.a'))
47
+ expect(File.expand_path('..a')).to eq(File.join(@pwd, '..a'))
48
+ expect(File.expand_path('a../b')).to eq(File.join(@pwd, 'a../b'))
49
+ end
50
+
51
+ example "converts a double dot pathname into the expected absolute pathname" do
52
+ expect( File.expand_path('a..')).to eq(File.join(@pwd, 'a'))
53
+ end
54
+
55
+ example "converts a pathname to an absolute pathname using a complete path" do
56
+ expect(File.expand_path('', @tmp)).to eq(@tmp)
57
+ expect(File.expand_path('a', @tmp)).to eq(File.join(@tmp, 'a'))
58
+ expect(File.expand_path('../a', "#{@tmp}/xxx")).to eq(File.join(@tmp, 'a'))
59
+ expect(File.expand_path('.', @root)).to eq(@root)
60
+ end
61
+
62
+ example "ignores supplied dir if path contains a drive letter" do
63
+ expect(File.expand_path(@root, "D:/")).to eq(@root)
64
+ end
65
+
66
+ example "removes trailing slashes from absolute path" do
67
+ expect(File.expand_path("#{@root}foo/")).to eq(File.join(@root, 'foo'))
68
+ expect(File.expand_path("#{@root}foo.rb/")).to eq(File.join(@root, 'foo.rb'))
69
+ end
70
+
71
+ example "removes trailing slashes from relative path" do
72
+ expect(File.expand_path("foo/")).to eq(File.join(@pwd, 'foo'))
73
+ expect(File.expand_path("foo//")).to eq(File.join(@pwd, 'foo'))
74
+ expect(File.expand_path("foo\\\\\\")).to eq(File.join(@pwd, 'foo'))
75
+ end
76
+
77
+ example "removes trailing spaces from absolute path" do
78
+ expect(File.expand_path("#{@root}foo ")).to eq(File.join(@root, 'foo'))
79
+ end
80
+
81
+ example "removes trailing dots from absolute path" do
82
+ expect(File.expand_path("#{@root}a.")).to eq(File.join(@root, 'a'))
83
+ end
84
+
85
+ example "converts a pathname with a drive letter but no slash" do
86
+ expect(File.expand_path("c:")).to match(/\Ac:\//i)
87
+ end
88
+
89
+ example "converts a pathname with a drive letter ignoring different drive dir" do
90
+ expect(File.expand_path("c:foo", "d:/bar")).to match(/\Ac:\//i)
91
+ end
92
+
93
+ example "converts a pathname which starts with a slash using current drive" do
94
+ expect(File.expand_path('/foo')).to match(/\A#{@drive}\/foo\z/i)
95
+ end
96
+
97
+ example "returns tainted strings or not" do
98
+ skip "Skipping on Ruby 2.7+" if RUBY_VERSION.to_f >= 2.7
99
+ expect(File.expand_path('foo').tainted?).to be true
100
+ expect(File.expand_path('foo'.taint).tainted?).to be true
101
+ expect(File.expand_path('/foo').tainted?).to be true
102
+ expect(File.expand_path('/foo'.taint).tainted?).to be true
103
+ expect(File.expand_path('C:/foo'.taint).tainted?).to be true
104
+ expect(File.expand_path('C:/foo').tainted?).to be false
105
+ expect(File.expand_path('//foo').tainted?).to be false
106
+ end
107
+
108
+ example "converts a pathname to an absolute pathname using tilde as base" do
109
+ expect(File.expand_path('~')).to eq(@home)
110
+ expect(File.expand_path('~/foo')).to eq("#{@home}/foo")
111
+ expect(File.expand_path('~/.foo')).to eq("#{@home}/.foo")
112
+ end
113
+
114
+ example "converts a pathname to an absolute pathname using tilde for UNC path" do
115
+ ENV['HOME'] = @unc
116
+ expect(File.expand_path('~')).to eq(@unc)
117
+ end
118
+
119
+ example "converts a tilde to path if used for dir argument" do
120
+ expect(File.expand_path('', '~')).to eq(@home)
121
+ expect(File.expand_path('', '~/foo')).to eq("#{@home}/foo")
122
+ expect(File.expand_path('foo', '~')).to eq("#{@home}/foo")
123
+ end
124
+
125
+ example "doesn't attempt to expand a tilde unless it's the first character" do
126
+ expect(File.expand_path("C:/Progra~1")).to eq("C:/Progra~1")
127
+ expect(File.expand_path("C:/Progra~1", "C:/Progra~1")).to eq("C:/Progra~1")
128
+ end
129
+
130
+ example "does not modify a HOME string argument" do
131
+ str = "~/a"
132
+ expect(File.expand_path(str)).to eq("#{@home}/a")
133
+ expect(str).to eq("~/a")
134
+ end
135
+
136
+ example "defaults to HOMEDRIVE + HOMEPATH if HOME or USERPROFILE are nil" do
137
+ ENV['HOME'] = nil
138
+ ENV['USERPROFILE'] = nil
139
+ ENV['HOMEDRIVE'] = "C:"
140
+ ENV['HOMEPATH'] = "\\Users\\foo"
141
+ expect(File.expand_path("~/bar")).to eq("C:/Users/foo/bar")
142
+ end
143
+
144
+ example "raises ArgumentError when HOME is nil" do
145
+ ENV['HOME'] = nil
146
+ ENV['USERPROFILE'] = nil
147
+ ENV['HOMEDRIVE'] = nil
148
+ expect{ File.expand_path('~') }.to raise_error(ArgumentError)
149
+ end
150
+
151
+ example "raises ArgumentError if HOME is relative" do
152
+ ENV['HOME'] = '.'
153
+ expect{ File.expand_path('~') }.to raise_error(ArgumentError)
154
+ end
155
+
156
+ example "raises ArgumentError if relative HOME path with tilde + user is provided" do
157
+ ENV['HOME'] = 'whatever'
158
+ expect{ File.expand_path('~anything') }.to raise_error(ArgumentError)
159
+ end
160
+
161
+ example "raises an ArgumentError if a bogus username is supplied" do
162
+ expect{ File.expand_path('~anything') }.to raise_error(ArgumentError)
163
+ end
164
+
165
+ example "converts a tilde plus username as expected" do
166
+ expect(File.expand_path("~#{login}")).to eq("C:/Users/#{login}")
167
+ expect(File.expand_path("~#{login}/foo")).to eq("C:/Users/#{login}/foo")
168
+ end
169
+
170
+ example "raises a TypeError if not passed a string" do
171
+ expect{ File.expand_path(1) }.to raise_error(TypeError)
172
+ expect{ File.expand_path(nil) }.to raise_error(TypeError)
173
+ expect{ File.expand_path(true) }.to raise_error(TypeError)
174
+ end
175
+
176
+ example "canonicalizes absolute path" do
177
+ expect(File.expand_path("C:/./dir")).to eq("C:/dir")
178
+ end
179
+
180
+ example "does not modify its argument" do
181
+ str = "./a/b/../c"
182
+ expect(File.expand_path(str, @home)).to eq("#{@home}/a/c")
183
+ expect(str).to eq("./a/b/../c")
184
+ end
185
+
186
+ example "accepts objects that have a to_path method" do
187
+ klass = Class.new{ def to_path; "a/b/c"; end }
188
+ obj = klass.new
189
+ expect(File.expand_path(obj)).to eq("#{@pwd}/a/b/c")
190
+ end
191
+
192
+ example "accepts objects that have a to_path method for relative dir argument" do
193
+ klass = Class.new{ def to_path; "bar"; end }
194
+ obj = klass.new
195
+ expect(File.expand_path('foo', obj)).to eq("#{@pwd}/bar/foo")
196
+ end
197
+
198
+ example "works with unicode characters" do
199
+ expect( File.expand_path("Ελλάσ")).to eq("#{@pwd}/Ελλάσ")
200
+ end
201
+
202
+ # The +1 below is for the slash trailing @pwd that's appended.
203
+ example "handles paths longer than 260 (MAX_PATH) characters" do
204
+ expect{ File.expand_path("a" * 261) }.not_to raise_error
205
+ expect{ File.expand_path("a" * 1024) }.not_to raise_error
206
+ expect(File.expand_path("a" * 1024).size).to eq(@pwd.size + 1024 + 1)
207
+ end
208
+
209
+ example "handles very long paths with tilde" do
210
+ path = "a * 1024"
211
+ expect{ File.expand_path("~/#{path}") }.not_to raise_error
212
+ end
213
+ end
data/win32-xpath.gemspec CHANGED
@@ -2,21 +2,29 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'win32-xpath'
5
- spec.version = '1.1.0'
5
+ spec.version = '1.2.0'
6
6
  spec.author = 'Daniel J. Berger'
7
- spec.license = 'Apache 2.0'
7
+ spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
9
9
  spec.homepage = 'http://github.com/djberg96/win32-xpath'
10
10
  spec.summary = 'Revamped File.expand_path for Windows'
11
- spec.test_file = 'test/test_win32_xpath.rb'
11
+ spec.test_file = 'spec/win32_xpath_spec.rb'
12
12
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
13
  spec.cert_chain = Dir['certs/*']
14
14
 
15
- spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
16
-
17
15
  spec.extensions = ['ext/extconf.rb']
18
16
  spec.add_development_dependency('rake')
19
- spec.add_development_dependency('test-unit', '>= 3.0.0')
17
+ spec.add_development_dependency('rspec', '~> 3.11')
18
+
19
+ spec.metadata = {
20
+ 'homepage_uri' => 'https://github.com/djberg96/win32-xpath',
21
+ 'bug_tracker_uri' => 'https://github.com/djberg96/win32-xpath/issues',
22
+ 'changelog_uri' => 'https://github.com/djberg96/win32-xpath/blob/main/CHANGES.md',
23
+ 'documentation_uri' => 'https://github.com/djberg96/win32-xpath/wiki',
24
+ 'source_code_uri' => 'https://github.com/djberg96/win32-xpath',
25
+ 'wiki_uri' => 'https://github.com/djberg96/win32-xpath/wiki',
26
+ 'rubygems_mfa_required' => 'true'
27
+ }
20
28
 
21
29
  spec.description = <<-EOF
22
30
  The win32-xpath library provides a revamped File.expand_path method
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,36 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-xpath
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
13
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
14
14
  cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
15
- MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTIwNDkxOFowPzERMA8GA1UEAwwIZGpi
15
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
16
16
  ZXJnOTYxFTATBgoJkiaJk/Is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0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
34
+ DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
35
+ ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
32
37
  -----END CERTIFICATE-----
33
- date: 2016-06-12 00:00:00.000000000 Z
38
+ date: 2022-07-09 00:00:00.000000000 Z
34
39
  dependencies:
35
40
  - !ruby/object:Gem::Dependency
36
41
  name: rake
@@ -47,19 +52,19 @@ dependencies:
47
52
  - !ruby/object:Gem::Version
48
53
  version: '0'
49
54
  - !ruby/object:Gem::Dependency
50
- name: test-unit
55
+ name: rspec
51
56
  requirement: !ruby/object:Gem::Requirement
52
57
  requirements:
53
- - - ">="
58
+ - - "~>"
54
59
  - !ruby/object:Gem::Version
55
- version: 3.0.0
60
+ version: '3.11'
56
61
  type: :development
57
62
  prerelease: false
58
63
  version_requirements: !ruby/object:Gem::Requirement
59
64
  requirements:
60
- - - ">="
65
+ - - "~>"
61
66
  - !ruby/object:Gem::Version
62
- version: 3.0.0
67
+ version: '3.11'
63
68
  description: |2
64
69
  The win32-xpath library provides a revamped File.expand_path method
65
70
  for MS Windows. It is significantly faster, and supports ~user
@@ -68,32 +73,34 @@ email: djberg96@gmail.com
68
73
  executables: []
69
74
  extensions:
70
75
  - ext/extconf.rb
71
- extra_rdoc_files:
72
- - README
73
- - CHANGES
74
- - MANIFEST
76
+ extra_rdoc_files: []
75
77
  files:
78
+ - CHANGES.md
79
+ - Gemfile
80
+ - LICENSE
81
+ - MANIFEST.md
82
+ - README.md
83
+ - Rakefile
76
84
  - appveyor.yml
77
- - bench
78
85
  - bench/bench_win32_xpath.rb
79
- - certs
80
86
  - certs/djberg96_pub.pem
81
- - CHANGES
82
- - ext
83
87
  - ext/extconf.rb
84
- - ext/win32
85
88
  - ext/win32/xpath.c
86
- - MANIFEST
87
- - Rakefile
88
- - README
89
- - test
90
- - test/test_win32_xpath.rb
89
+ - lib/win32-xpath.rb
90
+ - spec/win32_xpath_spec.rb
91
91
  - win32-xpath.gemspec
92
92
  homepage: http://github.com/djberg96/win32-xpath
93
93
  licenses:
94
- - Apache 2.0
95
- metadata: {}
96
- post_install_message:
94
+ - Apache-2.0
95
+ metadata:
96
+ homepage_uri: https://github.com/djberg96/win32-xpath
97
+ bug_tracker_uri: https://github.com/djberg96/win32-xpath/issues
98
+ changelog_uri: https://github.com/djberg96/win32-xpath/blob/main/CHANGES.md
99
+ documentation_uri: https://github.com/djberg96/win32-xpath/wiki
100
+ source_code_uri: https://github.com/djberg96/win32-xpath
101
+ wiki_uri: https://github.com/djberg96/win32-xpath/wiki
102
+ rubygems_mfa_required: 'true'
103
+ post_install_message:
97
104
  rdoc_options: []
98
105
  require_paths:
99
106
  - lib
@@ -108,10 +115,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
115
  - !ruby/object:Gem::Version
109
116
  version: '0'
110
117
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.6.4
113
- signing_key:
118
+ rubygems_version: 3.3.17
119
+ signing_key:
114
120
  specification_version: 4
115
121
  summary: Revamped File.expand_path for Windows
116
122
  test_files:
117
- - test/test_win32_xpath.rb
123
+ - spec/win32_xpath_spec.rb
metadata.gz.sig CHANGED
Binary file
data/CHANGES DELETED
@@ -1,21 +0,0 @@
1
- = 1.1.0 - 11-Jun-2016
2
- * Changed license to Apache 2.0.
3
- * Use PathCchXXX functions wherever I could that had not already been
4
- put into place.
5
- * Removed the "futzing" directory and contents.
6
- * Added an appveyor.yml file.
7
-
8
- = 1.0.4 - 26-Nov-2015
9
- * This gem is now signed.
10
-
11
- = 1.0.3 - 3-Jul-2015
12
- * Use PathCchXXX functions where available to improve long path handling.
13
-
14
- = 1.0.2 - 17-Jun-2015
15
- * Deal with non-standard swprintf issues so that it works with mingw compiler.
16
-
17
- = 1.0.1 - 2-Apr-2015
18
- * Altered internal handling of native C function failures.
19
-
20
- = 1.0.0 - 26-Feb-2015
21
- * Initial release
data/MANIFEST DELETED
@@ -1,10 +0,0 @@
1
- appveyor.yml
2
- bench/bench_win32_xpath.rb
3
- CHANGES
4
- certs/djberg96_pub.pem
5
- ext/extconf.rb
6
- ext/win32/xpath.c
7
- Rakefile
8
- README
9
- test/test_win32_xpath.rb
10
- win32-xpath.gemspec
data/README DELETED
@@ -1,59 +0,0 @@
1
- = Description
2
- A custom File.expand_path method for Ruby on Windows that's much
3
- faster and works better.
4
-
5
- = Installation
6
- gem install win32-xpath
7
-
8
- = Synopsis
9
- require 'win32/xpath'
10
-
11
- # That's it, you are now using this library when you call File.expand_path
12
-
13
- = Features
14
- * A 5x average performance boost over MRI's current method.
15
- * Support for ~user expansion.
16
-
17
- = Known Issues
18
- * This library does not support drive-current paths for the 2nd argument.
19
- * This library does not support alt-stream name autocorrection.
20
-
21
- It is very unlikely you will ever be affected by either of these things.
22
- Drive-current paths are a relic of DOS 1.0, but even so this library
23
- will handle them in the first argument.
24
-
25
- I don't support alt-stream mangling because I don't believe it's the
26
- job of this method to peform autocorrection. Even in MRI it only works
27
- for the default $DATA stream, and then only for a certain type of
28
- syntax error. I do not know when or why it was added.
29
-
30
- One possible "real" issue is that on Windows 7 or earlier you will be
31
- limited to 260 character paths. This is a limitation of the shlwapi.h
32
- functions that I use internally.
33
-
34
- If you discover any other issues, please report them on the project
35
- page at https://github.com/djberg96/win32-xpath.
36
-
37
- = Mingw and Devkit
38
- Make sure you have a recent version of the Devkit installed if you're
39
- using the one-click installer. If you see this warning then you need
40
- to upgrade your Devkit.
41
-
42
- "implicit declaration of function 'ConvertSidToStringSidW'"
43
-
44
- = Acknowledgements
45
- Park Heesob for encoding advice and help.
46
-
47
- == License
48
- Apache 2.0
49
-
50
- == Copyright
51
- (C) 2003-2016 Daniel J. Berger, All Rights Reserved
52
-
53
- == Warranty
54
- This package is provided "as is" and without any express or
55
- implied warranties, including, without limitation, the implied
56
- warranties of merchantability and fitness for a particular purpose.
57
-
58
- = Author
59
- Daniel Berger
@@ -1,212 +0,0 @@
1
- require 'test-unit'
2
- require 'tmpdir'
3
- require 'win32/xpath'
4
- require 'etc'
5
-
6
- class Test_XPath < Test::Unit::TestCase
7
- def self.startup
8
- ENV['HOME'] ||= ENV['USERPROFILE']
9
- @@login = Etc.getlogin
10
- end
11
-
12
- def setup
13
- @pwd = Dir.pwd
14
- @tmp = Dir.tmpdir
15
- @root = 'C:/'
16
- @drive = ENV['HOMEDRIVE']
17
- @home = ENV['HOME'].tr('\\', '/')
18
- @unc = "//foo/bar"
19
- end
20
-
21
- test "converts an empty pathname into absolute current pathname" do
22
- assert_equal(@pwd, File.expand_path(''))
23
- end
24
-
25
- test "converts '.' into absolute pathname using current directory" do
26
- assert_equal(@pwd, File.expand_path('.'))
27
- end
28
-
29
- test "converts 'foo' into absolute pathname using current directory" do
30
- assert_equal(File.join(@pwd, 'foo'), File.expand_path('foo'))
31
- end
32
-
33
- test "converts 'foo' into absolute pathname ignoring nil dir" do
34
- assert_equal(File.join(@pwd, 'foo'), File.expand_path('foo', nil))
35
- end
36
-
37
- test "converts 'foo' and 'bar' into absolute pathname" do
38
- assert_equal(File.join(@pwd, "bar", "foo"), File.expand_path('foo', 'bar'))
39
- end
40
-
41
- test "converts a pathname into absolute pathname" do
42
- assert_equal(File.join(@pwd, 'a'), File.expand_path('a.'))
43
- assert_equal(File.join(@pwd, '.a'), File.expand_path('.a'))
44
- assert_equal(File.join(@pwd, '..a'), File.expand_path('..a'))
45
- assert_equal(File.join(@pwd, 'a../b'), File.expand_path('a../b'))
46
- end
47
-
48
- test "converts a pathname and make it valid" do
49
- assert_equal(File.join(@pwd, 'a'), File.expand_path('a..'))
50
- end
51
-
52
- test "converts a pathname to an absolute pathname using a complete path" do
53
- assert_equal(@tmp, File.expand_path('', @tmp))
54
- assert_equal(File.join(@tmp, 'a'), File.expand_path('a', @tmp))
55
- assert_equal(File.join(@tmp, 'a'), File.expand_path('../a', "#{@tmp}/xxx"))
56
- assert_equal(@root, File.expand_path('.', @root))
57
- end
58
-
59
- test "ignores supplied dir if path contains a drive letter" do
60
- assert_equal(@root, File.expand_path(@root, "D:/"))
61
- end
62
-
63
- test "removes trailing slashes from absolute path" do
64
- assert_equal(File.join(@root, 'foo'), File.expand_path("#{@root}foo/"))
65
- assert_equal(File.join(@root, 'foo.rb'), File.expand_path("#{@root}foo.rb/"))
66
- end
67
-
68
- test "removes trailing slashes from relative path" do
69
- assert_equal(File.join(@pwd, 'foo'), File.expand_path("foo/"))
70
- assert_equal(File.join(@pwd, 'foo'), File.expand_path("foo//"))
71
- assert_equal(File.join(@pwd, 'foo'), File.expand_path("foo\\\\\\"))
72
- end
73
-
74
- test "removes trailing spaces from absolute path" do
75
- assert_equal(File.join(@root, 'foo'), File.expand_path("#{@root}foo "))
76
- end
77
-
78
- test "removes trailing dots from absolute path" do
79
- assert_equal(File.join(@root, 'a'), File.expand_path("#{@root}a."))
80
- end
81
-
82
- test "converts a pathname with a drive letter but no slash" do
83
- assert_match(/\Ac:\//i, File.expand_path("c:"))
84
- end
85
-
86
- test "converts a pathname with a drive letter ignoring different drive dir" do
87
- assert_match(/\Ac:\//i, File.expand_path("c:foo", "d:/bar"))
88
- end
89
-
90
- test "converts a pathname which starts with a slash using current drive" do
91
- assert_match(/\A#{@drive}\/foo\z/i, File.expand_path('/foo'))
92
- end
93
-
94
- test "returns tainted strings or not" do
95
- assert_true(File.expand_path('foo').tainted?)
96
- assert_true(File.expand_path('foo'.taint).tainted?)
97
- assert_true(File.expand_path('/foo').tainted?)
98
- assert_true(File.expand_path('/foo'.taint).tainted?)
99
- assert_true(File.expand_path('C:/foo'.taint).tainted?)
100
- assert_false(File.expand_path('C:/foo').tainted?)
101
- assert_false(File.expand_path('//foo').tainted?)
102
- end
103
-
104
- test "converts a pathname to an absolute pathname using tilde as base" do
105
- assert_equal(@home, File.expand_path('~'))
106
- assert_equal("#{@home}/foo", File.expand_path('~/foo'))
107
- assert_equal("#{@home}/.foo", File.expand_path('~/.foo'))
108
- end
109
-
110
- test "converts a pathname to an absolute pathname using tilde for UNC path" do
111
- ENV['HOME'] = @unc
112
- assert_equal(@unc, File.expand_path('~'))
113
- end
114
-
115
- test "converts a tilde to path if used for dir argument" do
116
- assert_equal(@home, File.expand_path('', '~'))
117
- assert_equal("#{@home}/foo", File.expand_path('', '~/foo'))
118
- assert_equal("#{@home}/foo", File.expand_path('foo', '~'))
119
- end
120
-
121
- test "does not modify a HOME string argument" do
122
- str = "~/a"
123
- assert_equal("#{@home}/a", File.expand_path(str))
124
- assert_equal("~/a", str)
125
- end
126
-
127
- test "defaults to HOMEDRIVE + HOMEPATH if HOME or USERPROFILE are nil" do
128
- ENV['HOME'] = nil
129
- ENV['USERPROFILE'] = nil
130
- ENV['HOMEDRIVE'] = "C:"
131
- ENV['HOMEPATH'] = "\\Users\\foo"
132
- assert_equal("C:/Users/foo/bar", File.expand_path("~/bar"))
133
- end
134
-
135
- test "raises ArgumentError when HOME is nil" do
136
- ENV['HOME'] = nil
137
- ENV['USERPROFILE'] = nil
138
- ENV['HOMEDRIVE'] = nil
139
- assert_raise(ArgumentError){ File.expand_path('~') }
140
- end
141
-
142
- test "raises ArgumentError if HOME is relative" do
143
- ENV['HOME'] = '.'
144
- assert_raise(ArgumentError){ File.expand_path('~') }
145
- end
146
-
147
- test "raises ArgumentError if relative user is provided" do
148
- ENV['HOME'] = '.'
149
- assert_raise(ArgumentError){ File.expand_path('~anything') }
150
- end
151
-
152
- test "raises an ArgumentError if a bogus username is supplied" do
153
- assert_raise(ArgumentError){ File.expand_path('~anything') }
154
- end
155
-
156
- test "converts a tilde plus username as expected" do
157
- assert_equal("C:/Users/#{@@login}", File.expand_path("~#{@@login}"))
158
- assert_equal("C:/Users/#{@@login}/foo", File.expand_path("~#{@@login}/foo"))
159
- end
160
-
161
- test "raises a TypeError if not passed a string" do
162
- assert_raise(TypeError){ File.expand_path(1) }
163
- assert_raise(TypeError){ File.expand_path(nil) }
164
- assert_raise(TypeError){ File.expand_path(true) }
165
- end
166
-
167
- test "canonicalizes absolute path" do
168
- assert_equal("C:/dir", File.expand_path("C:/./dir"))
169
- end
170
-
171
- test "does not modify its argument" do
172
- str = "./a/b/../c"
173
- assert_equal("#{@home}/a/c", File.expand_path(str, @home))
174
- assert_equal("./a/b/../c", str)
175
- end
176
-
177
- test "accepts objects that have a to_path method" do
178
- klass = Class.new{ def to_path; "a/b/c"; end }
179
- obj = klass.new
180
- assert_equal("#{@pwd}/a/b/c", File.expand_path(obj))
181
- end
182
-
183
- test "works with unicode characters" do
184
- assert_equal("#{@pwd}/Ελλάσ", File.expand_path("Ελλάσ"))
185
- end
186
-
187
- # The +1 below is for the slash trailing @pwd that's appended.
188
- test "handles paths longer than 260 (MAX_PATH) characters" do
189
- assert_nothing_raised{ File.expand_path("a" * 261) }
190
- assert_nothing_raised{ File.expand_path("a" * 1024) }
191
- assert_equal(@pwd.size + 1024 + 1, File.expand_path("a" * 1024).size)
192
- end
193
-
194
- test "handles very long paths with tilde" do
195
- path = "a * 1024"
196
- assert_nothing_raised{ File.expand_path("~/#{path}") }
197
- end
198
-
199
- def teardown
200
- @pwd = nil
201
- @unc = nil
202
- @dir = nil
203
- @root = nil
204
- @drive = nil
205
-
206
- ENV['HOME'] = @home
207
- end
208
-
209
- def self.shutdown
210
- @@login = nil
211
- end
212
- end