faster_path 0.1.6 → 0.1.7
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/README.md +1 -0
- data/lib/faster_path/optional/monkeypatches.rb +5 -0
- data/lib/faster_path/optional/refinements.rb +5 -0
- data/lib/faster_path/version.rb +1 -1
- data/lib/faster_path.rb +5 -0
- data/src/add_trailing_separator.rs +28 -0
- data/src/lib.rs +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7663e3cebaf52e71d0445b29c541e31ad1b6f87
|
4
|
+
data.tar.gz: 67071c8d8d399baf4d64705d1e7a5c147f56bc39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1607471e1395c8fc7c583fb936e5bfe618dd5066eda0d59613040b3499565ff6d7fe106a55447dcec7a8dc705fb7af96c011e535ec165b2f06b5f7e4fc983ccf
|
7
|
+
data.tar.gz: 312ba0423e39dce09031e7d2b1f29bfc5562865c89b15854713a771047b89be668e2ca35c254f4471398836999f44037a2539012a0dcdd6935160cdcc6d36105
|
data/README.md
CHANGED
@@ -131,6 +131,7 @@ Current methods implemented:
|
|
131
131
|
| `FasterPath.relative?` | `Pathname#relative?` | 1262.3% |
|
132
132
|
| `FasterPath.blank?` | | |
|
133
133
|
| `FasterPath.directory?` | `Pathname#directory?` | 20% |
|
134
|
+
| `FasterPath.add_trailing_separator` | `Pathname#add_trailing_separator` | 63.8% |
|
134
135
|
|
135
136
|
You may choose to use the methods directly, or scope change to rewrite behavior on the
|
136
137
|
standard library with the included refinements, or even call a method to monkeypatch
|
data/lib/faster_path/version.rb
CHANGED
data/lib/faster_path.rb
CHANGED
@@ -35,6 +35,10 @@ module FasterPath
|
|
35
35
|
Rust.basename(pth, ext)
|
36
36
|
end
|
37
37
|
|
38
|
+
def self.add_trailing_separator(pth)
|
39
|
+
Rust.add_trailing_separator(pth)
|
40
|
+
end
|
41
|
+
|
38
42
|
# EXAMPLE
|
39
43
|
#def self.one_and_two
|
40
44
|
# Rust.one_and_two.to_a
|
@@ -66,6 +70,7 @@ module FasterPath
|
|
66
70
|
attach_function :dirname, [ :string ], :string
|
67
71
|
attach_function :basename_for_chop, [ :string ], :string # decoupling behavior
|
68
72
|
attach_function :dirname_for_chop, [ :string ], :string # decoupling behavior
|
73
|
+
attach_function :add_trailing_separator, [ :string ], :string
|
69
74
|
|
70
75
|
# EXAMPLE
|
71
76
|
#attach_function :one_and_two, [], FromRustArray.by_value
|
@@ -0,0 +1,28 @@
|
|
1
|
+
use std::path::{Path, MAIN_SEPARATOR};
|
2
|
+
use libc::c_char;
|
3
|
+
use std::ffi::{CStr, CString};
|
4
|
+
use std::str;
|
5
|
+
|
6
|
+
#[no_mangle]
|
7
|
+
pub extern "C" fn add_trailing_separator(string: *const c_char) -> *const c_char {
|
8
|
+
let c_str = unsafe {
|
9
|
+
assert!(!string.is_null());
|
10
|
+
|
11
|
+
CStr::from_ptr(string)
|
12
|
+
};
|
13
|
+
let r_str = str::from_utf8(c_str.to_bytes()).unwrap_or("");
|
14
|
+
|
15
|
+
if r_str.is_empty() {
|
16
|
+
return string;
|
17
|
+
}
|
18
|
+
|
19
|
+
let path = Path::new(r_str);
|
20
|
+
let out_str = if !(path.to_str().unwrap().chars().last().unwrap() == '/') {
|
21
|
+
format!("{}{}", path.to_str().unwrap(), MAIN_SEPARATOR)
|
22
|
+
} else {
|
23
|
+
path.to_str().unwrap().to_string()
|
24
|
+
};
|
25
|
+
|
26
|
+
let output = CString::new(out_str).unwrap();
|
27
|
+
output.into_raw()
|
28
|
+
}
|
data/src/lib.rs
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faster_path
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/faster_path/optional/monkeypatches.rb
|
133
133
|
- lib/faster_path/optional/refinements.rb
|
134
134
|
- lib/faster_path/version.rb
|
135
|
+
- src/add_trailing_separator.rs
|
135
136
|
- src/basename.rs
|
136
137
|
- src/basename_for_chop.rs
|
137
138
|
- src/both_are_blank.rs
|