Permalink
Browse files

added some tests; removed relative_created_at and replaced with creat…

…ed at; getting ready to release 0.1

git-svn-id: http://svn.addictedtonew.com/public/gems/twitter@40 fe7eae16-9a24-0410-a59d-9e59979e88be
  • Loading branch information...
jnunemaker
jnunemaker committed Mar 31, 2007
1 parent c0f4a48 commit ff1ae65766109c75f80c4b15797e12a69d7c29ad
Showing with 146 additions and 10,871 deletions.
  1. +8 −6 Rakefile
  2. +2 −1 examples/twitter.rb
  3. +29 −54 lib/twitter/command.rb
  4. +6 −19 lib/twitter/status.rb
  5. +0 −17 lib/twitter/user.rb
  6. +2 −2 lib/twitter/version.rb
  7. BIN pkg/twitter-0.0.1.gem
  8. BIN pkg/twitter-0.0.1.tgz
  9. +0 −5 pkg/twitter-0.0.1/CHANGELOG
  10. +0 −12 pkg/twitter-0.0.1/Manifest.txt
  11. +0 −46 pkg/twitter-0.0.1/README
  12. +0 −57 pkg/twitter-0.0.1/Rakefile
  13. +0 −35 pkg/twitter-0.0.1/bin/twitter
  14. +0 −7 pkg/twitter-0.0.1/lib/twitter.rb
  15. +0 −93 pkg/twitter-0.0.1/lib/twitter/base.rb
  16. +0 −190 pkg/twitter-0.0.1/lib/twitter/command.rb
  17. +0 −43 pkg/twitter-0.0.1/lib/twitter/easy_class_maker.rb
  18. +0 −33 pkg/twitter-0.0.1/lib/twitter/status.rb
  19. +0 −32 pkg/twitter-0.0.1/lib/twitter/user.rb
  20. +0 −9 pkg/twitter-0.0.1/lib/twitter/version.rb
  21. +0 −1,585 pkg/twitter-0.0.1/setup.rb
  22. BIN pkg/twitter-0.0.2.gem
  23. BIN pkg/twitter-0.0.2.tgz
  24. +0 −5 pkg/twitter-0.0.2/CHANGELOG
  25. +0 −46 pkg/twitter-0.0.2/README
  26. +0 −57 pkg/twitter-0.0.2/Rakefile
  27. +0 −35 pkg/twitter-0.0.2/bin/twitter
  28. +0 −7 pkg/twitter-0.0.2/lib/twitter.rb
  29. +0 −93 pkg/twitter-0.0.2/lib/twitter/base.rb
  30. +0 −190 pkg/twitter-0.0.2/lib/twitter/command.rb
  31. +0 −43 pkg/twitter-0.0.2/lib/twitter/easy_class_maker.rb
  32. +0 −33 pkg/twitter-0.0.2/lib/twitter/status.rb
  33. +0 −32 pkg/twitter-0.0.2/lib/twitter/user.rb
  34. +0 −9 pkg/twitter-0.0.2/lib/twitter/version.rb
  35. +0 −1,585 pkg/twitter-0.0.2/setup.rb
  36. BIN pkg/twitter-0.0.3.gem
  37. BIN pkg/twitter-0.0.3.tgz
  38. +0 −5 pkg/twitter-0.0.3/CHANGELOG
  39. +0 −46 pkg/twitter-0.0.3/README
  40. +0 −57 pkg/twitter-0.0.3/Rakefile
  41. +0 −35 pkg/twitter-0.0.3/bin/twitter
  42. +0 −7 pkg/twitter-0.0.3/lib/twitter.rb
  43. +0 −93 pkg/twitter-0.0.3/lib/twitter/base.rb
  44. +0 −190 pkg/twitter-0.0.3/lib/twitter/command.rb
  45. +0 −43 pkg/twitter-0.0.3/lib/twitter/easy_class_maker.rb
  46. +0 −33 pkg/twitter-0.0.3/lib/twitter/status.rb
  47. +0 −32 pkg/twitter-0.0.3/lib/twitter/user.rb
  48. +0 −9 pkg/twitter-0.0.3/lib/twitter/version.rb
  49. +0 −1,585 pkg/twitter-0.0.3/setup.rb
  50. BIN pkg/twitter-0.0.4.gem
  51. BIN pkg/twitter-0.0.4.tgz
  52. +0 −5 pkg/twitter-0.0.4/CHANGELOG
  53. +0 −46 pkg/twitter-0.0.4/README
  54. +0 −57 pkg/twitter-0.0.4/Rakefile
  55. +0 −35 pkg/twitter-0.0.4/bin/twitter
  56. +0 −7 pkg/twitter-0.0.4/lib/twitter.rb
  57. +0 −93 pkg/twitter-0.0.4/lib/twitter/base.rb
  58. +0 −190 pkg/twitter-0.0.4/lib/twitter/command.rb
  59. +0 −43 pkg/twitter-0.0.4/lib/twitter/easy_class_maker.rb
  60. +0 −33 pkg/twitter-0.0.4/lib/twitter/status.rb
  61. +0 −40 pkg/twitter-0.0.4/lib/twitter/user.rb
  62. +0 −9 pkg/twitter-0.0.4/lib/twitter/version.rb
  63. +0 −1,585 pkg/twitter-0.0.4/setup.rb
  64. BIN pkg/twitter-0.0.5.gem
  65. BIN pkg/twitter-0.0.5.tgz
  66. +0 −5 pkg/twitter-0.0.5/CHANGELOG
  67. +0 −46 pkg/twitter-0.0.5/README
  68. +0 −44 pkg/twitter-0.0.5/README.txt
  69. +0 −57 pkg/twitter-0.0.5/Rakefile
  70. +0 −35 pkg/twitter-0.0.5/bin/twitter
  71. +0 −25 pkg/twitter-0.0.5/examples/twitter.rb
  72. +0 −7 pkg/twitter-0.0.5/lib/twitter.rb
  73. +0 −93 pkg/twitter-0.0.5/lib/twitter/base.rb
  74. +0 −190 pkg/twitter-0.0.5/lib/twitter/command.rb
  75. +0 −43 pkg/twitter-0.0.5/lib/twitter/easy_class_maker.rb
  76. +0 −33 pkg/twitter-0.0.5/lib/twitter/status.rb
  77. +0 −40 pkg/twitter-0.0.5/lib/twitter/user.rb
  78. +0 −9 pkg/twitter-0.0.5/lib/twitter/version.rb
  79. +0 −1,585 pkg/twitter-0.0.5/setup.rb
  80. +20 −0 test/test_helper.rb
  81. +12 −0 test/unit/base.rb
  82. 0 test/unit/command.rb
  83. 0 test/unit/easy_class_maker.rb
  84. +27 −0 test/unit/status.rb
  85. +40 −0 test/unit/user.rb
