Skip to content

Commit

Permalink
Vendored twitter and fixed twitter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Van Dyk authored and cpjolicoeur committed Aug 4, 2009
1 parent 6698eba commit 8b44e58
Show file tree
Hide file tree
Showing 53 changed files with 4,004 additions and 3 deletions.
1 change: 0 additions & 1 deletion Rakefile
Expand Up @@ -54,7 +54,6 @@ GEM_SPEC = Gem::Specification.new do |s|
s.add_dependency 'rake', '>= 0.7.3'
s.add_dependency 'xmpp4r', '>= 0.3.1'
s.add_dependency 'gmailer', '>= 0.1.7'
s.add_dependency 'twitter4r', '>= 0.3.0'

s.files = Dir.glob("{bin,lib,test}/**/*").delete_if { |item| item.include?('__workdir') }
s.files += %w(License.txt Readme.markdown Changelog.txt Rakefile)
Expand Down
1 change: 0 additions & 1 deletion lib/cerberus/publisher/twitter.rb
Expand Up @@ -13,7 +13,6 @@ def Time.parse(args)
class Cerberus::Publisher::Twitter < Cerberus::Publisher::Base
def self.publish(state, manager, options)
begin
gem 'twitter4r', '>=0.3.0'
require 'twitter'

twitter_options = options[:publisher, :twitter]
Expand Down
129 changes: 129 additions & 0 deletions lib/vendor/twitter/CHANGES
@@ -0,0 +1,129 @@
= CHANGES

Catalog(ue) of changes for Twitter4R 0.1.x releases including Retrospectiva ticket cross-reference numbers. Refer to http://retro.tautology.net/projects/twitter4r/tickets for more information.

== 0.3.1 Changes
*
* Added specs for Twitter::Client#profile (:info, :colors and :device cases)
* Added Twitter4R shell
* Improved code coverage for twitter/ext/stdlib code and removed hard coded extension in GET request path for retrieving account information
* Changed Twitter::RESTError super class to be RuntimeError instead of Exception
* Added URI.encode => CGI.escape fix
* Added block methods
* Added Twitter::Client#inspect method to XXXX out passwords
* Minor refactoring of spec/spec_helper.rb
* Added support for :page, :lite and :since options for Twitter::User#followers, Twitter::Client#my([:friends|:followers]...) and Twitter::Client#user([:friends|:followers]...)calls
* Added Twitter::Client.status(:replies) support


== 0.3.0 Changes
* Bunch of changes, but forgot to track them and too lazy to look through the SVN/Git logs. Sorry.

== 0.2.5 Changes

=== 2007-09-23
* Added paging support as per Sergio Santos' request (#36).

== 0.2.4 Changes

=== 2007-07-24
* Fixed ActiveSupport +Time#to_s+ conflict such that integration with Rails is much less painful (#34)

== 0.2.3 Changes

=== 2007-07-22
* Fixed defect #31 such that passing string screen name as for user argument is handled correctly.
* Fixed #30 typo: respond_to -> respond_to?
* Added relevant exception handling for #message(:post, ...) case (#32)
* Add ability to pass in Twitter::User object to Twitter::Client#user(...) #33
* Added stats Rake task
* Updated RDoc for Twitter::Client#user to warn against using it to get followers of authenticated user and updated ArgumentError raising logic as per #29.

== 0.2.2 Changes

