neufelry-twitter 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. data/History +122 -0
  2. data/License +19 -0
  3. data/Manifest +66 -0
  4. data/README +84 -0
  5. data/Rakefile +40 -0
  6. data/bin/twitter +14 -0
  7. data/examples/blocks.rb +15 -0
  8. data/examples/direct_messages.rb +29 -0
  9. data/examples/favorites.rb +20 -0
  10. data/examples/friends_followers.rb +25 -0
  11. data/examples/friendships.rb +13 -0
  12. data/examples/identica_timeline.rb +7 -0
  13. data/examples/location.rb +8 -0
  14. data/examples/posting.rb +9 -0
  15. data/examples/replies.rb +27 -0
  16. data/examples/search.rb +18 -0
  17. data/examples/sent_messages.rb +27 -0
  18. data/examples/timeline.rb +34 -0
  19. data/examples/twitter.rb +27 -0
  20. data/examples/verify_credentials.rb +13 -0
  21. data/lib/twitter.rb +42 -0
  22. data/lib/twitter/base.rb +270 -0
  23. data/lib/twitter/cli.rb +334 -0
  24. data/lib/twitter/cli/config.rb +9 -0
  25. data/lib/twitter/cli/helpers.rb +109 -0
  26. data/lib/twitter/cli/migrations/20080722194500_create_accounts.rb +13 -0
  27. data/lib/twitter/cli/migrations/20080722194508_create_tweets.rb +16 -0
  28. data/lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb +9 -0
  29. data/lib/twitter/cli/migrations/20080722214606_create_configurations.rb +13 -0
  30. data/lib/twitter/cli/models/account.rb +33 -0
  31. data/lib/twitter/cli/models/configuration.rb +13 -0
  32. data/lib/twitter/cli/models/tweet.rb +20 -0
  33. data/lib/twitter/direct_message.rb +22 -0
  34. data/lib/twitter/easy_class_maker.rb +43 -0
  35. data/lib/twitter/rate_limit_status.rb +19 -0
  36. data/lib/twitter/search.rb +101 -0
  37. data/lib/twitter/search_result.rb +83 -0
  38. data/lib/twitter/search_result_info.rb +82 -0
  39. data/lib/twitter/status.rb +22 -0
  40. data/lib/twitter/user.rb +37 -0
  41. data/lib/twitter/version.rb +3 -0
  42. data/spec/base_spec.rb +127 -0
  43. data/spec/cli/helper_spec.rb +49 -0
  44. data/spec/direct_message_spec.rb +35 -0
  45. data/spec/fixtures/followers.xml +706 -0
  46. data/spec/fixtures/friends.xml +609 -0
  47. data/spec/fixtures/friends_for.xml +584 -0
  48. data/spec/fixtures/friends_lite.xml +192 -0
  49. data/spec/fixtures/friends_timeline.xml +66 -0
  50. data/spec/fixtures/friendship_already_exists.xml +5 -0
  51. data/spec/fixtures/friendship_created.xml +12 -0
  52. data/spec/fixtures/public_timeline.xml +148 -0
  53. data/spec/fixtures/rate_limit_status.xml +7 -0
  54. data/spec/fixtures/search_result_info.yml +147 -0
  55. data/spec/fixtures/search_results.json +1 -0
  56. data/spec/fixtures/status.xml +25 -0
  57. data/spec/fixtures/user.xml +38 -0
  58. data/spec/fixtures/user_timeline.xml +465 -0
  59. data/spec/search_spec.rb +100 -0
  60. data/spec/spec.opts +1 -0
  61. data/spec/spec_helper.rb +23 -0
  62. data/spec/status_spec.rb +40 -0
  63. data/spec/user_spec.rb +42 -0
  64. data/twitter.gemspec +45 -0
  65. data/website/css/common.css +47 -0
  66. data/website/images/terminal_output.png +0 -0
  67. data/website/index.html +159 -0
  68. metadata +181 -0
