Permalink
Browse files

updated with leave and follow methods for twitter base and for the CL…

…I. also updated the manifest.

git-svn-id: http://svn.addictedtonew.com/public/gems/twitter@164 fe7eae16-9a24-0410-a59d-9e59979e88be
  • Loading branch information...
1 parent 9a53d29 commit 4878689063574ad88ea76343387094fc634ccead jnunemaker committed Jan 17, 2008
Showing with 70 additions and 7 deletions.
  1. +1 −0 CHANGELOG
  2. +9 −5 Manifest.txt
  3. +8 −0 lib/twitter/base.rb
  4. +41 −1 lib/twitter/command.rb
  5. +1 −1 lib/twitter/version.rb
  6. +10 −0 test/unit/base_test.rb
View
@@ -1,3 +1,4 @@
+0.2.2 - added leave and follow which are new twitter api methods for turning notifications on and off
0.2.0 - Aug 4, 2007
* added sent_messages
* alias direct_messages to received_messages
View
@@ -1,7 +1,10 @@
-README.txt
CHANGELOG
+MIT-LICENSE
+Manifest.txt
+README.txt
Rakefile
-setup.rb
+bin/twitter
+examples/twitter.rb
lib/twitter.rb
lib/twitter/base.rb
lib/twitter/command.rb
@@ -10,10 +13,11 @@ lib/twitter/easy_class_maker.rb
lib/twitter/status.rb
lib/twitter/user.rb
lib/twitter/version.rb
-examples/twitter.rb
-bin/twitter
+setup.rb
test/test_helper.rb
test/unit/base_test.rb
test/unit/direct_message_test.rb
test/unit/status_test.rb
-test/unit/user_test.rb
+test/unit/user_test.rb
+website/css/common.css
+website/index.html
View
@@ -122,6 +122,14 @@ def destroy_friendship(id_or_screenname)
users(request("friendships/destroy/#{id_or_screenname}.xml", :auth => true)).first
end
+ def follow(id_or_screenname)
+ users(request("notifications/follow/#{id_or_screenname}.xml", :auth => true)).first
+ end
+
+ def leave(id_or_screenname)
+ users(request("notifications/leave/#{id_or_screenname}.xml", :auth => true)).first
+ end
+
# Updates your twitter with whatever status string is passed in
def post(status)
url = URI.parse("http://#{@@api_url}/statuses/update.xml")
View
@@ -2,7 +2,7 @@
# It is only used and included in the bin/twitter file.
module Twitter
class Command
- @@commands = [:post, :timeline, :friends, :friend, :followers, :follower, :featured, :important]
+ @@commands = [:post, :timeline, :friends, :friend, :followers, :follower, :featured, :important, :follow, :leave]
@@template = <<EOF
# .twitter
@@ -162,6 +162,46 @@ def important
end
end
+ def follow
+ config = create_or_find_config
+
+ if ARGV.size == 0
+ puts %(\n You forgot to enter a screen name or id to follow.\n\n Usage: twitter follow jnunemaker\n)
+ exit(0)
+ end
+
+ screen_name = ARGV.shift
+
+ puts
+ found = false
+ begin
+ Twitter::Base.new(config['email'], config['password']).follow(screen_name)
+ puts "You are now following notifications for #{screen_name}."
+ rescue
+ puts "FAIL: Somethin went wrong. Sorry."
+ end
+ end
+
+ def leave
+ config = create_or_find_config
+
+ if ARGV.size == 0
+ puts %(\n You forgot to enter a screen name or id to leave.\n\n Usage: twitter leave jnunemaker\n)
+ exit(0)
+ end
+
+ screen_name = ARGV.shift
+
+ puts
+ found = false
+ begin
+ Twitter::Base.new(config['email'], config['password']).leave(screen_name)
+ puts "You are no longer following notifications for #{screen_name}."
+ rescue
+ puts "FAIL: Somethin went wrong. Sorry."
+ end
+ end
+
private
# Checks for the config, creates it if not found
def create_or_find_config
View
@@ -2,7 +2,7 @@ module Twitter #:nodoc:
module VERSION #:nodoc:
MAJOR = 0
MINOR = 2
- TINY = 1
+ TINY = 2
STRING = [MAJOR, MINOR, TINY].join('.')
end
View
@@ -69,6 +69,16 @@ def setup
puts "Destroying Friendship with Snitch Test", @t.destroy_friendship('snitch_test'), "*"*50
puts "Creating Friendship with Snitch Test", @t.create_friendship('snitch_test'), "*"*50
end
+
+ test 'should be able to follow a user' do
+ puts "Following a user", @t.follow('jnunemaker'), "*"*50
+ end
+
+ test 'should be able to leave a user' do
+ puts "Leaving a user", @t.leave('jnunemaker'), "*"*50
+ end
+
+
#
# test 'should be able to destroy a status' do
# # this has to be checked individually, create a status, put the id in and make sure it was deleted

0 comments on commit 4878689

Please sign in to comment.