sstephenson / hike Goto Github PK
View Code? Open in Web Editor NEWA Ruby library for finding files in a set of paths
License: MIT License
A Ruby library for finding files in a set of paths
License: MIT License
a example from http://rubydoc.info/gems/hike/1.2.0/Hike/Trail:find
trail.find("application") do |path|
return path if mime_type_for(path) == "text/css"
end
it raises
/home/guten/a/a.rb:8:in `block in <main>': unexpected return (LocalJumpError)
from /usr/lib/ruby/gems/1.9.1/gems/hike-1.2.0/lib/hike/index.rb:142:in `block in match'
from /usr/lib/ruby/gems/1.9.1/gems/hike-1.2.0/lib/hike/index.rb:134:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/hike-1.2.0/lib/hike/index.rb:134:in `match'
from /usr/lib/ruby/gems/1.9.1/gems/hike-1.2.0/lib/hike/index.rb:113:in `block in find_in_paths'
from /usr/lib/ruby/gems/1.9.1/gems/hike-1.2.0/lib/hike/index.rb:112:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/hike-1.2.0/lib/hike/index.rb:112:in `find_in_paths'
from /usr/lib/ruby/gems/1.9.1/gems/hike-1.2.0/lib/hike/index.rb:63:in `block in find'
from /usr/lib/ruby/gems/1.9.1/gems/hike-1.2.0/lib/hike/index.rb:57:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/hike-1.2.0/lib/hike/index.rb:57:in `find'
from /usr/lib/ruby/gems/1.9.1/gems/hike-1.2.0/lib/hike/trail.rb:139:in `find'
from /home/guten/a/a.rb:7:in `<main>'
for example
hike = Hike::Trail.new
hike.extensions.push ".rb"
hike.paths.replace $: # add $APP/lib/ into paths
hike.find("/etc/foo", "foo/rc", "~/.foorc") { |path|
# do some thing here.
}
it will find /etc/foo
, $APP/lib/foo/rc.rb
, ~/.foorc
files
trail = Hike::Trail.new
trail.extensions.push ".rb"
trail.paths.push "/tmp"
trail.find "foo"
for below files
/tmp/foo.rb
/tmp/foo
it finds "/tmp/foo". bug?
for another scene.
I want to find "/tmp/foo.rb", but we only have a "foo" file in "/tmp" directory, then it goes wrong.
I suggest like this
trail = Hike::Trail.new
trail.extensions.push ".rb", "" # first find "foo.rb", then "foo"
trail.paths.push "/tmp"
as none of the ruby files have a license header, you want to have some copyright/license in the gem file.
This test is now failing in brochure
BrochureTest#test_index_templates_are_rendered_for_directories
The regression started in 0.5.x
Please add a tag for 2.1.3
Pathname#absolute?
and Pathname#join?
are terrible slow. Lets axe as much as can. We still need to consider Windows while making these performance changes.
Hot spots:
https://github.com/sstephenson/hike/blob/master/lib/hike/cached_trail.rb#L115
https://github.com/sstephenson/hike/blob/master/lib/hike/cached_trail.rb#L122
https://github.com/sstephenson/hike/blob/master/lib/hike/cached_trail.rb#L137
/cc @cheald
sorry - I found my mistakes.
Ignore vim swap files ~
. Can you think of others? We already ignore .
files.
Hello, test suite fails on my computer (Fedora rawhide) with following errors:
$testrb test/
Loaded suite test
Started
...F...................................F.........................
Finished in 0.092777 seconds.
1) Failure:
test_entries(IndexTest) [./test/test_trail.rb:190]:
<[#<Pathname:application.js.coffee.erb>,
#<Pathname:application.js.coffee.str>,
#<Pathname:index.html.erb>,
#<Pathname:layouts>,
#<Pathname:projects>,
#<Pathname:projects.erb>,
#<Pathname:recordings>]> expected but was
<[#<Pathname:application.js.coffee.erb>,
#<Pathname:application.js.coffee.str>,
#<Pathname:index.html.erb>,
#<Pathname:layouts>,
#<Pathname:projects.erb>,
#<Pathname:projects>,
#<Pathname:recordings>]>.
2) Failure:
test_entries(TrailTest) [./test/test_trail.rb:190]:
<[#<Pathname:application.js.coffee.erb>,
#<Pathname:application.js.coffee.str>,
#<Pathname:index.html.erb>,
#<Pathname:layouts>,
#<Pathname:projects>,
#<Pathname:projects.erb>,
#<Pathname:recordings>]> expected but was
<[#<Pathname:application.js.coffee.erb>,
#<Pathname:application.js.coffee.str>,
#<Pathname:index.html.erb>,
#<Pathname:layouts>,
#<Pathname:projects.erb>,
#<Pathname:projects>,
#<Pathname:recordings>]>.
65 tests, 87 assertions, 2 failures, 0 errors
Notice the swapped 'projects.erb' and 'projects' pathnames It seems that somewhere should be applied some sorting to keep the results consistent.
The following file:
test/fixtures/app/views/.#application.js.coffee.erb
Is pointing at:
[email protected]
Which doesn't exists, it also seems to be a swp file (.application.js.coffee.erb.swp vi?) and ~ (index.html.erb~).
q
Something like:
trail.find("./index", :relative_to => filename)
It should ensure that the result actually exists in the path.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.