getclicky 0.1.beta1
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 +7 -0
 - data/Gemfile +2 -0
 - data/README.rdoc +89 -0
 - data/Rakefile +3 -0
 - data/getclicky.gemspec +25 -0
 - data/lib/getclicky.rb +52 -0
 - data/lib/getclicky/client.rb +14 -0
 - data/lib/getclicky/request.rb +34 -0
 - data/lib/getclicky/response.rb +20 -0
 - data/lib/getclicky/types.rb +62 -0
 - data/lib/getclicky/version.rb +15 -0
 - data/spec/getclicky/client_spec.rb +13 -0
 - data/spec/getclicky/request_spec.rb +8 -0
 - data/spec/getclicky_spec.rb +27 -0
 - data/spec/spec_helper.rb +19 -0
 - data/spec/support/helpers.rb +10 -0
 - metadata +132 -0
 
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/README.rdoc
    ADDED
    
    | 
         @@ -0,0 +1,89 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = Getclicky API Analytics Library
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            A swiss knife ruby wrapper for Getclicky API Analytics. For more information see: http://getclicky.com/help/api.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            == Installation
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              gem install getclicky
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            == Usage
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            === Ruby wrapper
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            First, you'll need to set up your site_id and sitekey. You can discover this information by accessing settings in your account at http://getclicky.com.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              Getclicky.configure do |config|
         
     | 
| 
      
 16 
     | 
    
         
            +
                config.site_id = "your site id here"
         
     | 
| 
      
 17 
     | 
    
         
            +
                config.sitekey = "your site key here"
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            Then you can simply instantiate a new Getclicky::Client object.
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              getclicky = Getclicky::Client.new
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            === Usage
         
     | 
| 
      
 25 
     | 
    
         
            +
            					
         
     | 
| 
      
 26 
     | 
    
         
            +
            All types in API are methods here looks, you can find all types http://getclicky.com/help/api:
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              getClicky.pages()
         
     | 
| 
      
 29 
     | 
    
         
            +
            	
         
     | 
| 
      
 30 
     | 
    
         
            +
              getClicky.tweets()
         
     | 
| 
      
 31 
     | 
    
         
            +
            	
         
     | 
| 
      
 32 
     | 
    
         
            +
              getClicky.visitors()
         
     | 
| 
      
 33 
     | 
    
         
            +
            	
         
     | 
| 
      
 34 
     | 
    
         
            +
            In each method you can pass optional parameters as a hash looks:
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              getClicky.visitors(:date => "last-7-days", :daily => 1)
         
     | 
| 
      
 37 
     | 
    
         
            +
            	
         
     | 
| 
      
 38 
     | 
    
         
            +
              getClicky.item(:date => "last-7-days", :item => "google.com")
         
     | 
| 
      
 39 
     | 
    
         
            +
            	
         
     | 
| 
      
 40 
     | 
    
         
            +
              getClicky.visitors_list(:domain => "google.com")
         
     | 
| 
      
 41 
     | 
    
         
            +
            	
         
     | 
| 
      
 42 
     | 
    
         
            +
            By default getclicky API returns XML as data, but you can change adding :output in parameter like:
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            ===== JSON
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              getClicky.visitors(:output => "json", :date => "last-7-days", :daily => 1)
         
     | 
| 
      
 47 
     | 
    
         
            +
            	
         
     | 
| 
      
 48 
     | 
    
         
            +
            ===== CSV
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              getClicky.visitors(:output => "csv", :date => "last-7-days", :daily => 1)
         
     | 
| 
      
 51 
     | 
    
         
            +
            	
         
     | 
| 
      
 52 
     | 
    
         
            +
            ===== PHP
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              getClicky.visitors(:output => "php", :date => "last-7-days", :daily => 1)
         
     | 
| 
      
 55 
     | 
    
         
            +
            	
         
     | 
| 
      
 56 
     | 
    
         
            +
            	
         
     | 
| 
      
 57 
     | 
    
         
            +
            This library does't support multiple types yet.
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            == Roadmap
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            * Multiple types for request
         
     | 
| 
      
 62 
     | 
    
         
            +
            * Improve the tests
         
     | 
| 
      
 63 
     | 
    
         
            +
            	
         
     | 
