Created
November 30, 2009 10:23
-
-
Save yannlugrin/245382 to your computer and use it in GitHub Desktop.
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 'net/http' | |
require 'rexml/document' | |
require 'date' | |
namespace :twitter do | |
DEFAULT_SCREEN_NAME = 'LiquidConcept' | |
DEFAULT_COUNT = 10 | |
desc "Return last twitts for screen name, use env to configure: TWIT_SCREEN_NAME | |
(default: #{DEFAULT_SCREEN_NAME}), TWIT_COUNT (default: #{DEFAULT_COUNT})." | |
task :timeline do | |
screen_name = ENV['TWIT_SCREEN_NAME'] || DEFAULT_SCREEN_NAME | |
count = ENV['TWIT_COUNT'] || DEFAULT_COUNT | |
# code to get and print last twitts... | |
end | |
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
require 'net/http' | |
require 'rexml/document' | |
require 'date' | |
task :default => [:timeline] | |
DEFAULT_SCREEN_NAME = 'LiquidConcept' | |
DEFAULT_COUNT = 10 | |
desc "Return last twitts for screen name, use env to configure: TWIT_SCREEN_NAME | |
(default: #{DEFAULT_SCREEN_NAME}), TWIT_COUNT (default: #{DEFAULT_COUNT})." | |
task :timeline do | |
screen_name = ENV['TWIT_SCREEN_NAME'] || DEFAULT_SCREEN_NAME | |
count = ENV['TWIT_COUNT'] || DEFAULT_COUNT | |
# code to get and print last twitts... | |
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
# code to get and print last twitts... | |
if result = Net::HTTP.get(URI.parse("http://twitter.com/statuses/user_timeline.xml | |
?screen_name=#{screen_name}&count=#{count}")) | |
status = REXML::Document.new(result) | |
puts "Twitts from #{screen_name}:" | |
status.elements.to_a("statuses/status").collect do |e| | |
{ | |
:date => DateTime.parse(e.elements["created_at"].text), | |
:text => e.elements["text"].text | |
} | |
end.sort{|a, b| a[:date] <=> b[:date]}.each do |status_element| | |
puts status_element[:date].strftime("%d.%m.%Y %H:%M | #{status_element[:text]}") | |
end | |
else | |
puts "nothing" | |
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
require 'net/http' | |
require 'rexml/document' | |
require 'date' | |
class Twitter < Thor | |
DEFAULT_SCREEN_NAME = 'LiquidConcept' | |
DEFAULT_COUNT = 10 | |
desc "timeline", "Return last twitts for screen name" | |
method_option :screen_name, :aliases => ["-s"], :type => :string, :required => false, | |
:default => DEFAULT_SCREEN_NAME, :desc => "The twitter screen name" | |
method_option :count, :aliases => ["-c"], :type => :numeric, :required => false, | |
:default => DEFAULT_COUNT, :desc => "The number of twitts to fetch" | |
def timeline | |
screen_name = options[:screen_name] | |
count = options[:count] | |
# code to get and print last twitts... | |
end | |
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
class Namespace < Thor | |
default_task :target | |
desc "target", "target description" | |
def target | |
# commands | |
end | |
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
# | |
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 'rake/packagetask' | |
Rake::PackageTask.new("myapp", "1.2.3") do |p| | |
p.need_tar_bz2 = true | |
p.package_files.include("README") | |
p.package_files.include("lib/**/*.rb") | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment