Skip to content

Instantly share code, notes, and snippets.

@cp
Created December 6, 2013 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cp/7818115 to your computer and use it in GitHub Desktop.
Save cp/7818115 to your computer and use it in GitHub Desktop.
# This is an example of what a lens may look like.
# It is required by Spectacle when the application is started.
class Twitter < Spectacle::Lens
database do
table do |t|
t.name :tweets
t.text :tweet_content
t.integer :favorites
end
end
# GET /twitter/tweets
get '/tweets' do
get(:tweets).limit(5)
end
post '/new' do
tweet = JSON.parse(PARAMS['TWEET'])
save(:tweets, tweet)
201
end
SCHEDULER.every '5m' do
tweets = HTTParty.post('https://twitter.com/aley/tweets')
if tweets.code == 200
tweets.each do |tweet|
save(:tweets, tweet)
end
200
else
500
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment