mirror of
https://github.com/sdsykes/fastimage.git
synced 2025-08-10 00:01:04 -04:00
Fix for files in local directories that have spaces in the names
This commit is contained in:
parent
f0d22d4c38
commit
7fb2e5787d
@ -5,11 +5,11 @@
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = %q{fastimage}
|
||||
s.version = "1.2.6"
|
||||
s.version = "1.2.7"
|
||||
|
||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||
s.authors = ["Stephen Sykes"]
|
||||
s.date = %q{2010-05-08}
|
||||
s.date = %q{2010-07-14}
|
||||
s.description = %q{FastImage finds the size or type of an image given its uri by fetching as little as needed.}
|
||||
s.email = %q{sdsykes@gmail.com}
|
||||
s.extra_rdoc_files = [
|
||||
|
@ -136,11 +136,16 @@ class FastImage
|
||||
@property = options[:type_only] ? :type : :size
|
||||
@timeout = options[:timeout] || DefaultTimeout
|
||||
@uri = uri
|
||||
@parsed_uri = URI.parse(uri)
|
||||
if @parsed_uri.scheme == "http" || @parsed_uri.scheme == "https"
|
||||
fetch_using_http
|
||||
else
|
||||
begin
|
||||
@parsed_uri = URI.parse(uri)
|
||||
rescue URI::InvalidURIError
|
||||
fetch_using_open_uri
|
||||
else
|
||||
if @parsed_uri.scheme == "http" || @parsed_uri.scheme == "https"
|
||||
fetch_using_http
|
||||
else
|
||||
fetch_using_open_uri
|
||||
end
|
||||
end
|
||||
raise SizeNotFound if options[:raise_on_failure] && @property == :size && !@size
|
||||
rescue Timeout::Error, SocketError, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET,
|
||||
|
BIN
test/fixtures/folder with spaces/test.bmp
vendored
Normal file
BIN
test/fixtures/folder with spaces/test.bmp
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
@ -98,6 +98,12 @@ class FastImageTest < Test::Unit::TestCase
|
||||
assert_equal info[1], FastImage.size(File.join(FixturePath, fn))
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_report_size_correctly_for_local_files_with_path_that_has_spaces
|
||||
Dir.chdir(PathHere) do
|
||||
assert_equal GoodFixtures["test.bmp"][1], FastImage.size(File.join("fixtures", "folder with spaces", "test.bmp"))
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_return_nil_on_fetch_failure_for_local_path
|
||||
assert_nil FastImage.size("does_not_exist")
|
||||
|
Loading…
x
Reference in New Issue
Block a user