Permalink
Browse files

updated home with favorited tweets

  • Loading branch information...
1 parent 05cb8bc commit 9af7a1126c0f18cfd31109e7ee8c54968a8f5c4e Sayem Islam committed Jun 26, 2011
View
6 Gemfile
@@ -31,10 +31,6 @@ gem 'rspec-rails'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
-
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
-# and rake tasks are available in development mode:
-# group :development, :test do
-# gem 'webrat'
-# end
+# and rake tasks are available in development mode:
View
11 Gemfile.lock
@@ -38,7 +38,7 @@ GEM
addressable (~> 2.2.4)
multipart-post (~> 1.1.0)
rack (< 2, >= 1.1.0)
- faraday_middleware (0.6.3)
+ faraday_middleware (0.6.5)
faraday (~> 0.6.0)
haml (3.1.2)
hashie (1.0.0)
@@ -52,7 +52,7 @@ GEM
multi_json (1.0.3)
multi_xml (0.2.2)
multipart-post (1.1.2)
- mysql2 (0.2.7)
+ mysql2 (0.2.11)
polyglot (0.3.1)
rack (1.2.3)
rack-mount (0.6.14)
@@ -73,8 +73,6 @@ GEM
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
- rash (0.3.0)
- hashie (~> 1.0.0)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
@@ -93,15 +91,14 @@ GEM
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
- twitter (1.5.0)
+ twitter (1.6.0)
faraday (~> 0.6.1)
faraday_middleware (~> 0.6.3)
hashie (~> 1.0.0)
multi_json (~> 1.0.0)
multi_xml (~> 0.2.0)
- rash (~> 0.3.0)
simple_oauth (~> 0.1.5)
- tzinfo (0.3.27)
+ tzinfo (0.3.28)
PLATFORMS
ruby
View
12 app/controllers/home_controller.rb
@@ -1,4 +1,16 @@
class HomeController < ApplicationController
def index
+ favs = Array.new
+ Techpeeps.all.each do |techpeep|
+ username = techpeep.username
+ picture = techpeep.picture
+ tweets = techpeep.tweets
+ tweets.each {|x| x.push(username, picture) }
+ favs.push(tweets)
+ end
+ favs.flatten!(1)
+ favs.delete_if {|x| x == [] }
+ favs.sort! {|a,b| -1*(a[3] <=> b[3]) }
+ @favs = favs
end
end
View
3 app/models/techpeeps.rb
@@ -5,8 +5,9 @@ class Techpeeps < ActiveRecord::Base
serialize :tweets
serialize :last_tweet
+
def self.daily
- Techpeeps.limit(3).each do |techpeep|
+ Techpeeps.limit(50).each do |techpeep|
user = Twitter.user(techpeep.twitter_id.to_i)
if user.favourites_count != techpeep.count
current_fav = techpeep.last_tweet[1]
View
14 app/views/home/index.html.erb
@@ -1 +1,13 @@
-STARTUPFAVS.COM
+
+<% @favs.each do |f| %>
+
+<a href=<%= "http://twitter.com/#{f[4]}" %> title=<%= f[4] %> target="_new" ><%= f[4] %><%= image_tag(f[5], :alt => f[4]) %></a>
+<a href=<%= "http://twitter.com/#{f[0]}" %> title=<%= f[0] %> target="_new" ><%= f[0] %><%= image_tag(f[1], :alt => f[0]) %><%= f[2] %></a>
+
+<br />
+<br />
+<br />
+<br />
+
+
+<% end %>
View
1 spec/helpers/home_helper_spec.rb
@@ -11,5 +11,4 @@
# end
# end
describe HomeHelper do
- pending "add some examples to (or delete) #{__FILE__}"
end
View
9 spec/models/techpeeps_spec.rb
@@ -3,4 +3,13 @@
require 'twitter'
describe Techpeeps do
+
+ techpeep = Techpeeps.new(:twitter_id => '16483617', :count => '3', :tweets => ['some random tweet', 'some random tweet'], :username => 'sayemislam', :picture => 'http://a2.twimg.com/profile_images/1138396798/sayem-twitter_normal.jpg')
+
+ it "should check favorite count" do
+
+
+ techpeep.should have(0) .errors_on(:twitter_id)
+ end
+
end

0 comments on commit 9af7a11

Please sign in to comment.