faster_path 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +5 -0
- data/Cargo.lock +12 -0
- data/Cargo.toml +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/Rakefile +15 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/faster_path.gemspec +25 -0
- data/lib/faster_path.rb +32 -0
- data/lib/faster_path/version.rb +3 -0
- data/src/lib.rs +28 -0
- data/target/release/libfaster_path.so +0 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4df270a95aa742a4ebdb10cac2ab2f761b1255b9
|
4
|
+
data.tar.gz: c3b4fe124baee6268a02ec46d9c25917ec63d5e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 40fcb306c9eb7d316f0fd590df581afc9e96165b7120d2e02ab6aeb750b3e3d03a4c325d2ecbe5212c563310114c43f7e9d37e4c737500ad37db3132f602a9f0
|
7
|
+
data.tar.gz: 3330b8afe7d5d1fd5ffab234bf2fbdd8e0dd988821f3133b32b5b2c62e93dad5a9df90ca1ef0daabb41fa72a6ef6139d19db360587b2b1da713e6c28bb9f50e2
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Cargo.lock
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
[root]
|
2
|
+
name = "faster_path"
|
3
|
+
version = "0.0.1"
|
4
|
+
dependencies = [
|
5
|
+
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
6
|
+
]
|
7
|
+
|
8
|
+
[[package]]
|
9
|
+
name = "libc"
|
10
|
+
version = "0.2.11"
|
11
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
12
|
+
|
data/Cargo.toml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
[package]
|
2
|
+
name = "faster_path"
|
3
|
+
version = "0.0.1"
|
4
|
+
authors = ["Daniel P. Clark <6ftdan@gmail.com>"]
|
5
|
+
description = "Alternative to Pathname"
|
6
|
+
homepage = "https://github.com/danielpclark/faster_path"
|
7
|
+
repository = "https://github.com/danielpclark/faster_path"
|
8
|
+
license = "MIT OR Apache-2.0"
|
9
|
+
readme = "README.md"
|
10
|
+
|
11
|
+
[lib]
|
12
|
+
name = "faster_path"
|
13
|
+
crate-type = ["dylib"]
|
14
|
+
|
15
|
+
[dependencies]
|
16
|
+
libc = "0.2.11"
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Daniel P. Clark
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# FasterPath
|
2
|
+
|
3
|
+
This project "WILL BE" a rewrite of Ruby's STDLIB **Pathname** optimized for speed and performance.
|
4
|
+
I am considering making it a \*nix OS gem, but that may likely just be an early phase. Windows support
|
5
|
+
can be added much later.
|
6
|
+
|
7
|
+
The primary **GOAL** of this project is to improve performance in the Rails environment as path relation
|
8
|
+
and file lookup is a huge bottleneck in performance. As this is the case the path performance updates
|
9
|
+
will likely not be limited to just changing Pathname but also will be offering changes in related methods
|
10
|
+
and classes.
|
11
|
+
|
12
|
+
Users will have the option to write their apps directly for this library, or they can choose to either
|
13
|
+
refine or monkeypatch the existing library. Refinements are narrowed to scope and monkeypatching will
|
14
|
+
be a sledge hammer ;-)
|
15
|
+
|
16
|
+
**NOTE**: Refinements and monkeypatch methods are highly likely to be changed and renamed pre version
|
17
|
+
0.1.0 so keep that in mind!
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'faster_path'
|
25
|
+
```
|
26
|
+
|
27
|
+
And then execute:
|
28
|
+
|
29
|
+
$ bundle
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
|
33
|
+
$ gem install faster_path
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
TODO: _(project is too young for usage details)_
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
42
|
+
|
43
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/danielpclark/faster_path.
|
48
|
+
|
49
|
+
|
50
|
+
## License
|
51
|
+
|
52
|
+
[MIT License](http://opensource.org/licenses/MIT) or APACHE 2.0 at your pleasure.
|
53
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
|
+
end
|
9
|
+
|
10
|
+
Rake::TestTask.new(:bench) do |t|
|
11
|
+
t.libs = %w(lib test)
|
12
|
+
t.pattern = 'test/**/*_benchmark.rb'
|
13
|
+
end
|
14
|
+
|
15
|
+
task :default => :test
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "faster_path"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/faster_path.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'faster_path/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "faster_path"
|
8
|
+
spec.version = FasterPath::VERSION
|
9
|
+
spec.authors = ["Daniel P. Clark"]
|
10
|
+
spec.email = ["6ftdan@gmail.com"]
|
11
|
+
spec.summary = %q{Reimplementation of Pathname for better performance}
|
12
|
+
spec.description = %q{FasterPath is a reimplementation of Pathname for better performance.}
|
13
|
+
spec.homepage = "https://github.com/danielpclark/faster_path"
|
14
|
+
spec.license = "MIT OR Apache-2.0"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "ffi"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "minitest", "~> 5.8"
|
25
|
+
end
|
data/lib/faster_path.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "faster_path/version"
|
2
|
+
require "ffi"
|
3
|
+
|
4
|
+
module FasterPath
|
5
|
+
def self.absolute?(pth)
|
6
|
+
Rust.absolute(pth)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.monkeypatch_pathname
|
10
|
+
class << ::Pathname
|
11
|
+
def absolute?
|
12
|
+
FasterPath.absolute?(@path)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module RefinePathname
|
18
|
+
refine Pathname do
|
19
|
+
def absolute?
|
20
|
+
FasterPath.absolute?(@path)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
module Rust
|
27
|
+
extend FFI::Library
|
28
|
+
ffi_lib 'target/release/libfaster_path.so'
|
29
|
+
attach_function :absolute, [ :string ], :bool
|
30
|
+
end
|
31
|
+
private_constant :Rust
|
32
|
+
end
|
data/src/lib.rs
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
// Copyright 2015-2016 Daniel P. Clark & Other Combinatorics Developers
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
|
4
|
+
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
|
5
|
+
// http://opensource.org/licenses/MIT>, at your option. This file may not be
|
6
|
+
// copied, modified, or distributed except according to those terms.
|
7
|
+
extern crate libc;
|
8
|
+
|
9
|
+
use libc::c_char;
|
10
|
+
use std::ffi::CStr;
|
11
|
+
use std::str;
|
12
|
+
|
13
|
+
#[no_mangle]
|
14
|
+
pub extern fn absolute(string: *const c_char) -> bool {
|
15
|
+
let c_str = unsafe {
|
16
|
+
assert!(!string.is_null());
|
17
|
+
|
18
|
+
CStr::from_ptr(string)
|
19
|
+
};
|
20
|
+
|
21
|
+
let r_str = str::from_utf8(c_str.to_bytes()).unwrap();
|
22
|
+
|
23
|
+
match r_str.chars().next() {
|
24
|
+
Some('/') => { true },
|
25
|
+
_ => { false },
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: faster_path
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel P. Clark
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.8'
|
69
|
+
description: FasterPath is a reimplementation of Pathname for better performance.
|
70
|
+
email:
|
71
|
+
- 6ftdan@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Cargo.lock
|
79
|
+
- Cargo.toml
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- faster_path.gemspec
|
87
|
+
- lib/faster_path.rb
|
88
|
+
- lib/faster_path/version.rb
|
89
|
+
- src/lib.rs
|
90
|
+
- target/release/libfaster_path.so
|
91
|
+
homepage: https://github.com/danielpclark/faster_path
|
92
|
+
licenses:
|
93
|
+
- MIT OR Apache-2.0
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.6.4
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Reimplementation of Pathname for better performance
|
115
|
+
test_files: []
|