This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#create tweets | |
#Since twitter API does not provide unique message check, | |
#I had to build db to validiate it. | |
def bark(tweet) | |
@tweet = Tweet.new(tweet) | |
if @tweet.save | |
############ RUN LATER BLOCK ################ | |
run_later do | |
begin | |
post(tweet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
gem('twitter4r', '0.3.0') | |
require 'twitter' | |
require 'time' | |
require 'nokogiri' | |
require 'open-uri' | |
require "shorturl" | |
array = @wycat_merb_commits = [] | |
@long_messages = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TwitterOnMerb < Merb::Controller | |
def _template_location(action, type = nil, controller = controller_name) | |
controller == "layout" ? "layout.#{action}.#{type}" : "#{action}.#{type}" | |
end | |
#shows twitter | |
def index | |
render | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use_orm :datamapper | |
use_test :rspec | |
use_template_engine :erb | |
merb_gems_version = "1.0.7.1" | |
dm_gems_version = "0.9.8" | |
dependency "merb-action-args", merb_gems_version | |
dependency "merb-assets", merb_gems_version | |
dependency "merb-cache", merb_gems_version | |
dependency "merb-helpers", merb_gems_version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:) [jaigouk@j-laptop twitter-on-merb]$ rake sessions:clear | |
(in /home/jaigouk/development/twitter-on-merb) | |
Loading init file from /home/jaigouk/development/twitter-on-merb/config/init.rb | |
Loading init file from /home/jaigouk/development/twitter-on-merb/config/init.rb | |
rake aborted! | |
twitter_fragment_store store already setup | |
/home/jaigouk/development/twitter-on-merb/Rakefile:24 | |
(See full trace by running task with --trace) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:) [jaigouk@j-laptop twitter-on-merb]$ rake -T | |
(in /home/jaigouk/development/twitter-on-merb) | |
Loading init file from /home/jaigouk/development/twitter-on-merb/config/init.rb | |
rake aborted! | |
can't activate do_sqlite3 (= 0.9.9, runtime), already activated do_sqlite3-0.9.10.1 | |
/home/jaigouk/development/twitter-on-merb/Rakefile:12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(merb 1.0.7.1) | |
The 'merb-cache' causes problem. If I delete the cache block, "rake db:automigrae" runs well. | |
I can not use cache on flat app? | |
I referenced 3 resources. 2 for init.rb and 1 for dm-do error. I followed instructions that Matt recommended. | |
But I did not bundled. It only caused more complex errors with twitter API. | |
My git repo is git://github.com/jaigouk/twitter-on-merb.git | |
(Current status: without bundling and caching, it runs well) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TwitterOnMerb < Merb::Controller | |
cache :commits, :about | |
eager_cache :commits | |
def _template_location(action, type = nil, controller = controller_name) | |
controller == "layout" ? "layout.#{action}.#{type}" : "#{action}.#{type}" | |
end | |
#shows twitter | |
def index | |
render |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :chores do | |
desc "Scrapes on every 30 min" | |
task :evenry30minutes => :merb_env do | |
chore("Every 30 minutes") do | |
p Tweet.scrape | |
end | |
end | |
desc "Scrapes on every hour" | |
task :hourly => :merb_env do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tweet | |
include DataMapper::SphinxResource | |
property :id, Serial | |
property :message, Text, :length => 255, :nullable => false | |
property :name, String, :length => 20 | |
property :category, String, :length => 20 | |
property :link, String | |
property :date, String | |
property :created_at, DateTime |