faster_path 0.3.2 → 0.3.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 -2
- data/Rakefile +1 -0
- data/ext/Rakefile +2 -1
- data/faster_path.gemspec +20 -20
- data/lib/faster_path/thermite_initialize.rb +16 -0
- data/lib/faster_path/version.rb +1 -1
- data/lib/faster_path.rb +1 -0
- data/lib/faster_path.so +0 -0
- data/src/helpers.rs +3 -1
- data/src/pathname.rs +29 -0
- data/src/pathname_sys.rs +16 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9810b638650c7a45d00f4e89971b0cac59275b7f93ecb0f14bef436178168d54
|
4
|
+
data.tar.gz: 50c8087b92194dc7ef647e10cfb196e1b34a3d07d4943a18f1fa3a2994ffe6e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce61ad5a3197562c9cb5669fdd255ad612fee60bab943c38ce2a6f14eba888bd493bf4a91872a6dda83a1fb03cedabcc9cba6d68803073fed8ee126f80631bfc
|
7
|
+
data.tar.gz: be4799a77231a45b410e8b4207903a288c65ba284ec58bd68a6061ab2ca2440d52e159b1513abf75ce582d3505c5a586d08023854e2c4d7fd108f357824de484
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![TravisCI Build Status](https://travis-ci.org/danielpclark/faster_path.svg?branch=master)](https://travis-ci.org/danielpclark/faster_path)
|
4
4
|
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/10ul0gk3cwhlt2lj/branch/master?svg=true)](https://ci.appveyor.com/project/danielpclark/faster-path/branch/master)
|
5
5
|
[![Latest Tag](https://img.shields.io/github/tag/danielpclark/faster_path.svg)](https://github.com/danielpclark/faster_path/tags)
|
6
|
-
[![Commits Since Last Release](https://img.shields.io/github/commits-since/danielpclark/faster_path/v0.3.
|
6
|
+
[![Commits Since Last Release](https://img.shields.io/github/commits-since/danielpclark/faster_path/v0.3.6.svg)](https://github.com/danielpclark/faster_path/pulse)
|
7
7
|
[![Binary Release](https://img.shields.io/github/release/danielpclark/faster_path.svg)](https://github.com/danielpclark/faster_path/releases)
|
8
8
|
[![Coverage Status](https://coveralls.io/repos/github/danielpclark/faster_path/badge.svg)](https://coveralls.io/github/danielpclark/faster_path)
|
9
9
|
[![Inline docs](http://inch-ci.org/github/danielpclark/faster_path.svg?branch=master)](http://inch-ci.org/github/danielpclark/faster_path)
|
@@ -115,7 +115,7 @@ curl -sSf https://static.rust-lang.org/rustup.sh | sh
|
|
115
115
|
Add this line to your application's Gemfile:
|
116
116
|
|
117
117
|
```ruby
|
118
|
-
gem 'faster_path', '~> 0.3.
|
118
|
+
gem 'faster_path', '~> 0.3.6'
|
119
119
|
```
|
120
120
|
|
121
121
|
And then execute:
|
data/Rakefile
CHANGED
data/ext/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'thermite/tasks'
|
2
|
+
require_relative '../lib/faster_path/thermite_initialize'
|
2
3
|
|
3
|
-
project_toplevel_dir = File.dirname(
|
4
|
+
project_toplevel_dir = File.dirname(__dir__)
|
4
5
|
Thermite::Tasks.new(cargo_project_path: project_toplevel_dir,
|
5
6
|
ruby_project_path: project_toplevel_dir)
|
6
7
|
|
data/faster_path.gemspec
CHANGED
@@ -4,36 +4,36 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'faster_path/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'faster_path'
|
8
8
|
spec.version = FasterPath::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Daniel P. Clark']
|
10
|
+
spec.email = ['6ftdan@gmail.com']
|
11
11
|
spec.summary = 'Reimplementation of Pathname for better performance'
|
12
12
|
spec.description = 'FasterPath is a reimplementation of Pathname for better performance.'
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'https://github.com/danielpclark/faster_path'
|
14
|
+
spec.license = 'MIT OR Apache-2.0'
|
15
15
|
|
16
16
|
spec.files = [
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
'Cargo.lock', 'Cargo.toml', 'Gemfile',
|
18
|
+
'MIT-LICENSE.txt', 'README.md', 'Rakefile', 'bin/console', 'bin/setup',
|
19
|
+
'ext/Rakefile', 'faster_path.gemspec'
|
20
20
|
]
|
21
21
|
spec.files += Dir['lib/**/*']
|
22
22
|
spec.files += Dir['src/**/*']
|
23
23
|
|
24
|
-
spec.extensions = [
|
25
|
-
spec.require_paths = [
|
24
|
+
spec.extensions = ['ext/Rakefile']
|
25
|
+
spec.require_paths = ['lib']
|
26
26
|
|
27
|
-
spec.add_dependency
|
28
|
-
spec.add_dependency
|
29
|
-
spec.add_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
27
|
+
spec.add_dependency 'bundler', '~> 1.12'
|
28
|
+
spec.add_dependency 'rake', '~> 12.0'
|
29
|
+
spec.add_dependency 'thermite', '0.13.0'
|
30
|
+
spec.add_development_dependency 'read_source', '~> 0.2.6'
|
31
|
+
spec.add_development_dependency 'minitest', '~> 5.10'
|
32
|
+
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
|
33
|
+
spec.add_development_dependency 'color_pound_spec_reporter', '~> 0.0.9'
|
34
|
+
spec.add_development_dependency 'rubocop', '0.53'
|
35
|
+
spec.add_development_dependency 'stop_watch', '~> 1.0'
|
36
36
|
if !ENV['CI'] && ENV['GRAPH']
|
37
|
-
spec.add_development_dependency
|
37
|
+
spec.add_development_dependency 'gruff', '~> 0.7.0'
|
38
38
|
end
|
39
39
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require_relative './version'
|
3
|
+
|
4
|
+
module Thermite
|
5
|
+
class Config
|
6
|
+
def ruby_version
|
7
|
+
"ruby#{RUBY_VERSION}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Tasks
|
12
|
+
def github_download_uri(_tag, version)
|
13
|
+
"#{github_uri}/releases/download/v#{FasterPath::VERSION}/#{config.tarball_filename(version)}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/faster_path/version.rb
CHANGED
data/lib/faster_path.rb
CHANGED
data/lib/faster_path.so
ADDED
Binary file
|
data/src/helpers.rs
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
use ruru::{RString, Object, Class, AnyObject};
|
2
|
+
extern crate ruby_sys;
|
2
3
|
use debug::RubyDebugInfo;
|
4
|
+
use pathname::Pathname;
|
3
5
|
|
4
6
|
pub trait TryFrom<T>: Sized {
|
5
7
|
type Error;
|
@@ -30,7 +32,7 @@ pub fn anyobject_to_string(item: AnyObject) -> Result<String, RubyDebugInfo> {
|
|
30
32
|
}
|
31
33
|
|
32
34
|
if result.respond_to("to_path") {
|
33
|
-
return Ok(
|
35
|
+
return Ok(Pathname::from(result.send("to_path", None).value()).
|
34
36
|
instance_variable_get("@path").
|
35
37
|
try_convert_to::<RString>().
|
36
38
|
unwrap_or(RString::new("")).
|
data/src/pathname.rs
CHANGED
@@ -9,6 +9,7 @@ use plus;
|
|
9
9
|
use relative_path_from;
|
10
10
|
use debug;
|
11
11
|
use helpers::TryFrom;
|
12
|
+
use pathname_sys::null_byte_check;
|
12
13
|
|
13
14
|
use ruru;
|
14
15
|
use ruru::{
|
@@ -20,6 +21,7 @@ use ruru::{
|
|
20
21
|
Object,
|
21
22
|
Class,
|
22
23
|
VerifiedObject,
|
24
|
+
Exception as Exc,
|
23
25
|
AnyException as Exception
|
24
26
|
};
|
25
27
|
use ruru::types::{Value, ValueType};
|
@@ -42,6 +44,31 @@ impl Pathname {
|
|
42
44
|
Pathname { value: instance.value() }
|
43
45
|
}
|
44
46
|
|
47
|
+
pub fn new_checked(path: AnyObject) -> Result<Pathname, Exception> {
|
48
|
+
let pth: Value = if Class::from_existing("String").case_equals(&path) {
|
49
|
+
path.value()
|
50
|
+
} else if path.respond_to("to_path") {
|
51
|
+
path.send("to_path", None).value()
|
52
|
+
} else {
|
53
|
+
return Err(
|
54
|
+
Exception::new(
|
55
|
+
"ArgumentError",
|
56
|
+
Some("The type for the argument provided to Pathname.new was invalid.")
|
57
|
+
)
|
58
|
+
)
|
59
|
+
};
|
60
|
+
|
61
|
+
if null_byte_check(path.value()) {
|
62
|
+
return Err( Exception::new("ArgumentError", Some("pathname contains null byte")) )
|
63
|
+
}
|
64
|
+
|
65
|
+
// if it crashes then dup the path string here before assigning to @path
|
66
|
+
let mut instance = Class::from_existing("Pathname").allocate();
|
67
|
+
instance.instance_variable_set("@path", RString::from(pth).to_any_object());
|
68
|
+
|
69
|
+
Ok(Pathname { value: instance.value() })
|
70
|
+
}
|
71
|
+
|
45
72
|
pub fn to_any_object(&self) -> AnyObject {
|
46
73
|
AnyObject::from(self.value())
|
47
74
|
}
|
@@ -60,6 +87,8 @@ impl TryFrom<AnyObject> for Pathname {
|
|
60
87
|
Ok(Pathname::new(&RString::from(obj.value()).to_string()))
|
61
88
|
} else if Class::from_existing("Pathname").case_equals(&obj) {
|
62
89
|
Ok(Pathname::from(obj.value()))
|
90
|
+
} else if obj.respond_to("to_path") {
|
91
|
+
Ok(Pathname::from(obj.send("to_path", None).value()))
|
63
92
|
} else {
|
64
93
|
Err(Self::Error::from(obj))
|
65
94
|
}
|
data/src/pathname_sys.rs
CHANGED
@@ -2,8 +2,23 @@ use ruru::{AnyObject, Array, Object, AnyException};
|
|
2
2
|
use ruru::types::{Argc, Value, CallbackPtr};
|
3
3
|
use ruru::util::str_to_cstring;
|
4
4
|
extern crate ruby_sys;
|
5
|
-
use self::ruby_sys::{class, util, vm};
|
5
|
+
use self::ruby_sys::{class, util, vm, string};
|
6
6
|
use ::pathname;
|
7
|
+
extern crate memchr;
|
8
|
+
use self::memchr::memchr;
|
9
|
+
use std::slice;
|
10
|
+
|
11
|
+
pub fn null_byte_check(value: Value) -> bool {
|
12
|
+
unsafe {
|
13
|
+
let str = string::rb_string_value_ptr(&value) as *const u8;
|
14
|
+
|
15
|
+
// `rb_str_len` is a ruby_sys specific thing. Consider:
|
16
|
+
// extern { fn rb_str_strlen(value: Value) -> c_long } as isize
|
17
|
+
let len = string::rb_str_len(value) as usize;
|
18
|
+
|
19
|
+
memchr(b'\0', slice::from_raw_parts(str, len)).is_some()
|
20
|
+
}
|
21
|
+
}
|
7
22
|
|
8
23
|
pub fn raise(exception: AnyException) {
|
9
24
|
unsafe { vm::rb_exc_raise(exception.value()); }
|
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.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: thermite
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.13.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.13.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -155,8 +155,10 @@ files:
|
|
155
155
|
- ext/Rakefile
|
156
156
|
- faster_path.gemspec
|
157
157
|
- lib/faster_path.rb
|
158
|
+
- lib/faster_path.so
|
158
159
|
- lib/faster_path/optional/monkeypatches.rb
|
159
160
|
- lib/faster_path/optional/refinements.rb
|
161
|
+
- lib/faster_path/thermite_initialize.rb
|
160
162
|
- lib/faster_path/version.rb
|
161
163
|
- src/basename.rs
|
162
164
|
- src/chop_basename.rs
|