faster_path 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/faster_path/optional/monkeypatches.rb +5 -1
- data/lib/faster_path/optional/refinements.rb +4 -0
- data/lib/faster_path/version.rb +1 -1
- data/lib/faster_path.rb +6 -0
- data/src/basename.rs +6 -1
- data/src/basename_for_chop.rs +5 -0
- data/src/both_are_blank.rs +4 -0
- data/src/dirname.rs +5 -0
- data/src/dirname_for_chop.rs +5 -0
- data/src/is_absolute.rs +6 -0
- data/src/is_blank.rs +4 -0
- data/src/is_directory.rs +17 -0
- data/src/is_relative.rs +5 -0
- data/src/lib.rs +11 -16
- data/src/ruby_array.rs +3 -0
- data/src/ruby_string.rs +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afefb5a6536b8fe153a66b6788725d3905582e88
|
4
|
+
data.tar.gz: 4b95f1bd231189b8223df2d4cfd7f778b114d734
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 058d9bf0ad593e4c4a63df7ce544a8903dd29f1b9cecb58965137def1c56e9248555dc2d1942b870809a5e277edb13b1bd384325549314c40838966e11451c11
|
7
|
+
data.tar.gz: 72af47b03e1e01e9787dec3ff8b58cdf1927a0ceef447cd5e142812ac2a2a53a25b78cd812f6120f2d2c81984efe6c144afcebf007d1611106a836d4c097306f
|
data/README.md
CHANGED
@@ -100,7 +100,7 @@ Ensure Rust is installed:
|
|
100
100
|
[Rust Downloads](https://www.rust-lang.org/downloads.html)
|
101
101
|
|
102
102
|
```
|
103
|
-
curl -sSf https://static.rust-lang.org/rustup.sh |
|
103
|
+
curl -sSf https://static.rust-lang.org/rustup.sh | sh
|
104
104
|
```
|
105
105
|
|
106
106
|
Add this line to your application's Gemfile:
|
@@ -130,6 +130,7 @@ Current methods implemented:
|
|
130
130
|
| `FasterPath.chop_basename` | `Pathname#chop_basename` | 66.0% |
|
131
131
|
| `FasterPath.relative?` | `Pathname#relative?` | 1262.3% |
|
132
132
|
| `FasterPath.blank?` | | |
|
133
|
+
| `FasterPath.directory?` | `Pathname#directory?` | 20% |
|
133
134
|
|
134
135
|
You may choose to use the methods directly, or scope change to rewrite behavior on the
|
135
136
|
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
@@ -8,6 +8,11 @@ module FasterPath
|
|
8
8
|
Rust.is_absolute(pth)
|
9
9
|
end
|
10
10
|
|
11
|
+
# Spec to Pathname#directory?
|
12
|
+
def self.directory?(pth)
|
13
|
+
Rust.is_directory(pth)
|
14
|
+
end
|
15
|
+
|
11
16
|
# Spec to Pathname#relative?
|
12
17
|
def self.relative?(pth)
|
13
18
|
Rust.is_relative(pth)
|
@@ -53,6 +58,7 @@ module FasterPath
|
|
53
58
|
end
|
54
59
|
|
55
60
|
attach_function :is_absolute, [ :string ], :bool
|
61
|
+
attach_function :is_directory, [ :string ], :bool
|
56
62
|
attach_function :is_relative, [ :string ], :bool
|
57
63
|
attach_function :is_blank, [ :string ], :bool
|
58
64
|
attach_function :both_are_blank, [ :string, :string ], :bool
|
data/src/basename.rs
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
use std::path::MAIN_SEPARATOR;
|
2
|
+
use libc::c_char;
|
3
|
+
use std::ffi::{CStr,CString};
|
4
|
+
use std::str;
|
5
|
+
|
1
6
|
#[allow(dead_code)]
|
2
7
|
fn rubyish_basename(string: &str, globish_string: &str) -> String {
|
3
8
|
let result = if globish_string == ".*" {
|
@@ -48,7 +53,7 @@ fn it_chomps_strings_correctly(){
|
|
48
53
|
assert_eq!(rubyish_basename("asdf/asdf.rb.swp", "rb.swp") , "asdf.");
|
49
54
|
}
|
50
55
|
|
51
|
-
|
56
|
+
#[no_mangle]
|
52
57
|
pub extern fn basename(str_pth: *const c_char, comp_ext: *const c_char) -> *const c_char {
|
53
58
|
let c_str1 = unsafe {
|
54
59
|
assert!(!str_pth.is_null());
|
data/src/basename_for_chop.rs
CHANGED
data/src/both_are_blank.rs
CHANGED
data/src/dirname.rs
CHANGED
data/src/dirname_for_chop.rs
CHANGED
data/src/is_absolute.rs
CHANGED
data/src/is_blank.rs
CHANGED
data/src/is_directory.rs
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
use libc::c_char;
|
2
|
+
use std::ffi::{CStr};
|
3
|
+
use std::str;
|
4
|
+
use std::path::Path;
|
5
|
+
|
6
|
+
#[no_mangle]
|
7
|
+
pub extern fn is_directory(string: *const c_char) -> bool {
|
8
|
+
let c_str = unsafe {
|
9
|
+
assert!(!string.is_null());
|
10
|
+
|
11
|
+
CStr::from_ptr(string)
|
12
|
+
};
|
13
|
+
|
14
|
+
let r_str = str::from_utf8(c_str.to_bytes()).unwrap_or("");
|
15
|
+
|
16
|
+
Path::new(r_str).is_dir()
|
17
|
+
}
|
data/src/is_relative.rs
CHANGED
data/src/lib.rs
CHANGED
@@ -6,22 +6,17 @@
|
|
6
6
|
// copied, modified, or distributed except according to those terms.
|
7
7
|
extern crate libc;
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
include!("both_are_blank.rs");
|
21
|
-
include!("basename.rs");
|
22
|
-
include!("dirname.rs");
|
23
|
-
include!("basename_for_chop.rs");
|
24
|
-
include!("dirname_for_chop.rs");
|
9
|
+
pub mod ruby_string;
|
10
|
+
pub mod ruby_array;
|
11
|
+
pub mod is_absolute;
|
12
|
+
pub mod is_directory;
|
13
|
+
pub mod is_relative;
|
14
|
+
pub mod is_blank;
|
15
|
+
pub mod both_are_blank;
|
16
|
+
pub mod basename;
|
17
|
+
pub mod dirname;
|
18
|
+
pub mod basename_for_chop;
|
19
|
+
pub mod dirname_for_chop;
|
25
20
|
|
26
21
|
// EXAMPLE
|
27
22
|
//
|
data/src/ruby_array.rs
CHANGED
data/src/ruby_string.rs
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- src/dirname_for_chop.rs
|
140
140
|
- src/is_absolute.rs
|
141
141
|
- src/is_blank.rs
|
142
|
+
- src/is_directory.rs
|
142
143
|
- src/is_relative.rs
|
143
144
|
- src/lib.rs
|
144
145
|
- src/ruby_array.rs
|