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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a936694d9f749570e5cc36ef77d191463d76012
4
- data.tar.gz: 48b762449beb96a05a019079b3b72a8cdd82a53a
3
+ metadata.gz: afefb5a6536b8fe153a66b6788725d3905582e88
4
+ data.tar.gz: 4b95f1bd231189b8223df2d4cfd7f778b114d734
5
5
  SHA512:
6
- metadata.gz: e01d2a339da0a848c696410dd975e84063dc4c5e59b8ef910c6e1f7657e949cdf3ae32770cba6ba801d4c54908bb9beb35e242e0ca1a5d7be619baaa227a20e2
7
- data.tar.gz: f3cbba7d7249fce672035d7964d913d393c5ef090a0915ad083f7c7ac6d5218ae1f952d3a502c34def28135388142612d52857f27af2b5548e9a834e8732b5c9
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 | sudo sh -s -- --channel=nightly
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
@@ -10,7 +10,11 @@ module FasterPath
10
10
  def absolute?
11
11
  FasterPath.absolute?(@path)
12
12
  end
13
-
13
+
14
+ def directory?
15
+ FasterPath.directory?(@path)
16
+ end
17
+
14
18
  def chop_basename(pth)
15
19
  FasterPath.chop_basename(pth)
16
20
  end
@@ -13,6 +13,10 @@ module FasterPath
13
13
  FasterPath.absolute?(@path)
14
14
  end
15
15
 
16
+ def directory?
17
+ FasterPath.directory?(@path)
18
+ end
19
+
16
20
  def chop_basename(pth)
17
21
  FasterPath.chop_basename(pth)
18
22
  end
@@ -1,3 +1,3 @@
1
1
  module FasterPath
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
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
- //#[no_mangle]
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());
@@ -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
  #[no_mangle]
2
7
  pub extern fn basename_for_chop(string: *const c_char) -> *const c_char {
3
8
  let c_str = unsafe {
@@ -1,3 +1,7 @@
1
+ use libc::c_char;
2
+ use std::ffi::{CStr};
3
+ use std::str;
4
+
1
5
  #[no_mangle]
2
6
  pub extern fn both_are_blank(s1: *const c_char, s2: *const c_char) -> bool {
3
7
  let c_str1 = unsafe {
data/src/dirname.rs CHANGED
@@ -1,3 +1,8 @@
1
+ use std::path::{Path,MAIN_SEPARATOR};
2
+ use libc::c_char;
3
+ use std::ffi::{CStr,CString};
4
+ use std::str;
5
+
1
6
  #[no_mangle]
2
7
  pub extern fn dirname(string: *const c_char) -> *const c_char {
3
8
  let c_str = unsafe {
@@ -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
  #[no_mangle]
2
7
  pub extern fn dirname_for_chop(string: *const c_char) -> *const c_char {
3
8
  let c_str = unsafe {
data/src/is_absolute.rs CHANGED
@@ -1,3 +1,9 @@
1
+ use libc::c_char;
2
+ use std::ffi::{CStr};
3
+ use std::str;
4
+ use std::path::MAIN_SEPARATOR;
5
+
6
+
1
7
  #[no_mangle]
2
8
  pub extern fn is_absolute(string: *const c_char) -> bool {
3
9
  let c_str = unsafe {
data/src/is_blank.rs CHANGED
@@ -1,3 +1,7 @@
1
+ use libc::c_char;
2
+ use std::ffi::{CStr};
3
+ use std::str;
4
+
1
5
  #[no_mangle]
2
6
  pub extern fn is_blank(string: *const c_char) -> bool {
3
7
  let c_str = unsafe {
@@ -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
@@ -1,3 +1,8 @@
1
+ use std::path::MAIN_SEPARATOR;
2
+ use libc::c_char;
3
+ use std::ffi::{CStr};
4
+ use std::str;
5
+
1
6
  #[no_mangle]
2
7
  pub extern fn is_relative(string: *const c_char) -> bool {
3
8
  let c_str = unsafe {
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
- use std::path::{Path,MAIN_SEPARATOR};
10
- use libc::c_char;
11
- use std::ffi::{CStr,CString};
12
- use std::str;
13
- use std::mem;
14
-
15
- include!("ruby_string.rs");
16
- include!("ruby_array.rs");
17
- include!("is_absolute.rs");
18
- include!("is_relative.rs");
19
- include!("is_blank.rs");
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
@@ -1,3 +1,6 @@
1
+ use libc;
2
+ use std::mem;
3
+
1
4
  #[repr(C)]
2
5
  pub struct RubyArray {
3
6
  len: libc::size_t,
data/src/ruby_string.rs CHANGED
@@ -1,3 +1,7 @@
1
+ use libc::c_char;
2
+ use std::ffi::{CStr,CString};
3
+ use std::str;
4
+
1
5
  pub struct RubyString;
2
6
 
3
7
  // Coercing strs into Strings has some loss of performance
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.5
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-17 00:00:00.000000000 Z
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