faster_path 0.1.11 → 0.1.12

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: ff5facbf74ee4f0f136736a30ac47a525f6eb39b
4
- data.tar.gz: 0a9ef741f3fce8b6786f2917fda4f43d2e81e185
3
+ metadata.gz: c5bfc3ff4266b588930207d414eeb0eb1ae7b8d7
4
+ data.tar.gz: 58191c69400ca14fdbdd0ce4d5c8ed7666e9674e
5
5
  SHA512:
6
- metadata.gz: 1b2b36657e420010b1cf931bb6e0ba75299277689cd2f84ca0e04b1b8b2e8d02ca00ffc0f3a39b27f1ea1b8451082caf26fb3a158f54eea8119081c63c0bb30f
7
- data.tar.gz: 111d7bf455b8db96f55f5f5b664d876ede2bb78b163e21672162a58c751c32d6328b2cb2340ffeaa1de561e3f114fd9417f93f9ffb147bd97ce1f24bfcb3dd91
6
+ metadata.gz: af28e5efb74251311e18af3991b99d08550f40961116738641f39b1c883d4ac0248547563210cd32c67ff87705da21ef7de7a7fbf02783c66625867bec79b0d3
7
+ data.tar.gz: 763bc9c1199eec48b708f00e5f68d4dba2e110c17d587b627a6148cfd06f2a134ea1e9a5a3f7d2db8574cce5ee3de1438527496d5f0b72bd30a3c02fe0272d83
data/Cargo.lock CHANGED
@@ -2,13 +2,20 @@
2
2
  name = "faster_path"
3
3
  version = "0.0.1"
4
4
  dependencies = [
5
+ "array_tool 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
5
6
  "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
6
7
  ]
7
8
 
9
+ [[package]]
10
+ name = "array_tool"
11
+ version = "0.3.8"
12
+ source = "registry+https://github.com/rust-lang/crates.io-index"
13
+
8
14
  [[package]]
9
15
  name = "libc"
10
16
  version = "0.2.11"
11
17
  source = "registry+https://github.com/rust-lang/crates.io-index"
12
18
 
13
19
  [metadata]
20
+ "checksum array_tool 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "10ef6b307cf6a0a6c1a7e3dbb4e9315cc79d2e2d27c2d9674413738686b63e62"
14
21
  "checksum libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c96061f0c8a2dc27482e394d82e23073569de41d73cd736672ccd3e5c7471bfd"
data/Cargo.toml CHANGED
@@ -14,3 +14,4 @@ crate-type = ["dylib"]
14
14
 
15
15
  [dependencies]
16
16
  libc = "0.2.11"
17
+ array_tool = "0.3.8"
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.1.10.svg)](https://github.com/danielpclark/faster_path/pulse)
6
+ [![Commits Since Last Release](https://img.shields.io/github/commits-since/danielpclark/faster_path/v0.1.11.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)
data/Rakefile CHANGED
@@ -2,6 +2,28 @@ require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
  require 'fileutils'
4
4
 
5
+ desc 'System Details'
6
+ task :sysinfo do
7
+ puts "faster_path #{FasterPath::VERSION}"
8
+ puts
9
+ puts `rustc -Vv`
10
+ puts `cargo -Vv`
11
+ IO.read('Cargo.toml').split('[dependencies]').last.split("\n").
12
+ select {|line| line =~ /=/ }.
13
+ each {|line| puts "%s\t%s" % line.match(/(\S+)[ ="']{1,4}([\d.]+)["']?/).captures }
14
+ puts
15
+ puts RUBY_DESCRIPTION
16
+ puts "bundler\t#{Bundler::VERSION}"
17
+ puts "rake\t#{Rake::VERSION}"
18
+ require 'ffi/version';
19
+ puts "ffi\t#{FFI::VERSION}"
20
+ begin
21
+ puts "%s\t%s" % IO.read('Gemfile.lock').match(/(mspec) \(([\d\.]+)\)/).captures
22
+ rescue Errno::ENOENT => _
23
+ puts "\nNo Gemfile.lock"
24
+ end
25
+ end
26
+
5
27
  desc "Build Rust extension"
6
28
  task :build_src do
7
29
  puts "Building extension..."
@@ -45,13 +67,23 @@ task test: [:minitest, :lint] do |_t|
45
67
  exec 'mspec --format spec core/file/basename core/file/extname core/file/dirname library/pathname'
46
68
  end
47
69
 
70
+ desc "Full mspec results w/o encoding"
71
+ task :mspec_full do
72
+ exec %(bash -c "TEST_MONKEYPATCHES=true WITH_REGRESSION=true mspec --format spec core/file/basename core/file/extname core/file/dirname library/pathname")
73
+ end
74
+
75
+ desc "Full mspec results w/ encoding"
76
+ task :mspec_encoding_full do
77
+ exec %(bash -c "ENCODING=1 TEST_MONKEYPATCHES=true WITH_REGRESSION=true mspec --format spec core/file/basename core/file/extname core/file/dirname library/pathname")
78
+ end
79
+
48
80
  Rake::TestTask.new(bench: :build_lib) do |t|
49
- t.libs = %w(lib test)
81
+ t.libs = %w[lib test]
50
82
  t.pattern = 'test/**/*_benchmark.rb'
51
83
  end
52
84
 
53
85
  Rake::TestTask.new(pbench: :build_lib) do |t|
54
- t.libs = %w(lib test test/pbench)
86
+ t.libs = %w[lib test test/pbench]
55
87
  t.pattern = 'test/pbench/pbench_suite.rb'
56
88
  end
57
89
 
@@ -2,20 +2,27 @@ require 'pathname'
2
2
 
3
3
  module FasterPath
4
4
  module MonkeyPatches
5
+ # rubocop:disable Metrics/CyclomaticComplexity
5
6
  def self._ruby_core_file!
6
7
  ::File.class_eval do
7
8
  def self.basename(pth, ext = '')
9
+ pth = pth.to_path if pth.respond_to? :to_path
10
+ raise TypeError unless pth.is_a? String
8
11
  FasterPath.basename(pth, ext)
9
12
  end
10
13
 
11
14
  def self.extname(pth)
15
+ pth = pth.to_path if pth.respond_to? :to_path
16
+ raise TypeError unless pth.is_a? String
12
17
  FasterPath.extname(pth)
13
18
  end
14
19
 
15
20
  def self.dirname(pth)
21
+ pth = pth.to_path if pth.respond_to? :to_path
22
+ raise TypeError unless pth.is_a? String
16
23
  FasterPath.dirname(pth)
17
24
  end
18
- end if ENV['WITH_REGRESSION']
25
+ end
19
26
  end
20
27
 
21
28
  def self._ruby_library_pathname!
@@ -55,8 +62,8 @@ module FasterPath
55
62
  end
56
63
  private_constant :MonkeyPatches
57
64
 
58
- def self.sledgehammer_everything!
59
- MonkeyPatches._ruby_core_file!
65
+ def self.sledgehammer_everything!(include_file = !!ENV['WITH_REGRESSION'])
66
+ MonkeyPatches._ruby_core_file! if include_file # SLOW; DON'T AUTO INCLUDE
60
67
  MonkeyPatches._ruby_library_pathname!
61
68
  "CAUTION: Monkey patching effects everything! Be very sure you want this!"
62
69
  end
@@ -4,14 +4,20 @@ module FasterPath
4
4
  module RefineFile
5
5
  refine File do
6
6
  def self.basename(pth, ext = '')
7
+ pth = pth.to_path if pth.respond_to? :to_path
8
+ raise TypeError unless pth.is_a? String
7
9
  FasterPath.basename(pth, ext)
8
10
  end
9
11
 
10
12
  def self.extname(pth)
13
+ pth = pth.to_path if pth.respond_to? :to_path
14
+ raise TypeError unless pth.is_a? String
11
15
  FasterPath.extname(pth)
12
16
  end
13
17
 
14
18
  def self.dirname(pth)
19
+ pth = pth.to_path if pth.respond_to? :to_path
20
+ raise TypeError unless pth.is_a? String
15
21
  FasterPath.dirname(pth)
16
22
  end
17
23
  end
@@ -1,3 +1,3 @@
1
1
  module FasterPath
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
data/src/basename.rs CHANGED
@@ -1,17 +1,23 @@
1
+ extern crate array_tool;
1
2
  use libc::c_char;
2
3
  use std::ffi::{CStr, CString};
3
4
  use path_parsing::extract_last_path_segment;
5
+ use self::array_tool::string::Squeeze;
4
6
 
5
7
  #[no_mangle]
6
8
  pub extern "C" fn basename(c_pth: *const c_char, c_ext: *const c_char) -> *const c_char {
7
- // TODO: rb_raise on type or encoding errors
8
- // TODO: support objects that respond to `to_path`
9
9
  if c_pth.is_null() || c_ext.is_null() {
10
10
  return c_pth;
11
11
  }
12
12
  let pth = unsafe { CStr::from_ptr(c_pth) }.to_str().unwrap();
13
13
  let ext = unsafe { CStr::from_ptr(c_ext) }.to_str().unwrap();
14
14
 
15
+ // Known edge case
16
+ match &pth.squeeze("/")[..] {
17
+ "/" => { return CString::new("/").unwrap().into_raw() }
18
+ _ => {}
19
+ }
20
+
15
21
  let mut name = extract_last_path_segment(pth);
16
22
 
17
23
  if ext == ".*" {
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.11
4
+ version: 0.1.12
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: 2017-03-01 00:00:00.000000000 Z
11
+ date: 2017-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  version: '0'
212
212
  requirements: []
213
213
  rubyforge_project:
214
- rubygems_version: 2.6.10
214
+ rubygems_version: 2.6.11
215
215
  signing_key:
216
216
  specification_version: 4
217
217
  summary: Reimplementation of Pathname for better performance