=== 2007-07-18
* Fixed URI paths for user, messaging and friendship APIs (#25)
* Added action checks for Twitter::Client methods: #user, #my, #message, #messages, #status, #timeline, #friend (#26)
* Added 'source' configuration documentation.
* Added missing attributes for Twitter::User (#28)

== 0.2.1 Changes

=== 2007-07-17
* Added 'source' feature and configurability.

== 0.2.0 Changes

=== 2007-07-08
* Added featured users API as an "extra" (#19).
* Productionized website for publishing.
* Published Ruby Gem on Rubyforge.

=== 2007-07-07
* Refactored Twitter4R API to be more consistent, by grouping APIs (#6):
- Messaging APIs: direct_messages, new, destroy, replies
- Friendship APIs: create, destroy
* Added following features (#7):
- Retrieving direct messages
- User APIs: friends, followers, show
* Updated documentation and example code.

=== 2007-07-06
* Refactored Twitter4R API to be more consistent, by grouping APIs (#6):
- Status APIs: show, update, destroy
- User APIs: friends, followers, show
* Added X-Twitter-Client HTTP headers and Twitter::Config options (#16)
* Removed redundant feature (#8):
- Followers timeline
* Refactored HTTP request/response code to DRY up code.
* Fix REST error handling to use #is_a?(HTTPSuccess) instead of code in ['200', '201'] to determine REST error (#15).

=== 2007-06-25
* Updated example documentation (#14)
* Refactored marshaling unmarshaling code (#13)

=== 2007-06-20
* Added proxy user/pass support. Tested only via endo-testing. (No system/integration testing behind real proxy as I do not have that environment).


=== 2007-06-17
* Refactored Twitter4R API to be more consistent, by grouping APIs (#6):
- Timeline APIs: public, friends, user

=== 2007-06-13
* Added RSpec Autotest integration
* Fixed Twitter::Meta generation of spec for hash values
* Added HTTP header to each request including generated User-Agent header
* Added RCovMorpher and template to restyle RCov output upon release
* Added Gemspec dependencies and requirements
* Added default tidy YAML configuration file for RCovMorpher
* Added Contributors list and updated external dependencies list to README
* Removed shebang from examples

=== 2007-06-12
* Added proxy support as per Kaiichi Matsunaga submitted patch (#11).
* Added SSL support (#12)

=== 2007-05-19
* Translated RSpec specifications from 0.8.2 compliant to 1.0.0 (#10)

== 0.1.1 Changes

=== 2007-06-25
* Added SSL support (#12)
* Added Proxy support (#11)

== 0.1.0 Changes

=== 2007-05-08
* Added Google Analytics Javascript code to website pages (#5)

=== 2007-05-07
* Fixed errors in online sample code documentation and redeployed website (#2 and #3)
* Created more consistent RDoc theme to go more with website home page (#4)

=== 2007-05-06
* Initial revision of codebase commited; includes:
- Achieved 80% Twitter API feature-completeness
- Attained 100% RSpec C0 code coverage
- Rake tasks for: RSpec, RCov, RDoc, Gem, Rubyforge Publishing, etc.
20 changes: 20 additions & 0 deletions lib/vendor/twitter/MIT-LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2006-2007 Susan Potter <me _at_ susanpotter _dot_ net>.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 changes: 37 additions & 0 deletions lib/vendor/twitter/README
@@ -0,0 +1,37 @@
= Twitter4R

* Project Website - http://twitter4r.rubyforge.org
* Mailing List - http://groups.google.com/group/twitter4r-users

== Developers
* {Susan Potter}[http://SusanPotter.NET] <me at susanpotter dot net>

== Contributors
Code:
* Kaiichi Matsunaga <ma2 at lifemedia dot co dot jp> - proxy code suggestion
* Sergio Santos <> - message paging code suggestion
* Adam Stiles <adam at stilesoft dot com> - URI.encode => CGI.escape fix
* Carl Crawley <cwcrawley at gmail dot com> - Friendship get => post fix
* Christian Johansen <christian at cjohansen dot no> - in_reply_to attributes in Twitter::Status

Design Suggestions:
* Bosco So <rubymeetup at boscoso dot com> - making Twitter::Error a RuntimeError instead of an Exception to prevent irb from crashing out.

== Description
Twitter4R provides an object based API to query or update your Twitter account via pure Ruby. It hides the ugly HTTP/REST code from your code.

== External Dependencies
* Ruby 1.8 (tested with 1.8.6)
* RSpec gem 1.0.0+ (tested with 1.1.3)
* JSON gem 0.4.3+ (tested with versions: 1.1.1 and 1.1.2)
* jcode (for unicode support)

== Usage Examples
Twitter4R starting with version 0.1.1 and above is organized into seven parts:
* {Configuration API}[link:files/examples/configure_rb.html]
* {Friendship API}[link:files/examples/friendship_rb.html]
* {Messaging API}[link:files/examples/messaging_rb.html]
* {Model API}[link:files/examples/model_rb.html]
* {Status API}[link:files/examples/status_rb.html]
* {Timeline API}[link:files/examples/timeline_rb.html]
* {User API}[link:files/examples/user_rb.html]
7 changes: 7 additions & 0 deletions lib/vendor/twitter/TODO
@@ -0,0 +1,7 @@

0.3.1 TODO:
* Add specs for :page, :lite and :since options support in Twitter::Client#my(...), Twitter::Client#user(....) and Twitter::User#followers calls
* Add specs for :replies support in Twitter::Client#status(...) and Twitter::Client#timeline_for(...)
* Add RDoc for :replies support
* Add better RDoc for Twitter::Client.account_info(:rate_limit_status)
* Add specs for Twitter::Client.account_info(:rate_limit_status)
34 changes: 34 additions & 0 deletions lib/vendor/twitter/lib/twitter.rb
@@ -0,0 +1,34 @@
#
require('rubygems')

module Twitter; end

def require_local(suffix)
require(File.expand_path(File.join(File.dirname(__FILE__), suffix)))
end

# For better unicode support in 1.8
if RUBY_VERSION < '1.9'
$KCODE = 'u'
require 'jcode'
end

# External requires
require('yaml')
require('date')
require('time')
require('net/https')
require('uri')
require('cgi')
require('json')
require('yaml')

# Ordering matters...pay attention here!
require_local('twitter/ext')
require_local('twitter/version')
require_local('twitter/meta')
require_local('twitter/core')
require_local('twitter/model')
require_local('twitter/config')
require_local('twitter/client')
require_local('twitter/console')
24 changes: 24 additions & 0 deletions lib/vendor/twitter/lib/twitter/client.rb
@@ -0,0 +1,24 @@
# client.rb contains the classes, methods and extends <tt>Twitter4R</tt>
# features to define client calls to the Twitter REST API.
#
# See:
# * <tt>Twitter::Client</tt>

# Used to query or post to the Twitter REST API to simplify code.
class Twitter::Client
include Twitter::ClassUtilMixin
end

require('twitter/client/base')
require('twitter/client/timeline')
require('twitter/client/status')
require('twitter/client/friendship')
require('twitter/client/messaging')
require('twitter/client/user')
require('twitter/client/auth')
require('twitter/client/favorites')
require('twitter/client/blocks')
require('twitter/client/account')
require('twitter/client/graph')
require('twitter/client/profile')
require('twitter/client/search')
24 changes: 24 additions & 0 deletions lib/vendor/twitter/lib/twitter/client/account.rb
@@ -0,0 +1,24 @@
class Twitter::Client
@@ACCOUNT_URIS = {
:rate_limit_status => '/account/rate_limit_status',
}

# Provides access to the Twitter rate limit status API.
#
# You can find out information about your account status. Currently the only
# supported type of account status is the <tt>:rate_limit_status</tt> which
# returns a <tt>Twitter::RateLimitStatus</tt> object.
#
# Example:
# account_status = client.account_info
# puts account_status.remaining_hits
def account_info(type = :rate_limit_status)
connection = create_http_connection
connection.start do |connection|
response = http_connect do |conn|
create_http_get_request(@@ACCOUNT_URIS[type])
end
bless_models(Twitter::RateLimitStatus.unmarshal(response.body))
end
end
end
27 changes: 27 additions & 0 deletions lib/vendor/twitter/lib/twitter/client/auth.rb
@@ -0,0 +1,27 @@
class Twitter::Client
@@AUTHENTICATION_URIS = {
:verify => '/account/verify_credentials',
}

# Provides access to the Twitter verify credentials API.
#
# You can verify Twitter user credentials with minimal overhead using this method.
#
# Example:
# client.authenticate?("osxisforlightweights", "l30p@rd_s^cks!")
def authenticate?(login, password)
verify_credentials(login, password)
end

private
def verify_credentials(username, passwd)
connection = create_http_connection
connection.start do |connection|
request = create_http_get_request("#{@@AUTHENTICATION_URIS[:verify]}.json")
request.basic_auth(username, passwd)
response = connection.request(request)
response.is_a?(Net::HTTPSuccess) ? true : false
end
end
end

0 comments on commit 8b44e58

Please sign in to comment.