faster_path 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40367b49892754c5b9d83891289cc0ce30e757d6
4
- data.tar.gz: 8a92f9a7796c946a873cfded321b529f1f8d57bf
3
+ metadata.gz: ff5facbf74ee4f0f136736a30ac47a525f6eb39b
4
+ data.tar.gz: 0a9ef741f3fce8b6786f2917fda4f43d2e81e185
5
5
  SHA512:
6
- metadata.gz: 8dc854ddd64ba12ac79ff11e792bf5fc6723d3ea547056d474a344572e0608f0e0c0c0d688c39a70c50e5a636d36215d0906a952cd65f58402a7fc05d8f135c4
7
- data.tar.gz: f0e6009a18eeeb0414836f3b13d4684db44839e466845b745c6b08440da63ad247be78acc7671ef53c07dc8c69237d0e964e81c3bd9bb9dd717ce17a65fd2184
6
+ metadata.gz: 1b2b36657e420010b1cf931bb6e0ba75299277689cd2f84ca0e04b1b8b2e8d02ca00ffc0f3a39b27f1ea1b8451082caf26fb3a158f54eea8119081c63c0bb30f
7
+ data.tar.gz: 111d7bf455b8db96f55f5f5b664d876ede2bb78b163e21672162a58c751c32d6328b2cb2340ffeaa1de561e3f114fd9417f93f9ffb147bd97ce1f24bfcb3dd91
data/Gemfile CHANGED
@@ -1,11 +1,14 @@
1
1
  source 'https://rubygems.org' do
2
2
  # Specify your gem's dependencies in faster_path.gemspec
3
3
  gemspec
4
+ group :test do
5
+ gem 'coveralls', require: false
6
+ end
4
7
  end
5
8
 
6
9
  begin
7
10
  # https://github.com/ruby/spec dependencies
8
- eval_gemfile File.expand_path('spec/ruby_spec/Gemfile', File.dirname(__FILE__))
11
+ eval_gemfile File.expand_path('spec/ruby_spec/Gemfile', File.dirname(__FILE__))
9
12
  rescue
10
13
  `git submodule update --init`
11
14
  eval_gemfile File.expand_path('spec/ruby_spec/Gemfile', File.dirname(__FILE__))
