Permalink
Browse files

Revert "Doing some thread voodoo."

This reverts commit 5e5a11e.

Conflicts:
	app/fotolog.rb
	fotologffffffu.rb
	spec/fotolog_spec.rb
  • Loading branch information...
1 parent 873ef69 commit bc4e8c83d7d566d17a8683e7e791d905e15d7fb4 @lunks lunks committed Nov 24, 2013
Showing with 9 additions and 17 deletions.
  1. +4 −11 app/fotolog.rb
  2. +0 −1 fotologffffffu.rb
  3. +4 −4 spec/fotolog_spec.rb
  4. +1 −1 spec/spec_helper.rb
View
@@ -25,20 +25,13 @@ def archive_url
end
def photos
- years.flat_map do |year|
- (1..12).map do |month| photos_for_month(year, month)
- end
- end.map do |thread|
- thread.join["photos"]
- end.flatten
+ years.map { |year| (1..12).map { |month| photos_for_month year, month}}.flatten
end
def photos_for_month year, month
- Thread.new do
- doc = Nokogiri::HTML(@client.get_content("http://www.fotolog.com.br/#{@user}/archive/#{'0' if month.to_i < 10}#{month.to_i}/#{year}/"))
- Thread.current["photos"] = doc.css('.calendar_month_day img').map do |photo|
- full_image_for photo.attributes['src'].value
- end
+ doc = Nokogiri::HTML(@client.get_content("http://www.fotolog.com.br/#{@user}/archive/#{'0' if month.to_i < 10}#{month.to_i}/#{year}"))
+ doc.css('.calendar_month_day img').map do |photo|
+ full_image_for photo.attributes['src'].value
end
end
View
@@ -3,7 +3,6 @@
require 'dalli'
Bundler.setup
Bundler.require :default
-require 'open-uri'
set :app_file, __FILE__
set :server, 'unicorn'
View
@@ -3,7 +3,7 @@
describe Fotolog do
context 'for non existent fotolog' do
- before { FakeWeb.register_uri(:get, "http://www.fotolog.com.br/this_fotolog_doesnt_exists/archive", :body => fixture_file('non_existent_fotolog.html'), :status => ["404", "Not Found"]) }
+ before { FakeWeb.register_uri(:get, "http://www.fotolog.com/this_fotolog_doesnt_exists/archive", :body => fixture_file('non_existent_fotolog.html'), :status => ["404", "Not Found"]) }
let(:fotolog) { Fotolog.new 'this_fotolog_doesnt_exists' }
it 'should tell it is not valid' do
fotolog.should_not be_valid
@@ -12,15 +12,15 @@
context 'that exists' do
before(:each) do
- FakeWeb.register_uri(:get, "http://www.fotolog.com.br/marano/archive", :body => fixture_file('archive.html'))
+ FakeWeb.register_uri(:get, "http://www.fotolog.com/marano/archive", :body => fixture_file('archive.html'))
end
let(:fotolog) { Fotolog.new 'marano' }
it 'should tell it is valid' do
fotolog.should be_valid
end
context 'retrieving archive information' do
before(:each) do
- FakeWeb.register_uri(:get, "http://www.fotolog.com.br/marano/archive", :body => fixture_file('archive.html'))
+ FakeWeb.register_uri(:get, "http://www.fotolog.com/marano/archive", :body => fixture_file('archive.html'))
end
it 'should retrieve user archive URL' do
fotolog.archive_url.should == 'http://www.fotolog.com.br/marano/archive/'
@@ -42,7 +42,7 @@
it 'should retrieve photo urls' do
photos = ["http://sp4.fotolog.com/photo/20/29/104/marano/1220844280164_f.jpg", "http://sp4.fotolog.com/photo/20/29/104/marano/1221058240106_f.jpg", "http://sp4.fotolog.com/photo/20/29/104/marano/1221348619989_f.jpg", "http://sp4.fotolog.com/photo/20/29/104/marano/1221433699200_f.jpg", "http://sp4.fotolog.com/photo/20/29/104/marano/1221691789949_f.jpg", "http://sp4.fotolog.com/photo/20/29/104/marano/1222477956299_f.jpg"]
- fotolog.photos_for_month('2008', '09').join["photos"].should == photos
+ fotolog.photos_for_month('2008', '09').should == photos
end
it 'should parse photo url correctly' do
photo = 'http://spc.fotolog.com.br/photo/12/16/103/pink_that/1189983175_t.jpg'
View
@@ -18,7 +18,7 @@ def fixture_file(file)
end
def mock_requests_fixture_for_fotolog name
- FakeWeb.register_uri(:get, "http://www.fotolog.com.br/#{name}/archive", :body => fixture_file('archive.html'))
+ FakeWeb.register_uri(:get, "http://www.fotolog.com/#{name}/archive", :body => fixture_file('archive.html'))
(2003..2013).to_a.each do |year|
(1..12).to_a.each do |month|

0 comments on commit bc4e8c8

Please sign in to comment.