gus 0.0.1
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/.gitignore +2 -0
 - data/Gemfile +8 -0
 - data/Gemfile.lock +28 -0
 - data/README +40 -0
 - data/Rakefile +7 -0
 - data/gus.gemspec +24 -0
 - data/lib/gus.rb +4 -0
 - data/lib/gus/shortener.rb +25 -0
 - data/lib/gus/version.rb +3 -0
 - data/spec/gus/shortener_spec.rb +19 -0
 - metadata +107 -0
 
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            PATH
         
     | 
| 
      
 2 
     | 
    
         
            +
              remote: .
         
     | 
| 
      
 3 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 4 
     | 
    
         
            +
                gus (0.0.1)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  crack (>= 0.1.8)
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            GEM
         
     | 
| 
      
 8 
     | 
    
         
            +
              remote: http://rubygems.org/
         
     | 
| 
      
 9 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 10 
     | 
    
         
            +
                crack (0.1.8)
         
     | 
| 
      
 11 
     | 
    
         
            +
                diff-lcs (1.1.2)
         
     | 
| 
      
 12 
     | 
    
         
            +
                rspec (2.3.0)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  rspec-core (~> 2.3.0)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  rspec-expectations (~> 2.3.0)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  rspec-mocks (~> 2.3.0)
         
     | 
| 
      
 16 
     | 
    
         
            +
                rspec-core (2.3.0)
         
     | 
| 
      
 17 
     | 
    
         
            +
                rspec-expectations (2.3.0)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  diff-lcs (~> 1.1.2)
         
     | 
| 
      
 19 
     | 
    
         
            +
                rspec-mocks (2.3.0)
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            PLATFORMS
         
     | 
| 
      
 22 
     | 
    
         
            +
              ruby
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            DEPENDENCIES
         
     | 
| 
      
 25 
     | 
    
         
            +
              bundler (>= 1.0.0.rc.5)
         
     | 
| 
      
 26 
     | 
    
         
            +
              crack (>= 0.1.8)
         
     | 
| 
      
 27 
     | 
    
         
            +
              gus!
         
     | 
| 
      
 28 
     | 
    
         
            +
              rspec
         
     | 
    
        data/README
    ADDED
    
    | 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = gus
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            == DESCRIPTION:
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            A Ruby API for the Google Url Shortener (http://goo.gl). Goo.gl currently 
         
     | 
| 
      
 6 
     | 
    
         
            +
            only provides support for shortening urls, but not expanding. As Goo.gl enhances their API, Gus will follow suit.
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            == INSTALLATION:
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            gem install gus
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            == USAGE:
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            short_url = Gus::Shortener.shorten(long_url)
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            == LICENSE:
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            (The MIT License)
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            Copyright (c) 2010 Bill Siggelkow
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 24 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 25 
     | 
    
         
            +
            'Software'), to deal in the Software without restriction, including
         
     | 
| 
      
 26 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 27 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 28 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 29 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 32 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 35 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 36 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
         
     | 
| 
      
 37 
     | 
    
         
            +
            IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
         
     | 
| 
      
 38 
     | 
    
         
            +
            CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
         
     | 
| 
      
 39 
     | 
    
         
            +
            TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
         
     | 
| 
      
 40 
     | 
    
         
            +
            SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/Rakefile
    ADDED
    
    
    
        data/gus.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'gus/version'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.name        = "gus"
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.version     = Gus::VERSION
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.platform    = Gem::Platform::RUBY
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.authors     = []
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.email       = []
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.homepage    = "http://rubygems.org/gems/gus"
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.summary     = "Simple Ruby API for the Google Url Shortener"
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.description = "Gus provides a simple Ruby wrapper around the Google Url shortener."
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              s.required_rubygems_version = ">= 1.3.6"
         
     | 
| 
      
 16 
     | 
    
         
            +
              s.rubyforge_project         = "gus"
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              s.add_development_dependency "bundler", ">= 1.0.0.rc.5"
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.add_dependency "crack", ">= 0.1.8"
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              s.files        = `git ls-files`.split("\n")
         
     | 
| 
      
 22 
     | 
    
         
            +
              s.executables  = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
         
     | 
| 
      
 23 
     | 
    
         
            +
              s.require_path = 'lib'
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/gus.rb
    ADDED
    
    
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Gus
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Shortener
         
     | 
| 
      
 3 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def shorten(url)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    get_result(url)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  end
         
     | 
| 
      
 7 
     | 
    
         
            +
                  
         
     | 
| 
      
 8 
     | 
    
         
            +
                  private 
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  def get_result(url)
         
     | 
