プロジェクト

全般

プロフィール

環境対応 #954 » 0001-Retriever-URI-URI-uri_filter-refs-954.patch

toshi_a 初音, 2017-10-13 09:08

差分を表示:

core/lib/retriever/uri.rb
end
def generate_uri_by_string
URI.parse(@uri_string)
rescue URI::InvalidComponentError
Addressable::URI.parse(@uri_string)
uri, = Plugin.filtering(:uri_filter, @uri_string)
case uri
when URI, Addressable::URI
uri
when String
raise Retriever::InvalidURIError, 'The string is not URI.'
else
raise Retriever::InvalidURIError, "Filter `uri_filter' returns instance of `#{uri.class}', but expect URI or Addressable::URI."
end
end
def generate_uri_by_hash
core/plugin/photo/model/photo.rb
case uri
when self
uri
when URI, Addressable::URI, Retriever::URI
when URI, Addressable::URI, Retriever::URI, String
photos[uri.to_s.hash] ||= new(perma_link: uri)
when String
if uri.start_with?('http')
photos[uri.hash] ||= new(perma_link: uri)
elsif uri.start_with?('/')
uri = Retriever::URI.new(scheme: 'file', path: uri)
photos[uri.hash] ||= new(perma_link: uri)
end
end
end
core/plugin/photo/photo.rb
photos << Plugin::Photo::Photo[permalink]
[permalink, photos]
end
# Generic URI
filter_uri_filter do |uri|
if uri.is_a?(String) && uri.match(%r<\A\w+:>)
[Addressable::URI.parse(uri)]
else
[uri]
end
end
# Unix local file path
filter_uri_filter do |uri|
if uri.is_a?(String) && uri.start_with?('/')
[Addressable::URI.new(scheme: 'file', path: uri)]
else
[uri]
end
end
end
(2-2/5)