diff --git a/lib/contacts b/lib/contacts index 9d3c2f6..e3c7a2b 120000 --- a/lib/contacts +++ b/lib/contacts @@ -1 +1 @@ -../vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts \ No newline at end of file +../vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts \ No newline at end of file diff --git a/lib/contacts.rb b/lib/contacts.rb index 2fc5b6a..196c99e 120000 --- a/lib/contacts.rb +++ b/lib/contacts.rb @@ -1 +1 @@ -../vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts.rb \ No newline at end of file +../vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts.rb \ No newline at end of file diff --git a/lib/gdata b/lib/gdata new file mode 120000 index 0000000..16cb450 --- /dev/null +++ b/lib/gdata @@ -0,0 +1 @@ +../vendor/gdata-1.1.1/lib/gdata \ No newline at end of file diff --git a/lib/gdata.rb b/lib/gdata.rb new file mode 120000 index 0000000..7b63524 --- /dev/null +++ b/lib/gdata.rb @@ -0,0 +1 @@ +../vendor/gdata-1.1.1/lib/gdata.rb \ No newline at end of file diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/.gitignore b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/.gitignore deleted file mode 100644 index a1462cb..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.DS_Store -test/accounts.yml \ No newline at end of file diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/LICENSE b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/LICENSE deleted file mode 100644 index 0791910..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/LICENSE +++ /dev/null @@ -1,10 +0,0 @@ -Copyright (c) 2006, Lucas Carlson, MOG -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -Neither the name of the Lucas Carlson nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/README b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/README deleted file mode 100644 index 55065b2..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/README +++ /dev/null @@ -1,43 +0,0 @@ -== Welcome to Contacts - -Contacts is a universal interface to grab contact list information from various providers including Hotmail, Gmail and Yahoo. - -== Download - -* gem install contacts -* http://rubyforge.org/projects/contacts -* svn co svn://rubyforge.org/var/svn/contacts - -== Background - -For a long time, the only way to get a list of contacts from your free online email accounts was with proprietary PHP scripts that would cost you $50. The act of grabbing that list is a simple matter of screen scrapping and this library gives you all the functionality you need. Thanks to the generosity of the highly popular Rails website MOG (http://mog.com) for allowing this library to be released open-source to the world. It is easy to extend this library to add new free email providers, so please contact the author if you would like to help. - -== Usage - - Contacts::Hotmail.new(login, password).contacts # => [["name", "foo@bar.com"], ["another name", "bow@wow.com"]] - Contacts::Yahoo.new(login, password).contacts - Contacts::Gmail.new(login, password).contacts - - Contacts.new(:gmail, login, password).contacts - Contacts.new(:hotmail, login, password).contacts - Contacts.new(:yahoo, login, password).contacts - - Contacts.guess(login, password).contacts - -Notice there are three ways to use this library so that you can limit the use as much as you would like in your particular application. The Contacts.guess method will automatically concatenate all the address book contacts from each of the successful logins in the case that a username password works across multiple services. - -== Examples - -See the examples/ directory. - -== Authors - -* Lucas Carlson from MOG (mailto:lucas@rufy.com) - http://mog.com - -== Contributors - -* Britt Selvitelle from Twitter (mailto:anotherbritt@gmail.com) - http://twitter.com -* Tony Targonski from GigPark (mailto:tony@gigpark.com) - http://gigpark.com - -This library is released under the terms of the BSD. - diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/Rakefile b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/Rakefile deleted file mode 100644 index dbb1cf8..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/Rakefile +++ /dev/null @@ -1,90 +0,0 @@ -require 'rubygems' -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' -require 'rake/gempackagetask' -require 'rake/contrib/rubyforgepublisher' -require 'lib/contacts' - -PKG_VERSION = Contacts::VERSION - -PKG_FILES = FileList[ - "lib/**/*", "bin/*", "test/**/*", "[A-Z]*", "Rakefile", "doc/**/*", "examples/**/*" -] - -desc "Default Task" -task :default => [ :test ] - -# Run the unit tests -desc "Run all unit tests" -Rake::TestTask.new("test") { |t| - t.libs << "lib" - t.pattern = 'test/*/*_test.rb' - t.verbose = true -} - -# Make a console, useful when working on tests -desc "Generate a test console" -task :console do - verbose( false ) { sh "irb -I lib/ -r 'contacts'" } -end - -# Genereate the RDoc documentation -desc "Create documentation" -Rake::RDocTask.new("doc") { |rdoc| - rdoc.title = "Contact List - ridiculously easy contact list information from various providers including Yahoo, Gmail, and Hotmail" - rdoc.rdoc_dir = 'doc' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -} - -# Genereate the package -spec = Gem::Specification.new do |s| - - #### Basic information. - - s.name = 'contacts' - s.version = PKG_VERSION - s.summary = <<-EOF - Ridiculously easy contact list information from various providers including Yahoo, Gmail, and Hotmail - EOF - s.description = <<-EOF - Ridiculously easy contact list information from various providers including Yahoo, Gmail, and Hotmail - EOF - - #### Which files are to be included in this gem? Everything! (Except CVS directories.) - - s.files = PKG_FILES - - #### Load-time details: library and application (you will need one or both). - - s.require_path = 'lib' - s.autorequire = 'contacts' - - s.add_dependency('json', '>= 0.4.1') - s.requirements << "A json parser" - - #### Documentation and testing. - - s.has_rdoc = true - - #### Author and project details. - - s.author = "Lucas Carlson" - s.email = "lucas@rufy.com" - s.homepage = "http://rubyforge.org/projects/contacts" -end - -Rake::GemPackageTask.new(spec) do |pkg| - pkg.need_zip = true - pkg.need_tar = true -end - -desc "Report code statistics (KLOCs, etc) from the application" -task :stats do - require 'code_statistics' - CodeStatistics.new( - ["Library", "lib"], - ["Units", "test"] - ).to_s -end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/contacts.gemspec b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/contacts.gemspec deleted file mode 100644 index 8416f72..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/contacts.gemspec +++ /dev/null @@ -1,13 +0,0 @@ -Gem::Specification.new do |s| - s.name = "contacts" - s.version = "1.0.14" - s.date = "2009-05-06" - s.summary = "A universal interface to grab contact list information from various providers including Yahoo, Gmail, Hotmail, and Plaxo." - s.email = "lucas@rufy.com" - s.homepage = "http://github.com/cardmagic/contacts" - s.description = "A universal interface to grab contact list information from various providers including Yahoo, Gmail, Hotmail, and Plaxo." - s.has_rdoc = false - s.authors = ["Lucas Carlson"] - s.files = ["LICENSE", "Rakefile", "README", "examples/grab_contacts.rb", "lib/contacts.rb", "lib/contacts/base.rb", "lib/contacts/gmail.rb", "lib/contacts/hotmail.rb", "lib/contacts/plaxo.rb", "lib/contacts/yahoo.rb"] - s.add_dependency("json", [">= 1.1.1"]) -end diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/cruise_config.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/cruise_config.rb deleted file mode 100644 index 6ccfad2..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/cruise_config.rb +++ /dev/null @@ -1,22 +0,0 @@ -# Project-specific configuration for CruiseControl.rb - -Project.configure do |project| - - # Send email notifications about broken and fixed builds to email1@your.site, email2@your.site (default: send to nobody) - # if building this on your own CI box, please remove! - project.email_notifier.emails = ['opensource@pivotallabs.com'] - - # Set email 'from' field to john@doe.com: - # project.email_notifier.from = 'john@doe.com' - - # Build the project by invoking rake task 'custom' - # project.rake_task = 'custom' - - # Build the project by invoking shell script "build_my_app.sh". Keep in mind that when the script is invoked, current working directory is - # [cruise]/projects/your_project/work, so if you do not keep build_my_app.sh in version control, it should be '../build_my_app.sh' instead - # project.build_command = 'build_my_app.sh' - - # Ping Subversion for new revisions every 5 minutes (default: 30 seconds) - # project.scheduler.polling_interval = 5.minutes - -end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/examples/grab_contacts.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/examples/grab_contacts.rb deleted file mode 100644 index c5c4239..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/examples/grab_contacts.rb +++ /dev/null @@ -1,12 +0,0 @@ -require File.dirname(__FILE__)+"/../lib/contacts" - -login = ARGV[0] -password = ARGV[1] - -Contacts::Gmail.new(login, password).contacts - -Contacts.new(:gmail, login, password).contacts - -Contacts.new("gmail", login, password).contacts - -Contacts.guess(login, password).contacts \ No newline at end of file diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/geminstaller.yml b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/geminstaller.yml deleted file mode 100644 index f5f6e38..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/geminstaller.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -defaults: - install_options: --no-ri --no-rdoc -gems: - - name: json - version: >= 1.1.1 diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts.rb deleted file mode 100644 index d2c4448..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts.rb +++ /dev/null @@ -1,8 +0,0 @@ -$:.unshift(File.dirname(__FILE__)+"/contacts/") - -require 'rubygems' -require 'base' -require 'gmail' -require 'hotmail' -require 'yahoo' -require 'plaxo' \ No newline at end of file diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts/base.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts/base.rb deleted file mode 100644 index ad72938..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts/base.rb +++ /dev/null @@ -1,210 +0,0 @@ -require "cgi" -require "net/http" -require "net/https" -require "uri" -require "zlib" -require "stringio" -require "thread" - -class Contacts - TYPES = {} - VERSION = "1.0.13" - - class Base - def initialize(login, password) - @login = login - @password = password - @connections = {} - connect - end - - def connect - raise AuthenticationError, "Login and password must not be nil, login: #{@login.inspect}, password: #{@password.inspect}" if @login.nil? || @password.nil? - real_connect - end - - def connected? - @cookies && !@cookies.empty? - end - - def contacts(options = {}) - return @contacts if @contacts - if connected? - url = URI.parse(contact_list_url) - http = open_http(url) - resp, data = http.get("#{url.path}?#{url.query}", - "Cookie" => @cookies - ) - - if resp.code_type != Net::HTTPOK - raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR) - end - - parse(data, options) - end - end - - def login - @attempt ||= 0 - @attempt += 1 - - if @attempt == 1 - @login - else - if @login.include?("@#{domain}") - @login.sub("@#{domain}","") - else - "#{@login}@#{domain}" - end - end - end - - def password - @password - end - - private - - def domain - @d ||= URI.parse(self.class.const_get(:URL)).host.sub(/^www\./,'') - end - - def contact_list_url - self.class.const_get(:CONTACT_LIST_URL) - end - - def address_book_url - self.class.const_get(:ADDRESS_BOOK_URL) - end - - def open_http(url) - c = @connections[Thread.current.object_id] ||= {} - http = c["#{url.host}:#{url.port}"] - unless http - http = Net::HTTP.new(url.host, url.port) - if url.port == 443 - http.use_ssl = true - http.verify_mode = OpenSSL::SSL::VERIFY_NONE - end - c["#{url.host}:#{url.port}"] = http - end - http.start unless http.started? - http - end - - def parse_cookies(data, existing="") - return existing if data.nil? - - cookies = existing.split(";").map{|i|i.split("=", 2).map{|j|j.strip}}.inject({}){|h,i|h[i[0]]=i[1];h} - - data.gsub!(/ ?[\w]+=EXPIRED;/,'') - data.gsub!(/ ?expires=(.*?, .*?)[;,$]/i, ';') - data.gsub!(/ ?(domain|path)=[\S]*?[;,$]/i,';') - data.gsub!(/[,;]?\s*(secure|httponly)/i,'') - data.gsub!(/(;\s*){2,}/,', ') - data.gsub!(/(,\s*){2,}/,', ') - data.sub!(/^,\s*/,'') - data.sub!(/\s*,$/,'') - - data.split(", ").map{|t|t.to_s.split(";").first}.each do |data| - k, v = data.split("=", 2).map{|j|j.strip} - if cookies[k] && v.empty? - cookies.delete(k) - elsif v && !v.empty? - cookies[k] = v - end - end - - cookies.map{|k,v| "#{k}=#{v}"}.join("; ") - end - - def remove_cookie(cookie, cookies) - parse_cookies("#{cookie}=", cookies) - end - - def post(url, postdata, cookies="", referer="") - url = URI.parse(url) - http = open_http(url) - resp, data = http.post(url.path, postdata, - "User-Agent" => "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0", - "Accept-Encoding" => "gzip", - "Cookie" => cookies, - "Referer" => referer, - "Content-Type" => 'application/x-www-form-urlencoded' - ) - data = uncompress(resp, data) - cookies = parse_cookies(resp.response['set-cookie'], cookies) - forward = resp.response['Location'] - forward ||= (data =~ / "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0", - "Accept-Encoding" => "gzip", - "Cookie" => cookies, - "Referer" => referer - ) - data = uncompress(resp, data) - cookies = parse_cookies(resp.response['set-cookie'], cookies) - forward = resp.response['Location'] - if (not forward.nil?) && URI.parse(forward).host.nil? - forward = url.scheme.to_s + "://" + url.host.to_s + forward - end - return data, resp, cookies, forward - end - - def uncompress(resp, data) - case resp.response['content-encoding'] - when 'gzip': - gz = Zlib::GzipReader.new(StringIO.new(data)) - data = gz.read - gz.close - resp.response['content-encoding'] = nil - # FIXME: Not sure what Hotmail was feeding me with their 'deflate', - # but the headers definitely were not right - when 'deflate': - data = Zlib::Inflate.inflate(data) - resp.response['content-encoding'] = nil - end - - data - end - end - - class ContactsError < StandardError - end - - class AuthenticationError < ContactsError - end - - class ConnectionError < ContactsError - end - - class TypeNotFound < ContactsError - end - - def self.new(type, login, password) - if TYPES.include?(type.to_s.intern) - TYPES[type.to_s.intern].new(login, password) - else - raise TypeNotFound, "#{type.inspect} is not a valid type, please choose one of the following: #{TYPES.keys.inspect}" - end - end - - def self.guess(login, password) - TYPES.inject([]) do |a, t| - begin - a + t[1].new(login, password).contacts - rescue AuthenticationError - a - end - end.uniq - end -end diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts/gmail.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts/gmail.rb deleted file mode 100644 index f50fe3a..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts/gmail.rb +++ /dev/null @@ -1,94 +0,0 @@ -begin - # If the json gem is available, use it - require "json/add/rails" -rescue MissingSourceFile - # Otherwise wrap the ActiveSupport JSON implementation for our simple use case - class JSON - def self.parse(i) - ActiveSupport::JSON.decode(i) - end - end -end - -class Contacts - class Gmail < Base - URL = "https://mail.google.com/mail/" - LOGIN_URL = "https://www.google.com/accounts/ServiceLoginAuth" - LOGIN_REFERER_URL = "https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%3Fui%3Dhtml%26zy%3Dl<mpl=yj_blanco<mplcache=2&hl=en" - CONTACT_LIST_URL = "https://mail.google.com/mail/contacts/data/contacts?thumb=true&show=ALL&enums=true&psort=Name&max=10000&out=js&rf=&jsx=true" - PROTOCOL_ERROR = "Gmail has changed its protocols, please upgrade this library first. If that does not work, dive into the code and submit a patch at http://github.com/cardmagic/contacts" - - def real_connect - postdata = "ltmpl=yj_blanco" - postdata += "&continue=%s" % CGI.escape(URL) - postdata += "<mplcache=2" - postdata += "&service=mail" - postdata += "&rm=false" - postdata += "<mpl=yj_blanco" - postdata += "&hl=en" - postdata += "&Email=%s" % CGI.escape(login) - postdata += "&Passwd=%s" % CGI.escape(password) - postdata += "&rmShown=1" - postdata += "&null=Sign+in" - - time = Time.now.to_i - time_past = Time.now.to_i - 8 - rand(12) - cookie = "GMAIL_LOGIN=T#{time_past}/#{time_past}/#{time}" - - data, resp, cookies, forward, old_url = post(LOGIN_URL, postdata, cookie, LOGIN_REFERER_URL) + [LOGIN_URL] - - cookies = remove_cookie("GMAIL_LOGIN", cookies) - - if data.index("Username and password do not match") - raise AuthenticationError, "Username and password do not match" - elsif data.index("The username or password you entered is incorrect") - raise AuthenticationError, "Username and password do not match" - elsif data.index("Required field must not be blank") - raise AuthenticationError, "Login and password must not be blank" - elsif data.index("errormsg_0_logincaptcha") - raise AuthenticationError, "Captcha error" - elsif data.index("Invalid request") - raise ConnectionError, PROTOCOL_ERROR - elsif cookies == "" - raise ConnectionError, PROTOCOL_ERROR - end - - cookies = remove_cookie("LSID", cookies) - cookies = remove_cookie("GV", cookies) - - @cookies = cookies - end - - private - - def parse(data, options) - data.gsub!(/^while \(true\); &&&START&&&/, '') - data.gsub!(/ &&&END&&&$/, '') - data.gsub!(/\t/, ' ') # tabs in the note field cause errors with JSON.parse - data.gsub!(/[\t\x00-\x1F]/, " ") # strip control characters - - @contacts = JSON.parse(data)['Body']['Contacts'] || {} - - # Determine in which format to return the data. - - # Return the full JSON Hash. - return @contacts if(options[:details]) - - # Default format. - # ['Name', 'Email1', 'Email2', ...] - if @contacts != nil - @contacts = @contacts.delete_if {|c| c["Emails"].nil?}.map do |c| - name, emails = c.values_at "Name", "Emails" - # emails are returned in a form of - # [{"Address"=>"home.email@gmail.com"}, {"Type"=>{"Id"=>"WORK"}, "Address"=>"work.email@gmail.com"}] - emails = emails.collect{|a| a.values_at("Address")} - [name, emails].flatten - end - else - [] - end - end - end - - TYPES[:gmail] = Gmail -end diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts/hotmail.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts/hotmail.rb deleted file mode 100644 index 1fae72e..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts/hotmail.rb +++ /dev/null @@ -1,179 +0,0 @@ -class Contacts - class Hotmail < Base - URL = "http://login.live.com/login.srf?id=2" - OLD_CONTACT_LIST_URL = "http://%s/cgi-bin/addresses" - NEW_CONTACT_LIST_URL = "http://%s/mail/GetContacts.aspx" - NEWEST_CONTACT_LIST_URL = "http://%s/mail/options.aspx?subsection=26" - COMPOSE_URL = "http://%s/cgi-bin/compose?" - PROTOCOL_ERROR = "Hotmail has changed its protocols, please upgrade this library first. If that does not work, report this error at http://rubyforge.org/forum/?group_id=2693" - PWDPAD = "IfYouAreReadingThisYouHaveTooMuchFreeTime" - MAX_HTTP_THREADS = 8 - - def real_connect - data, resp, cookies, forward = get(URL) - - old_url = URL - until forward.nil? - data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward] - end - - postdata = "PPSX=%s&PwdPad=%s&login=%s&passwd=%s&LoginOptions=2&PPFT=%s" % [ - CGI.escape(data.split("><").grep(/PPSX/).first[/=\S+$/][2..-3]), - PWDPAD[0...(PWDPAD.length-@password.length)], - CGI.escape(login), - CGI.escape(password), - CGI.escape(data.split("><").grep(/PPFT/).first[/=\S+$/][2..-3]) - ] - - form_url = data.split("><").grep(/form/).first.split[5][8..-2] - data, resp, cookies, forward = post(form_url, postdata, cookies) - - if data.index("The e-mail address or password is incorrect") - raise AuthenticationError, "Username and password do not match" - elsif data != "" - raise AuthenticationError, "Required field must not be blank" - elsif cookies == "" - raise ConnectionError, PROTOCOL_ERROR - end - - old_url = form_url - until forward.nil? - data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward] - end - -=begin - if data =~ %r{action="(.*?)"} - forward = $1 - puts forward - napexp = CGI.escape(data.to_s[/id="NAPExp" value="(.*?)"/][19...-1]) - nap = CGI.escape(data.to_s[/id="NAP" value="(.*?)"/][16...-1]) - anon = CGI.escape(data.to_s[/id="ANON" value="(.*?)"/][17...-1]) - anonexp = CGI.escape(data.to_s[/id="ANONExp" value="(.*?)"/][20...-1]) - t = CGI.escape(data.to_s[/id="t" value="(.*?)"/][14...-1]) - - postdata = "NAPExp=%s&NAP=%s&ANON=%s&ANONExp=%s&t=%s" % [ napexp, nap, anon, anonexp, t ] - puts postdata - data, resp, cookies, forward, old_url = post(forward, postdata, cookies, old_url) + [forward] - end - - until forward.nil? - data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward] - end -=end - - data, resp, cookies, forward = get("http://mail.live.com/mail", cookies) - until forward.nil? - data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward] - end - - # click on 'Contiune' if presented with the Hotmail Listened page - # look for the Submit button with a "TakeMeToInbox" name (this should work for other languages) - if (not old_url.grep(/MessageAtLogin.aspx/).first.nil?) - - viewState = data.split(/>\s*?\s*?\s*? m - if @attempt == 1 - retry - else - raise m - end - end - - def contacts(options = {}) - return @contacts if @contacts - if connected? - url = URI.parse(contact_list_url) - data, resp, cookies, forward = get( contact_list_url, @cookies ) - - if resp.code_type != Net::HTTPOK - raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR) - end - - # we have to click on the Export Contacts button to get the csv: - # Search the content for __VIEWSTATE or __EVENTVALIDATION - viewState = data.split(/>\s*?\s*?\s*? "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0", - "Accept-Encoding" => "gzip", - "Cookie" => cookies, - "Referer" => contact_list_url, - "Content-Type" => 'application/x-www-form-urlencoded' - ) - - data = uncompress(resp, data) - parse(data, options) - end - end - - - private - - def contact_list_url - NEWEST_CONTACT_LIST_URL % @domain - end - - def follow_email(data, id, contacts_slot) - compose_url = COMPOSE_URL % @domain - postdata = "HrsTest=&to=#{id}&mailto=1&ref=addresses" - postdata += "&curmbox=00000000-0000-0000-0000-000000000001" - - a = data.split(/>\s*\s* - - - 401 - 1 - User not found. - - - - -Bad password -============ - - - - 401 - 4 - Bad password or security token. - - - - -Success -======= - - - - - 200 - OK - 77311236242 - - - - - - 61312569 - Joe Blow1 - Joe Blow1 - Joe - Blow1 - joeblow1@mailinator.com - joeblow1@mailinator.com - 5291351 - - - - 61313159 - Joe Blow2 - Joe Blow2 - Joe - Blow2 - joeblow2@mailinator.com - joeblow2@mailinator.com - 5291351 - - - - - 2 - 3 - - - -' diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts/yahoo.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts/yahoo.rb deleted file mode 100644 index 75b717e..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/lib/contacts/yahoo.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'csv' - -class Contacts - class Yahoo < Base - URL = "http://mail.yahoo.com/" - LOGIN_URL = "https://login.yahoo.com/config/login" - ADDRESS_BOOK_URL = "http://address.mail.yahoo.com/?1&VPC=import_export" - CONTACT_LIST_URL = "http://address.yahoo.com/index.php?VPC=import_export&A=B&submit[action_export_yahoo]=Export%20Now" - PROTOCOL_ERROR = "Yahoo has changed its protocols, please upgrade this library first. If that does not work, dive into the code and submit a patch at http://github.com/cardmagic/contacts" - - def real_connect - postdata = ".tries=2&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=us&.bypass=" - postdata += "&.partner=&.u=4eo6isd23l8r3&.v=0&.challenge=gsMsEcoZP7km3N3NeI4mX" - postdata += "kGB7zMV&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=1&.chkP=Y&." - postdata += "done=#{CGI.escape(URL)}&login=#{CGI.escape(login)}&passwd=#{CGI.escape(password)}" - - data, resp, cookies, forward = post(LOGIN_URL, postdata) - - if data.index("Invalid ID or password") || data.index("This ID is not yet taken") - raise AuthenticationError, "Username and password do not match" - elsif data.index("Sign in") && data.index("to Yahoo!") - raise AuthenticationError, "Required field must not be blank" - elsif !data.match(/uncompressed\/chunked/) - raise ConnectionError, PROTOCOL_ERROR - elsif cookies == "" - raise ConnectionError, PROTOCOL_ERROR - end - - data, resp, cookies, forward = get(forward, cookies, LOGIN_URL) - - if resp.code_type != Net::HTTPOK - raise ConnectionError, PROTOCOL_ERROR - end - - @cookies = cookies - end - - def contacts - return @contacts if @contacts - if connected? - # first, get the addressbook site with the new crumb parameter - url = URI.parse(address_book_url) - http = open_http(url) - resp, data = http.get("#{url.path}?#{url.query}", - "Cookie" => @cookies - ) - - if resp.code_type != Net::HTTPOK - raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR) - end - - crumb = data.to_s[/id="crumb2" value="(.*?)"/][19...-1] - - # now proceed with the new ".crumb" parameter to get the csv data - url = URI.parse("#{contact_list_url}&.crumb=#{crumb}") - http = open_http(url) - resp, data = http.get("#{url.path}?#{url.query}", - "Cookie" => @cookies - ) - - if resp.code_type != Net::HTTPOK - raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR) - end - - parse data - end - end - - private - - def parse(data, options={}) - data = CSV.parse(data) - col_names = data.shift - @contacts = data.map do |person| - [[person[0], person[1], person[2]].delete_if{|i|i.empty?}.join(" "), person[4]] unless person[4].empty? - end.compact - end - - end - - TYPES[:yahoo] = Yahoo -end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/example_accounts.yml b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/example_accounts.yml deleted file mode 100644 index bc56eac..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/example_accounts.yml +++ /dev/null @@ -1,40 +0,0 @@ -gmail: - username: - password: - contacts: - - - name: "FirstName1 LastName1" - email_address: "firstname1@example.com" - - - name: "FirstName2 LastName2" - email_address: "firstname2@example.com" -yahoo: - username: - password: - contacts: - - - name: "FirstName1 LastName1" - email_address: "firstname1@example.com" - - - name: "FirstName2 LastName2" - email_address: "firstname2@example.com" -hotmail: - username: - password: - contacts: - - - name: "FirstName1 LastName1" - email_address: "firstname1@example.com" - - - name: "FirstName2 LastName2" - email_address: "firstname2@example.com" -aol: - username: - password: - contacts: - - - name: "FirstName1 LastName1" - email_address: "firstname1@example.com" - - - name: "FirstName2 LastName2" - email_address: "firstname2@example.com" diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/test_helper.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/test_helper.rb deleted file mode 100644 index a335b2c..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/test_helper.rb +++ /dev/null @@ -1,30 +0,0 @@ -dir = File.dirname(__FILE__) -$LOAD_PATH.unshift(dir + "/../lib/") -require 'test/unit' -require 'contacts' - -class ContactImporterTestCase < Test::Unit::TestCase - # Add more helper methods to be used by all tests here... - def default_test - assert true - end -end - -class TestAccounts - def self.[](type) - load[type] - end - - def self.load(file = File.dirname(__FILE__) + "/accounts.yml") - raise "/test/accounts.yml file not found, please create, see /test/example_accounts.yml for information" unless File.exist?(file) - - accounts = {} - YAML::load(File.open(file)).each do |type, contents| - contacts = contents["contacts"].collect {|contact| [contact["name"], contact["email_address"]]} - accounts[type.to_sym] = Account.new(type.to_sym, contents["username"], contents["password"], contacts) - end - accounts - end - - Account = Struct.new :type, :username, :password, :contacts -end diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/test_suite.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/test_suite.rb deleted file mode 100644 index 0b764ad..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/test_suite.rb +++ /dev/null @@ -1,4 +0,0 @@ -dir = File.dirname(__FILE__) -Dir["#{dir}/**/*_test.rb"].each do |file| - require file -end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/unit/gmail_contact_importer_test.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/unit/gmail_contact_importer_test.rb deleted file mode 100644 index 34e1d5d..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/unit/gmail_contact_importer_test.rb +++ /dev/null @@ -1,37 +0,0 @@ -dir = File.dirname(__FILE__) -require "#{dir}/../test_helper" -require 'contacts' - -class GmailContactImporterTest < ContactImporterTestCase - def setup - super - @account = TestAccounts[:gmail] - end - - def test_successful_login - Contacts.new(:gmail, @account.username, @account.password) - end - - def test_importer_fails_with_invalid_password - assert_raise(Contacts::AuthenticationError) do - Contacts.new(:gmail, @account.username, "wrong_password") - end - end - - def test_importer_fails_with_blank_password - assert_raise(Contacts::AuthenticationError) do - Contacts.new(:gmail, @account.username, "") - end - end - - def test_importer_fails_with_blank_username - assert_raise(Contacts::AuthenticationError) do - Contacts.new(:gmail, "", @account.password) - end - end - - def test_fetch_contacts - contacts = Contacts.new(:gmail, @account.username, @account.password).contacts - assert_equal @account.contacts, contacts - end -end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/unit/hotmail_contact_importer_test.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/unit/hotmail_contact_importer_test.rb deleted file mode 100644 index 4ec2f67..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/unit/hotmail_contact_importer_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -dir = File.dirname(__FILE__) -require "#{dir}/../test_helper" -require 'contacts' - -class HotmailContactImporterTest < ContactImporterTestCase - def setup - super - @account = TestAccounts[:hotmail] - end - - def test_successful_login - Contacts.new(:hotmail, @account.username, @account.password) - end - - def test_importer_fails_with_invalid_password - assert_raise(Contacts::AuthenticationError) do - Contacts.new(:hotmail, @account.username,"wrong_password") - end - end - - def test_fetch_contacts - contacts = Contacts.new(:hotmail, @account.username, @account.password).contacts - assert_equal @account.contacts, contacts - end -end diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/unit/test_accounts_test.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/unit/test_accounts_test.rb deleted file mode 100644 index 7f5aec4..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/unit/test_accounts_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -dir = File.dirname(__FILE__) -require "#{dir}/../test_helper" - -class TestAccountsTest < ContactImporterTestCase - def test_test_accounts_loads_data_from_example_accounts_file - account = TestAccounts.load(File.dirname(__FILE__) + "/../example_accounts.yml")[:gmail] - - assert_equal :gmail, account.type - assert_equal "", account.username - assert_equal "", account.password - assert_equal [["FirstName1 LastName1", "firstname1@example.com"], ["FirstName2 LastName2", "firstname2@example.com"]], account.contacts - end - - def test_test_accounts_blows_up_if_file_doesnt_exist - assert_raise(RuntimeError) do - TestAccounts.load("file_that_does_not_exist.yml") - end - end - - def test_we_can_load_from_account_file - assert_not_nil TestAccounts[:gmail].username - end -end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/unit/yahoo_csv_contact_importer_test.rb b/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/unit/yahoo_csv_contact_importer_test.rb deleted file mode 100644 index b91dd53..0000000 --- a/vendor/cardmagic-contacts-cedf6f38c8fee32e119bae4005799ef073015b8d/test/unit/yahoo_csv_contact_importer_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -dir = File.dirname(__FILE__) -require "#{dir}/../test_helper" -require 'contacts' - -class YahooContactImporterTest < ContactImporterTestCase - def setup - super - @account = TestAccounts[:yahoo] - end - - def test_successful_login - Contacts.new(:yahoo, @account.username, @account.password) - end - - def test_importer_fails_with_invalid_password - assert_raise(Contacts::AuthenticationError) do - Contacts.new(:yahoo, @account.username,"wrong_password") - end - # run the "successful" login test to ensure we reset yahoo's failed login lockout counter - # See http://www.pivotaltracker.com/story/show/138210 - assert_nothing_raised do - Contacts.new(:yahoo, @account.username, @account.password) - end - end - - def test_fetch_contacts - contacts = Contacts.new(:yahoo, @account.username, @account.password).contacts - assert_equal @account.contacts, contacts - end -end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/LICENSE b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/LICENSE new file mode 100644 index 0000000..0791910 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/LICENSE @@ -0,0 +1,10 @@ +Copyright (c) 2006, Lucas Carlson, MOG +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +Neither the name of the Lucas Carlson nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/README b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/README new file mode 100644 index 0000000..8dfc1d1 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/README @@ -0,0 +1,47 @@ +== Welcome to Contacts + +Contacts is a universal interface to grab contact list information from various providers including Hotmail, AOL, Gmail and Yahoo. + +== Download + +* gem install contacts +* http://github.com/cardmagic/contacts +* git clone git://github.com/cardmagic/contacts.git + +== Background + +For a long time, the only way to get a list of contacts from your free online email accounts was with proprietary PHP scripts that would cost you $50. The act of grabbing that list is a simple matter of screen scrapping and this library gives you all the functionality you need. Thanks to the generosity of the highly popular Rails website MOG (http://mog.com) for allowing this library to be released open-source to the world. It is easy to extend this library to add new free email providers, so please contact the author if you would like to help. + +== Usage + + Contacts::Hotmail.new(login, password).contacts # => [["name", "foo@bar.com"], ["another name", "bow@wow.com"]] + Contacts::Yahoo.new(login, password).contacts + Contacts::Gmail.new(login, password).contacts + + Contacts.new(:gmail, login, password).contacts + Contacts.new(:hotmail, login, password).contacts + Contacts.new(:yahoo, login, password).contacts + + Contacts.guess(login, password).contacts + +Notice there are three ways to use this library so that you can limit the use as much as you would like in your particular application. The Contacts.guess method will automatically concatenate all the address book contacts from each of the successful logins in the case that a username password works across multiple services. + +== Examples + +See the examples/ directory. + +== Authors + +* Lucas Carlson from MOG (mailto:lucas@rufy.com) - http://mog.com + +== Contributors + +* Britt Selvitelle from Twitter (mailto:anotherbritt@gmail.com) - http://twitter.com +* Tony Targonski from GigPark (mailto:tony@gigpark.com) - http://gigpark.com +* Waheed Barghouthi from Watwet (mailto:waheed.barghouthi@gmail.com) - http://watwet.com +* Glenn Sidney from Glenn Fu (mailto:glenn@glennfu.com) - http://glennfu.com +* Brian McQuay from Onomojo (mailto:brian@onomojo.com) - http://onomojo.com +* Adam Hunter (mailto:adamhunter@me.com) - http://adamhunter.me/ + +This library is released under the terms of the BSD. + diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/Rakefile b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/Rakefile new file mode 100644 index 0000000..2b74dc8 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/Rakefile @@ -0,0 +1,91 @@ +require 'rubygems' +require 'rake' +require 'rake/testtask' +require 'rake/rdoctask' +require 'rake/gempackagetask' +require 'rake/contrib/rubyforgepublisher' +require 'lib/contacts' + +PKG_VERSION = Contacts::VERSION + +PKG_FILES = FileList[ + "lib/**/*", "bin/*", "test/**/*", "[A-Z]*", "Rakefile", "doc/**/*", "examples/**/*" +] - ["test/accounts.yml"] + +desc "Default Task" +task :default => [ :test ] + +# Run the unit tests +desc "Run all unit tests" +Rake::TestTask.new("test") { |t| + t.libs << "lib" + t.pattern = 'test/*/*_test.rb' + t.verbose = true +} + +# Make a console, useful when working on tests +desc "Generate a test console" +task :console do + verbose( false ) { sh "irb -I lib/ -r 'contacts'" } +end + +# Genereate the RDoc documentation +desc "Create documentation" +Rake::RDocTask.new("doc") { |rdoc| + rdoc.title = "Contact List - ridiculously easy contact list information from various providers including Yahoo, Gmail, and Hotmail" + rdoc.rdoc_dir = 'doc' + rdoc.rdoc_files.include('README') + rdoc.rdoc_files.include('lib/**/*.rb') +} + +# Genereate the package +spec = Gem::Specification.new do |s| + + #### Basic information. + + s.name = 'adamhunter-contacts' + s.version = PKG_VERSION + s.summary = <<-EOF + Ridiculously easy contact list information from various providers including Yahoo, Gmail, and Hotmail + EOF + s.description = <<-EOF + Ridiculously easy contact list information from various providers including Yahoo, Gmail, and Hotmail + EOF + + #### Which files are to be included in this gem? Everything! (Except CVS directories.) + + s.files = PKG_FILES + + #### Load-time details: library and application (you will need one or both). + + s.require_path = 'lib' + s.autorequire = 'contacts' + + s.add_dependency('json', '>= 0.4.1') + s.add_dependency('gdata', '= 1.1.1') + s.requirements << "A json parser, the gdata ruby gem" + + #### Documentation and testing. + + s.has_rdoc = true + + #### Author and project details. + + s.author = "Lucas Carlson" + s.email = "lucas@rufy.com" + s.homepage = "http://rubyforge.org/projects/contacts" +end + +Rake::GemPackageTask.new(spec) do |pkg| + pkg.need_zip = true + pkg.need_tar = true +end + +desc "Report code statistics (KLOCs, etc) from the application" +task :stats do + require 'code_statistics' + CodeStatistics.new( + ["Library", "lib"], + ["Units", "test"] + ).to_s +end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/contacts.gemspec b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/contacts.gemspec new file mode 100644 index 0000000..ea16d08 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/contacts.gemspec @@ -0,0 +1,14 @@ +Gem::Specification.new do |s| + s.name = "contacts" + s.version = "1.2.0" + s.date = "2009-05-06" + s.summary = "A universal interface to grab contact list information from various providers including Yahoo, Gmail, Hotmail, and Plaxo." + s.email = "lucas@rufy.com" + s.homepage = "http://github.com/cardmagic/contacts" + s.description = "A universal interface to grab contact list information from various providers including Yahoo, Gmail, Hotmail, and Plaxo." + s.has_rdoc = false + s.authors = ["Lucas Carlson"] + s.files = ["LICENSE", "Rakefile", "README", "examples/grab_contacts.rb", "lib/contacts.rb", "lib/contacts/base.rb", "lib/contacts/json_picker.rb", "lib/contacts/gmail.rb", "lib/contacts/aol.rb", "lib/contacts/hotmail.rb", "lib/contacts/plaxo.rb", "lib/contacts/yahoo.rb"] + s.add_dependency("json", ">= 1.1.1") + s.add_dependency('gdata', '>= 1.1.1') +end diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/cruise_config.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/cruise_config.rb new file mode 100644 index 0000000..6ccfad2 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/cruise_config.rb @@ -0,0 +1,22 @@ +# Project-specific configuration for CruiseControl.rb + +Project.configure do |project| + + # Send email notifications about broken and fixed builds to email1@your.site, email2@your.site (default: send to nobody) + # if building this on your own CI box, please remove! + project.email_notifier.emails = ['opensource@pivotallabs.com'] + + # Set email 'from' field to john@doe.com: + # project.email_notifier.from = 'john@doe.com' + + # Build the project by invoking rake task 'custom' + # project.rake_task = 'custom' + + # Build the project by invoking shell script "build_my_app.sh". Keep in mind that when the script is invoked, current working directory is + # [cruise]/projects/your_project/work, so if you do not keep build_my_app.sh in version control, it should be '../build_my_app.sh' instead + # project.build_command = 'build_my_app.sh' + + # Ping Subversion for new revisions every 5 minutes (default: 30 seconds) + # project.scheduler.polling_interval = 5.minutes + +end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/examples/grab_contacts.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/examples/grab_contacts.rb new file mode 100644 index 0000000..c5c4239 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/examples/grab_contacts.rb @@ -0,0 +1,12 @@ +require File.dirname(__FILE__)+"/../lib/contacts" + +login = ARGV[0] +password = ARGV[1] + +Contacts::Gmail.new(login, password).contacts + +Contacts.new(:gmail, login, password).contacts + +Contacts.new("gmail", login, password).contacts + +Contacts.guess(login, password).contacts \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/geminstaller.yml b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/geminstaller.yml new file mode 100644 index 0000000..26448aa --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/geminstaller.yml @@ -0,0 +1,8 @@ +--- +defaults: + install_options: --no-ri --no-rdoc +gems: + - name: json + version: >= 1.1.1 + - name: gdata + version: >= 1.1.1 diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts.rb new file mode 100644 index 0000000..e154b72 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts.rb @@ -0,0 +1,11 @@ +$:.unshift(File.dirname(__FILE__)+"/contacts/") + +require 'rubygems' + +require 'base' +require 'gmail' +require 'hotmail' +require 'yahoo' +require 'plaxo' +require 'aol' +require 'json_picker' \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/aol.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/aol.rb new file mode 100644 index 0000000..27eddcb --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/aol.rb @@ -0,0 +1,148 @@ +class Hash + def to_query_string + u = ERB::Util.method(:u) + map { |k, v| + u.call(k) + "=" + u.call(v) + }.join("&") + end +end + +class Contacts + require 'hpricot' + class Aol < Base + URL = "http://www.aol.com/" + LOGIN_URL = "https://my.screenname.aol.com/_cqr/login/login.psp" + LOGIN_REFERER_URL = "http://webmail.aol.com/" + LOGIN_REFERER_PATH = "sitedomain=sns.webmail.aol.com&lang=en&locale=us&authLev=0&uitype=mini&loginId=&redirType=js&xchk=false" + AOL_NUM = "29970-343" # this seems to change each time they change the protocol + + CONTACT_LIST_URL = "http://webmail.aol.com/#{AOL_NUM}/aim-2/en-us/Lite/ContactList.aspx?folder=Inbox&showUserFolders=False" + CONTACT_LIST_CSV_URL = "http://webmail.aol.com/#{AOL_NUM}/aim-2/en-us/Lite/ABExport.aspx?command=all" + PROTOCOL_ERROR = "AOL has changed its protocols, please upgrade this library first. If that does not work, dive into the code and submit a patch at http://github.com/cardmagic/contacts" + + def real_connect + + postdata = { + "loginId" => login, + "password" => password, + "rememberMe" => "on", + "_sns_fg_color_" => "", + "_sns_err_color_" => "", + "_sns_link_color_" => "", + "_sns_width_" => "", + "_sns_height_" => "", + "offerId" => "mail-second-en-us", + "_sns_bg_color_" => "", + "sitedomain" => "sns.webmail.aol.com", + "regPromoCode" => "", + "mcState" => "initialized", + "uitype" => "std", + "siteId" => "", + "lang" => "en", + "locale" => "us", + "authLev" => "0", + "siteState" => "", + "isSiteStateEncoded" => "false", + "use_aam" => "0", + "seamless" => "novl", + "aolsubmit" => CGI.escape("Sign In"), + "idType" => "SN", + "usrd" => "", + "doSSL" => "", + "redirType" => "", + "xchk" => "false" + } + + # Get this cookie and stick it in the form to confirm to Aol that your cookies work + data, resp, cookies, forward = get(URL) + postdata["stips"] = cookie_hash_from_string(cookies)["stips"] + postdata["tst"] = cookie_hash_from_string(cookies)["tst"] + + data, resp, cookies, forward, old_url = get(LOGIN_REFERER_URL, cookies) + [URL] + until forward.nil? + data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward] + end + + data, resp, cookies, forward, old_url = get("#{LOGIN_URL}?#{LOGIN_REFERER_PATH}", cookies) + [LOGIN_REFERER_URL] + until forward.nil? + data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward] + end + + doc = Hpricot(data) + (doc/:input).each do |input| + postdata["usrd"] = input.attributes["value"] if input.attributes["name"] == "usrd" + end + # parse data for and add it to the postdata + + postdata["SNS_SC"] = cookie_hash_from_string(cookies)["SNS_SC"] + postdata["SNS_LDC"] = cookie_hash_from_string(cookies)["SNS_LDC"] + postdata["LTState"] = cookie_hash_from_string(cookies)["LTState"] + # raise data.inspect + + data, resp, cookies, forward, old_url = post(LOGIN_URL, postdata.to_query_string, cookies, LOGIN_REFERER_URL) + [LOGIN_REFERER_URL] + + until forward.nil? + data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward] + end + + if data.index("Invalid Screen Name or Password.") + raise AuthenticationError, "Username and password do not match" + elsif data.index("Required field must not be blank") + raise AuthenticationError, "Login and password must not be blank" + elsif data.index("errormsg_0_logincaptcha") + raise AuthenticationError, "Captcha error" + elsif data.index("Invalid request") + raise ConnectionError, PROTOCOL_ERROR + elsif cookies == "" + raise ConnectionError, PROTOCOL_ERROR + end + + @cookies = cookies + end + + def contacts + postdata = { + "file" => 'contacts', + "fileType" => 'csv' + } + + return @contacts if @contacts + if connected? + data, resp, cookies, forward, old_url = get(CONTACT_LIST_URL, @cookies, CONTACT_LIST_URL) + [CONTACT_LIST_URL] + + until forward.nil? + data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward] + end + + if resp.code_type != Net::HTTPOK + raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR) + end + + # parse data and grab + doc = Hpricot(data) + (doc/:input).each do |input| + postdata["user"] = input.attributes["value"] if input.attributes["name"] == "user" + end + + data, resp, cookies, forward, old_url = get(CONTACT_LIST_CSV_URL, @cookies, CONTACT_LIST_URL) + [CONTACT_LIST_URL] + + if forward.nil? + parse data + else + raise AuthenticationError, "Account cancelled" + end + end + end + private + + def parse(data, options={}) + data = CSV.parse(data) + col_names = data.shift + @contacts = data.map do |person| + ["#{person[0]} #{person[1]}", person[4]] unless person[4].empty? + end.compact + end + end + + TYPES[:aol] = Aol +end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/base.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/base.rb new file mode 100644 index 0000000..7d0926e --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/base.rb @@ -0,0 +1,215 @@ +require "cgi" +require "net/http" +require "net/https" +require "uri" +require "zlib" +require "stringio" +require "thread" +require "erb" + +class Contacts + TYPES = {} + VERSION = "1.2.0" + + class Base + def initialize(login, password) + @login = login + @password = password + @connections = {} + connect + end + + def connect + raise AuthenticationError, "Login and password must not be nil, login: #{@login.inspect}, password: #{@password.inspect}" if @login.nil? || @login.empty? || @password.nil? || @password.empty? + real_connect + end + + def connected? + @cookies && !@cookies.empty? + end + + def contacts(options = {}) + return @contacts if @contacts + if connected? + url = URI.parse(contact_list_url) + http = open_http(url) + resp, data = http.get("#{url.path}?#{url.query}", + "Cookie" => @cookies + ) + + if resp.code_type != Net::HTTPOK + raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR) + end + + parse(data, options) + end + end + + def login + @attempt ||= 0 + @attempt += 1 + + if @attempt == 1 + @login + else + if @login.include?("@#{domain}") + @login.sub("@#{domain}","") + else + "#{@login}@#{domain}" + end + end + end + + def password + @password + end + + private + + def domain + @d ||= URI.parse(self.class.const_get(:URL)).host.sub(/^www\./,'') + end + + def contact_list_url + self.class.const_get(:CONTACT_LIST_URL) + end + + def address_book_url + self.class.const_get(:ADDRESS_BOOK_URL) + end + + def open_http(url) + c = @connections[Thread.current.object_id] ||= {} + http = c["#{url.host}:#{url.port}"] + unless http + http = Net::HTTP.new(url.host, url.port) + if url.port == 443 + http.use_ssl = true + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + end + c["#{url.host}:#{url.port}"] = http + end + http.start unless http.started? + http + end + + def cookie_hash_from_string(cookie_string) + cookie_string.split(";").map{|i|i.split("=", 2).map{|j|j.strip}}.inject({}){|h,i|h[i[0]]=i[1];h} + end + + def parse_cookies(data, existing="") + return existing if data.nil? + + cookies = cookie_hash_from_string(existing) + + data.gsub!(/ ?[\w]+=EXPIRED;/,'') + data.gsub!(/ ?expires=(.*?, .*?)[;,$]/i, ';') + data.gsub!(/ ?(domain|path)=[\S]*?[;,$]/i,';') + data.gsub!(/[,;]?\s*(secure|httponly)/i,'') + data.gsub!(/(;\s*){2,}/,', ') + data.gsub!(/(,\s*){2,}/,', ') + data.sub!(/^,\s*/,'') + data.sub!(/\s*,$/,'') + + data.split(", ").map{|t|t.to_s.split(";").first}.each do |data| + k, v = data.split("=", 2).map{|j|j.strip} + if cookies[k] && v.empty? + cookies.delete(k) + elsif v && !v.empty? + cookies[k] = v + end + end + + cookies.map{|k,v| "#{k}=#{v}"}.join("; ") + end + + def remove_cookie(cookie, cookies) + parse_cookies("#{cookie}=", cookies) + end + + def post(url, postdata, cookies="", referer="") + url = URI.parse(url) + http = open_http(url) + resp, data = http.post(url.path, postdata, + "User-Agent" => "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0", + "Accept-Encoding" => "gzip", + "Cookie" => cookies, + "Referer" => referer, + "Content-Type" => 'application/x-www-form-urlencoded' + ) + data = uncompress(resp, data) + cookies = parse_cookies(resp.response['set-cookie'], cookies) + forward = resp.response['Location'] + forward ||= (data =~ / "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0", + "Accept-Encoding" => "gzip", + "Cookie" => cookies, + "Referer" => referer + ) + data = uncompress(resp, data) + cookies = parse_cookies(resp.response['set-cookie'], cookies) + forward = resp.response['Location'] + if (not forward.nil?) && URI.parse(forward).host.nil? + forward = url.scheme.to_s + "://" + url.host.to_s + forward + end + return data, resp, cookies, forward + end + + def uncompress(resp, data) + case resp.response['content-encoding'] + when 'gzip': + gz = Zlib::GzipReader.new(StringIO.new(data)) + data = gz.read + gz.close + resp.response['content-encoding'] = nil + # FIXME: Not sure what Hotmail was feeding me with their 'deflate', + # but the headers definitely were not right + when 'deflate': + data = Zlib::Inflate.inflate(data) + resp.response['content-encoding'] = nil + end + + data + end + end + + class ContactsError < StandardError + end + + class AuthenticationError < ContactsError + end + + class ConnectionError < ContactsError + end + + class TypeNotFound < ContactsError + end + + def self.new(type, login, password) + if TYPES.include?(type.to_s.intern) + TYPES[type.to_s.intern].new(login, password) + else + raise TypeNotFound, "#{type.inspect} is not a valid type, please choose one of the following: #{TYPES.keys.inspect}" + end + end + + def self.guess(login, password) + TYPES.inject([]) do |a, t| + begin + a + t[1].new(login, password).contacts + rescue AuthenticationError + a + end + end.uniq + end +end diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/gmail.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/gmail.rb new file mode 100644 index 0000000..d3c3801 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/gmail.rb @@ -0,0 +1,35 @@ +require 'gdata' + +class Contacts + class Gmail < Base + + CONTACTS_SCOPE = 'http://www.google.com/m8/feeds/' + CONTACTS_FEED = CONTACTS_SCOPE + 'contacts/default/full/?max-results=1000' + + def contacts + return @contacts if @contacts + end + + def real_connect + @client = GData::Client::Contacts.new + @client.clientlogin(@login, @password) + + feed = @client.get(CONTACTS_FEED).to_xml + + @contacts = feed.elements.to_a('entry').collect do |entry| + title, email = entry.elements['title'].text, nil + entry.elements.each('gd:email') do |e| + email = e.attribute('address').value if e.attribute('primary') + end + [title, email] unless email.nil? + end + @contacts.compact! + rescue GData::Client::AuthorizationError => e + raise AuthenticationError, "Username or password are incorrect" + end + + private + + TYPES[:gmail] = Gmail + end +end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/hotmail.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/hotmail.rb new file mode 100644 index 0000000..4d41e0c --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/hotmail.rb @@ -0,0 +1,124 @@ +class Contacts + class Hotmail < Base + URL = "https://login.live.com/login.srf?id=2" + OLD_CONTACT_LIST_URL = "http://%s/cgi-bin/addresses" + NEW_CONTACT_LIST_URL = "http://%s/mail/GetContacts.aspx" + CONTACT_LIST_URL = "http://mpeople.live.com/default.aspx?pg=0" + COMPOSE_URL = "http://%s/cgi-bin/compose?" + PROTOCOL_ERROR = "Hotmail has changed its protocols, please upgrade this library first. If that does not work, report this error at http://rubyforge.org/forum/?group_id=2693" + PWDPAD = "IfYouAreReadingThisYouHaveTooMuchFreeTime" + MAX_HTTP_THREADS = 8 + + def real_connect + data, resp, cookies, forward = get(URL) + old_url = URL + until forward.nil? + data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward] + end + + postdata = "PPSX=%s&PwdPad=%s&login=%s&passwd=%s&LoginOptions=2&PPFT=%s" % [ + CGI.escape(data.split("><").grep(/PPSX/).first[/=\S+$/][2..-3]), + PWDPAD[0...(PWDPAD.length-@password.length)], + CGI.escape(login), + CGI.escape(password), + CGI.escape(data.split("><").grep(/PPFT/).first[/=\S+$/][2..-3]) + ] + + form_url = data.split("><").grep(/form/).first.split[5][8..-2] + data, resp, cookies, forward = post(form_url, postdata, cookies) + + old_url = form_url + until cookies =~ /; PPAuth=/ || forward.nil? + data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward] + end + + if data.index("The e-mail address or password is incorrect") + raise AuthenticationError, "Username and password do not match" + elsif data != "" + raise AuthenticationError, "Required field must not be blank" + elsif cookies == "" + raise ConnectionError, PROTOCOL_ERROR + end + + data, resp, cookies, forward = get("http://mail.live.com/mail", cookies) + until forward.nil? + data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward] + end + + @domain = URI.parse(old_url).host + @cookies = cookies + rescue AuthenticationError => m + if @attempt == 1 + retry + else + raise m + end + end + + def contacts(options = {}) + if connected? + url = URI.parse(contact_list_url) + data, resp, cookies, forward = get( contact_list_url, @cookies ) + + if resp.code_type != Net::HTTPOK + raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR) + end + + @contacts = [] + build_contacts = [] + go = true + index = 0 + + while(go) do + go = false + url = URI.parse(get_contact_list_url(index)) + http = open_http(url) + resp, data = http.get(get_contact_list_url(index), "Cookie" => @cookies) + + email_match_text_beginning = Regexp.escape("http://m.mail.live.com/?rru=compose&to=") + email_match_text_end = Regexp.escape("&") + + raw_html = resp.body.grep(/(?:e|dn)lk[0-9]+/) + raw_html.delete_at 0 + raw_html.inject do |memo, row| + c_info = row.match(/(e|dn)lk([0-9])+/) + + # Same contact, or different? + build_contacts << [] if memo != c_info[2] + + # Grab info + case c_info[1] + when "e" # Email + build_contacts.last[1] = row.match(/#{email_match_text_beginning}(.*)#{email_match_text_end}/)[1] + when "dn" # Name + build_contacts.last[0] = row.match(/]*>(.+)<\/a>/)[1] + end + + # Set memo to contact id + c_info[2] + end + + go = resp.body.include?("Next page") + index += 1 + end + + build_contacts.each do |contact| + unless contact[1].nil? + # Only return contacts with email addresses + contact[1] = CGI::unescape(contact[1]) + @contacts << contact + end + end + return @contacts + end + end + + def get_contact_list_url(index) + "http://mpeople.live.com/default.aspx?pg=#{index}" + end + + private + + TYPES[:hotmail] = Hotmail + end +end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/json_picker.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/json_picker.rb new file mode 100644 index 0000000..6149b62 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/json_picker.rb @@ -0,0 +1,16 @@ +if !Object.const_defined?('ActiveSupport') + require 'json' +end + +class Contacts + def self.parse_json( string ) + if Object.const_defined?('ActiveSupport') and + ActiveSupport.const_defined?('JSON') + ActiveSupport::JSON.decode( string ) + elsif Object.const_defined?('JSON') + JSON.parse( string ) + else + raise 'Contacts requires JSON or Rails (with ActiveSupport::JSON)' + end + end +end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/plaxo.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/plaxo.rb new file mode 100644 index 0000000..e86e51a --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/plaxo.rb @@ -0,0 +1,130 @@ +require 'rexml/document' + +class Contacts + class Plaxo < Base + URL = "http://www.plaxo.com/" + LOGIN_URL = "https://www.plaxo.com/signin" + ADDRESS_BOOK_URL = "http://www.plaxo.com/po3/?module=ab&operation=viewFull&mode=normal" + CONTACT_LIST_URL = "http://www.plaxo.com/axis/soap/contact?_action=getContacts&_format=xml" + PROTOCOL_ERROR = "Plaxo has changed its protocols, please upgrade this library first. If that does not work, dive into the code and submit a patch at http://github.com/cardmagic/contacts" + + def real_connect + + end # real_connect + + def contacts + getdata = "&authInfo.authByEmail.email=%s" % CGI.escape(login) + getdata += "&authInfo.authByEmail.password=%s" % CGI.escape(password) + data, resp, cookies, forward = get(CONTACT_LIST_URL + getdata) + + if resp.code_type != Net::HTTPOK + raise ConnectionError, PROTOCOL_ERROR + end + + parse data + end # contacts + + private + def parse(data, options={}) + doc = REXML::Document.new(data) + code = doc.elements['//response/code'].text + + if code == '401' + raise AuthenticationError, "Username and password do not match" + elsif code == '200' + @contacts = [] + doc.elements.each('//contact') do |cont| + name = if cont.elements['fullName'] + cont.elements['fullName'].text + elsif cont.elements['displayName'] + cont.elements['displayName'].text + end + email = if cont.elements['email1'] + cont.elements['email1'].text + end + if name || email + @contacts << [name, email] + end + end + @contacts + else + raise ConnectionError, PROTOCOL_ERROR + end + + end # parse + + end # Plaxo + + TYPES[:plaxo] = Plaxo + +end # Contacts + + +# sample contacts responses +=begin +Bad email +========= + + + + 401 + 1 + User not found. + + + + +Bad password +============ + + + + 401 + 4 + Bad password or security token. + + + + +Success +======= + + + + + 200 + OK + 77311236242 + + + + + + 61312569 + Joe Blow1 + Joe Blow1 + Joe + Blow1 + joeblow1@mailinator.com + joeblow1@mailinator.com + 5291351 + + + + 61313159 + Joe Blow2 + Joe Blow2 + Joe + Blow2 + joeblow2@mailinator.com + joeblow2@mailinator.com + 5291351 + + + + + 2 + 3 + + +=end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/yahoo.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/yahoo.rb new file mode 100644 index 0000000..9a1d24f --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/lib/contacts/yahoo.rb @@ -0,0 +1,109 @@ +class Contacts + class Yahoo < Base + URL = "http://mail.yahoo.com/" + LOGIN_URL = "https://login.yahoo.com/config/login" + ADDRESS_BOOK_URL = "http://address.mail.yahoo.com/?.rand=430244936" + CONTACT_LIST_URL = "http://address.mail.yahoo.com/?_src=&_crumb=crumb&sortfield=3&bucket=1&scroll=1&VPC=social_list&.r=time" + PROTOCOL_ERROR = "Yahoo has changed its protocols, please upgrade this library first. If that does not work, dive into the code and submit a patch at http://github.com/cardmagic/contacts" + + def real_connect + postdata = ".tries=2&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=us&.bypass=" + postdata += "&.partner=&.u=4eo6isd23l8r3&.v=0&.challenge=gsMsEcoZP7km3N3NeI4mX" + postdata += "kGB7zMV&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=1&.chkP=Y&." + postdata += "done=#{CGI.escape(URL)}&login=#{CGI.escape(login)}&passwd=#{CGI.escape(password)}" + + data, resp, cookies, forward = post(LOGIN_URL, postdata) + + if data.index("Invalid ID or password") || data.index("This ID is not yet taken") + raise AuthenticationError, "Username and password do not match" + elsif data.index("Sign in") && data.index("to Yahoo!") + raise AuthenticationError, "Required field must not be blank" + elsif !data.match(/uncompressed\/chunked/) + raise ConnectionError, PROTOCOL_ERROR + elsif cookies == "" + raise ConnectionError, PROTOCOL_ERROR + end + + data, resp, cookies, forward = get(forward, cookies, LOGIN_URL) + + if resp.code_type != Net::HTTPOK + raise ConnectionError, PROTOCOL_ERROR + end + + @cookies = cookies + end + + def contacts + return @contacts if @contacts + if connected? + # first, get the addressbook site with the new crumb parameter + url = URI.parse(address_book_url) + http = open_http(url) + resp, data = http.get("#{url.path}?#{url.query}", + "Cookie" => @cookies + ) + + if resp.code_type != Net::HTTPOK + raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR) + end + + crumb = data.to_s[/dotCrumb: '(.*?)'/][13...-1] + + # now proceed with the new ".crumb" parameter to get the csv data + url = URI.parse(contact_list_url.sub("_crumb=crumb","_crumb=#{crumb}").sub("time", Time.now.to_f.to_s.sub(".","")[0...-2])) + http = open_http(url) + resp, more_data = http.get("#{url.path}?#{url.query}", + "Cookie" => @cookies, + "X-Requested-With" => "XMLHttpRequest", + "Referer" => address_book_url + ) + + if resp.code_type != Net::HTTPOK + raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR) + end + + parse data + + parse more_data + + if more_data =~ /"TotalABContacts":(\d+)/ + total = $1.to_i + ((total / 50)).times do |i| + # now proceed with the new ".crumb" parameter to get the csv data + url = URI.parse(contact_list_url.sub("bucket=1","bucket=#{i+2}").sub("_crumb=crumb","_crumb=#{crumb}").sub("time", Time.now.to_f.to_s.sub(".","")[0...-2])) + http = open_http(url) + resp, more_data = http.get("#{url.path}?#{url.query}", + "Cookie" => @cookies, + "X-Requested-With" => "XMLHttpRequest", + "Referer" => address_book_url + ) + + if resp.code_type != Net::HTTPOK + raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR) + end + + parse more_data + end + end + + @contacts + end + end + + private + + def parse(data, options={}) + @contacts ||= [] + if data =~ /var InitialContacts = (\[.*?\])/ + @contacts += Contacts.parse_json($1).select{|contact|!contact["email"].to_s.empty?}.map{|contact|[contact["contactName"], contact["email"]]} + elsif data =~ /^\{"response":/ + @contacts += Contacts.parse_json(data)["response"]["ResultSet"]["Contacts"].to_a.select{|contact|!contact["email"].to_s.empty?}.map{|contact|[contact["contactName"], contact["email"]]} + else + @contacts + end + end + + end + + TYPES[:yahoo] = Yahoo +end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/example_accounts.yml b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/example_accounts.yml new file mode 100644 index 0000000..bc56eac --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/example_accounts.yml @@ -0,0 +1,40 @@ +gmail: + username: + password: + contacts: + - + name: "FirstName1 LastName1" + email_address: "firstname1@example.com" + - + name: "FirstName2 LastName2" + email_address: "firstname2@example.com" +yahoo: + username: + password: + contacts: + - + name: "FirstName1 LastName1" + email_address: "firstname1@example.com" + - + name: "FirstName2 LastName2" + email_address: "firstname2@example.com" +hotmail: + username: + password: + contacts: + - + name: "FirstName1 LastName1" + email_address: "firstname1@example.com" + - + name: "FirstName2 LastName2" + email_address: "firstname2@example.com" +aol: + username: + password: + contacts: + - + name: "FirstName1 LastName1" + email_address: "firstname1@example.com" + - + name: "FirstName2 LastName2" + email_address: "firstname2@example.com" diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/test_helper.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/test_helper.rb new file mode 100644 index 0000000..a335b2c --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/test_helper.rb @@ -0,0 +1,30 @@ +dir = File.dirname(__FILE__) +$LOAD_PATH.unshift(dir + "/../lib/") +require 'test/unit' +require 'contacts' + +class ContactImporterTestCase < Test::Unit::TestCase + # Add more helper methods to be used by all tests here... + def default_test + assert true + end +end + +class TestAccounts + def self.[](type) + load[type] + end + + def self.load(file = File.dirname(__FILE__) + "/accounts.yml") + raise "/test/accounts.yml file not found, please create, see /test/example_accounts.yml for information" unless File.exist?(file) + + accounts = {} + YAML::load(File.open(file)).each do |type, contents| + contacts = contents["contacts"].collect {|contact| [contact["name"], contact["email_address"]]} + accounts[type.to_sym] = Account.new(type.to_sym, contents["username"], contents["password"], contacts) + end + accounts + end + + Account = Struct.new :type, :username, :password, :contacts +end diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/test_suite.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/test_suite.rb new file mode 100644 index 0000000..0b764ad --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/test_suite.rb @@ -0,0 +1,4 @@ +dir = File.dirname(__FILE__) +Dir["#{dir}/**/*_test.rb"].each do |file| + require file +end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/aol_contact_importer_test.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/aol_contact_importer_test.rb new file mode 100644 index 0000000..0953867 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/aol_contact_importer_test.rb @@ -0,0 +1,39 @@ +dir = File.dirname(__FILE__) +require "#{dir}/../test_helper" +require 'contacts' + +class AolContactImporterTest < ContactImporterTestCase + def setup + super + @account = TestAccounts[:aol] + end + + def test_successful_login + Contacts.new(:aol, @account.username, @account.password) + end + + def test_importer_fails_with_invalid_password + assert_raise(Contacts::AuthenticationError) do + Contacts.new(:aol, @account.username, "wrong_password") + end + end + + def test_importer_fails_with_blank_password + assert_raise(Contacts::AuthenticationError) do + Contacts.new(:aol, @account.username, "") + end + end + + def test_importer_fails_with_blank_username + assert_raise(Contacts::AuthenticationError) do + Contacts.new(:aol, "", @account.password) + end + end + + def test_fetch_contacts + contacts = Contacts.new(:aol, @account.username, @account.password).contacts + @account.contacts.each do |contact| + assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}" + end + end +end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/gmail_contact_importer_test.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/gmail_contact_importer_test.rb new file mode 100644 index 0000000..cdaeb36 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/gmail_contact_importer_test.rb @@ -0,0 +1,39 @@ +dir = File.dirname(__FILE__) +require "#{dir}/../test_helper" +require 'contacts' + +class GmailContactImporterTest < ContactImporterTestCase + def setup + super + @account = TestAccounts[:gmail] + end + + def test_successful_login + Contacts.new(:gmail, @account.username, @account.password) + end + + def test_importer_fails_with_invalid_password + assert_raise(Contacts::AuthenticationError) do + Contacts.new(:gmail, @account.username, "wrong_password") + end + end + + def test_importer_fails_with_blank_password + assert_raise(Contacts::AuthenticationError) do + Contacts.new(:gmail, @account.username, "") + end + end + + def test_importer_fails_with_blank_username + assert_raise(Contacts::AuthenticationError) do + Contacts.new(:gmail, "", @account.password) + end + end + + def test_fetch_contacts + contacts = Contacts.new(:gmail, @account.username, @account.password).contacts + @account.contacts.each do |contact| + assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}" + end + end +end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/hotmail_contact_importer_test.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/hotmail_contact_importer_test.rb new file mode 100644 index 0000000..6f914b1 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/hotmail_contact_importer_test.rb @@ -0,0 +1,41 @@ +dir = File.dirname(__FILE__) +require "#{dir}/../test_helper" +require 'contacts' + +class HotmailContactImporterTest < ContactImporterTestCase + def setup + super + @account = TestAccounts[:hotmail] + end + + def test_successful_login + Contacts.new(:hotmail, @account.username, @account.password) + end + + def test_importer_fails_with_invalid_password + assert_raise(Contacts::AuthenticationError) do + Contacts.new(:hotmail, @account.username,"wrong_password") + end + end + + def test_fetch_contacts + contacts = Contacts.new(:hotmail, @account.username, @account.password).contacts + @account.contacts.each do |contact| + assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}" + end + end + + def test_importer_fails_with_invalid_msn_password + assert_raise(Contacts::AuthenticationError) do + Contacts.new(:hotmail, "test@msn.com","wrong_password") + end + end + + # Since the hotmail scraper doesn't read names, test email + def test_fetch_email + contacts = Contacts.new(:hotmail, @account.username, @account.password).contacts + @account.contacts.each do |contact| + assert contacts.any?{|book_contact| book_contact.last == contact.last }, "Could not find: #{contact.inspect} in #{contacts.inspect}" + end + end +end diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/test_accounts_test.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/test_accounts_test.rb new file mode 100644 index 0000000..7f5aec4 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/test_accounts_test.rb @@ -0,0 +1,23 @@ +dir = File.dirname(__FILE__) +require "#{dir}/../test_helper" + +class TestAccountsTest < ContactImporterTestCase + def test_test_accounts_loads_data_from_example_accounts_file + account = TestAccounts.load(File.dirname(__FILE__) + "/../example_accounts.yml")[:gmail] + + assert_equal :gmail, account.type + assert_equal "", account.username + assert_equal "", account.password + assert_equal [["FirstName1 LastName1", "firstname1@example.com"], ["FirstName2 LastName2", "firstname2@example.com"]], account.contacts + end + + def test_test_accounts_blows_up_if_file_doesnt_exist + assert_raise(RuntimeError) do + TestAccounts.load("file_that_does_not_exist.yml") + end + end + + def test_we_can_load_from_account_file + assert_not_nil TestAccounts[:gmail].username + end +end \ No newline at end of file diff --git a/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/yahoo_csv_contact_importer_test.rb b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/yahoo_csv_contact_importer_test.rb new file mode 100644 index 0000000..6736d84 --- /dev/null +++ b/vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073/test/unit/yahoo_csv_contact_importer_test.rb @@ -0,0 +1,32 @@ +dir = File.dirname(__FILE__) +require "#{dir}/../test_helper" +require 'contacts' + +class YahooContactImporterTest < ContactImporterTestCase + def setup + super + @account = TestAccounts[:yahoo] + end + + def test_a_successful_login + Contacts.new(:yahoo, @account.username, @account.password) + end + + def test_importer_fails_with_invalid_password + assert_raise(Contacts::AuthenticationError) do + Contacts.new(:yahoo, @account.username, "wrong_password") + end + # run the "successful" login test to ensure we reset yahoo's failed login lockout counter + # See http://www.pivotaltracker.com/story/show/138210 + assert_nothing_raised do + Contacts.new(:yahoo, @account.username, @account.password) + end + end + + def test_a_fetch_contacts + contacts = Contacts.new(:yahoo, @account.username, @account.password).contacts + @account.contacts.each do |contact| + assert contacts.include?(contact), "Could not find: #{contact.inspect} in #{contacts.inspect}" + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/LICENSE b/vendor/gdata-1.1.1/LICENSE new file mode 100644 index 0000000..65ee1c1 --- /dev/null +++ b/vendor/gdata-1.1.1/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/vendor/gdata-1.1.1/README b/vendor/gdata-1.1.1/README new file mode 100644 index 0000000..d60e996 --- /dev/null +++ b/vendor/gdata-1.1.1/README @@ -0,0 +1,97 @@ += GData + +* http://code.google.com/p/gdata + +== DESCRIPTION: + +Ruby wrapper for working with Google Data APIs + +== SYNOPSIS: + + yt = GData::Client::YouTube.new + yt.source = 'my_cool_application' + yt.clientlogin('username', 'password') + yt.client_id = 'CLIENT_ID' + yt.developer_key = 'DEVELOPER_KEY' + feed = yt.get('http://gdata.youtube.com/feeds/api/users/default/uploads').to_xml + + # creating, updating, and deleting a playlist + + entry = <<-EOF + + Ruby Utility Unit Test + This is a test playlist. + + EOF + + response = yt.post('http://gdata.youtube.com/feeds/api/users/default/playlists', entry).to_xml + + edit_uri = response.elements["link[@rel='edit']"].attributes['href'] + + response.elements["summary"].text = "Updated description" + + response = yt.put(edit_uri, response.to_s).to_xml + + yt.delete(edit_uri).to_xml + + # uploading a video + + test_movie = '/path/to/a/movie.mov' + mime_type = 'video/quicktime' + feed = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads' + + entry = < + + Test Movie + + This is a test with the Ruby library + + People + + test,lame + + + EOF + + response = @yt.post_file(feed, test_movie, mime_type, entry).to_xml + +== REQUIREMENTS: + +* A sunny disposition + +Tested against Ruby 1.8.6 patch level 114 + +== INSTALL: + + sudo gem install gdata + +To generate documentation: + + rake doc + +To run unit tests: + + cp test/test_config.yml.example test/test_config.yml + # edit test/test_config.yml + rake test + +== LICENSE: + +Copyright (C) 2008 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/vendor/gdata-1.1.1/Rakefile b/vendor/gdata-1.1.1/Rakefile new file mode 100644 index 0000000..cd9c622 --- /dev/null +++ b/vendor/gdata-1.1.1/Rakefile @@ -0,0 +1,64 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'rubygems' +require 'rake/gempackagetask' +require 'rake/rdoctask' +require 'rake/testtask' + +task :default => [:test] + +task :test do + ruby "test/ts_gdata.rb" +end + +task :prepdoc do + all_doc_files = FileList.new('doc/**/*') + all_doc_files.each do |file| + system "hg add #{file}" + end +end + +task :doc do + system "rdoc -U --title 'gdata module documentation' -m README README lib/" +end + +spec = Gem::Specification.new do |s| + s.platform = Gem::Platform::RUBY + s.author = 'Jeff Fisher' + s.email = 'jfisher@youtube.com' + s.homepage = 'http://code.google.com/p/gdata-ruby-util' + s.summary = "Google Data APIs Ruby Utility Library" + s.rubyforge_project = 'gdata' + s.name = 'gdata' + s.version = '1.1.1' + s.requirements << 'none' + s.require_path = 'lib' + s.test_files = FileList['test/ts_gdata.rb'] + s.has_rdoc = true + s.extra_rdoc_files = ['README', 'LICENSE'] + s.rdoc_options << '--main' << 'README' + s.files = FileList.new('[A-Z]*', 'lib/**/*.rb', 'test/**/*') do |fl| + fl.exclude(/test_config\.yml$/) + end + s.description = < headers, + :method => method, :body => body) + + if @auth_handler and @auth_handler.respond_to?(:sign_request!) + @auth_handler.sign_request!(request) + end + + service = http_service.new + response = service.make_request(request) + + case response.status_code + when 200, 201, 302 + #Do nothing, it's a success. + when 401, 403 + raise AuthorizationError.new(response) + when 400 + raise BadRequestError.new(response) + when 409 + raise VersionConflictError.new(response) + when 500 + raise ServerError.new(response) + else + raise UnknownError.new(response) + end + + return response + end + + # Performs an HTTP GET against the API. + def get(url) + return self.make_request(:get, url) + end + + # Performs an HTTP PUT against the API. + def put(url, body) + return self.make_request(:put, url, body) + end + + # Performs an HTTP PUT with the given file + def put_file(url, file_path, mime_type, entry = nil) + return self.make_file_request(:put, url, file_path, mime_type, entry) + end + + # Performs an HTTP POST against the API. + def post(url, body) + return self.make_request(:post, url, body) + end + + # Performs an HTTP POST with the given file + def post_file(url, file_path, mime_type, entry = nil) + return self.make_file_request(:post, url, file_path, mime_type, entry) + end + + # Performs an HTTP DELETE against the API. + def delete(url) + return self.make_request(:delete, url) + end + + # Constructs some necessary headers for every request. + def prepare_headers + headers = @headers + headers['GData-Version'] = @version + headers['User-Agent'] = GData::Auth::SOURCE_LIB_STRING + @source + # by default we assume we are sending Atom entries + if not headers.has_key?('Content-Type') + headers['Content-Type'] = 'application/atom+xml' + end + return headers + end + + # Performs ClientLogin for the service. See GData::Auth::ClientLogin + # for details. + def clientlogin(username, password, captcha_token = nil, + captcha_answer = nil, service = nil, account_type = nil) + if service.nil? + service = @clientlogin_service + end + options = { :account_type => account_type } + self.auth_handler = GData::Auth::ClientLogin.new(service, options) + if @clientlogin_url + @auth_handler.auth_url = @clientlogin_url + end + source = GData::Auth::SOURCE_LIB_STRING + @source + @auth_handler.get_token(username, password, source, captcha_token, captcha_answer) + end + + def authsub_url(next_url, secure = false, session = true, domain = nil, + scope = nil) + if scope.nil? + scope = @authsub_scope + end + GData::Auth::AuthSub.get_url(next_url, scope, secure, session, domain) + end + + # Sets an AuthSub token for the service. + def authsub_token=(token) + self.auth_handler = GData::Auth::AuthSub.new(token) + end + + # Sets a private key to use with AuthSub requests. + def authsub_private_key=(key) + if @auth_handler.class == GData::Auth::AuthSub + @auth_handler.private_key = key + else + raise Error, "An AuthSub token must be set first." + end + end + end + end +end diff --git a/vendor/gdata-1.1.1/lib/gdata/client/blogger.rb b/vendor/gdata-1.1.1/lib/gdata/client/blogger.rb new file mode 100644 index 0000000..1226d0e --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/blogger.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the Blogger API. + class Blogger < Base + + def initialize(options = {}) + options[:clientlogin_service] ||= 'blogger' + options[:authsub_scope] ||= 'http://www.blogger.com/feeds/' + super(options) + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/booksearch.rb b/vendor/gdata-1.1.1/lib/gdata/client/booksearch.rb new file mode 100644 index 0000000..f9b040f --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/booksearch.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the Book Search Data API. + class BookSearch < Base + + def initialize(options = {}) + options[:clientlogin_service] ||= 'print' + options[:authsub_scope] ||= 'http://www.google.com/books/feeds/' + super(options) + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/calendar.rb b/vendor/gdata-1.1.1/lib/gdata/client/calendar.rb new file mode 100644 index 0000000..f282aac --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/calendar.rb @@ -0,0 +1,58 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the Calendar Data API. + class Calendar < Base + + # Holds on to a session cookie + attr_accessor :session_cookie + + def initialize(options = {}) + options[:clientlogin_service] ||= 'cl' + options[:authsub_scope] ||= 'http://www.google.com/calendar/feeds/' + super(options) + end + + # Overrides auth_handler= so if the authentication changes, + # the session cookie is cleared. + def auth_handler=(handler) + @session_cookie = nil + return super(handler) + end + + # Overrides make_request to handle 302 redirects with a session cookie. + def make_request(method, url, body = '', retries = 4) + response = super(method, url, body) + if response.status_code == 302 and retries > 0 + @session_cookie = response.headers['set-cookie'] + return self.make_request(method, url, body, + retries - 1) + else + return response + end + end + + # Custom prepare_headers to include the session cookie if it exists + def prepare_headers + if @session_cookie + @headers['cookie'] = @session_cookie + end + super + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/contacts.rb b/vendor/gdata-1.1.1/lib/gdata/client/contacts.rb new file mode 100644 index 0000000..0e67ba9 --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/contacts.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the Contacts API. + class Contacts < Base + + def initialize(options = {}) + options[:clientlogin_service] ||= 'cp' + options[:authsub_scope] ||= 'http://www.google.com/m8/feeds/' + super(options) + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/doclist.rb b/vendor/gdata-1.1.1/lib/gdata/client/doclist.rb new file mode 100644 index 0000000..f4017e3 --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/doclist.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the Documents List Data API. + class DocList < Base + + def initialize(options = {}) + options[:clientlogin_service] ||= 'writely' + options[:authsub_scope] ||= 'http://docs.google.com/feeds/' + super(options) + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/finance.rb b/vendor/gdata-1.1.1/lib/gdata/client/finance.rb new file mode 100644 index 0000000..f51fac5 --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/finance.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the Finance API. + class Finance < Base + + def initialize(options = {}) + options[:clientlogin_service] ||= 'finance' + options[:authsub_scope] ||= 'http://finance.google.com/finance/feeds/' + super(options) + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/gbase.rb b/vendor/gdata-1.1.1/lib/gdata/client/gbase.rb new file mode 100644 index 0000000..f3ee982 --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/gbase.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the Google Base API. + class GBase < Base + + def initialize(options = {}) + options[:clientlogin_service] ||= 'gbase' + options[:authsub_scope] ||= 'http://www.google.com/base/feeds/' + super(options) + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/gmail.rb b/vendor/gdata-1.1.1/lib/gdata/client/gmail.rb new file mode 100644 index 0000000..5030ad5 --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/gmail.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the GMail Atom Feed. + class GMail < Base + + def initialize(options = {}) + options[:clientlogin_service] ||= 'mail' + options[:authsub_scope] ||= 'https://mail.google.com/mail/feed/atom/' + super(options) + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/health.rb b/vendor/gdata-1.1.1/lib/gdata/client/health.rb new file mode 100644 index 0000000..3b3b333 --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/health.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the Health API. + class Health < Base + + def initialize(options = {}) + options[:clientlogin_service] ||= 'health' + options[:authsub_scope] ||= 'https://www.google.com/health/feeds/' + super(options) + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/notebook.rb b/vendor/gdata-1.1.1/lib/gdata/client/notebook.rb new file mode 100644 index 0000000..52cfaf3 --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/notebook.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the Notebook Data API. + class Notebook < Base + + def initialize(options = {}) + options[:clientlogin_service] ||= 'notebook' + options[:authsub_scope] ||= 'http://www.google.com/notebook/feeds/' + super(options) + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/photos.rb b/vendor/gdata-1.1.1/lib/gdata/client/photos.rb new file mode 100644 index 0000000..3b004e7 --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/photos.rb @@ -0,0 +1,29 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the Picasa Web Albums API. + class Photos < Base + + def initialize(options = {}) + options[:clientlogin_service] ||= 'lh2' + options[:authsub_scope] ||= 'http://picasaweb.google.com/data/' + options[:version] ||= '1' + super(options) + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/spreadsheets.rb b/vendor/gdata-1.1.1/lib/gdata/client/spreadsheets.rb new file mode 100644 index 0000000..902e3bf --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/spreadsheets.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the Spreadsheets API. + class Spreadsheets < Base + + def initialize(options = {}) + options[:clientlogin_service] ||= 'wise' + options[:authsub_scope] ||= 'http://spreadsheets.google.com/feeds/' + super(options) + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/webmaster_tools.rb b/vendor/gdata-1.1.1/lib/gdata/client/webmaster_tools.rb new file mode 100644 index 0000000..a5cf9cb --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/webmaster_tools.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the Webmaster Tools API. + class WebmasterTools < Base + + def initialize(options = {}) + options[:clientlogin_service] ||= 'sitemaps' + options[:authsub_scope] ||= 'http://www.google.com/webmasters/tools/feeds/' + super(options) + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/client/youtube.rb b/vendor/gdata-1.1.1/lib/gdata/client/youtube.rb new file mode 100644 index 0000000..00d52bc --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/client/youtube.rb @@ -0,0 +1,47 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module GData + module Client + + # Client class to wrap working with the YouTube API. Sets some + # YouTube-specific options. + class YouTube < Base + + # The YouTube developer key being used. + attr_accessor :developer_key + # The YouTube ClientID being used. + attr_accessor :client_id + + def initialize(options = {}) + options[:clientlogin_service] ||= 'youtube' + options[:clientlogin_url] ||= 'https://www.google.com/youtube/accounts/ClientLogin' + options[:authsub_scope] ||= 'http://gdata.youtube.com' + options[:version] ||= '2' + super(options) + end + + # Custom prepare_headers to include the developer key and clientID + def prepare_headers + if @client_id + @headers['X-GData-Client'] = @client_id + end + if @developer_key + @headers['X-GData-Key'] = "key=#{@developer_key}" + end + super + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/http.rb b/vendor/gdata-1.1.1/lib/gdata/http.rb new file mode 100644 index 0000000..2a6fe0c --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/http.rb @@ -0,0 +1,18 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'gdata/http/default_service' +require 'gdata/http/mime_body' +require 'gdata/http/request' +require 'gdata/http/response' diff --git a/vendor/gdata-1.1.1/lib/gdata/http/default_service.rb b/vendor/gdata-1.1.1/lib/gdata/http/default_service.rb new file mode 100644 index 0000000..c0b9c70 --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/http/default_service.rb @@ -0,0 +1,82 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'net/http' +require 'net/https' +require 'uri' + +module GData + module HTTP + + # This is the default implementation of the HTTP layer that uses + # Net::HTTP. You could roll your own if you have different requirements + # or cannot use Net::HTTP for some reason. + class DefaultService + + # Take a GData::HTTP::Request, execute the request, and return a + # GData::HTTP::Response object. + def make_request(request) + url = URI.parse(request.url) + http = Net::HTTP.new(url.host, url.port) + http.use_ssl = (url.scheme == 'https') + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + + case request.method + when :get + req = Net::HTTP::Get.new(url.request_uri) + when :put + req = Net::HTTP::Put.new(url.request_uri) + when :post + req = Net::HTTP::Post.new(url.request_uri) + when :delete + req = Net::HTTP::Delete.new(url.request_uri) + else + raise ArgumentError, "Unsupported HTTP method specified." + end + + case request.body + when String + req.body = request.body + when Hash + req.set_form_data(request.body) + when File + req.body_stream = request.body + request.chunked = true + when GData::HTTP::MimeBody + req.body_stream = request.body + request.chunked = true + else + req.body = request.body.to_s + end + + request.headers.each do |key, value| + req[key] = value + end + + request.calculate_length! + + res = http.request(req) + + response = Response.new + response.body = res.body + response.headers = Hash.new + res.each do |key, value| + response.headers[key] = value + end + response.status_code = res.code.to_i + return response + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/http/mime_body.rb b/vendor/gdata-1.1.1/lib/gdata/http/mime_body.rb new file mode 100644 index 0000000..0dbf867 --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/http/mime_body.rb @@ -0,0 +1,95 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +module GData + module HTTP + + # Class acts as a virtual file handle to a MIME multipart message body + class MimeBody + + # The MIME boundary being used. + attr_reader :boundary + + # All fields are required, the entry should be a string and is assumed + # to be XML. + def initialize(entry, file, file_mime_type) + @boundary = "END_OF_PART_#{rand(64000)}" + entry = wrap_entry(entry, file_mime_type) + closing_boundary = MimeBodyString.new("\r\n--#{@boundary}--") + @parts = [entry, file, closing_boundary] + @current_part = 0 + end + + # Implement read so that this class can be treated as a stream. + def read(bytes_requested) + if @current_part >= @parts.length + return false + end + + buffer = @parts[@current_part].read(bytes_requested) + + until buffer.length == bytes_requested + @current_part += 1 + next_buffer = self.read(bytes_requested - buffer.length) + break if not next_buffer + buffer += next_buffer + end + + return buffer + end + + # Returns the content type of the message including boundary. + def content_type + return "multipart/related; boundary=\"#{@boundary}\"" + end + + private + + # Sandwiches the entry body into a MIME message + def wrap_entry(entry, file_mime_type) + wrapped_entry = "--#{@boundary}\r\n" + wrapped_entry += "Content-Type: application/atom+xml\r\n\r\n" + wrapped_entry += entry + wrapped_entry += "\r\n--#{@boundary}\r\n" + wrapped_entry += "Content-Type: #{file_mime_type}\r\n\r\n" + return MimeBodyString.new(wrapped_entry) + end + + end + + # Class makes a string into a stream-like object + class MimeBodyString + + def initialize(source_string) + @string = source_string + @bytes_read = 0 + end + + # Implement read so that this class can be treated as a stream. + def read(bytes_requested) + if @bytes_read == @string.length + return false + elsif bytes_requested > @string.length - @bytes_read + bytes_requested = @string.length - @bytes_read + end + + buffer = @string[@bytes_read, bytes_requested] + @bytes_read += bytes_requested + + return buffer + end + end + end +end diff --git a/vendor/gdata-1.1.1/lib/gdata/http/request.rb b/vendor/gdata-1.1.1/lib/gdata/http/request.rb new file mode 100644 index 0000000..bd86d9e --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/http/request.rb @@ -0,0 +1,74 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "rexml/document" + +module GData + module HTTP + + # Very simple class to hold everything about an HTTP request. + class Request + + # The URL of the request. + attr_accessor :url + # The body of the request. + attr_accessor :body + # The HTTP method being used in the request. + attr_accessor :method + # The HTTP headers of the request. + attr_accessor :headers + + # Only the URL itself is required, everything else is optional. + def initialize(url, options = {}) + @url = url + options.each do |key, value| + self.send("#{key}=", value) + end + + @method ||= :get + @headers ||= {} + end + + # Returns whether or not a request is chunked. + def chunked? + if @headers['Transfer-Encoding'] == 'chunked' + return true + else + return false + end + end + + # Sets if the request is using chunked transfer-encoding. + def chunked=(enabled) + if enabled + @headers['Transfer-Encoding'] = 'chunked' + else + @headers.delete('Transfer-Encoding') + end + end + + # Calculates and sets the length of the body. + def calculate_length! + if not @headers['Content-Length'] and not chunked? \ + and method != :get and method != :delete + if @body + @headers['Content-Length'] = @body.length + else + @headers['Content-Length'] = 0 + end + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/lib/gdata/http/response.rb b/vendor/gdata-1.1.1/lib/gdata/http/response.rb new file mode 100644 index 0000000..0624dd2 --- /dev/null +++ b/vendor/gdata-1.1.1/lib/gdata/http/response.rb @@ -0,0 +1,44 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'gdata/client' + +module GData + module HTTP + + # An extremely simple class to hold the values of an HTTP response. + class Response + + # The HTTP response code. + attr_accessor :status_code + # The body of the HTTP response. + attr_accessor :body + # The headers of the HTTP response. + attr_accessor :headers + + # Converts the response body into a REXML::Document + def to_xml + if @body + begin + return REXML::Document.new(@body).root + rescue + raise GData::Client::Error, "Response body not XML." + end + else + return nil + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/tc_gdata_auth_authsub.rb b/vendor/gdata-1.1.1/test/tc_gdata_auth_authsub.rb new file mode 100644 index 0000000..9c6f760 --- /dev/null +++ b/vendor/gdata-1.1.1/test/tc_gdata_auth_authsub.rb @@ -0,0 +1,53 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$:.unshift(File.dirname(__FILE__)) +require 'test_helper' + +class TC_GData_Auth_AuthSub < Test::Unit::TestCase + + include TestHelper + + def test_make_authenticated_request + token = self.get_authsub_token() + key = self.get_authsub_private_key() + service = GData::Client::YouTube.new + if token + + service.authsub_token = token + if key + service.authsub_private_key = key + end + + feed = service.get('http://gdata.youtube.com/feeds/api/users/default/uploads?max-results=1') + self.assert_not_nil(feed, 'Feed should not be nil') + end + end + + def test_generate_url + scope = 'http://gdata.youtube.com' + next_url = 'http://example.com' + secure = true + session = false + url = GData::Auth::AuthSub.get_url(next_url, scope, secure, session) + self.assert_equal('https://www.google.com/accounts/AuthSubRequest?next=http%3A%2F%2Fexample.com&scope=http%3A%2F%2Fgdata.youtube.com&session=0&secure=1', url) + + # test generating with a pre-populated scope + yt = GData::Client::YouTube.new + client_url = yt.authsub_url(next_url, secure, session) + self.assert_equal(url, client_url) + + end + +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/tc_gdata_auth_clientlogin.rb b/vendor/gdata-1.1.1/test/tc_gdata_auth_clientlogin.rb new file mode 100644 index 0000000..25588a7 --- /dev/null +++ b/vendor/gdata-1.1.1/test/tc_gdata_auth_clientlogin.rb @@ -0,0 +1,59 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$:.unshift(File.dirname(__FILE__)) +require 'test_helper' + +class TC_GData_Auth_ClientLogin < Test::Unit::TestCase + + include TestHelper + + def test_has_config + self.assert_not_nil(self.get_username(), + 'Must have a username in test_config.yml') + self.assert_not_nil(self.get_password(), + 'Must have a password in test_config.yml') + end + + def test_get_token + client_login = GData::Auth::ClientLogin.new('cl') + source = 'GDataUnitTest' + assert_nothing_raised do + token = client_login.get_token(self.get_username(), self.get_password(), source) + end + end + + def test_all_clients + source = 'GDataUnitTest' + GData::Client.constants.each do |const_name| + const = GData::Client.const_get(const_name) + if const.superclass == GData::Client::Base + instance = const.new + assert_nothing_raised do + instance.clientlogin(self.get_username(), self.get_password(), source) + end + end + end + end + + def test_specify_account_type + gp = GData::Client::Photos.new + gp.source = 'GDataUnitTest' + assert_nothing_raised do + token = gp.clientlogin(self.get_username(), self.get_password(), nil, nil, nil, 'GOOGLE') + end + end + + +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/tc_gdata_client_base.rb b/vendor/gdata-1.1.1/test/tc_gdata_client_base.rb new file mode 100644 index 0000000..ef802b0 --- /dev/null +++ b/vendor/gdata-1.1.1/test/tc_gdata_client_base.rb @@ -0,0 +1,37 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$:.unshift(File.dirname(__FILE__)) +require 'test_helper' + +class TC_GData_Client_Base < Test::Unit::TestCase + + include TestHelper + + def test_simple_gdata_get + service = GData::Client::Base.new + feed = service.get('http://gdata.youtube.com/feeds/base/videos?max-results=1').to_xml + assert_not_nil(feed, 'feed can not be nil') + end + + def test_clientlogin_with_service + service = GData::Client::Base.new + service.clientlogin(self.get_username(), self.get_password(), nil, nil, + 'youtube') + feed = service.get('http://gdata.youtube.com/feeds/api/users/default/uploads?max-results=1').to_xml + assert_not_nil(feed, 'feed can not be nil') + end + +end + \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/tc_gdata_client_calendar.rb b/vendor/gdata-1.1.1/test/tc_gdata_client_calendar.rb new file mode 100644 index 0000000..24529c7 --- /dev/null +++ b/vendor/gdata-1.1.1/test/tc_gdata_client_calendar.rb @@ -0,0 +1,40 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$:.unshift(File.dirname(__FILE__)) +require 'test_helper' + +class TC_GData_Client_Calendar < Test::Unit::TestCase + + include TestHelper + + def setup + @cl = GData::Client::Calendar.new + @cl.clientlogin(self.get_username, self.get_password) + end + + def test_get_all_calendars + response = @cl.get('http://www.google.com/calendar/feeds/default/allcalendars/full') + self.assert_equal(200, response.status_code, 'Must not be a redirect.') + self.assert_not_nil(@cl.session_cookie, 'Must have a session cookie.') + feed = response.to_xml + self.assert_not_nil(feed, 'feed can not be nil') + + #login again to make sure the session cookie gets cleared + @cl.clientlogin(self.get_username, self.get_password) + self.assert_nil(@cl.session_cookie, 'Should clear session cookie.') + end + + +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/tc_gdata_client_photos.rb b/vendor/gdata-1.1.1/test/tc_gdata_client_photos.rb new file mode 100644 index 0000000..c66300e --- /dev/null +++ b/vendor/gdata-1.1.1/test/tc_gdata_client_photos.rb @@ -0,0 +1,65 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$:.unshift(File.dirname(__FILE__)) +require 'test_helper' + +class TC_GData_Client_Photos < Test::Unit::TestCase + + include TestHelper + + def setup + @gp = GData::Client::Photos.new + @gp.source = 'Ruby Client Unit Tests' + @gp.clientlogin(self.get_username(), self.get_password()) + end + + def test_authenticated_dropbox_feed + feed = @gp.get('http://picasaweb.google.com/data/feed/api/user/default/albumid/default?max-results=1').to_xml + self.assert_not_nil(feed, 'feed can not be nil') + end + + def test_photo_upload + test_image = File.join(File.dirname(__FILE__), 'testimage.jpg') + mime_type = 'image/jpeg' + + response = @gp.post_file('http://picasaweb.google.com/data/feed/api/user/default/albumid/default', + test_image, mime_type).to_xml + + edit_uri = response.elements["link[@rel='edit']"].attributes['href'] + + @gp.delete(edit_uri) + end + + def test_photo_upload_with_metadata + test_image = File.join(File.dirname(__FILE__), 'testimage.jpg') + mime_type = 'image/jpeg' + + entry = <<-EOF + + ruby-client-testing.jpg + Test case for Ruby Client Library. + + + EOF + + response = @gp.post_file('http://picasaweb.google.com/data/feed/api/user/default/albumid/default', + test_image, mime_type, entry).to_xml + + edit_uri = response.elements["link[@rel='edit']"].attributes['href'] + + @gp.delete(edit_uri) + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/tc_gdata_client_youtube.rb b/vendor/gdata-1.1.1/test/tc_gdata_client_youtube.rb new file mode 100644 index 0000000..f67ba79 --- /dev/null +++ b/vendor/gdata-1.1.1/test/tc_gdata_client_youtube.rb @@ -0,0 +1,77 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$:.unshift(File.dirname(__FILE__)) +require 'test_helper' + +class TC_GData_Client_YouTube < Test::Unit::TestCase + + include TestHelper + + def setup + @yt = GData::Client::YouTube.new + self.assert(@yt.headers.empty?, 'headers should be empty.') + @yt.clientlogin(self.get_username(), self.get_password()) + @yt.client_id = 'ytapi-Google-GDataUnitTests-lcqr3u89-1' + @yt.developer_key = 'AI39si4vwXwDLR5MrtsdR1ULUD8__EnEccla-0bnqV40KpeFDIyCwEv0VJqZKHUsO3MvVM_bXHp3cAr55HmMYMhqfxzLMUgDXA' + end + + def test_authenticated_uploads_feed + + + feed = @yt.get('http://gdata.youtube.com/feeds/api/users/default/uploads?max-results=1').to_xml + self.assert_not_nil(feed, 'feed can not be nil') + end + + def test_favorites + + video_id = 'zlfKdbWwruY' + + entry = <<-EOF + + #{video_id} + + EOF + + response = @yt.post('http://gdata.youtube.com/feeds/api/users/default/favorites', entry).to_xml + + edit_uri = response.elements["link[@rel='edit']"].attributes['href'] + + @yt.delete(edit_uri) + + end + + def test_playlist + entry = <<-EOF + + Ruby Utility Unit Test + This is a test playlist. + + EOF + + response = @yt.post('http://gdata.youtube.com/feeds/api/users/default/playlists', entry).to_xml + + edit_uri = response.elements["link[@rel='edit']"].attributes['href'] + + response.elements["summary"].text = "Updated description" + + response = @yt.put(edit_uri, response.to_s).to_xml + + self.assert_equal("Updated description", response.elements["summary"].text) + + @yt.delete(edit_uri) + end + +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/tc_gdata_http_mime_body.rb b/vendor/gdata-1.1.1/test/tc_gdata_http_mime_body.rb new file mode 100644 index 0000000..94dff56 --- /dev/null +++ b/vendor/gdata-1.1.1/test/tc_gdata_http_mime_body.rb @@ -0,0 +1,46 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$:.unshift(File.dirname(__FILE__)) +require 'test_helper' + +class TC_GData_HTTP_MimeBody < Test::Unit::TestCase + + include TestHelper + + def test_mime_body_string + stream = GData::HTTP::MimeBodyString.new('testing 1 2 3') + + self.assert_equal('t', stream.read(1)) + self.assert_equal('esting', stream.read(6)) + self.assert_equal(' 1 2 ', stream.read(5)) + self.assert_equal('3', stream.read(50)) + self.assert_equal(false, stream.read(10)) + end + + def test_mime_body_string_large_read + stream = GData::HTTP::MimeBodyString.new('test string') + + self.assert_equal('test string', stream.read(1024)) + self.assert_equal(false, stream.read(1024)) + end + + def test_mime_body_string_unicode + stream = GData::HTTP::MimeBodyString.new('λ') + self.assert(stream.read(1), 'Greek character should be two bytes') + self.assert(stream.read(1), 'Greek character should be two full bytes') + self.assert_equal(false, stream.read(1)) + end + +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/tc_gdata_http_request.rb b/vendor/gdata-1.1.1/test/tc_gdata_http_request.rb new file mode 100644 index 0000000..4ee1581 --- /dev/null +++ b/vendor/gdata-1.1.1/test/tc_gdata_http_request.rb @@ -0,0 +1,36 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$:.unshift(File.dirname(__FILE__)) +require 'test_helper' + +class TC_GData_HTTP_Request < Test::Unit::TestCase + + include TestHelper + + def test_world_is_sane + assert(true, 'World is not sane.') + end + + def test_google_is_live + request = GData::HTTP::Request.new('http://www.google.com') + + service = GData::HTTP::DefaultService.new + + response = service.make_request(request) + + assert_equal(200, response.status_code) + end + +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/test_helper.rb b/vendor/gdata-1.1.1/test/test_helper.rb new file mode 100644 index 0000000..5b134a8 --- /dev/null +++ b/vendor/gdata-1.1.1/test/test_helper.rb @@ -0,0 +1,47 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'yaml' +require 'test/unit' +require 'test/unit/ui/console/testrunner' + +$:.unshift File.join(File.dirname(__FILE__), '..', 'lib') +require 'gdata' + +module TestHelper + + def get_config() + if not defined?(@config_file) + @config_file = YAML::load_file(File.join(File.dirname(__FILE__), 'test_config.yml')) + end + return @config_file + end + + def get_username() + return self.get_config()['username'] + end + + def get_password() + return self.get_config()['password'] + end + + def get_authsub_token() + return self.get_config()['authsub_token'] + end + + def get_authsub_private_key() + return self.get_config()['authsub_private_key'] + end + +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/testimage.jpg b/vendor/gdata-1.1.1/test/testimage.jpg new file mode 100644 index 0000000..165db62 Binary files /dev/null and b/vendor/gdata-1.1.1/test/testimage.jpg differ diff --git a/vendor/gdata-1.1.1/test/ts_gdata.rb b/vendor/gdata-1.1.1/test/ts_gdata.rb new file mode 100644 index 0000000..b66cc48 --- /dev/null +++ b/vendor/gdata-1.1.1/test/ts_gdata.rb @@ -0,0 +1,42 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$:.unshift(File.dirname(__FILE__)) +require 'test_helper' +require 'ts_gdata_http' +require 'ts_gdata_client' +require 'ts_gdata_auth' + +class TS_GData + def self.suite + suite = Test::Unit::TestSuite.new("GData Test Suite") + suite << UnicodeStringTest.suite + suite << TS_GData_HTTP.suite + suite << TS_GData_Client.suite + suite << TS_GData_Auth.suite + return suite + end +end + +class UnicodeStringTest < Test::Unit::TestCase + def test_jlength + s = "Καλημέρα κόσμε!" + assert_equal(15, s.jlength) # Note the 'j' + assert_not_equal(15, s.length) # Normal, non unicode length + assert_equal(28, s.length) # Greek letters happen to take two-bytes + end +end + + +Test::Unit::UI::Console::TestRunner.run(TS_GData) \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/ts_gdata_auth.rb b/vendor/gdata-1.1.1/test/ts_gdata_auth.rb new file mode 100644 index 0000000..3e9cf72 --- /dev/null +++ b/vendor/gdata-1.1.1/test/ts_gdata_auth.rb @@ -0,0 +1,25 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'tc_gdata_auth_clientlogin' +require 'tc_gdata_auth_authsub' + +class TS_GData_Auth + def self.suite + suite = Test::Unit::TestSuite.new + suite << TC_GData_Auth_ClientLogin.suite + suite << TC_GData_Auth_AuthSub.suite + return suite + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/ts_gdata_client.rb b/vendor/gdata-1.1.1/test/ts_gdata_client.rb new file mode 100644 index 0000000..ca186dd --- /dev/null +++ b/vendor/gdata-1.1.1/test/ts_gdata_client.rb @@ -0,0 +1,29 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'tc_gdata_client_base' +require 'tc_gdata_client_calendar' +require 'tc_gdata_client_photos' +require 'tc_gdata_client_youtube' + +class TS_GData_Client + def self.suite + suite = Test::Unit::TestSuite.new + suite << TC_GData_Client_Base.suite + suite << TC_GData_Client_Calendar.suite + suite << TC_GData_Client_Photos.suite + suite << TC_GData_Client_YouTube.suite + return suite + end +end \ No newline at end of file diff --git a/vendor/gdata-1.1.1/test/ts_gdata_http.rb b/vendor/gdata-1.1.1/test/ts_gdata_http.rb new file mode 100644 index 0000000..9297108 --- /dev/null +++ b/vendor/gdata-1.1.1/test/ts_gdata_http.rb @@ -0,0 +1,25 @@ +# Copyright (C) 2008 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'tc_gdata_http_request' +require 'tc_gdata_http_mime_body' + +class TS_GData_HTTP + def self.suite + suite = Test::Unit::TestSuite.new + suite << TC_GData_HTTP_Request.suite + suite << TC_GData_HTTP_MimeBody.suite + return suite + end +end \ No newline at end of file -- libgit2 0.21.2