data/README.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # FasterPath
2
2
  [![Gem Version](https://badge.fury.io/rb/faster_path.svg)](https://badge.fury.io/rb/faster_path)
3
- [![Build Status](https://travis-ci.org/danielpclark/faster_path.svg?branch=master)](https://travis-ci.org/danielpclark/faster_path)
3
+ [![TravisCI Build Status](https://travis-ci.org/danielpclark/faster_path.svg?branch=master)](https://travis-ci.org/danielpclark/faster_path)
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
+ [![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)
7
+ [![Binary Release](https://img.shields.io/github/release/danielpclark/faster_path.svg)](https://github.com/danielpclark/faster_path/releases)
8
+ [![Coverage Status](https://coveralls.io/repos/github/danielpclark/faster_path/badge.svg)](https://coveralls.io/github/danielpclark/faster_path)
9
+ [![Inline docs](http://inch-ci.org/github/danielpclark/faster_path.svg?branch=master)](http://inch-ci.org/github/danielpclark/faster_path)
10
+ [![Code Triagers Badge](https://www.codetriage.com/danielpclark/faster_path/badges/users.svg)](https://www.codetriage.com/danielpclark/faster_path)
4
11
  [![Tweet This](https://raw.githubusercontent.com/danielpclark/faster_path/master/assets/tweet.png)](https://twitter.com/share?url=https%3A%2F%2Fgithub.com%2Fdanielpclark%2Ffaster_path&via=6ftdan&hashtags=Ruby&text=You%20could%20save%2015%25%20or%20more%20on%20website%20page%20load%20time%20by%20switching%20to%20the%20FasterPath%20gem.)
5
- [New Wiki Up!](https://github.com/danielpclark/faster_path/wiki)
6
12
 
7
13
  #### This gem shaves off more than 30% of my Rails application page load time.
8
14
 
@@ -176,7 +182,7 @@ FasterPath.sledgehammer_everything!
176
182
  It's been my observation (and some others) that the Rust implementation of the C code for `File` has similar results but
177
183
  performance seems to vary based on CPU cache on possibly 64bit/32bit system environmnets.
178
184
 
179
- **Developers for FasterPath:** Most of these need to be rewritten, please use `WITH_REGRESSION` in your testing. You can see the resulting failures currently on TravisCI under "Allow Failures".
185
+ **Developers for FasterPath:** Most of these need to be rewritten, please use `WITH_REGRESSION=true TEST_MONKEYPATCHES=true` in your testing. You can see the resulting failures currently on TravisCI under "Allow Failures".
180
186
 
181
187
  ## Getting Started with Development
182
188
 
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'fileutils'
5
5
  desc "Build Rust extension"
6
6
  task :build_src do
7
7
  puts "Building extension..."
8
- system("cargo build --release")
8
+ sh "cargo build --release"
9
9
  end
10
10
 
11
11
  desc "Clean up Rust build"
@@ -16,9 +16,9 @@ task :clean_src do
16
16
  rm_rf(
17
17
  Dir.
18
18
  glob('target/release/*').
19
- keep_if {|f|
19
+ keep_if do |f|
20
20
  !f[/\.(?:so|dll|dylib|deps)\z/]
21
- }
21
+ end
22
22
  )
23
23
  end
24
24
 
@@ -27,13 +27,21 @@ task build_lib: [:build_src, :clean_src] do
27
27
  puts "Completed build!"
28
28
  end
29
29
 
30
+ desc "Code Quality Check"
31
+ task :lint do
32
+ puts
33
+ puts "Quality check starting..."
34
+ sh "rubocop"
35
+ puts
36
+ end
37
+
30
38
  Rake::TestTask.new(minitest: :build_lib) do |t|
31
39
  t.libs << "test"
32
40
  t.libs << "lib"
33
41
  t.test_files = FileList['test/**/*_test.rb']
34
42
  end
35
43
 
36
- task :test => :minitest do |t|
44
+ task test: [:minitest, :lint] do |_t|
37
45
  exec 'mspec --format spec core/file/basename core/file/extname core/file/dirname library/pathname'
38
46
  end
39
47
 
@@ -8,12 +8,12 @@ unless find_executable('cargo')
8
8
  puts
9
9
  puts "curl -sSf https://static.rust-lang.org/rustup.sh | sudo sh -s -- --channel=nightly"
10
10
  puts
11
- END { puts "Exiting..."}
11
+ at_exit { puts "Exiting..."}
12
12
  end
13
13
 
14
14
  Dir.chdir(File.expand_path("../../", File.dirname(__FILE__))) do
15
- %x(rake build_src)
16
- %x(rake clean_src)
15
+ `rake build_src`
16
+ `rake clean_src`
17
17
  end
18
18
 
19
19
  create_makefile('faster_path/dummy')
data/faster_path.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = FasterPath::VERSION
9
9
  spec.authors = ["Daniel P. Clark"]
10
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.}
11
+ spec.summary = 'Reimplementation of Pathname for better performance'
12
+ spec.description = 'FasterPath is a reimplementation of Pathname for better performance.'
13
13
  spec.homepage = "https://github.com/danielpclark/faster_path"
14
14
  spec.license = "MIT OR Apache-2.0"
15
15
 
@@ -30,8 +30,9 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "method_source", "~> 0.8.2"
31
31
  spec.add_development_dependency "minitest", "~> 5.10"
32
32
  spec.add_development_dependency "minitest-reporters", "~> 1.1"
33
- spec.add_development_dependency "color_pound_spec_reporter", "~> 0.0.5"
34
- unless ENV['TRAVIS']
33
+ spec.add_development_dependency "color_pound_spec_reporter", "~> 0.0.9"
34
+ spec.add_development_dependency "rubocop", "~> 0.47"
35
+ unless ENV['CI']
35
36
  spec.add_development_dependency "stop_watch", "~> 0.1.0"
36
37
  spec.add_development_dependency "gruff", "~> 0.7.0"
37
38
  end
data/lib/faster_path.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "faster_path/version"
2
2
  require 'pathname'
3
3
  require "ffi"
4
+ require 'faster_path/asset_resolution'
4
5
 
5
6
  module FasterPath
6
7
  def self.rust_arch_bits
@@ -35,8 +36,9 @@ module FasterPath
35
36
  # This implementation correctly handles blank strings just as Pathname had intended
36
37
  # to handle non-path strings.
37
38
  def self.chop_basename(pth)
38
- d,b = [Rust.dirname_for_chop(pth), Rust.basename_for_chop(pth)]
39
- [d,b] unless Rust.both_are_blank(d,b)
39
+ d = Rust.dirname_for_chop(pth)
40
+ b = Rust.basename_for_chop(pth)
41
+ [d, b] unless Rust.both_are_blank(d, b)
40
42
  end
41
43
 
42
44
  def self.blank?(str)
@@ -64,16 +66,15 @@ module FasterPath
64
66
  end
65
67
 
66
68
  # EXAMPLE
67
- #def self.one_and_two
69
+ # def self.one_and_two
68
70
  # Rust.one_and_two.to_a
69
- #end
71
+ # end
70
72
 
71
- private
72
73
  module Rust
73
74
  extend FFI::Library
74
75
  ffi_lib begin
75
76
  prefix = Gem.win_platform? ? "" : "lib"
76
- "#{File.expand_path("../target/release/", File.dirname(__FILE__))}/#{prefix}faster_path.#{FFI::Platform::LIBSUFFIX}"
77
+ "#{File.expand_path("../target/release/", __dir__)}/#{prefix}faster_path.#{FFI::Platform::LIBSUFFIX}"
77
78
  end
78
79
 
79
80
  class FromRustArray < FFI::Struct
@@ -101,7 +102,7 @@ module FasterPath
101
102
  attach_function :entries, [ :string ], FromRustArray.by_value
102
103
 
103
104
  # EXAMPLE
104
- #attach_function :one_and_two, [], FromRustArray.by_value
105
+ # attach_function :one_and_two, [], FromRustArray.by_value
105
106
  end
106
107
  private_constant :Rust
107
108
  end
@@ -0,0 +1,59 @@
1
+ # This is a redundancy check for the rust compiled library needed for this gem.
2
+ # If the asset is not available and we can't compile it from this code then FAIL
3
+ # on require of 'faster_path' with a very clear message as to why."
4
+
5
+ module FasterPath
6
+ module AssetResolution # BREAK IN CASE OF EMERGENCY ;-)
7
+ class << self
8
+ def verify!
9
+ return lib_file if file?
10
+
11
+ if rust?
12
+ compile!
13
+ raise "Rust failed to compile asset! The dynamic library for this package was not found." unless file?
14
+ return lib_file
15
+ end
16
+
17
+ raise "The dynamic library for this package was not found nor was Rust's cargo executable found. This package will not work without it!"
18
+ end
19
+
20
+ private
21
+
22
+ def compile!
23
+ require 'open3'
24
+ Dir.chdir(File.expand_path('../../', __dir__)) do
25
+ Open3.popen3("rake build_lib") do |stdin, stdout, stderr, wait_thr|
26
+ stdin.close
27
+
28
+ wait_thr && wait_thr.value.exitstatus
29
+ out = Thread.new { stdout.read }.value.strip
30
+ Thread.new { stderr.read }.value
31
+ out
32
+ end
33
+ end
34
+ File.exist? lib_file
35
+ end
36
+
37
+ def rust?
38
+ require 'mkmf'
39
+ MakeMakefile::Logging.instance_variable_set(:@log, File.open(File::NULL, 'w'))
40
+ MakeMakefile.instance_eval "undef :message; def message(*); end"
41
+ MakeMakefile.find_executable('cargo')
42
+ end
43
+
44
+ def file?
45
+ File.exist? lib_file
46
+ end
47
+
48
+ def lib_dir
49
+ File.expand_path("../../target/release/", __dir__)
50
+ end
51
+
52
+ def lib_file
53
+ prefix = Gem.win_platform? ? "" : "lib"
54
+ "#{lib_dir}/#{prefix}faster_path.#{FFI::Platform::LIBSUFFIX}"
55
+ end
56
+ end
57
+ end
58
+ end
59
+ FasterPath::AssetResolution.verify! unless ENV['TEST']
@@ -1,53 +1,63 @@
1
1
  require 'pathname'
2
2
 
3
3
  module FasterPath
4
- def self.sledgehammer_everything!
5
- ::File.class_eval do
6
- def self.basename(pth, ext = '')
7
- FasterPath.basename(pth, ext)
8
- end if ENV['WITH_REGRESSION']
9
-
10
- def self.extname(pth)
11
- FasterPath.extname(pth)
12
- end if ENV['WITH_REGRESSION']
13
-
14
- def self.dirname(pth)
15
- FasterPath.dirname(pth)
4
+ module MonkeyPatches
5
+ def self._ruby_core_file!
6
+ ::File.class_eval do
7
+ def self.basename(pth, ext = '')
8
+ FasterPath.basename(pth, ext)
9
+ end
10
+
11
+ def self.extname(pth)
12
+ FasterPath.extname(pth)
13
+ end
14
+
15
+ def self.dirname(pth)
16
+ FasterPath.dirname(pth)
17
+ end
16
18
  end if ENV['WITH_REGRESSION']
17
19
  end
18
20
 
19
- ::Pathname.class_eval do
20
- def absolute?
21
- FasterPath.absolute?(@path)
22
- end
23
-
24
- def directory?
25
- FasterPath.directory?(@path)
26
- end
27
-
28
- def chop_basename(pth)
29
- FasterPath.chop_basename(pth)
30
- end
31
- private :chop_basename
32
-
33
- def relative?
34
- FasterPath.relative?(@path)
35
- end
36
-
37
- def add_trailing_separator(pth)
38
- FasterPath.add_trailing_separator(pth)
39
- end
40
- private :add_trailing_separator
41
-
42
- def has_trailing_separator?(pth)
43
- FasterPath.has_trailing_separator?(pth)
21
+ def self._ruby_library_pathname!
22
+ ::Pathname.class_eval do
23
+ def absolute?
24
+ FasterPath.absolute?(@path)
25
+ end
26
+
27
+ def directory?
28
+ FasterPath.directory?(@path)
29
+ end
30
+
31
+ def chop_basename(pth)
32
+ FasterPath.chop_basename(pth)
33
+ end
34
+ private :chop_basename
35
+
36
+ def relative?
37
+ FasterPath.relative?(@path)
38
+ end
39
+
40
+ def add_trailing_separator(pth)
41
+ FasterPath.add_trailing_separator(pth)
42
+ end
43
+ private :add_trailing_separator
44
+
45
+ def has_trailing_separator?(pth)
46
+ FasterPath.has_trailing_separator?(pth)
47
+ end
48
+ private :has_trailing_separator?
49
+
50
+ def entries
51
+ FasterPath.entries(@path)
52
+ end
44
53
  end
45
- private :has_trailing_separator?
46
-
47
- def entries
48
- FasterPath.entries(@path)
49
- end if ENV['WITH_REGRESSION']
50
54
  end
55
+ end
56
+ private_constant :MonkeyPatches
57
+
58
+ def self.sledgehammer_everything!
59
+ MonkeyPatches._ruby_core_file!
60
+ MonkeyPatches._ruby_library_pathname!
51
61
  "CAUTION: Monkey patching effects everything! Be very sure you want this!"
52
62
  end
53
63
  end
@@ -47,7 +47,7 @@ module FasterPath
47
47
 
48
48
  def entries
49
49
  FasterPath.entries(@path)
50
- end if ENV['WITH_REGRESSION']
50
+ end
51
51
  end
52
52
  end
53
53
  end
@@ -1,3 +1,3 @@
1
1
  module FasterPath
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
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.10
4
+ version: 0.1.11
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-02-25 00:00:00.000000000 Z
11
+ date: 2017-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,14 +100,28 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.0.5
103
+ version: 0.0.9
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.0.5
110
+ version: 0.0.9
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.47'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.47'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: stop_watch
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -155,6 +169,7 @@ files:
155
169
  - ext/faster_path/extconf.rb
156
170
  - faster_path.gemspec
157
171
  - lib/faster_path.rb
172
+ - lib/faster_path/asset_resolution.rb
158
173
  - lib/faster_path/optional/monkeypatches.rb
159
174
  - lib/faster_path/optional/refinements.rb
160
175
  - lib/faster_path/version.rb