Kill trailing whitespace in ruby files

This commit is contained in:
小太
2013-03-19 23:10:10 +11:00
parent c107f96cec
commit cba839ba76
319 changed files with 2710 additions and 2710 deletions

View File

@@ -2,14 +2,14 @@ module Sources
class Site
attr_reader :url, :strategy
delegate :get, :referer_url, :site_name, :artist_name, :profile_url, :image_url, :tags, :artist_record, :unique_id, :to => :strategy
def self.strategies
[Strategies::NicoSeiga, Strategies::Pixiv]
end
def initialize(url)
@url = url
Site.strategies.each do |strategy|
if strategy.url_match?(url)
@strategy = strategy.new(url)
@@ -18,7 +18,7 @@ module Sources
end
end
end
def to_json
return {
:artist_name => artist_name,
@@ -30,7 +30,7 @@ module Sources
:unique_id => unique_id
}.to_json
end
def available?
strategy.present?
end

View File

@@ -3,28 +3,28 @@ module Sources
class Base
attr_reader :url
attr_reader :artist_name, :profile_url, :image_url, :tags
def self.url_match?(url)
false
end
def initialize(url)
@url = url
end
# No remote calls are made until this method is called.
def get
raise NotImplementedError
end
def site_name
raise NotImplementedError
end
def unique_id
artist_name
end
def artist_record
if artist_name.present?
Artist.other_names_match(artist_name)
@@ -32,11 +32,11 @@ module Sources
nil
end
end
def referer_url(template)
template.params[:ref] || template.params[:url]
end
protected
def agent
raise NotImplementedError

View File

@@ -8,7 +8,7 @@ module Sources
def site_name
"Nico Seiga"
end
def unique_id
profile_url =~ /\/illust\/(\d+)/
"nicoseiga" + $1
@@ -21,9 +21,9 @@ module Sources
@tags = get_tags_from_page(page)
end
end
protected
def get_profile_from_page(page)
links = page.search("div.illust_user_name a")
@@ -34,10 +34,10 @@ module Sources
profile_url = nil
artist_name = nil
end
return [artist_name, profile_url].compact
end
def get_image_url_from_page(page)
links = page.search("a#illust_link")
@@ -47,7 +47,7 @@ module Sources
nil
end
end
def get_tags_from_page(page)
links = page.search("div#tag_block nobr a.tag")
@@ -55,7 +55,7 @@ module Sources
[node.text, "http://seiga.nicovideo.jp" + node.attr("href")]
end
end
def agent
@agent ||= begin
mech = Mechanize.new

View File

@@ -4,7 +4,7 @@ module Sources
def self.url_match?(url)
url =~ /^https?:\/\/(?:\w+\.)?pixiv\.net/
end
def referer_url(template)
if template.params[:ref] =~ /pixiv\.net\/member_illust/ && template.params[:ref] !~ /mode=manga/
template.params[:ref]
@@ -12,16 +12,16 @@ module Sources
template.params[:url]
end
end
def site_name
"Pixiv"
end
def unique_id
image_url =~ /\/img\/([^\/]+)/
$1
end
def get
agent.get(URI.parse(normalized_url).request_uri) do |page|
@artist_name, @profile_url = get_profile_from_page(page)
@@ -31,13 +31,13 @@ module Sources
end
protected
def get_profile_from_page(page)
profile_url = page.search("a.user-link").first
if profile_url
profile_url = "http://www.pixiv.net" + profile_url["href"]
end
artist_name = page.search("h1.user").first
if artist_name
artist_name = artist_name.inner_text
@@ -45,7 +45,7 @@ module Sources
return [artist_name, profile_url]
end
def get_image_url_from_page(page)
element = page.search("div.works_display a img").first
if element
@@ -54,10 +54,10 @@ module Sources
nil
end
end
def get_tags_from_page(page)
# puts page.root.to_xhtml
links = page.search("ul.tags a.text").find_all do |node|
node["href"] =~ /search\.php/
end
@@ -70,7 +70,7 @@ module Sources
[]
end
end
def normalized_url
@normalized_url ||= begin
if url =~ /\/(\d+)(?:_big)?(?:_m|_p\d+)?\.(?:jpg|jpeg|png|gif)/i
@@ -84,7 +84,7 @@ module Sources
end
end
end
def agent
@agent ||= begin
mech = Mechanize.new