| 
      
 64 
     | 
    
         
            +
            == Maintainer
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            * Peterson Ferreira (petersonferreiras@gmail.com)
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            == License
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            (The MIT License)
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 73 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 74 
     | 
    
         
            +
            'Software'), to deal in the Software without restriction, including
         
     | 
| 
      
 75 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 76 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 77 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 78 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 81 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 84 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 85 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
         
     | 
| 
      
 86 
     | 
    
         
            +
            IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
         
     | 
| 
      
 87 
     | 
    
         
            +
            CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
         
     | 
| 
      
 88 
     | 
    
         
            +
            TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
         
     | 
| 
      
 89 
     | 
    
         
            +
            SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/Rakefile
    ADDED
    
    
    
        data/getclicky.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            $:.push File.expand_path("../lib", __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "getclicky"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.name        = "getclicky"
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.version     = Getclicky::Version::STRING
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.authors     = ["Peterson Ferreira"]
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.email       = ["petersonferreiras@gmail.com"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.homepage    = "http://github.com/petersonferreira/getclicky"
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.summary     = %q{Ruby Wrapper for GetClicky API Analytics}
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.description = s.summary
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.add_dependency "activesupport"            , "~> 3.0"
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.add_dependency "httparty"                 , "~> 0.7.8"
         
     | 
| 
      
 16 
     | 
    
         
            +
              s.add_development_dependency "rspec"        , "~> 2.6"
         
     | 
| 
      
 17 
     | 
    
         
            +
              s.add_development_dependency "test_notifier", "~> 0.3"
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.add_development_dependency "fakeweb"      , "~> 1.3"
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.add_development_dependency "ruby-debug19" , "~> 0.11"
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              s.files         = `git ls-files`.split("\n")
         
     | 
| 
      
 22 
     | 
    
         
            +
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
| 
      
 23 
     | 
    
         
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         
     | 
| 
      
 24 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/getclicky.rb
    ADDED
    
    | 
         @@ -0,0 +1,52 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Getclicky API Analytics Ruby Client Library
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Allows access to the getclicky.com Analytics API using the ruby programming language.
         
     | 
| 
      
 4 
     | 
    
         
            +
            #
         
     | 
| 
      
 5 
     | 
    
         
            +
            # Copyright (c) 2011+ Peterson Ferreira
         
     | 
| 
      
 6 
     | 
    
         
            +
            # See LICENSE for details
         
     | 
| 
      
 7 
     | 
    
         
            +
            #
         
     | 
| 
      
 8 
     | 
    
         
            +
            require "httparty"
         
     | 
| 
      
 9 
     | 
    
         
            +
            require "active_support/core_ext/object/to_param"
         
     | 
| 
      
 10 
     | 
    
         
            +
            require "active_support/core_ext/object/to_query"
         
     | 
| 
      
 11 
     | 
    
         
            +
            require "active_support/inflector"
         
     | 
| 
      
 12 
     | 
    
         
            +
            require "active_support/core_ext/string/strip"
         
     | 
| 
      
 13 
     | 
    
         
            +
            require "active_support/core_ext/object/blank"
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            # A Ruby class to call the Getclicky API Analytics.
         
     | 
| 
      
 16 
     | 
    
         
            +
            # You might use this if you want to see data of Getclicky in your application.
         
     | 
| 
      
 17 
     | 
    
         
            +
            #
         
     | 
| 
      
 18 
     | 
    
         
            +
            module Getclicky
         
     | 
| 
      
 19 
     | 
    
         
            +
              autoload :Client  , "getclicky/client"
         
     | 
| 
      
 20 
     | 
    
         
            +
              autoload :Request , "getclicky/request"
         
     | 
| 
      
 21 
     | 
    
         
            +
              autoload :Response, "getclicky/response"
         
     | 
| 
      
 22 
     | 
    
         
            +
              autoload :Types   , "getclicky/types"
         
     | 
| 
      
 23 
     | 
    
         
            +
              autoload :Version , "getclicky/version"
         
     | 
| 
      
 24 
     | 
    
         
            +
              
         
     | 
| 
      
 25 
     | 
    
         
            +
              # Class implemented to abstract 404 errors.
         
     | 
| 
      
 26 
     | 
    
         
            +
              #
         
     | 
| 
      
 27 
     | 
    
         
            +
              class Getclicky::NotFoundError < StandardError; end
         
     | 
| 
      
 28 
     | 
    
         
            +
              
         
     | 
| 
      
 29 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 30 
     | 
    
         
            +
                # Set the site_id that will do requests to the API.
         
     | 
| 
      
 31 
     | 
    
         
            +
                # Will be required in every request.
         
     | 
| 
      
 32 
     | 
    
         
            +
                #
         
     | 
| 
      
 33 
     | 
    
         
            +
                attr_accessor :site_id
         
     | 
| 
      
 34 
     | 
    
         
            +
                
         
     | 
| 
      
 35 
     | 
    
         
            +
                # Set the sitekey that will do request to the API.
         
     | 
| 
      
 36 
     | 
    
         
            +
                # Will be required in every request.
         
     | 
| 
      
 37 
     | 
    
         
            +
                #
         
     | 
| 
      
 38 
     | 
    
         
            +
                attr_accessor :sitekey
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
              
         
     | 
| 
      
 41 
     | 
    
         
            +
              # API endpoint of Getclicky
         
     | 
| 
      
 42 
     | 
    
         
            +
              #
         
     | 
| 
      
 43 
     | 
    
         
            +
              def self.endpoint
         
     | 
| 
      
 44 
     | 
    
         
            +
                ENV.fetch("GETCLICKY_ENDPOINT", "http://api.getclicky.com/api/stats/4")
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
              
         
     | 
| 
      
 47 
     | 
    
         
            +
              # Yield Getclicky module so you can easily configure options
         
     | 
| 
      
 48 
     | 
    
         
            +
              #
         
     | 
| 
      
 49 
     | 
    
         
            +
              def self.configure(&block)
         
     | 
| 
      
 50 
     | 
    
         
            +
                yield Getclicky
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Getclicky
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Client    
         
     | 
| 
      
 3 
     | 
    
         
            +
                # Dynamically defines the methods to be called by type
         
     | 
| 
      
 4 
     | 
    
         
            +
                #
         
     | 
| 
      
 5 
     | 
    
         
            +
                Getclicky::Types::ALL.each do |type|
         
     | 
| 
      
 6 
     | 
    
         
            +
                  class_eval <<-RUBY, __FILE__, __LINE__  
         
     | 
| 
      
 7 
     | 
    
         
            +
                    def #{type.to_s.downcase}(params = {})                                            # def pages(params = {})
         
     | 
| 
      
 8 
     | 
    
         
            +
                      response = Getclicky::Request.get(:#{type.to_s.gsub(/[_]/, '-')}, params = {})  #   response = Getclicky::Request.get(:pages, params = {})
         
     | 
| 
      
 9 
     | 
    
         
            +
                      response.data                                                                   #   response.data
         
     | 
| 
      
 10 
     | 
    
         
            +
                    end                                                                               # end
         
     | 
| 
      
 11 
     | 
    
         
            +
                  RUBY
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Getclicky API Analytics Ruby Client Library
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Allows access to the getclicky.com Analytics API using the ruby programming language.
         
     | 
| 
      
 4 
     | 
    
         
            +
            #
         
     | 
| 
      
 5 
     | 
    
         
            +
            # Copyright (c) 2011+ Peterson Ferreira
         
     | 
| 
      
 6 
     | 
    
         
            +
            # See LICENSE for details
         
     | 
| 
      
 7 
     | 
    
         
            +
            #
         
     | 
| 
      
 8 
     | 
    
         
            +
            module Getclicky
         
     | 
| 
      
 9 
     | 
    
         
            +
              module Request  
         
     | 
| 
      
 10 
     | 
    
         
            +
                include HTTParty
         
     | 
| 
      
 11 
     | 
    
         
            +
                extend self
         
     | 
| 
      
 12 
     | 
    
         
            +
                
         
     | 
| 
      
 13 
     | 
    
         
            +
                # Handle all HTTP::Get request, wrapping all the logic
         
     | 
| 
      
 14 
     | 
    
         
            +
                # like endpoint and more.
         
     | 
| 
      
 15 
     | 
    
         
            +
                #
         
     | 
| 
      
 16 
     | 
    
         
            +
                def get(type, params = {})
         
     | 
| 
      
 17 
     | 
    
         
            +
                  response = self.class.get(Getclicky.endpoint, :query => build_params(type, params))
         
     | 
| 
      
 18 
     | 
    
         
            +
                  
         
     | 
| 
      
 19 
     | 
    
         
            +
                  case response.code
         
     | 
| 
      
 20 
     | 
    
         
            +
                  when "404"
         
     | 
| 
      
 21 
     | 
    
         
            +
                    raise Getclicky::NotFoundError
         
     | 
| 
      
 22 
     | 
    
         
            +
                  else
         
     | 
| 
      
 23 
     | 
    
         
            +
                    Getclicky::Response.new(response)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
                
         
     | 
| 
      
 27 
     | 
    
         
            +
                # Build the hash of options for given a resquest to API
         
     | 
| 
      
 28 
     | 
    
         
            +
                #
         
     | 
| 
      
 29 
     | 
    
         
            +
                def build_params(type, params = {})
         
     | 
| 
      
 30 
     | 
    
         
            +
                  query = { :site_id => Getclicky.site_id, :sitekey => Getclicky.sitekey, :type => type }
         
     | 
| 
      
 31 
     | 
    
         
            +
                  query.merge(params)
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Getclicky API Analytics Ruby Client Library
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Allows access to the getclicky.com Analytics API using the ruby programming language.
         
     | 
| 
      
 4 
     | 
    
         
            +
            #
         
     | 
| 
      
 5 
     | 
    
         
            +
            # Copyright (c) 2011+ Peterson Ferreira
         
     | 
| 
      
 6 
     | 
    
         
            +
            # See LICENSE for details
         
     | 
| 
      
 7 
     | 
    
         
            +
            #
         
     | 
| 
      
 8 
     | 
    
         
            +
            module Getclicky
         
     | 
| 
      
 9 
     | 
    
         
            +
              class Response    
         
     | 
| 
      
 10 
     | 
    
         
            +
                attr_accessor :request
         
     | 
| 
      
 11 
     | 
    
         
            +
                
         
     | 
| 
      
 12 
     | 
    
         
            +
                def initializer(request)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @request = request
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
                
         
     | 
| 
      
 16 
     | 
    
         
            +
                def data
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @request.body
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,62 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Getclicky API Analytics Ruby Client Library
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Allows access to the getclicky.com Analytics API using the ruby programming language.
         
     | 
| 
      
 4 
     | 
    
         
            +
            #
         
     | 
| 
      
 5 
     | 
    
         
            +
            # Copyright (c) 2011+ Peterson Ferreira
         
     | 
| 
      
 6 
     | 
    
         
            +
            # See LICENSE for details
         
     | 
| 
      
 7 
     | 
    
         
            +
            #
         
     | 
| 
      
 8 
     | 
    
         
            +
            module Getclicky
         
     | 
| 
      
 9 
     | 
    
         
            +
              module Types
         
     | 
| 
      
 10 
     | 
    
         
            +
                
         
     | 
| 
      
 11 
     | 
    
         
            +
                # Request types that the API accepts.
         
     | 
| 
      
 12 
     | 
    
         
            +
                #
         
     | 
| 
      
 13 
     | 
    
         
            +
                ALL = [
         
     | 
| 
      
 14 
     | 
    
         
            +
                  :pages,
         
     | 
| 
      
 15 
     | 
    
         
            +
                  :pages_entrance,
         
     | 
| 
      
 16 
     | 
    
         
            +
                  :pages_exit,
         
     | 
| 
      
 17 
     | 
    
         
            +
                  :downloads,
         
     | 
| 
      
 18 
     | 
    
         
            +
                  :clicks,
         
     | 
| 
      
 19 
     | 
    
         
            +
                  :links,
         
     | 
| 
      
 20 
     | 
    
         
            +
                  :links_domains,
         
     | 
| 
      
 21 
     | 
    
         
            +
                  :links_outbound,
         
     | 
| 
      
 22 
     | 
    
         
            +
                  :searches,
         
     | 
| 
      
 23 
     | 
    
         
            +
                  :searches_keywords,
         
     | 
| 
      
 24 
     | 
    
         
            +
                  :searches_engines,
         
     | 
| 
      
 25 
     | 
    
         
            +
                  :goals,
         
     | 
| 
      
 26 
     | 
    
         
            +
                  :split_tests,
         
     | 
| 
      
 27 
     | 
    
         
            +
                  :campaigns,
         
     | 
| 
      
 28 
     | 
    
         
            +
                  :countries,
         
     | 
| 
      
 29 
     | 
    
         
            +
                  :cities,
         
     | 
| 
      
 30 
     | 
    
         
            +
                  :regions,
         
     | 
| 
      
 31 
     | 
    
         
            +
                  :languages,
         
     | 
| 
      
 32 
     | 
    
         
            +
                  :web_browsers,
         
     | 
| 
      
 33 
     | 
    
         
            +
                  :operating_systems,
         
     | 
| 
      
 34 
     | 
    
         
            +
                  :screen_resolutions,
         
     | 
| 
      
 35 
     | 
    
         
            +
                  :hostnames,
         
     | 
| 
      
 36 
     | 
    
         
            +
                  :organizations,
         
     | 
| 
      
 37 
     | 
    
         
            +
                  :engagement_actions,
         
     | 
| 
      
 38 
     | 
    
         
            +
                  :engagement_times,
         
     | 
| 
      
 39 
     | 
    
         
            +
                  :segmentation,
         
     | 
| 
      
 40 
     | 
    
         
            +
                  :visitors_most_active,
         
     | 
| 
      
 41 
     | 
    
         
            +
                  :traffic_sources,
         
     | 
| 
      
 42 
     | 
    
         
            +
                  :tweets,
         
     | 
| 
      
 43 
     | 
    
         
            +
                  :shorturls,
         
     | 
| 
      
 44 
     | 
    
         
            +
                  :visitors_list,
         
     | 
| 
      
 45 
     | 
    
         
            +
                  :actions_list,
         
     | 
| 
      
 46 
     | 
    
         
            +
                  :searches_recent,
         
     | 
| 
      
 47 
     | 
    
         
            +
                  :searches_unique,
         
     | 
| 
      
 48 
     | 
    
         
            +
                  :links_recent,
         
     | 
| 
      
 49 
     | 
    
         
            +
                  :links_unique,
         
     | 
| 
      
 50 
     | 
    
         
            +
                  :visitors,
         
     | 
| 
      
 51 
     | 
    
         
            +
                  :visitors_unique,
         
     | 
| 
      
 52 
     | 
    
         
            +
                  :actions,
         
     | 
| 
      
 53 
     | 
    
         
            +
                  :actions_average,
         
     | 
| 
      
 54 
     | 
    
         
            +
                  :time_average,
         
     | 
| 
      
 55 
     | 
    
         
            +
                  :time_average_pretty,
         
     | 
| 
      
 56 
     | 
    
         
            +
                  :time_total,
         
     | 
| 
      
 57 
     | 
    
         
            +
                  :time_total_pretty,
         
     | 
| 
      
 58 
     | 
    
         
            +
                  :bounce_rate,
         
     | 
| 
      
 59 
     | 
    
         
            +
                  :visitors_online
         
     | 
| 
      
 60 
     | 
    
         
            +
                ] 
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Getclicky API Analytics Ruby Client Library
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Allows access to the getclicky.com Analytics API using the ruby programming language.
         
     | 
| 
      
 4 
     | 
    
         
            +
            #
         
     | 
| 
      
 5 
     | 
    
         
            +
            # Copyright (c) 2011+ Peterson Ferreira
         
     | 
| 
      
 6 
     | 
    
         
            +
            # See LICENSE for details
         
     | 
| 
      
 7 
     | 
    
         
            +
            #
         
     | 
| 
      
 8 
     | 
    
         
            +
            module Getclicky
         
     | 
| 
      
 9 
     | 
    
         
            +
              module Version
         
     | 
| 
      
 10 
     | 
    
         
            +
                MAJOR = 0
         
     | 
| 
      
 11 
     | 
    
         
            +
                MINOR = 1
         
     | 
| 
      
 12 
     | 
    
         
            +
                PATCH = "beta1"
         
     | 
| 
      
 13 
     | 
    
         
            +
                STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Getclicky::Client do
         
     | 
| 
      
 4 
     | 
    
         
            +
              context "methods for request type" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                Getclicky::Types::ALL.each do |type|
         
     | 
| 
      
 6 
     | 
    
         
            +
                  class_eval <<-RUBY, __FILE__, __LINE__  
         
     | 
| 
      
 7 
     | 
    
         
            +
                    it "should be implement #{type.to_s} method" do
         
     | 
| 
      
 8 
     | 
    
         
            +
                      subject.should respond_to(type)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    end
         
     | 
| 
      
 10 
     | 
    
         
            +
                  RUBY
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,8 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Getclicky::Request do
         
     | 
| 
      
 4 
     | 
    
         
            +
              it "should be set the right parameters" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                params = subject.build_params(:pages, :limit => 10, :hourly => 1)
         
     | 
| 
      
 6 
     | 
    
         
            +
                params.should == { :site_id => Getclicky.site_id, :sitekey => Getclicky.sitekey, :type => :pages, :limit => 10, :hourly => 1}
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Getclicky do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe "configure" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                it "should be set site_id" do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  Getclicky.configure { |c| c.site_id = "123" }
         
     | 
| 
      
 7 
     | 
    
         
            +
                  Getclicky.site_id.should == "123"
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
                
         
     | 
| 
      
 10 
     | 
    
         
            +
                it "should be set sitekey" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                  Getclicky.configure { |c| c.sitekey = "123" }
         
     | 
| 
      
 12 
     | 
    
         
            +
                  Getclicky.sitekey.should == "123"
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
              
         
     | 
| 
      
 16 
     | 
    
         
            +
              describe "endpoint" do
         
     | 
| 
      
 17 
     | 
    
         
            +
                it "should be returns the real url" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                  ENV.delete("GETCLICKY_ENDPOINT")
         
     | 
| 
      
 19 
     | 
    
         
            +
                  Getclicky.endpoint.should == "http://api.getclicky.com/api/stats/4"
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
                
         
     | 
| 
      
 22 
     | 
    
         
            +
                it "should be changes the url" do
         
     | 
| 
      
 23 
     | 
    
         
            +
                  ENV["GETCLICKY_ENDPOINT"] = "http://getclicky.com"
         
     | 
| 
      
 24 
     | 
    
         
            +
                  Getclicky.endpoint.should == "http://getclicky.com"
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "bundler"
         
     | 
| 
      
 2 
     | 
    
         
            +
            Bundler.setup(:default, :development)
         
     | 
| 
      
 3 
     | 
    
         
            +
            Bundler.require(:default, :development)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require "getclicky"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "rspec"
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "test_notifier/runner/rspec"
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            FakeWeb.allow_net_connect = false
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|file| require file}
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 14 
     | 
    
         
            +
              config.include Helpers
         
     | 
| 
      
 15 
     | 
    
         
            +
                
         
     | 
| 
      
 16 
     | 
    
         
            +
              # config.before do
         
     | 
| 
      
 17 
     | 
    
         
            +
              #   ENV.delete("GETCLICKY_ENDPOINT")
         
     | 
| 
      
 18 
     | 
    
         
            +
              # end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,132 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: getclicky
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.beta1
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: 4
         
     | 
| 
      
 6 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 7 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Peterson Ferreira
         
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 10 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 11 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2011-08-11 00:00:00.000000000Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 14 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 15 
     | 
    
         
            +
              name: activesupport
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: &70254699111300 !ruby/object:Gem::Requirement
         
     | 
| 
      
 17 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: '3.0'
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: *70254699111300
         
     | 
| 
      
 25 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 26 
     | 
    
         
            +
              name: httparty
         
     | 
| 
      
 27 
     | 
    
         
            +
              requirement: &70254699110800 !ruby/object:Gem::Requirement
         
     | 
| 
      
 28 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 29 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 30 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 31 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 32 
     | 
    
         
            +
                    version: 0.7.8
         
     | 
| 
      
 33 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 34 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 35 
     | 
    
         
            +
              version_requirements: *70254699110800
         
     | 
| 
      
 36 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 37 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 38 
     | 
    
         
            +
              requirement: &70254699110340 !ruby/object:Gem::Requirement
         
     | 
| 
      
 39 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 40 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 41 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 42 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 43 
     | 
    
         
            +
                    version: '2.6'
         
     | 
| 
      
 44 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 45 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 46 
     | 
    
         
            +
              version_requirements: *70254699110340
         
     | 
| 
      
 47 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 48 
     | 
    
         
            +
              name: test_notifier
         
     | 
| 
      
 49 
     | 
    
         
            +
              requirement: &70254699109860 !ruby/object:Gem::Requirement
         
     | 
| 
      
 50 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '0.3'
         
     | 
| 
      
 55 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 56 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 57 
     | 
    
         
            +
              version_requirements: *70254699109860
         
     | 
| 
      
 58 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 59 
     | 
    
         
            +
              name: fakeweb
         
     | 
| 
      
 60 
     | 
    
         
            +
              requirement: &70254699109400 !ruby/object:Gem::Requirement
         
     | 
| 
      
 61 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 62 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 63 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 64 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 65 
     | 
    
         
            +
                    version: '1.3'
         
     | 
| 
      
 66 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 67 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 68 
     | 
    
         
            +
              version_requirements: *70254699109400
         
     | 
| 
      
 69 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: ruby-debug19
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: &70254699108920 !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 73 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 74 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 75 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 76 
     | 
    
         
            +
                    version: '0.11'
         
     | 
| 
      
 77 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 78 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 79 
     | 
    
         
            +
              version_requirements: *70254699108920
         
     | 
| 
      
 80 
     | 
    
         
            +
            description: Ruby Wrapper for GetClicky API Analytics
         
     | 
| 
      
 81 
     | 
    
         
            +
            email:
         
     | 
| 
      
 82 
     | 
    
         
            +
            - petersonferreiras@gmail.com
         
     | 
| 
      
 83 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 84 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 85 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 86 
     | 
    
         
            +
            files:
         
     | 
| 
      
 87 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 88 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 89 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 90 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 91 
     | 
    
         
            +
            - getclicky.gemspec
         
     | 
| 
      
 92 
     | 
    
         
            +
            - lib/getclicky.rb
         
     | 
| 
      
 93 
     | 
    
         
            +
            - lib/getclicky/client.rb
         
     | 
| 
      
 94 
     | 
    
         
            +
            - lib/getclicky/request.rb
         
     | 
| 
      
 95 
     | 
    
         
            +
            - lib/getclicky/response.rb
         
     | 
| 
      
 96 
     | 
    
         
            +
            - lib/getclicky/types.rb
         
     | 
| 
      
 97 
     | 
    
         
            +
            - lib/getclicky/version.rb
         
     | 
| 
      
 98 
     | 
    
         
            +
            - spec/getclicky/client_spec.rb
         
     | 
| 
      
 99 
     | 
    
         
            +
            - spec/getclicky/request_spec.rb
         
     | 
| 
      
 100 
     | 
    
         
            +
            - spec/getclicky_spec.rb
         
     | 
| 
      
 101 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 102 
     | 
    
         
            +
            - spec/support/helpers.rb
         
     | 
| 
      
 103 
     | 
    
         
            +
            homepage: http://github.com/petersonferreira/getclicky
         
     | 
| 
      
 104 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 105 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 106 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 107 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 108 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 109 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 110 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 111 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 112 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 113 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 114 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 115 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 116 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 117 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 118 
     | 
    
         
            +
              - - ! '>'
         
     | 
| 
      
 119 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 120 
     | 
    
         
            +
                  version: 1.3.1
         
     | 
| 
      
 121 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 122 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 123 
     | 
    
         
            +
            rubygems_version: 1.8.7
         
     | 
| 
      
 124 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 125 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 126 
     | 
    
         
            +
            summary: Ruby Wrapper for GetClicky API Analytics
         
     | 
| 
      
 127 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 128 
     | 
    
         
            +
            - spec/getclicky/client_spec.rb
         
     | 
| 
      
 129 
     | 
    
         
            +
            - spec/getclicky/request_spec.rb
         
     | 
| 
      
 130 
     | 
    
         
            +
            - spec/getclicky_spec.rb
         
     | 
| 
      
 131 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 132 
     | 
    
         
            +
            - spec/support/helpers.rb
         
     |