bitly 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +12 -0
 - data/Manifest +1 -1
 - data/README.md +87 -0
 - data/Rakefile +1 -1
 - data/bitly.gemspec +10 -9
 - data/lib/bitly/v3/client.rb +18 -6
 - data/lib/bitly/version.rb +1 -1
 - metadata +12 -12
 - data/README.txt +0 -87
 
    
        data/History.txt
    CHANGED
    
    | 
         @@ -1,3 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            === 0.6.2 / 2011-11-10
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            * 2 minor enhancements
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              * Adds days parameter to clicks_by_minute v3 API call
         
     | 
| 
      
 6 
     | 
    
         
            +
              * Converts Readme to markdown
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            * 2 minor bug fixes
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              * Increases HTTParty version to avoid issues with Rubygems
         
     | 
| 
      
 11 
     | 
    
         
            +
              * Stops mutating arguments on array methods
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
       1 
13 
     | 
    
         
             
            === 0.6.1 / 2011-01-12
         
     | 
| 
       2 
14 
     | 
    
         | 
| 
       3 
15 
     | 
    
         
             
            * 1 minor enhancement
         
     | 
    
        data/Manifest
    CHANGED
    
    
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,87 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # bitly
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            ## DESCRIPTION:
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            A Ruby API for [http://bit.ly](http://bit.ly) (and now (http://j.mp)[http://j.mp])
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            [http://code.google.com/p/bitly-api/wiki/ApiDocumentation](http://code.google.com/p/bitly-api/wiki/ApiDocumentation)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ## NOTE:
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            Bitly recently released their version 3 API. From this 0.5.0 release, the gem will continue to work the same but also provide a V3 module, using the version 3 API. The standard module will become deprecated, as Bitly do not plan to keep the version 2 API around forever.
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            To move to using the version 3 API, call:
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                Bitly.use_api_version_3
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            Then, when you call ``Bitly.new(username, api_key)`` you will get a ``Bitly::V3::Client`` instead, which provides the version 3 api calls (``shorten``, ``expand``, ``clicks``, ``validate`` and ``bitly_pro_domain``). See [http://api.bit.ly](http://api.bit.ly) for details.
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            Eventually, this will become the default version used and finally, the V3 module will disappear, with the version 3 classes replacing the version 2 classes.
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            (Please excuse the lack of tests for the v3 classes, they are fully tested and ready to replace this whole codebase in the v3 branch of the GitHub repo, until I realized it would break everything.)
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ## INSTALLATION:
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                gem install bitly
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            ## USAGE:
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            ### Version 2 API
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            Create a Bitly client using your username and api key as follows:
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                bitly = Bitly.new(username, api_key)
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            You can then use that client to shorten or expand urls or return more information or statistics as so:
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                bitly.shorten('http://www.google.com')
         
     | 
| 
      
 38 
     | 
    
         
            +
                bitly.shorten('http://www.google.com', :history => 1) # adds the url to the api user's history
         
     | 
| 
      
 39 
     | 
    
         
            +
                bitly.expand('wQaT')
         
     | 
| 
      
 40 
     | 
    
         
            +
                bitly.info('http://bit.ly/wQaT')
         
     | 
| 
      
 41 
     | 
    
         
            +
                bitly.stats('http://bit.ly/wQaT')
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            Each can be used in all the methods described in the API docs, the shorten function, for example, takes a url or an array of urls.
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            All four functions return a ``Bitly::Url`` object (or an array of ``Bitly::Url`` objects if you supplied an array as the input). You can then get all the information required from that object.
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                u = bitly.shorten('http://www.google.com') #=> Bitly::Url
         
     | 
| 
      
 48 
     | 
    
         
            +
                
         
     | 
| 
      
 49 
     | 
    
         
            +
                u.long_url #=> "http://www.google.com"
         
     | 
| 
      
 50 
     | 
    
         
            +
                u.short_url #=> "http://bit.ly/Ywd1"
         
     | 
| 
      
 51 
     | 
    
         
            +
                u.bitly_url #=> "http://bit.ly/Ywd1"
         
     | 
| 
      
 52 
     | 
    
         
            +
                u.jmp_url #=> "http://j.mp/Ywd1"
         
     | 
| 
      
 53 
     | 
    
         
            +
                u.user_hash #=> "Ywd1"
         
     | 
| 
      
 54 
     | 
    
         
            +
                u.hash #=> "2V6CFi"
         
     | 
| 
      
 55 
     | 
    
         
            +
                u.info #=> a ruby hash of the JSON returned from the API
         
     | 
| 
      
 56 
     | 
    
         
            +
                u.stats #=> a ruby hash of the JSON returned from the API
         
     | 
| 
      
 57 
     | 
    
         
            +
                
         
     | 
| 
      
 58 
     | 
    
         
            +
                bitly.shorten('http://www.google.com', 'keyword')
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            ### Version 3 API
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            Please see the Bit.ly API documentation [http://api.bit.ly](http://api.bit.ly) for details on the V3 API.
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            ## LICENSE:
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            > (The MIT License)
         
     | 
| 
      
 67 
     | 
    
         
            +
            >
         
     | 
| 
      
 68 
     | 
    
         
            +
            > Copyright (c) 2009 Phil Nash
         
     | 
| 
      
 69 
     | 
    
         
            +
            >
         
     | 
| 
      
 70 
     | 
    
         
            +
            > Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 71 
     | 
    
         
            +
            > a copy of this software and associated documentation files (the
         
     | 
| 
      
 72 
     | 
    
         
            +
            > 'Software'), to deal in the Software without restriction, including
         
     | 
| 
      
 73 
     | 
    
         
            +
            > without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 74 
     | 
    
         
            +
            > distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 75 
     | 
    
         
            +
            > permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 76 
     | 
    
         
            +
            > the following conditions:
         
     | 
| 
      
 77 
     | 
    
         
            +
            > 
         
     | 
| 
      
 78 
     | 
    
         
            +
            > The above copyright notice and this permission notice shall be
         
     | 
| 
      
 79 
     | 
    
         
            +
            > included in all copies or substantial portions of the Software.
         
     | 
| 
      
 80 
     | 
    
         
            +
            > 
         
     | 
| 
      
 81 
     | 
    
         
            +
            > THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 82 
     | 
    
         
            +
            > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 83 
     | 
    
         
            +
            > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
         
     | 
| 
      
 84 
     | 
    
         
            +
            > IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
         
     | 
| 
      
 85 
     | 
    
         
            +
            > CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
         
     | 
| 
      
 86 
     | 
    
         
            +
            > TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
         
     | 
| 
      
 87 
     | 
    
         
            +
            > SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -8,6 +8,6 @@ Echoe.new('bitly', Bitly::VERSION) do |p| 
     | 
|
| 
       8 
8 
     | 
    
         
             
              p.url = "http://github.com/philnash/bitly"
         
     | 
| 
       9 
9 
     | 
    
         
             
              p.author = "Phil Nash"
         
     | 
| 
       10 
10 
     | 
    
         
             
              p.email = "philnash@gmail.com"
         
     | 
| 
       11 
     | 
    
         
            -
              p.extra_deps      = [['crack', '>= 0.1.4'], ['httparty', '>= 0. 
     | 
| 
      
 11 
     | 
    
         
            +
              p.extra_deps      = [['crack', '>= 0.1.4'], ['httparty', '>= 0.7.6'], ['oauth2', '>= 0.1.1']]
         
     | 
| 
       12 
12 
     | 
    
         
             
              p.development_dependencies = []
         
     | 
| 
       13 
13 
     | 
    
         
             
            end
         
     | 
    
        data/bitly.gemspec
    CHANGED
    
    | 
         @@ -2,38 +2,39 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       4 
4 
     | 
    
         
             
              s.name = %q{bitly}
         
     | 
| 
       5 
     | 
    
         
            -
              s.version = "0.6. 
     | 
| 
      
 5 
     | 
    
         
            +
              s.version = "0.6.2"
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
         
     | 
| 
       8 
8 
     | 
    
         
             
              s.authors = ["Phil Nash"]
         
     | 
| 
       9 
     | 
    
         
            -
              s.date = %q{2011- 
     | 
| 
      
 9 
     | 
    
         
            +
              s.date = %q{2011-11-10}
         
     | 
| 
       10 
10 
     | 
    
         
             
              s.description = %q{Use the bit.ly API to shorten or expand URLs}
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.email = %q{philnash@gmail.com}
         
     | 
| 
       12 
     | 
    
         
            -
              s.extra_rdoc_files = ["README. 
     | 
| 
       13 
     | 
    
         
            -
              s.files = ["History.txt", "Manifest", "README. 
     | 
| 
      
 12 
     | 
    
         
            +
              s.extra_rdoc_files = ["README.md", "lib/bitly.rb", "lib/bitly/client.rb", "lib/bitly/url.rb", "lib/bitly/utils.rb", "lib/bitly/v3.rb", "lib/bitly/v3/bitly.rb", "lib/bitly/v3/client.rb", "lib/bitly/v3/country.rb", "lib/bitly/v3/day.rb", "lib/bitly/v3/missing_url.rb", "lib/bitly/v3/oauth.rb", "lib/bitly/v3/realtime_link.rb", "lib/bitly/v3/referrer.rb", "lib/bitly/v3/url.rb", "lib/bitly/v3/user.rb", "lib/bitly/version.rb"]
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.files = ["History.txt", "Manifest", "README.md", "Rakefile", "bitly.gemspec", "lib/bitly.rb", "lib/bitly/client.rb", "lib/bitly/url.rb", "lib/bitly/utils.rb", "lib/bitly/v3.rb", "lib/bitly/v3/bitly.rb", "lib/bitly/v3/client.rb", "lib/bitly/v3/country.rb", "lib/bitly/v3/day.rb", "lib/bitly/v3/missing_url.rb", "lib/bitly/v3/oauth.rb", "lib/bitly/v3/realtime_link.rb", "lib/bitly/v3/referrer.rb", "lib/bitly/v3/url.rb", "lib/bitly/v3/user.rb", "lib/bitly/version.rb", "test/bitly/test_client.rb", "test/bitly/test_url.rb", "test/bitly/test_utils.rb", "test/fixtures/cnn.json", "test/fixtures/cnn_and_google.json", "test/fixtures/expand_cnn.json", "test/fixtures/expand_cnn_and_google.json", "test/fixtures/google_and_cnn_info.json", "test/fixtures/google_info.json", "test/fixtures/google_stats.json", "test/fixtures/shorten_error.json", "test/test_helper.rb"]
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.homepage = %q{http://github.com/philnash/bitly}
         
     | 
| 
       15 
     | 
    
         
            -
              s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Bitly", "--main", "README. 
     | 
| 
      
 15 
     | 
    
         
            +
              s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Bitly", "--main", "README.md"]
         
     | 
| 
       16 
16 
     | 
    
         
             
              s.require_paths = ["lib"]
         
     | 
| 
       17 
17 
     | 
    
         
             
              s.rubyforge_project = %q{bitly}
         
     | 
| 
       18 
     | 
    
         
            -
              s.rubygems_version = %q{1. 
     | 
| 
      
 18 
     | 
    
         
            +
              s.rubygems_version = %q{1.3.7}
         
     | 
| 
       19 
19 
     | 
    
         
             
              s.summary = %q{Use the bit.ly API to shorten or expand URLs}
         
     | 
| 
       20 
20 
     | 
    
         
             
              s.test_files = ["test/bitly/test_client.rb", "test/bitly/test_url.rb", "test/bitly/test_utils.rb", "test/test_helper.rb"]
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
              if s.respond_to? :specification_version then
         
     | 
| 
      
 23 
     | 
    
         
            +
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         
     | 
| 
       23 
24 
     | 
    
         
             
                s.specification_version = 3
         
     | 
| 
       24 
25 
     | 
    
         | 
| 
       25 
26 
     | 
    
         
             
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         
     | 
| 
       26 
27 
     | 
    
         
             
                  s.add_runtime_dependency(%q<crack>, [">= 0.1.4"])
         
     | 
| 
       27 
     | 
    
         
            -
                  s.add_runtime_dependency(%q<httparty>, [">= 0. 
     | 
| 
      
 28 
     | 
    
         
            +
                  s.add_runtime_dependency(%q<httparty>, [">= 0.7.6"])
         
     | 
| 
       28 
29 
     | 
    
         
             
                  s.add_runtime_dependency(%q<oauth2>, [">= 0.1.1"])
         
     | 
| 
       29 
30 
     | 
    
         
             
                else
         
     | 
| 
       30 
31 
     | 
    
         
             
                  s.add_dependency(%q<crack>, [">= 0.1.4"])
         
     | 
| 
       31 
     | 
    
         
            -
                  s.add_dependency(%q<httparty>, [">= 0. 
     | 
| 
      
 32 
     | 
    
         
            +
                  s.add_dependency(%q<httparty>, [">= 0.7.6"])
         
     | 
| 
       32 
33 
     | 
    
         
             
                  s.add_dependency(%q<oauth2>, [">= 0.1.1"])
         
     | 
| 
       33 
34 
     | 
    
         
             
                end
         
     | 
| 
       34 
35 
     | 
    
         
             
              else
         
     | 
| 
       35 
36 
     | 
    
         
             
                s.add_dependency(%q<crack>, [">= 0.1.4"])
         
     | 
| 
       36 
     | 
    
         
            -
                s.add_dependency(%q<httparty>, [">= 0. 
     | 
| 
      
 37 
     | 
    
         
            +
                s.add_dependency(%q<httparty>, [">= 0.7.6"])
         
     | 
| 
       37 
38 
     | 
    
         
             
                s.add_dependency(%q<oauth2>, [">= 0.1.1"])
         
     | 
| 
       38 
39 
     | 
    
         
             
              end
         
     | 
| 
       39 
40 
     | 
    
         
             
            end
         
     | 
    
        data/lib/bitly/v3/client.rb
    CHANGED
    
    | 
         @@ -63,7 +63,7 @@ module Bitly 
     | 
|
| 
       63 
63 
     | 
    
         
             
                  #
         
     | 
| 
       64 
64 
     | 
    
         
             
                  # Returns the results in the order they were entered
         
     | 
| 
       65 
65 
     | 
    
         
             
                  def lookup(input)
         
     | 
| 
       66 
     | 
    
         
            -
                    input =  
     | 
| 
      
 66 
     | 
    
         
            +
                    input = arrayize(input)
         
     | 
| 
       67 
67 
     | 
    
         
             
                    query = input.inject([]) { |query, i| query << "url=#{CGI.escape(i)}" }
         
     | 
| 
       68 
68 
     | 
    
         
             
                    query = "/lookup?" + query.join('&')
         
     | 
| 
       69 
69 
     | 
    
         
             
                    response = get(query)
         
     | 
| 
         @@ -104,11 +104,20 @@ module Bitly 
     | 
|
| 
       104 
104 
     | 
    
         
             
                  end
         
     | 
| 
       105 
105 
     | 
    
         | 
| 
       106 
106 
     | 
    
         
             
                  # Takes a short url, hash or array of either and gets the clicks by day
         
     | 
| 
       107 
     | 
    
         
            -
                  def clicks_by_day(input)
         
     | 
| 
       108 
     | 
    
         
            -
                     
     | 
| 
      
 107 
     | 
    
         
            +
                  def clicks_by_day(input, opts={})
         
     | 
| 
      
 108 
     | 
    
         
            +
                    opts.reject! { |k, v| k.to_s != 'days' }
         
     | 
| 
      
 109 
     | 
    
         
            +
                    get_method(:clicks_by_day, input, opts)
         
     | 
| 
       109 
110 
     | 
    
         
             
                  end
         
     | 
| 
       110 
111 
     | 
    
         | 
| 
       111 
112 
     | 
    
         
             
                  private
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                  def arrayize(arg)
         
     | 
| 
      
 115 
     | 
    
         
            +
                    if arg.is_a?(String)
         
     | 
| 
      
 116 
     | 
    
         
            +
                      [arg] 
         
     | 
| 
      
 117 
     | 
    
         
            +
                    else
         
     | 
| 
      
 118 
     | 
    
         
            +
                      arg.dup
         
     | 
| 
      
 119 
     | 
    
         
            +
                    end
         
     | 
| 
      
 120 
     | 
    
         
            +
                  end
         
     | 
| 
       112 
121 
     | 
    
         | 
| 
       113 
122 
     | 
    
         
             
                  def get(method, opts={})
         
     | 
| 
       114 
123 
     | 
    
         
             
                    opts[:query] ||= {}
         
     | 
| 
         @@ -137,8 +146,8 @@ module Bitly 
     | 
|
| 
       137 
146 
     | 
    
         
             
                    return Bitly::V3::Url.new(self,response['data'])
         
     | 
| 
       138 
147 
     | 
    
         
             
                  end
         
     | 
| 
       139 
148 
     | 
    
         | 
| 
       140 
     | 
    
         
            -
                  def get_method(method, input)
         
     | 
| 
       141 
     | 
    
         
            -
                    input =  
     | 
| 
      
 149 
     | 
    
         
            +
                  def get_method(method, input, opts={})
         
     | 
| 
      
 150 
     | 
    
         
            +
                    input = arrayize(input)
         
     | 
| 
       142 
151 
     | 
    
         
             
                    query = input.inject([]) do |query,i|
         
     | 
| 
       143 
152 
     | 
    
         
             
                      if is_a_short_url?(i)
         
     | 
| 
       144 
153 
     | 
    
         
             
                        query << "shortUrl=#{CGI.escape(i)}"
         
     | 
| 
         @@ -146,6 +155,9 @@ module Bitly 
     | 
|
| 
       146 
155 
     | 
    
         
             
                        query << "hash=#{CGI.escape(i)}"
         
     | 
| 
       147 
156 
     | 
    
         
             
                      end
         
     | 
| 
       148 
157 
     | 
    
         
             
                    end
         
     | 
| 
      
 158 
     | 
    
         
            +
                    query = opts.inject(query) do |query, (k,v)|
         
     | 
| 
      
 159 
     | 
    
         
            +
                      query << "#{k}=#{v}"
         
     | 
| 
      
 160 
     | 
    
         
            +
                    end
         
     | 
| 
       149 
161 
     | 
    
         
             
                    query = "/#{method}?" + query.join('&')
         
     | 
| 
       150 
162 
     | 
    
         
             
                    response = get(query)
         
     | 
| 
       151 
163 
     | 
    
         
             
                    results = response['data'][method.to_s].inject([]) do |results, url|
         
     | 
| 
         @@ -165,4 +177,4 @@ module Bitly 
     | 
|
| 
       165 
177 
     | 
    
         
             
                  end
         
     | 
| 
       166 
178 
     | 
    
         
             
                end
         
     | 
| 
       167 
179 
     | 
    
         
             
              end
         
     | 
| 
       168 
     | 
    
         
            -
            end
         
     | 
| 
      
 180 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/bitly/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: bitly
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
       5 
     | 
    
         
            -
              prerelease: 
         
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 3
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 6
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 0.6. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 2
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.6.2
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Phil Nash
         
     | 
| 
         @@ -15,7 +15,7 @@ autorequire: 
     | 
|
| 
       15 
15 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
16 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            date: 2011- 
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2011-11-10 00:00:00 +00:00
         
     | 
| 
       19 
19 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       21 
21 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -45,9 +45,9 @@ dependencies: 
     | 
|
| 
       45 
45 
     | 
    
         
             
                    hash: 15
         
     | 
| 
       46 
46 
     | 
    
         
             
                    segments: 
         
     | 
| 
       47 
47 
     | 
    
         
             
                    - 0
         
     | 
| 
       48 
     | 
    
         
            -
                    -  
     | 
| 
       49 
     | 
    
         
            -
                    -  
     | 
| 
       50 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 48 
     | 
    
         
            +
                    - 7
         
     | 
| 
      
 49 
     | 
    
         
            +
                    - 6
         
     | 
| 
      
 50 
     | 
    
         
            +
                    version: 0.7.6
         
     | 
| 
       51 
51 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       52 
52 
     | 
    
         
             
              version_requirements: *id002
         
     | 
| 
       53 
53 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -73,7 +73,7 @@ executables: [] 
     | 
|
| 
       73 
73 
     | 
    
         
             
            extensions: []
         
     | 
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
            extra_rdoc_files: 
         
     | 
| 
       76 
     | 
    
         
            -
            - README. 
     | 
| 
      
 76 
     | 
    
         
            +
            - README.md
         
     | 
| 
       77 
77 
     | 
    
         
             
            - lib/bitly.rb
         
     | 
| 
       78 
78 
     | 
    
         
             
            - lib/bitly/client.rb
         
     | 
| 
       79 
79 
     | 
    
         
             
            - lib/bitly/url.rb
         
     | 
| 
         @@ -93,7 +93,7 @@ extra_rdoc_files: 
     | 
|
| 
       93 
93 
     | 
    
         
             
            files: 
         
     | 
| 
       94 
94 
     | 
    
         
             
            - History.txt
         
     | 
| 
       95 
95 
     | 
    
         
             
            - Manifest
         
     | 
| 
       96 
     | 
    
         
            -
            - README. 
     | 
| 
      
 96 
     | 
    
         
            +
            - README.md
         
     | 
| 
       97 
97 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       98 
98 
     | 
    
         
             
            - bitly.gemspec
         
     | 
| 
       99 
99 
     | 
    
         
             
            - lib/bitly.rb
         
     | 
| 
         @@ -135,7 +135,7 @@ rdoc_options: 
     | 
|
| 
       135 
135 
     | 
    
         
             
            - --title
         
     | 
| 
       136 
136 
     | 
    
         
             
            - Bitly
         
     | 
| 
       137 
137 
     | 
    
         
             
            - --main
         
     | 
| 
       138 
     | 
    
         
            -
            - README. 
     | 
| 
      
 138 
     | 
    
         
            +
            - README.md
         
     | 
| 
       139 
139 
     | 
    
         
             
            require_paths: 
         
     | 
| 
       140 
140 
     | 
    
         
             
            - lib
         
     | 
| 
       141 
141 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
         @@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       160 
160 
     | 
    
         
             
            requirements: []
         
     | 
| 
       161 
161 
     | 
    
         | 
| 
       162 
162 
     | 
    
         
             
            rubyforge_project: bitly
         
     | 
| 
       163 
     | 
    
         
            -
            rubygems_version: 1. 
     | 
| 
      
 163 
     | 
    
         
            +
            rubygems_version: 1.3.7
         
     | 
| 
       164 
164 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       165 
165 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       166 
166 
     | 
    
         
             
            summary: Use the bit.ly API to shorten or expand URLs
         
     | 
    
        data/README.txt
    DELETED
    
    | 
         @@ -1,87 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            = bitly
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            == DESCRIPTION:
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            A Ruby API for http://bit.ly (and now http://j.mp)
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            http://code.google.com/p/bitly-api/wiki/ApiDocumentation
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            == NOTE:
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            Bitly recently released their version 3 API. From this 0.5.0 release, the gem will continue to work the same but also provide a V3 module, using the version 3 API. The standard module will become deprecated, as Bitly do not plan to keep the version 2 API around forever.
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            To move to using the version 3 API, call:
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            Bitly.use_api_version_3
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            Then, when you call Bitly.new(username, api_key) you will get a Bitly::V3::Client instead, which provides the version 3 api calls (shorten, expand, clicks, validate and bitly_pro_domain). See http://api.bit.ly for details.
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            Eventually, this will become the default version used and finally, the V3 module will disappear, with the version 3 classes replacing the version 2 classes.
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
            (Please excuse the lack of tests for the v3 classes, they are fully tested and ready to replace this whole codebase in the v3 branch of the github repo, until I realised it would break everything.)
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
            == INSTALLATION:
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
            gem install bitly
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
            == USAGE:
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
            === Version 2 API
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
            Create a Bitly client using your username and api key as follows:
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
            bitly = Bitly.new(username, api_key)
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
            You can then use that client to shorten or expand urls or return more information or statistics as so:
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
            bitly.shorten('http://www.google.com')
         
     | 
| 
       38 
     | 
    
         
            -
            bitly.shorten('http://www.google.com', :history => 1) # adds the url to the api user's history
         
     | 
| 
       39 
     | 
    
         
            -
            bitly.expand('wQaT')
         
     | 
| 
       40 
     | 
    
         
            -
            bitly.info('http://bit.ly/wQaT')
         
     | 
| 
       41 
     | 
    
         
            -
            bitly.stats('http://bit.ly/wQaT')
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
            Each can be used in all the methods described in the API docs, the shorten function, for example, takes a url or an array of urls.
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
            All four functions return a Bitly::Url object (or an array of Bitly::Url objects if you supplied an array as the input). You can then get all the information required from that object.
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
            u = bitly.shorten('http://www.google.com') #=> Bitly::Url
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
            u.long_url #=> "http://www.google.com"
         
     | 
| 
       50 
     | 
    
         
            -
            u.short_url #=> "http://bit.ly/Ywd1"
         
     | 
| 
       51 
     | 
    
         
            -
            u.bitly_url #=> "http://bit.ly/Ywd1"
         
     | 
| 
       52 
     | 
    
         
            -
            u.jmp_url #=> "http://j.mp/Ywd1"
         
     | 
| 
       53 
     | 
    
         
            -
            u.user_hash #=> "Ywd1"
         
     | 
| 
       54 
     | 
    
         
            -
            u.hash #=> "2V6CFi"
         
     | 
| 
       55 
     | 
    
         
            -
            u.info #=> a ruby hash of the JSON returned from the API
         
     | 
| 
       56 
     | 
    
         
            -
            u.stats #=> a ruby hash of the JSON returned from the API
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
            bitly.shorten('http://www.google.com', 'keyword')
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
            === Version 3 API
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
            Please see the Bit.ly API documentation http://api.bit.ly for details on the V3 API
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
            == LICENSE:
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
            (The MIT License)
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
            Copyright (c) 2009 Phil Nash
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
       71 
     | 
    
         
            -
            a copy of this software and associated documentation files (the
         
     | 
| 
       72 
     | 
    
         
            -
            'Software'), to deal in the Software without restriction, including
         
     | 
| 
       73 
     | 
    
         
            -
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
       74 
     | 
    
         
            -
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
       75 
     | 
    
         
            -
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
       76 
     | 
    
         
            -
            the following conditions:
         
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
            The above copyright notice and this permission notice shall be
         
     | 
| 
       79 
     | 
    
         
            -
            included in all copies or substantial portions of the Software.
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
            THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
       82 
     | 
    
         
            -
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
       83 
     | 
    
         
            -
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
         
     | 
| 
       84 
     | 
    
         
            -
            IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
         
     | 
| 
       85 
     | 
    
         
            -
            CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
         
     | 
| 
       86 
     | 
    
         
            -
            TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
         
     | 
| 
       87 
     | 
    
         
            -
            SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     |