faster_path 0.3.10 → 0.4.0
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.
- checksums.yaml +4 -4
- data/Cargo.lock +19 -37
- data/Cargo.toml +5 -6
- data/Gemfile +3 -7
- data/README.md +94 -30
- data/Rakefile +11 -2
- data/faster_path.gemspec +6 -3
- data/lib/faster_path/version.rb +1 -1
- data/lib/faster_path.rb +4 -2
- data/src/basename.rs +166 -69
- data/src/chop_basename.rs +84 -21
- data/src/cleanpath_aggressive.rs +87 -71
- data/src/cleanpath_conservative.rs +175 -79
- data/src/dirname.rs +96 -32
- data/src/extname.rs +150 -20
- data/src/lib.rs +54 -104
- data/src/path_parsing.rs +282 -21
- data/src/pathname.rs +296 -256
- data/src/plus.rs +90 -74
- data/src/prepend_prefix.rs +11 -13
- data/src/relative_path_from.rs +72 -48
- data/src/ruby.rs +530 -0
- metadata +17 -18
- data/src/debug.rs +0 -29
- data/src/helpers.rs +0 -51
- data/src/memrnchr.rs +0 -70
- data/src/pathname_sys.rs +0 -41
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5e04d827e927a1e405d74ccf0fe49946faaf67650c935ad1e5a5dec744254d27
|
|
4
|
+
data.tar.gz: '067897cef2171835830c97c8340397ad2d4a97ad1c72b15a88c0876bf58a1690'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 16298d55d4cd08d92555ed02e995a55520430527e37d057d7372182e7b9f12758bbf730d2f5969740f806e4bc3221b32843e2a90a8aacb96a57d95500995e477
|
|
7
|
+
data.tar.gz: c09f83ba8f3687b3dc509536fbf985435528a160161795285baf612edf965f409bbac07f6b6de7075be3b5df29d23263de41176ad478d90ade20a567e1fb2a8d
|
data/Cargo.lock
CHANGED
|
@@ -1,57 +1,39 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
1
5
|
[[package]]
|
|
2
6
|
name = "faster_path"
|
|
3
|
-
version = "0.0
|
|
7
|
+
version = "0.1.0"
|
|
4
8
|
dependencies = [
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"ruby-sys 0.3.0 (git+https://github.com/danielpclark/ruby-sys?branch=playground)",
|
|
8
|
-
"ruru 0.9.3 (git+https://github.com/danielpclark/ruru?branch=playground)",
|
|
9
|
+
"memchr",
|
|
10
|
+
"rutie",
|
|
9
11
|
]
|
|
10
12
|
|
|
11
13
|
[[package]]
|
|
12
14
|
name = "lazy_static"
|
|
13
|
-
version = "
|
|
14
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
-
|
|
16
|
-
[[package]]
|
|
17
|
-
name = "lazy_static"
|
|
18
|
-
version = "1.0.0"
|
|
15
|
+
version = "1.5.1"
|
|
19
16
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
17
|
+
checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
|
|
20
18
|
|
|
21
19
|
[[package]]
|
|
22
20
|
name = "libc"
|
|
23
|
-
version = "0.2.
|
|
21
|
+
version = "0.2.189"
|
|
24
22
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
23
|
+
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
|
25
24
|
|
|
26
25
|
[[package]]
|
|
27
26
|
name = "memchr"
|
|
28
|
-
version = "2.
|
|
27
|
+
version = "2.8.3"
|
|
29
28
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
30
|
-
|
|
31
|
-
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
32
|
-
]
|
|
29
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
33
30
|
|
|
34
31
|
[[package]]
|
|
35
|
-
name = "
|
|
36
|
-
version = "0.
|
|
37
|
-
source = "
|
|
38
|
-
|
|
39
|
-
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
40
|
-
]
|
|
41
|
-
|
|
42
|
-
[[package]]
|
|
43
|
-
name = "ruru"
|
|
44
|
-
version = "0.9.3"
|
|
45
|
-
source = "git+https://github.com/danielpclark/ruru?branch=playground#ab84ad4b97c41bfe6fd6d0f8540b2efd77583561"
|
|
32
|
+
name = "rutie"
|
|
33
|
+
version = "0.10.2"
|
|
34
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
35
|
+
checksum = "a97641d6bd3731d263d914141e960a8b515bf5ff4ca6c961b25ca4b2694c6490"
|
|
46
36
|
dependencies = [
|
|
47
|
-
"lazy_static
|
|
48
|
-
"
|
|
37
|
+
"lazy_static",
|
|
38
|
+
"libc",
|
|
49
39
|
]
|
|
50
|
-
|
|
51
|
-
[metadata]
|
|
52
|
-
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
|
|
53
|
-
"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d"
|
|
54
|
-
"checksum libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)" = "f54263ad99207254cf58b5f701ecb432c717445ea2ee8af387334bdd1a03fdff"
|
|
55
|
-
"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d"
|
|
56
|
-
"checksum ruby-sys 0.3.0 (git+https://github.com/danielpclark/ruby-sys?branch=playground)" = "<none>"
|
|
57
|
-
"checksum ruru 0.9.3 (git+https://github.com/danielpclark/ruru?branch=playground)" = "<none>"
|
data/Cargo.toml
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "faster_path"
|
|
3
|
-
version = "0.0
|
|
3
|
+
version = "0.1.0"
|
|
4
4
|
authors = ["Daniel P. Clark <6ftdan@gmail.com>"]
|
|
5
5
|
description = "Alternative to Pathname"
|
|
6
6
|
homepage = "https://github.com/danielpclark/faster_path"
|
|
7
7
|
repository = "https://github.com/danielpclark/faster_path"
|
|
8
8
|
license = "MIT OR Apache-2.0"
|
|
9
9
|
readme = "README.md"
|
|
10
|
+
edition = "2021"
|
|
10
11
|
|
|
11
12
|
[package.metadata.thermite]
|
|
12
13
|
github_releases = true
|
|
13
14
|
|
|
14
15
|
[lib]
|
|
15
16
|
name = "faster_path"
|
|
16
|
-
crate-type = ["
|
|
17
|
+
crate-type = ["cdylib"]
|
|
17
18
|
|
|
18
19
|
[dependencies]
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
lazy_static = "1.0"
|
|
22
|
-
memchr = "2.0.1"
|
|
20
|
+
rutie = "0.10.2"
|
|
21
|
+
memchr = "2"
|
data/Gemfile
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
# Specify your gem's dependencies in faster_path.gemspec
|
|
3
|
-
gemspec
|
|
1
|
+
source 'https://rubygems.org'
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
end
|
|
8
|
-
end
|
|
3
|
+
# Specify your gem's dependencies in faster_path.gemspec
|
|
4
|
+
gemspec
|
data/README.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
# FasterPath
|
|
2
2
|
[](https://badge.fury.io/rb/faster_path)
|
|
3
|
-
[](https://ci.appveyor.com/project/danielpclark/faster-path/branch/master)
|
|
3
|
+
[](https://github.com/danielpclark/faster_path/actions/workflows/ci.yml)
|
|
5
4
|
[](https://github.com/danielpclark/faster_path/tags)
|
|
6
5
|
[](https://github.com/danielpclark/faster_path/pulse)
|
|
7
6
|
[](https://github.com/danielpclark/faster_path/releases)
|
|
8
|
-
[](https://coveralls.io/github/danielpclark/faster_path?branch=master)
|
|
9
7
|
[](http://inch-ci.org/github/danielpclark/faster_path)
|
|
10
8
|
[](https://www.codetriage.com/danielpclark/faster_path)
|
|
11
9
|
|
|
@@ -103,7 +101,7 @@ So now we have some real numbers to work with We can be generoues and use 66% a
|
|
|
103
101
|
|
|
104
102
|
## What Rails Versions Will This Apply To?
|
|
105
103
|
|
|
106
|
-
As mentioned earlier Sprockets, which handles assets, changed away from using `Pathname` at all when moving from major version 2 to 3. So if you're using Sprockets 3 or later you won't reap the biggest performance
|
|
104
|
+
As mentioned earlier Sprockets, which handles assets, changed away from using `Pathname` at all when moving from major version 2 to 3. So if you're using Sprockets 3 or later you won't reap the biggest performance rewards from using this gem for now _(it's my goal to have this project become a core feature that Rails depends on and yes… that's a big ask)_. That is unless you write you're own implementation to re-integrate the use of `Pathname` and `FasterPath` into your asset handling library. For now just know that the Sprockets 2 series primarily works with Rails 4.1 and earlier. It may work in later Rails versions but I have not investigated this.
|
|
107
105
|
|
|
108
106
|
## Status
|
|
109
107
|
|
|
@@ -111,7 +109,13 @@ As mentioned earlier Sprockets, which handles assets, changed away from using `P
|
|
|
111
109
|
* Methods are stable
|
|
112
110
|
* Thoroughly tested
|
|
113
111
|
* Testers and developers are most welcome
|
|
114
|
-
* Windows
|
|
112
|
+
* Windows: paths follow Ruby's Windows rules (`\` and `/` separators, drive letters, UNC paths)
|
|
113
|
+
* Paths keep their encoding, as with Ruby's own methods
|
|
114
|
+
|
|
115
|
+
## Requirements
|
|
116
|
+
|
|
117
|
+
* Ruby 2.5, 2.6 or 2.7 (the Rust extension is built with [Rutie](https://github.com/danielpclark/rutie) 0.10, which supports these)
|
|
118
|
+
* Rust 1.71 or later
|
|
115
119
|
|
|
116
120
|
## Installation
|
|
117
121
|
|
|
@@ -120,13 +124,13 @@ Ensure Rust is installed:
|
|
|
120
124
|
[Rust Downloads](https://www.rust-lang.org/downloads.html)
|
|
121
125
|
|
|
122
126
|
```
|
|
123
|
-
curl -sSf https://
|
|
127
|
+
curl -sSf https://sh.rustup.rs | sh
|
|
124
128
|
```
|
|
125
129
|
|
|
126
130
|
Add this line to your application's Gemfile:
|
|
127
131
|
|
|
128
132
|
```ruby
|
|
129
|
-
gem 'faster_path', '~> 0.
|
|
133
|
+
gem 'faster_path', '~> 0.4.0'
|
|
130
134
|
```
|
|
131
135
|
|
|
132
136
|
And then execute:
|
|
@@ -147,27 +151,35 @@ improvement result for the `chop_basename` method.
|
|
|
147
151
|
|
|
148
152
|
## Usage
|
|
149
153
|
|
|
154
|
+
Add the proper require to your project.
|
|
155
|
+
|
|
156
|
+
```ruby
|
|
157
|
+
require "faster_path"
|
|
158
|
+
```
|
|
159
|
+
|
|
150
160
|
Current methods implemented:
|
|
151
161
|
|
|
152
|
-
|FasterPath Rust Implementation|Ruby 2.
|
|
153
|
-
|
|
154
|
-
| `FasterPath.absolute?` | `Pathname#absolute?` | 95.
|
|
155
|
-
| `FasterPath.add_trailing_separator` | `Pathname#add_trailing_separator` |
|
|
156
|
-
| `FasterPath.basename` | `File.basename` |
|
|
157
|
-
| `FasterPath.children` | `Pathname#children` |
|
|
158
|
-
| `FasterPath.chop_basename` | `Pathname#chop_basename` |
|
|
159
|
-
| `FasterPath.cleanpath_aggressive` | `Pathname#cleanpath_aggressive` |
|
|
160
|
-
| `FasterPath.cleanpath_conservative` | `Pathname#cleanpath_conservative` |
|
|
161
|
-
| `FasterPath.del_trailing_separator` | `Pathname#del_trailing_separator` | 85.
|
|
162
|
-
| `FasterPath.directory?` | `Pathname#directory?` |
|
|
163
|
-
| `FasterPath.dirname` | `File.dirname` |
|
|
164
|
-
| `FasterPath.entries` | `Pathname#entries` |
|
|
165
|
-
| `FasterPath.extname` | `File.extname` |
|
|
166
|
-
| `FasterPath.has_trailing_separator?` | `Pathname#has_trailing_separator` | 88.
|
|
167
|
-
| `FasterPath.
|
|
168
|
-
| `FasterPath.plus` | `Pathname#plus` |
|
|
169
|
-
| `FasterPath.relative?` | `Pathname#relative?` | 92.
|
|
170
|
-
| `FasterPath.relative_path_from` | `Pathname#relative_path_from` | 93.
|
|
162
|
+
|FasterPath Rust Implementation|Ruby Implementation|Time Shaved Off (Ruby 2.7)|Time Shaved Off (Ruby 2.5)|
|
|
163
|
+
|---|---|:---:|:---:|
|
|
164
|
+
| `FasterPath.absolute?` | `Pathname#absolute?` | 95.7% | 96.7% |
|
|
165
|
+
| `FasterPath.add_trailing_separator` | `Pathname#add_trailing_separator` | 85.4% | 83.0% |
|
|
166
|
+
| `FasterPath.basename` | `File.basename` | 42.4% | 39.1% |
|
|
167
|
+
| `FasterPath.children` | `Pathname#children` | 54.7% | 47.8% |
|
|
168
|
+
| `FasterPath.chop_basename` | `Pathname#chop_basename` | 70.4% | 75.1% |
|
|
169
|
+
| `FasterPath.cleanpath_aggressive` | `Pathname#cleanpath_aggressive` | 90.3% | 90.6% |
|
|
170
|
+
| `FasterPath.cleanpath_conservative` | `Pathname#cleanpath_conservative` | 89.6% | 91.6% |
|
|
171
|
+
| `FasterPath.del_trailing_separator` | `Pathname#del_trailing_separator` | 85.3% | 87.6% |
|
|
172
|
+
| `FasterPath.directory?` | `Pathname#directory?` | 34.3% | 37.5% |
|
|
173
|
+
| `FasterPath.dirname` | `File.dirname` | 56.8% | 54.7% |
|
|
174
|
+
| `FasterPath.entries` | `Pathname#entries` | 38.0% | 33.9% |
|
|
175
|
+
| `FasterPath.extname` | `File.extname` | 74.0% | 73.1% |
|
|
176
|
+
| `FasterPath.has_trailing_separator?` | `Pathname#has_trailing_separator` | 88.5% | 89.1% |
|
|
177
|
+
| `FasterPath.join` | `Pathname#join` | 88.1% | 90.3% |
|
|
178
|
+
| `FasterPath.plus` | `Pathname#plus` | 91.7% | 93.4% |
|
|
179
|
+
| `FasterPath.relative?` | `Pathname#relative?` | 92.8% | 95.2% |
|
|
180
|
+
| `FasterPath.relative_path_from` | `Pathname#relative_path_from` | 92.5% | 93.6% |
|
|
181
|
+
|
|
182
|
+
See [Benchmarks](#benchmarks) for how these are measured.
|
|
171
183
|
|
|
172
184
|
You may choose to use the methods directly, or scope change to rewrite behavior on the
|
|
173
185
|
standard library with the included refinements, or even call a method to monkeypatch
|
|
@@ -193,14 +205,66 @@ FasterPath.sledgehammer_everything!
|
|
|
193
205
|
|
|
194
206
|
These will **not** be included by default in monkey-patches. To try them with monkeypatching use the environment flag of `WITH_REGRESSION`. These methods are here to be improved upon.
|
|
195
207
|
|
|
196
|
-
|FasterPath Implementation|Ruby Implementation|
|
|
197
|
-
|
|
198
|
-
| `FasterPath.entries_compat` | `Pathname.entries` |
|
|
199
|
-
| `FasterPath.children_compat` | `Pathname.children` |
|
|
208
|
+
|FasterPath Implementation|Ruby Implementation|Time Shaved Off (Ruby 2.7)|Time Shaved Off (Ruby 2.5)|
|
|
209
|
+
|---|---|:---:|:---:|
|
|
210
|
+
| `FasterPath.entries_compat` | `Pathname.entries` | 16.8% | 9.2% |
|
|
211
|
+
| `FasterPath.children_compat` | `Pathname.children` | 32.1% | 26.6% |
|
|
200
212
|
|
|
201
213
|
It's been my observation (and some others) that the Rust implementation of the C code for `File` has similar results but
|
|
202
214
|
performance seems to vary based on CPU cache on possibly 64bit/32bit system environments. These are not included by default when the monkey patch method `FasterPath.sledgehammer_everything!` is executed.
|
|
203
215
|
|
|
216
|
+
## Benchmarks
|
|
217
|
+
|
|
218
|
+
The "Time Shaved Off" figures come from the project's Pinch-bench (`rake pbench`, in
|
|
219
|
+
`test/pbench`): each method runs against Ruby's own implementation, and the result is how much
|
|
220
|
+
less time FasterPath took. They are the median of 3 runs of `LONG_RUN=10 rake pbench` (500,000
|
|
221
|
+
calls of each method, 5 times) on Linux x86_64 with Ruby 2.7.8 and 2.5.7, built with Rust 1.97.
|
|
222
|
+
Expect a few points of difference from run to run.
|
|
223
|
+
|
|
224
|
+
`rake pbench` is also the performance regression test: each method has a floor in
|
|
225
|
+
`test/pbench/pbench_suite.rb` (about half of the improvement in the table above) and the task
|
|
226
|
+
fails when a method measures below it, so a change that makes a method slower shows up in
|
|
227
|
+
`rake test`. On Windows, where `join` is currently slower than Ruby's
|
|
228
|
+
([#185](https://github.com/danielpclark/faster_path/issues/185)), the floors are reported but not
|
|
229
|
+
enforced.
|
|
230
|
+
|
|
231
|
+
### Before and after the Rutie 0.10 upgrade
|
|
232
|
+
|
|
233
|
+
Measured the same way, alternating runs of the code before the upgrade (built with Rutie 0.6)
|
|
234
|
+
and after it. Higher is better; the change is in percentage points.
|
|
235
|
+
|
|
236
|
+
|Method|Ruby 2.7 before|Ruby 2.7 after|Change|Ruby 2.5 before|Ruby 2.5 after|Change|
|
|
237
|
+
|---|:---:|:---:|:---:|:---:|:---:|:---:|
|
|
238
|
+
| `absolute?` | 93.3% | 95.7% | +2.4 | 96.1% | 96.7% | +0.6 |
|
|
239
|
+
| `add_trailing_separator` | 66.6% | 85.4% | **+18.8** | 64.3% | 83.0% | **+18.7** |
|
|
240
|
+
| `basename` | 42.4% | 42.4% | 0.0 | 32.1% | 39.1% | **+7.0** |
|
|
241
|
+
| `children` | 52.8% | 54.7% | +1.9 | 46.5% | 47.8% | +1.3 |
|
|
242
|
+
| `children_compat` | −1.2% | 32.1% | **+33.3** | 1.1% | 26.6% | **+25.5** |
|
|
243
|
+
| `chop_basename` | 71.2% | 70.4% | −0.8 | 74.7% | 75.1% | +0.4 |
|
|
244
|
+
| `cleanpath_aggressive` | 90.3% | 90.3% | 0.0 | 92.7% | 90.6% | −2.1 |
|
|
245
|
+
| `cleanpath_conservative` | 89.8% | 89.6% | −0.2 | 91.7% | 91.6% | −0.1 |
|
|
246
|
+
| `del_trailing_separator` | 86.5% | 85.3% | −1.2 | 87.0% | 87.6% | +0.6 |
|
|
247
|
+
| `directory?` | 33.2% | 34.3% | +1.1 | 37.2% | 37.5% | +0.3 |
|
|
248
|
+
| `dirname` | 49.8% | 56.8% | **+7.0** | 51.2% | 54.7% | +3.5 |
|
|
249
|
+
| `entries` | 40.4% | 38.0% | −2.4 | 33.6% | 33.9% | +0.3 |
|
|
250
|
+
| `entries_compat` | −29.8% | 16.8% | **+46.6** | −23.3% | 9.2% | **+32.5** |
|
|
251
|
+
| `extname` | 70.3% | 74.0% | +3.7 | 74.0% | 73.1% | −0.9 |
|
|
252
|
+
| `has_trailing_separator?` | 87.5% | 88.5% | +1.0 | 87.1% | 89.1% | +2.0 |
|
|
253
|
+
| `join` | crashes | 88.1% | | crashes | 90.3% | |
|
|
254
|
+
| `plus` | 92.3% | 91.7% | −0.6 | 93.0% | 93.4% | +0.4 |
|
|
255
|
+
| `relative?` | 90.7% | 92.8% | +2.1 | 93.6% | 95.2% | +1.6 |
|
|
256
|
+
| `relative_path_from` | 92.7% | 92.5% | −0.2 | 94.0% | 93.6% | −0.4 |
|
|
257
|
+
|
|
258
|
+
Before the upgrade, `FasterPath.join` segfaulted, so its benchmark can't be measured.
|
|
259
|
+
`add_trailing_separator`, `dirname` and the `_compat` methods gained the most:
|
|
260
|
+
`add_trailing_separator` no longer builds a temporary string, no method checks its arguments
|
|
261
|
+
for valid UTF-8 any more, and the `_compat` methods build `Pathname` objects without calling
|
|
262
|
+
`Pathname.new`. `basename` was re-measured after it was made to take a shorter path on Unix
|
|
263
|
+
and skip an empty extension; it was the one method that first measured slower on Ruby 2.5.
|
|
264
|
+
Its timings vary a lot from run to run (Ruby 2.5 before: 40.0%, 32.1%, 28.7%; after: 29.6%,
|
|
265
|
+
39.1%, 39.2%), so its instruction counts from `valgrind --tool=callgrind` are a steadier
|
|
266
|
+
measure. They went from 2439 to 2331 per call on Ruby 2.5 and from 2689 to 2561 on Ruby 2.7.
|
|
267
|
+
|
|
204
268
|
## Getting Started with Development
|
|
205
269
|
|
|
206
270
|
The primary methods to target are mostly listed in the **Why** section above. You may find the Ruby
|
data/Rakefile
CHANGED
|
@@ -46,7 +46,14 @@ end
|
|
|
46
46
|
|
|
47
47
|
desc "Run Rust Tests"
|
|
48
48
|
task :cargo do
|
|
49
|
-
|
|
49
|
+
ruby_lib = RbConfig::CONFIG['libdir']
|
|
50
|
+
sh(
|
|
51
|
+
{
|
|
52
|
+
'LD_LIBRARY_PATH' => ruby_lib,
|
|
53
|
+
'DYLD_LIBRARY_PATH' => ruby_lib
|
|
54
|
+
},
|
|
55
|
+
'cargo -vv test -- --nocapture'
|
|
56
|
+
)
|
|
50
57
|
end
|
|
51
58
|
|
|
52
59
|
Rake::TestTask.new(minitest: :build_lib) do |t|
|
|
@@ -62,7 +69,9 @@ task :init_mspec do |_t|
|
|
|
62
69
|
end
|
|
63
70
|
|
|
64
71
|
task test: [:cargo, :minitest, :lint, :pbench, :init_mspec] do |_t|
|
|
65
|
-
|
|
72
|
+
# Run through Ruby so this also works on Windows
|
|
73
|
+
exec Gem.ruby, 'spec/mspec/bin/mspec', '--format', 'spec',
|
|
74
|
+
'core/file/basename', 'core/file/extname', 'core/file/dirname', 'library/pathname'
|
|
66
75
|
end
|
|
67
76
|
|
|
68
77
|
desc "Full mspec results w/o encoding"
|
data/faster_path.gemspec
CHANGED
|
@@ -24,11 +24,14 @@ Gem::Specification.new do |spec|
|
|
|
24
24
|
spec.extensions = ['ext/Rakefile']
|
|
25
25
|
spec.require_paths = ['lib']
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
spec.
|
|
27
|
+
# Rutie 0.10, which the Rust extension is built with, supports Ruby 2.5 to 2.7
|
|
28
|
+
spec.required_ruby_version = ['>= 2.5', '< 3.0']
|
|
29
|
+
|
|
30
|
+
spec.add_dependency 'bundler', '>= 1.12'
|
|
31
|
+
spec.add_dependency 'rake', '>= 12.3'
|
|
29
32
|
spec.add_dependency 'thermite', '0.13.0'
|
|
30
33
|
spec.add_development_dependency 'read_source', '~> 0.2.6'
|
|
31
|
-
spec.add_development_dependency 'minitest', '~> 5.
|
|
34
|
+
spec.add_development_dependency 'minitest', '~> 5.11'
|
|
32
35
|
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
|
|
33
36
|
spec.add_development_dependency 'color_pound_spec_reporter', '~> 0.0.9'
|
|
34
37
|
spec.add_development_dependency 'rubocop', '0.53'
|
data/lib/faster_path/version.rb
CHANGED
data/lib/faster_path.rb
CHANGED
|
@@ -22,7 +22,7 @@ module FasterPath
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
Fiddle::Function.
|
|
25
|
-
new(Fiddle.dlopen(FFI_LIBRARY)['Init_faster_pathname'], [], Fiddle::
|
|
25
|
+
new(Fiddle.dlopen(FFI_LIBRARY)['Init_faster_pathname'], [], Fiddle::TYPE_VOID).
|
|
26
26
|
call
|
|
27
27
|
|
|
28
28
|
Public.class_eval do
|
|
@@ -40,7 +40,9 @@ module FasterPath
|
|
|
40
40
|
# The Ruby architecture bit width: 64bits or 32bits
|
|
41
41
|
# @return [Integer]
|
|
42
42
|
def self.ruby_arch_bits
|
|
43
|
-
1.size
|
|
43
|
+
# The width of a pointer; `1.size` is the width of a C `long`, which is
|
|
44
|
+
# 4 bytes on 64-bit Windows.
|
|
45
|
+
[0].pack('J').bytesize * 8
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
# A very fast way to check if a string is blank
|