Skip to content

Commit

Permalink
simplify getting of blog and tweets
Browse files Browse the repository at this point in the history
  • Loading branch information
seamusabshere committed Mar 12, 2012
1 parent d5242dc commit f5d3a24
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion brighter_planet_layout.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]

s.add_dependency 'simple-rss', '>=1.2.3'
s.add_dependency 'eat'
s.add_dependency 'tronprint', '>=1.2.0'
s.add_development_dependency 'test-unit'
end
19 changes: 8 additions & 11 deletions lib/brighter_planet_layout.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require 'net/http'
require 'uri'
require 'fileutils'
require 'singleton'
require 'simple-rss'
require 'eat'
#require 'tronprint'
require 'brighter_planet_metadata'

Expand Down Expand Up @@ -113,19 +114,15 @@ def rails_root
end

def latest_tweet
::SimpleRSS.parse(eat(TWITTER_RSS)).entries.first
rescue ::SocketError, ::Timeout::Error, ::Errno::ETIMEDOUT, ::Errno::ENETUNREACH, ::Errno::ECONNRESET, ::Errno::ECONNREFUSED
# nil
rescue ::NoMethodError
# nil
::SimpleRSS.parse(::Net::HTTP.get(::URI.parse(TWITTER_RSS))).entries.first
rescue ::Exception
$stderr.puts "[brighter_planet_layout] Can't get latest tweet because of #{$!.inspect}"
end

def latest_blog_post
::SimpleRSS.parse(eat(BLOG_ATOM)).entries.first
rescue ::SocketError, ::Timeout::Error, ::Errno::ETIMEDOUT, ::Errno::ENETUNREACH, ::Errno::ECONNRESET, ::Errno::ECONNREFUSED
# nil
rescue ::NoMethodError
# nil
::SimpleRSS.parse(::Net::HTTP.get(::URI.parse(BLOG_ATOM))).entries.first
rescue ::Exception
$stderr.puts "[brighter_planet_layout] Can't get latest blog post because of #{$!.inspect}"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_brighter_planet_layout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def name
end
end

class TestBrighterPlanet.layout < Test::Unit::TestCase
class TestBrighterPlanetLayout < Test::Unit::TestCase
def test_application_name
assert_equal 'Foobar', BrighterPlanet.layout.application_name
end
Expand Down

0 comments on commit f5d3a24

Please sign in to comment.