| 
      
 11 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 12 
     | 
    
         
            +
                      response = Net::HTTP.post_form(
         
     | 
| 
      
 13 
     | 
    
         
            +
                        URI.parse('http://goo.gl/api/shorten'),
         
     | 
| 
      
 14 
     | 
    
         
            +
                        {'url'=>url}
         
     | 
| 
      
 15 
     | 
    
         
            +
                      )
         
     | 
| 
      
 16 
     | 
    
         
            +
                      result = Crack::JSON.parse(response.body)
         
     | 
| 
      
 17 
     | 
    
         
            +
                      result['short_url']
         
     | 
| 
      
 18 
     | 
    
         
            +
                    # rescue
         
     | 
| 
      
 19 
     | 
    
         
            +
                    #   raise "Goo.gl error: #{response.status_code}"
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/gus/version.rb
    ADDED
    
    
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'gus'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rspec'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe Gus::Shortener do
         
     | 
| 
      
 5 
     | 
    
         
            +
              let :shortener do 
         
     | 
| 
      
 6 
     | 
    
         
            +
                Gus::Shortener
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
              let :long_url do
         
     | 
| 
      
 9 
     | 
    
         
            +
                "http://www.example.com"
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              it 'should create a shortened url' do
         
     | 
| 
      
 13 
     | 
    
         
            +
                shortener.shorten(long_url).should_not be_nil
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
              it 'should shorten the url' do
         
     | 
| 
      
 16 
     | 
    
         
            +
                short_url = shortener.shorten(long_url)
         
     | 
| 
      
 17 
     | 
    
         
            +
                (short_url.length < long_url.length).should be_true
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,107 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: gus
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 5 
     | 
    
         
            +
              segments: 
         
     | 
| 
      
 6 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 1
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 10 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 11 
     | 
    
         
            +
            authors: []
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 14 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 15 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2010-12-16 00:00:00 -05:00
         
     | 
| 
      
 18 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 19 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 20 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 21 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 22 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 23 
     | 
    
         
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 24 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 25 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 26 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 27 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 28 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 29 
     | 
    
         
            +
                    - 1
         
     | 
| 
      
 30 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 31 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 32 
     | 
    
         
            +
                    - rc
         
     | 
| 
      
 33 
     | 
    
         
            +
                    - 5
         
     | 
| 
      
 34 
     | 
    
         
            +
                    version: 1.0.0.rc.5
         
     | 
| 
      
 35 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: *id001
         
     | 
| 
      
 37 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 38 
     | 
    
         
            +
              name: crack
         
     | 
| 
      
 39 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 40 
     | 
    
         
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 41 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 42 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 43 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 44 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 45 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 46 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 47 
     | 
    
         
            +
                    - 1
         
     | 
| 
      
 48 
     | 
    
         
            +
                    - 8
         
     | 
| 
      
 49 
     | 
    
         
            +
                    version: 0.1.8
         
     | 
| 
      
 50 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 51 
     | 
    
         
            +
              version_requirements: *id002
         
     | 
| 
      
 52 
     | 
    
         
            +
            description: Gus provides a simple Ruby wrapper around the Google Url shortener.
         
     | 
| 
      
 53 
     | 
    
         
            +
            email: []
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 62 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 63 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 64 
     | 
    
         
            +
            - Gemfile.lock
         
     | 
| 
      
 65 
     | 
    
         
            +
            - README
         
     | 
| 
      
 66 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 67 
     | 
    
         
            +
            - gus.gemspec
         
     | 
| 
      
 68 
     | 
    
         
            +
            - lib/gus.rb
         
     | 
| 
      
 69 
     | 
    
         
            +
            - lib/gus/shortener.rb
         
     | 
| 
      
 70 
     | 
    
         
            +
            - lib/gus/version.rb
         
     | 
| 
      
 71 
     | 
    
         
            +
            - spec/gus/shortener_spec.rb
         
     | 
| 
      
 72 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 73 
     | 
    
         
            +
            homepage: http://rubygems.org/gems/gus
         
     | 
| 
      
 74 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 77 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 80 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 81 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 82 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 83 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 84 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 85 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 86 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 87 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 88 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 89 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 90 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 91 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 92 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 93 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 94 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 95 
     | 
    
         
            +
                  - 1
         
     | 
| 
      
 96 
     | 
    
         
            +
                  - 3
         
     | 
| 
      
 97 
     | 
    
         
            +
                  - 6
         
     | 
| 
      
 98 
     | 
    
         
            +
                  version: 1.3.6
         
     | 
| 
      
 99 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            rubyforge_project: gus
         
     | 
| 
      
 102 
     | 
    
         
            +
            rubygems_version: 1.3.7
         
     | 
| 
      
 103 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 104 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 105 
     | 
    
         
            +
            summary: Simple Ruby API for the Google Url Shortener
         
     | 
| 
      
 106 
     | 
    
         
            +
            test_files: []
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     |