View
@@ -48,10 +48,12 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
#p.spec_extras - A hash of extra values to set in the gemspec.
end
-
-
-desc "Package and Install Gem"
-task :package_and_install do
- `rake package`
- `sudo gem install pkg/#{NAME}-#{VERS}.gem`
+desc 'Publish HTML to RubyForge'
+task :publish_html do
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
+ host = "#{config["username"]}@rubyforge.org"
+ remote_dir = "/var/www/gforge-projects/snitch/"
+ local_dir = 'html'
+ sh %{rsync -av --delete #{local_dir}/ #{host}:#{remote_dir}}
+ `rake publish_docs`
end
View
@@ -1,4 +1,5 @@
-require '../lib/twitter'
+require 'rubygems'
+require 'twitter'
puts "Public Timeline", "=" * 50
Twitter::Base.new('emailaddress', 'password').timeline(:public).each do |s|
View
@@ -15,8 +15,7 @@ class Command
email:
password:
EOF
- @@error_msg = "Something went wrong!!!\n\nMost likely: The twitter gem requires hpricot version >= 0.4.59. Check to make sure that you have at least that version installed. To install the newest version of hpricot:\n\n sudo gem install hpricot --source http://code.whytheluckystiff.net"
-
+
class << self
def process!
command = ARGV.shift
@@ -51,12 +50,8 @@ def post
post = ARGV.shift
- begin
- status = Twitter::Base.new(config['email'], config['password']).post(post)
- puts "\nGot it! New twitter created at: #{status.created_at}\n"
- rescue
- puts "\nTwitter what?. Something went wrong and your status could not be updated.\n"
- end
+ status = Twitter::Base.new(config['email'], config['password']).post(post)
+ puts "\nGot it! New twitter created at: #{status.created_at}\n"
end
# Shows status, time and user for the specified timeline
@@ -66,28 +61,20 @@ def timeline
timeline = :friends
timeline = ARGV.shift.intern if ARGV.size > 0 && Twitter::Base.timelines.include?(ARGV[0].intern)
- begin
- puts
- Twitter::Base.new(config['email'], config['password']).timeline(timeline).each do |s|
- puts "#{s.text}\n-- #{s.relative_created_at} by #{s.user.name}"
- puts
- end
- rescue
- puts @@error_msg
+ puts
+ Twitter::Base.new(config['email'], config['password']).timeline(timeline).each do |s|
+ puts "#{s.text}\n-- #{s.created_at} by #{s.user.name}"
end
+ puts
end
def friends
config = create_or_find_config
- begin
+ puts
+ Twitter::Base.new(config['email'], config['password']).friends.each do |u|
+ puts "#{u.name} (#{u.screen_name}) last updated #{u.status.created_at}\n-- #{u.status.text}"
puts
- Twitter::Base.new(config['email'], config['password']).friends.each do |u|
- puts "#{u.name} (#{u.screen_name}) last updated #{u.status.relative_created_at}\n-- #{u.status.text}"
- puts
- end
- rescue
- puts @@error_msg
end
end
@@ -103,23 +90,17 @@ def friend
screen_name = ARGV.shift
- begin
- puts
- found = false
- Twitter::Base.new(config['email'], config['password']).friends.each do |u|
- if u.screen_name == screen_name
- puts "#{u.name} last updated #{u.status.relative_created_at}\n-- #{u.status.text}"
- found = true
- end
- end
-
- unless found
- puts "Sorry couldn't find a friend of yours with #{screen_name} as a screen name"
+ puts
+ found = false
+ Twitter::Base.new(config['email'], config['password']).friends.each do |u|
+ if u.screen_name == screen_name
+ puts "#{u.name} last updated #{u.status.created_at}\n-- #{u.status.text}"
+ found = true
end
- puts
- rescue
- puts @@error_msg
end
+
+ puts "Sorry couldn't find a friend of yours with #{screen_name} as a screen name" unless found
+ puts
end
# Shows all followers and their last updated status
@@ -129,7 +110,7 @@ def followers
begin
puts
Twitter::Base.new(config['email'], config['password']).followers.each do |u|
- puts "#{u.name} last updated #{u.status.relative_created_at}\n-- #{u.status.text}"
+ puts "#{u.name} last updated #{u.status.created_at}\n-- #{u.status.text}"
puts
end
rescue
@@ -149,23 +130,17 @@ def follower
screen_name = ARGV.shift
- begin
- puts
- found = false
- Twitter::Base.new(config['email'], config['password']).followers.each do |u|
- if u.screen_name == screen_name
- puts "#{u.name} (#{u.screen_name}) last updated #{u.status.relative_created_at}\n-- #{u.status.text}"
- found = true
- end
- end
-
- unless found
- puts "Sorry couldn't find a follower of yours with #{screen_name} as a screen name"
+ puts
+ found = false
+ Twitter::Base.new(config['email'], config['password']).followers.each do |u|
+ if u.screen_name == screen_name
+ puts "#{u.name} (#{u.screen_name}) last updated #{u.status.created_at}\n-- #{u.status.text}"
+ found = true
end
- puts
- rescue
- puts @@error_msg
end
+
+ puts "Sorry couldn't find a follower of yours with #{screen_name} as a screen name" unless found
+ puts
end
private
View
@@ -1,31 +1,18 @@
-# The attributes are created_at, id, text, relative_created_at, and user (which is a user object)
-# new_from_xml expects xml along the lines of:
-# <status>
-# <id>1</id>
-# <created_at>a date</created_at>
-# <text>some text</text>
-# <relative_created_at>about 1 min ago</relative_created_at>
-# <user>
-# <id>1</id>
-# <name>John Nunemaker</name>
-# <screen_name>jnunemaker</screen_name>
-# </user>
-# </status>
module Twitter
class Status
include EasyClassMaker
- attributes :created_at, :id, :text, :relative_created_at, :user
+ attributes :created_at, :id, :text, :user
class << self
# Creates a new status from a piece of xml
def new_from_xml(xml)
Status.new do |s|
- s.id = (xml).at('id').innerHTML
- s.created_at = (xml).at('created_at').innerHTML
- s.text = (xml).at('text').innerHTML
- s.relative_created_at = (xml).at('relative_created_at').innerHTML
- s.user = User.new_from_xml(xml) if (xml).at('user')
+ s.id = (xml).at('id').innerHTML
+ s.created_at = (xml).at('created_at').innerHTML
+ s.text = (xml).at('text').innerHTML
+ s.created_at = (xml).at('created_at').innerHTML
+ s.user = User.new_from_xml(xml) if (xml).at('user')
end
end
end
View
@@ -1,20 +1,3 @@
-# The attributes for user are id, name, screen_name, status (which is a status object)
-# new_from_xml expects xml along the lines of:
-# <user>
-# <id>12796</id>
-# <name>William H Harle Jr.</name>
-# <screen_name>wharle</screen_name>
-# <location>South Bend, IN</location>
-# <description></description>
-# <profile_image_url>http://twitter.com/system/user/profile_image/12796/normal/Photo_248.jpg</profile_image_url>
-# <url>http://90percentgravity.com</url>
-# <status>
-# <created_at>Sat Jan 20 14:02:33 +0000 2007</created_at>
-# <id>3450573</id>
-# <text>proud of the weekend workout, day 4 of power 90 done</text>
-# <relative_created_at>about 15 hours ago</relative_created_at>
-# </status>
-# </user>
module Twitter
class User
include EasyClassMaker
View
@@ -1,8 +1,8 @@
module Twitter #:nodoc:
module VERSION #:nodoc:
MAJOR = 0
- MINOR = 0
- TINY = 5
+ MINOR = 1
+ TINY = 0
STRING = [MAJOR, MINOR, TINY].join('.')
end
View
Binary file not shown.
View
Binary file not shown.
@@ -1,5 +0,0 @@
-0.0.5 - just a bit of code cleanup
-0.0.4 - added :location, :description, :url, :profile_image_url to user class (Alex Payne)
-0.0.3 - added a bit more informative message when things go wrong
-0.0.2 - added the command line options i forgot to add (friend and follower); improved some docs
-0.0.1 - initial release
@@ -1,12 +0,0 @@
-README
-CHANGELOG
-Rakefile
-setup.rb
-bin/twitter
-lib/twitter.rb
-lib/twitter/base.rb
-lib/twitter/command.rb
-lib/twitter/easy_class_maker.rb
-lib/twitter/status.rb
-lib/twitter/user.rb
-lib/twitter/version.rb
View
@@ -1,46 +0,0 @@
-addicted to twitter
-==================
-
-... a sweet little diddy that helps you twitter your life away
-
-
-== Command Line Use
-
-$ twitter
-
-That will show the commands and each command will either run or show you the options it needs to run
-
-$ twitter post "releasing my new twitter gem"
-
-That will post a status update to your twitter
-
-== Examples
-
- Twitter::Base.new('your email', 'your password').update('watching veronica mars')
-
- # or you can use post
- Twitter::Base.new('your email', 'your password').post('post works too')
-
- puts "Public Timeline", "=" * 50
- Twitter::Base.new('your email', 'your password').timeline(:public).each do |s|
- puts s.text, s.user.name
- puts
- end
-
- puts '', "Friends Timeline", "=" * 50
- Twitter::Base.new('your email', 'your password').timeline.each do |s|
- puts s.text, s.user.name
- puts
- end
-
- puts '', "Friends", "=" * 50
- Twitter::Base.new('your email', 'your password').friends.each do |u|
- puts u.name, u.status.text
- puts
- end
-
- puts '', "Followers", "=" * 50
- Twitter::Base.new('your email', 'your password').followers.each do |u|
- puts u.name, u.status.text
- puts
- end
View
@@ -1,57 +0,0 @@
-require 'rubygems'
-require 'rake'
-require 'rake/clean'
-require 'rake/testtask'
-require 'rake/packagetask'
-require 'rake/gempackagetask'
-require 'rake/rdoctask'
-require 'rake/contrib/rubyforgepublisher'
-require 'fileutils'
-require 'hoe'
-include FileUtils
-require File.join(File.dirname(__FILE__), 'lib', 'twitter', 'version')
-
-AUTHOR = "John Nunemaker" # can also be an array of Authors
-EMAIL = "nunemaker@gmail.com"
-DESCRIPTION = "a command line interface for twitter, also a library which wraps the twitter api"
-GEM_NAME = "twitter" # what ppl will type to install your gem
-RUBYFORGE_PROJECT = "twitter" # The unix name for your project
-HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
-RELEASE_TYPES = %w( gem ) # can use: gem, tar, zip
-
-
-NAME = "twitter"
-REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
-VERS = ENV['VERSION'] || (Twitter::VERSION::STRING + (REV ? ".#{REV}" : ""))
-CLEAN.include ['**/.*.sw?', '*.gem', '.config']
-RDOC_OPTS = ['--quiet', '--title', "twitter documentation",
- "--opname", "index.html",
- "--line-numbers",
- "--main", "README",
- "--inline-source"]
-
-# Generate all the Rake tasks
-# Run 'rake -T' to see list of generated tasks (from gem root directory)
-hoe = Hoe.new(GEM_NAME, VERS) do |p|
- p.author = AUTHOR
- p.description = DESCRIPTION
- p.email = EMAIL
- p.summary = DESCRIPTION
- p.url = HOMEPATH
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
- p.test_globs = ["test/**/*_test.rb"]
- p.clean_globs = CLEAN #An array of file patterns to delete on clean.
-
- # == Optional
- #p.changes - A description of the release's latest changes.
- p.extra_deps = %w( hpricot )
- #p.spec_extras - A hash of extra values to set in the gemspec.
-end
-
-
-
-desc "Package and Install Gem"
-task :package_and_install do
- `rake package`
- `sudo gem install pkg/#{NAME}-#{VERS}.gem`
-end
@@ -1,35 +0,0 @@
-#!/usr/bin/env ruby
-# = addicted to twitter
-#
-# ... a sweet little diddy that helps you twitter your life away from the command line
-#
-# == Install
-#
-# $ sudo gem install twitter
-#
-# == Command Line Use
-#
-# $ twitter
-#
-# Usage: twitter <command> [options]
-#
-# Available Commands:
-# - post
-# - timeline
-# - friends
-# - friend
-# - followers
-# - follower
-#
-# That will show the commands and each command will either run or show you the options it needs to run
-#
-# $ twitter post "releasing my new twitter gem"
-#
-# Got it! New twitter created at: Mon Nov 27 00:22:27 UTC 2006
-#
-# That will post a status update to your twitter
-require 'rubygems'
-require 'twitter'
-require 'twitter/command'
-
-Twitter::Command.process!
Oops, something went wrong.

0 comments on commit ff1ae65

Please sign in to comment.