data/History ADDED
@@ -0,0 +1,122 @@
1
+ 0.4.1 - January 1, 2009
2
+ * 4 minor enhancements and 2 bug fixes:
3
+ * Added better exception handling (Billy Gray)
4
+ * Added page to search (Michael Ivey)
5
+ * Adding an option to display tweets on CLI in reverse order (oldest first). (Cameron Booth)
6
+ * Added in_reply_to_status_id option for replying to statuses (anthonycrumley)
7
+ * Fixed a bug where the @config was improperly set (K. Adam Christensen)
8
+ * Fix verify_credentials to include a format (breaks in laconica). (dustin)
9
+
10
+ 0.4.0 - December 23, 2008
11
+ * 3 major changes
12
+ * Removed active support as dependency
13
+ * Removed CLI dependencies from install dependency list
14
+ (they are now only installed by you manually)
15
+ * Switched to echoe for gem managment
16
+
17
+ 0.3.7 - August 26, 2008
18
+ * Fixed source param not getting through
19
+
20
+ 0.3.6 - August 11, 2008
21
+ * Fixed a few more methods that required post.
22
+ * Refactored the remaining methods that were not using #request to use it.
23
+
24
+ 0.3.5 - August 4, 2008
25
+ * Removed sqlite-ruby 1.2.2 as a dependency due to install issues on linux
26
+
27
+ 0.3.4 - August 3, 2008
28
+ * Added search support
29
+
30
+ 0.3.3 - August 3, 2008
31
+ * Now has option for host when initializing to support identi.ca (Dustin Sallings)
32
+ * Twitter changed a bunch of methods to POST only so I updated those to now work
33
+
34
+ 0.3.2 - July 26, 2008
35
+ * added the CLI gems as dependencies for now until I separate out the CLI from the API wrapper
36
+ * cleaner CLI errors for no active account or no accounts at all
37
+ * remove sets a new active account if there are none
38
+ * added username and password optional arguments to add
39
+ * added import attempt on install and on anything that uses #current_account helper
40
+
41
+ 0.3.1 - July 23, 2008
42
+ * added open to CLI twitter open jnunemaker would open default browser to http://twitter.com/jnunemaker
43
+ * added -f to timeline and replies which ignores the since_id and shows all results
44
+ * added clear_config to remove all cached since id's and such
45
+ * Majorly pimped the output of timelines and replies.
46
+
47
+ 0.3.0 - July 22, 2008
48
+ * complete rewrite of CLI. Now supports multiple accounts and changing between them.
49
+ * added source, truncated, in_reply_to_status_id, in_reply_to_user_id, and favorited to Twitter::Status
50
+ * added protected to Twitter::User
51
+ * d CLI method now takes standard input like post
52
+ * Rewrote several methods that had since parameter to now use a hash instead. This makes it more flexible as API updates.
53
+ * Rewrote the methods that took lite or since as an argument to instead take a hash.
54
+ * added Twitter::Base#friendship_exists?
55
+ * added Twitter::Base#update_location
56
+ * added Twitter::Base#update_delivery_device
57
+ * added Twitter::Base#favorites
58
+ * added Twitter::Base#create_favorite
59
+ * added Twitter::Base#destroy_favorite
60
+ * added Twitter::Base#block
61
+ * added Twitter::Base#unblock
62
+
63
+ BACKWORDS COMPATIBILITY BREAK:
64
+ Any method that you have using lite or since as an argument
65
+ will no longer work with this version. Simply change to a
66
+ hash and you'll be fine. For example:
67
+
68
+ friends(true) would now be friends(:lite => true)
69
+
70
+ 0.2.7 - June 29, 2008
71
+ * added #rate_limit_status (Daniel Morrison)
72
+ * added source parameter option to Base#post
73
+ * added twittergem as source when posting from command line
74
+ * Twitter::RateExceeded raised when you hit your limit (Jim O'Leary)
75
+ * Twitter::Unavailable raised when twitter returns 503
76
+ * Twitter::CantConnect is now more descriptive as to what is the problem when it is raised during a request
77
+ * quoting your message when using twitter post on the command line is now optional (Benoit Caccinolo)
78
+ * aliased post to p on command line so it's shorter (Benoit Caccinolo)
79
+ * unescaped html and added some color in command line view (Miles Z. Sterrett)
80
+ * added gemspec (technoweenie, Miles Z. Sterrett)
81
+ * Fixed stack trace error on first command line operation (Matt Rose)
82
+ 0.2.6 - April 2, 2008
83
+ * found a more simple way of doing stdin without any extra gem dependencies
84
+ 0.2.5 - April 2, 2008
85
+ * Command line interface can now use stdin for posting (ideas and example code from Jeremy Friesen)
86
+ $ twitter post 'test without stdin' # => twitters: test without stdin
87
+ $ echo 'test with stdin' | twitter post 'and an argv[1]' # => twitters: test with stdin and an argv[1]
88
+ $ echo 'test with stdin without any argv[1]' | twitter post # => twitters: test with stdin without any argv[1]
89
+ 0.2.4 - Mar 31, 2008
90
+ * Added lite option to friends and followers, which doesn't include the user's current status (Daniel Morrison)
91
+ * Updated since option to use HTTP header, and added the option on timeline() and replies(). (Daniel Morrison)
92
+ 0.2.3 - Jan 16, 2008
93
+ * added d to command line interface twitter d jnunemaker 'hola' (Humbucker)
94
+ * added progress dots when posting for confirmation when twitter is running slow (Hendy Irawan)
95
+ 0.2.2 - added leave and follow which are new twitter api methods for turning notifications on and off
96
+ 0.2.0 - Aug 4, 2007
97
+ * added sent_messages
98
+ * alias direct_messages to received_messages
99
+ * added create_friendship
100
+ * added destroy_friendship
101
+ * added featured to retrieve the featured twitter users
102
+ * added replies
103
+ * added destroy to destroy a status by id
104
+ * added status to find a status by id
105
+ * added active support as an extra dependency
106
+ * implemented d method to send direct messages (jnewland)
107
+ * fixed since argument in direct_messages method (jnewland)
108
+ 0.1.1 - May 20, 2007
109
+ * hpricot 0.5+ now supported; just a bug fix (Ryan Waldron is the man!)
110
+ 0.1.0 - March 31, 2007
111
+ * added d method for creating direct messages (waiting for it to work as documented)
112
+ * added featured method for getting featured users statuses (waiting for it to work as documented)
113
+ * added direct_messages method
114
+ * added friends_for method
115
+ * added a few tests
116
+ * removed relative_created_at as it is deprecated
117
+ * separated out the call method into call, request and parse methods
118
+ 0.0.5 - just a bit of code cleanup
119
+ 0.0.4 - added :location, :description, :url, :profile_image_url to user class (Alex Payne)
120
+ 0.0.3 - added a bit more informative message when things go wrong
121
+ 0.0.2 - added the command line options i forgot to add (friend and follower); improved some docs
122
+ 0.0.1 - initial release
data/License ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2007 John Nunemaker
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/Manifest ADDED
@@ -0,0 +1,66 @@
1
+ bin/twitter
2
+ examples/blocks.rb
3
+ examples/direct_messages.rb
4
+ examples/favorites.rb
5
+ examples/friends_followers.rb
6
+ examples/friendships.rb
7
+ examples/identica_timeline.rb
8
+ examples/location.rb
9
+ examples/posting.rb
10
+ examples/replies.rb
11
+ examples/search.rb
12
+ examples/sent_messages.rb
13
+ examples/timeline.rb
14
+ examples/twitter.rb
15
+ examples/verify_credentials.rb
16
+ History
17
+ lib/twitter/base.rb
18
+ lib/twitter/cli/config.rb
19
+ lib/twitter/cli/helpers.rb
20
+ lib/twitter/cli/migrations/20080722194500_create_accounts.rb
21
+ lib/twitter/cli/migrations/20080722194508_create_tweets.rb
22
+ lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb
23
+ lib/twitter/cli/migrations/20080722214606_create_configurations.rb
24
+ lib/twitter/cli/models/account.rb
25
+ lib/twitter/cli/models/configuration.rb
26
+ lib/twitter/cli/models/tweet.rb
27
+ lib/twitter/cli.rb
28
+ lib/twitter/direct_message.rb
29
+ lib/twitter/easy_class_maker.rb
30
+ lib/twitter/rate_limit_status.rb
31
+ lib/twitter/search.rb
32
+ lib/twitter/search_result.rb
33
+ lib/twitter/search_result_info.rb
34
+ lib/twitter/status.rb
35
+ lib/twitter/user.rb
36
+ lib/twitter/version.rb
37
+ lib/twitter.rb
38
+ License
39
+ Manifest
40
+ Rakefile
41
+ README
42
+ spec/base_spec.rb
43
+ spec/cli/helper_spec.rb
44
+ spec/direct_message_spec.rb
45
+ spec/fixtures/followers.xml
46
+ spec/fixtures/friends.xml
47
+ spec/fixtures/friends_for.xml
48
+ spec/fixtures/friends_lite.xml
49
+ spec/fixtures/friends_timeline.xml
50
+ spec/fixtures/friendship_already_exists.xml
51
+ spec/fixtures/friendship_created.xml
52
+ spec/fixtures/public_timeline.xml
53
+ spec/fixtures/rate_limit_status.xml
54
+ spec/fixtures/search_result_info.yml
55
+ spec/fixtures/search_results.json
56
+ spec/fixtures/status.xml
57
+ spec/fixtures/user.xml
58
+ spec/fixtures/user_timeline.xml
59
+ spec/search_spec.rb
60
+ spec/spec.opts
61
+ spec/spec_helper.rb
62
+ spec/status_spec.rb
63
+ spec/user_spec.rb
64
+ website/css/common.css
65
+ website/images/terminal_output.png
66
+ website/index.html
data/README ADDED
@@ -0,0 +1,84 @@
1
+ = addicted to twitter
2
+
3
+ ... a sweet little diddy that helps you twitter your life away
4
+
5
+ == Install
6
+
7
+ sudo gem install twitter will work just fine. For command line use, you'll need a few other gems: sudo gem install main highline activerecord sqlite3-ruby
8
+
9
+ == Examples
10
+
11
+ Twitter::Base.new('your email', 'your password').update('watching veronica mars')
12
+
13
+ # or you can use post
14
+ Twitter::Base.new('your email', 'your password').post('post works too')
15
+
16
+ puts "Public Timeline", "=" * 50
17
+ Twitter::Base.new('your email', 'your password').timeline(:public).each do |s|
18
+ puts s.text, s.user.name
19
+ puts
20
+ end
21
+
22
+ puts '', "Friends Timeline", "=" * 50
23
+ Twitter::Base.new('your email', 'your password').timeline.each do |s|
24
+ puts s.text, s.user.name
25
+ puts
26
+ end
27
+
28
+ puts '', "Friends", "=" * 50
29
+ Twitter::Base.new('your email', 'your password').friends.each do |u|
30
+ puts u.name, u.status.text
31
+ puts
32
+ end
33
+
34
+ puts '', "Followers", "=" * 50
35
+ Twitter::Base.new('your email', 'your password').followers.each do |u|
36
+ puts u.name, u.status.text
37
+ puts
38
+ end
39
+
40
+ == Search Examples
41
+
42
+ Twitter::Search.new('httparty').each { |r| puts r.inspect }
43
+ Twitter::Search.new('httparty').from('jnunemaker').each { |r| puts r.inspect }
44
+ Twitter::Search.new.from('jnunemaker').to('oaknd1').each { |r| puts r.inspect }
45
+
46
+
47
+ == Command Line Use
48
+
49
+ Note: If you want to use twitter from the command line be sure that sqlite3 and the sqlite3-ruby gem are installed. I removed the sqlite3-ruby gem as a dependency because you shouldn't need that to just use the API wrapper. Eventually I'll move the CLI interface into another gem.
50
+
51
+ $ twitter
52
+
53
+ Will give you a list of all the commands. You can get the help for each command by running twitter [command] -h.
54
+
55
+ The first thing you'll want to do is install the database so your account(s) can be stored.
56
+
57
+ $ twitter install
58
+
59
+ You can always uninstall twitter like this:
60
+
61
+ $ twitter uninstall
62
+
63
+ Once the twitter database is installed and migrated, you can add accounts like this:
64
+
65
+ $ twitter add
66
+ Add New Account:
67
+ Username: jnunemaker
68
+ Password (won't be displayed):
69
+ Account added.
70
+
71
+ You can also list all the accounts you've added.
72
+
73
+ $ twitter list
74
+ Account List
75
+ * jnunemaker
76
+ snitch_test
77
+
78
+ The * means denotes the account that will be used when posting, befriending, defriending, following, leaving or viewing a timeline.
79
+
80
+ To post using the account marked with the *, simply type the following:
81
+
82
+ $ twitter post "releasing my new twitter gem"
83
+
84
+ That is about it. You can do pretty much anything that you can do with twitter from the command line interface.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ ProjectName = 'twitter'
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+ require 'echoe'
6
+ require 'spec/rake/spectask'
7
+ require "lib/#{ProjectName}/version"
8
+
9
+ Echoe.new(ProjectName, Twitter::Version) do |p|
10
+ p.description = "a command line interface for twitter, also a library which wraps the twitter api - Now with Nokogiri"
11
+ p.url = "http://#{ProjectName}.rubyforge.org"
12
+ p.author = "Ryan Neufeld"
13
+ p.email = "neufelry@gmail.com"
14
+ p.extra_deps = [['nokogiri', '>= 1.1.1'], ['activesupport', '>= 2.1'], ['httparty', '>= 0.2.4']]
15
+ p.need_tar_gz = false
16
+ end
17
+
18
+ desc 'Upload website files to rubyforge'
19
+ task :website do
20
+ sh %{rsync -av website/ #{WebsitePath}}
21
+ Rake::Task['website_docs'].invoke
22
+ end
23
+
24
+ task :website_docs do
25
+ Rake::Task['redocs'].invoke
26
+ sh %{rsync -av doc/ #{WebsitePath}/docs}
27
+ end
28
+
29
+ desc 'Preps the gem for a new release'
30
+ task :prepare do
31
+ %w[manifest build_gemspec].each do |task|
32
+ Rake::Task[task].invoke
33
+ end
34
+ end
35
+
36
+ Rake::Task[:default].prerequisites.clear
37
+ task :default => :spec
38
+ Spec::Rake::SpecTask.new do |t|
39
+ t.spec_files = FileList["spec/**/*_spec.rb"]
40
+ end
data/bin/twitter ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # if we have stdin, let's prepend it to the message for post
4
+ if ARGV[0] && ARGV[0] == 'post' && !STDIN.tty?
5
+ ARGV[1] = "#{STDIN.read}#{ARGV[1]}"
6
+ end
7
+
8
+ # if we have stdin, let's prepend it to the message for d
9
+ if ARGV[0] && ARGV[0] == 'd' && !STDIN.tty?
10
+ ARGV[2] = "#{STDIN.read}#{ARGV[2]}"
11
+ end
12
+
13
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'twitter'))
14
+ require 'twitter/cli'
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
3
+ config = YAML::load(open(ENV['HOME'] + '/.twitter'))
4
+
5
+ twitter = Twitter::Base.new(config['email'], config['password'])
6
+
7
+ puts 'BLOCK CREATE'
8
+ puts twitter.block('project_rockne').name
9
+ puts
10
+ puts
11
+
12
+ puts 'BLOCK DESTROY'
13
+ puts twitter.block('project_rockne').name
14
+ puts
15
+ puts
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ require 'activesupport'
3
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
4
+ config = YAML::load(open(ENV['HOME'] + '/.twitter'))
5
+
6
+ twitter = Twitter::Base.new(config['email'], config['password'])
7
+
8
+ puts 'SINCE'
9
+ twitter.direct_messages(:since => Time.now - 5.day).each do |s|
10
+ puts "- #{s.id} #{s.text}"
11
+ end
12
+ puts
13
+ puts
14
+
15
+ # puts 'SINCE_ID'
16
+ # twitter.direct_messages(:since_id => 33505386).each do |s|
17
+ # puts "- #{s.text}"
18
+ # end
19
+ # puts
20
+ # puts
21
+ #
22
+ # puts 'PAGE'
23
+ # twitter.direct_messages(:page => 1).each do |s|
24
+ # puts "- #{s.text}"
25
+ # end
26
+ # puts
27
+ # puts
28
+
29
+ # puts twitter.destroy_direct_message(34489057).inspect
@@ -0,0 +1,20 @@
1
+ require 'rubygems'
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
3
+ config = YAML::load(open(ENV['HOME'] + '/.twitter'))
4
+
5
+ twitter = Twitter::Base.new(config['email'], config['password'])
6
+
7
+ puts 'CREATE'
8
+ puts twitter.create_favorite(865416114).text
9
+ puts
10
+ puts
11
+
12
+ puts 'FAVORITES'
13
+ twitter.favorites.each { |f| puts f.text }
14
+ puts
15
+ puts
16
+
17
+ puts 'DESTROY'
18
+ puts twitter.destroy_favorite(865416114).text
19
+ puts
20
+ puts
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
3
+ config = YAML::load(open(ENV['HOME'] + '/.twitter'))
4
+
5
+ twitter = Twitter::Base.new(config['email'], config['password'])
6
+
7
+ puts "FRIENDS"
8
+ twitter.friends.each { |f| puts f.name }
9
+ puts
10
+ puts
11
+
12
+ puts "FRIENDS FOR"
13
+ twitter.friends_for('orderedlist', :lite => true).each { |f| puts f.name }
14
+ puts
15
+ puts
16
+
17
+ puts "FOLLOWERS"
18
+ twitter.followers(:lite => true).each { |f| puts f.name }
19
+ puts
20
+ puts
21
+
22
+ puts "FOLLOWERS FOR"
23
+ twitter.followers_for('orderedlist', :lite => true).each { |f| puts f.name }
24
+ puts
25
+ puts