Fixed some major bugs with implications, cleaning up the cache

expiration process and adding some additional tests.

Cleaned up the unit tests.  They should all run cleanly with rake
test:units now.
This commit is contained in:
albert
2010-10-27 16:56:12 -04:00
parent 484ff696e2
commit 1c9d8c37c7
16 changed files with 214 additions and 104 deletions

View File

@@ -23,7 +23,7 @@ class PixivProxy
mech = create_mechanize
hash = {}
mech.get(url) do |page|
hash[:artist] = page.search("div#profile/div/a/img").attr("alt")
hash[:artist] = page.search("a.avatar_m").attr("title").value
hash[:listing_url] = "/member_illust.php?id=" + url[/id=(\d+)/, 1]
end
hash
@@ -34,13 +34,13 @@ class PixivProxy
mech = create_mechanize
hash = {}
mech.get(url) do |page|
if page.search("div#profile/div/a/img")
hash[:artist] = page.search("div#profile/div/a/img").attr("alt")
hash[:image_url] = page.search("div#profile/div/a/img").attr("src").sub("_m.", ".")
hash[:profile_url] = page.search("div#profile/div/a").attr("href")
hash[:jp_tags] = page.search("div#tag_area/span#tags/a").map do |node|
if page.search("a.avatar_m")
hash[:artist] = page.search("a.avatar_m").attr("title").value
hash[:image_url] = page.search("div.works_display/a/img").attr("src").value.sub("_m.", ".")
hash[:profile_url] = page.search("a.avatar_m").attr("href").value
hash[:jp_tags] = page.search("span#tags/a").map do |node|
[node.inner_text, node.attribute("href").to_s]
end
end.reject {|x| x[0].empty?}
else
hash[:artist] = "?"
hash[:image_url] = "?"
@@ -80,10 +80,10 @@ class PixivProxy
end
def self.create_mechanize
mech = WWW::Mechanize.new
mech = Mechanize.new
mech.get("http://www.pixiv.net") do |page|
page.form_with(:action => "login.php") do |form|
page.form_with(:action => "/login.php") do |form|
form.pixiv_id = "uroobnad"
form.pass = "uroobnad556"
end.click_button