pingdom-client 0.0.2.alpha → 0.0.3.alpha
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/Readme.md +9 -4
- data/lib/pingdom-client.rb +0 -1
- data/lib/pingdom.rb +1 -1
- data/lib/pingdom/check.rb +2 -1
- data/lib/pingdom/client.rb +5 -4
- data/pingdom-client.gemspec +2 -2
- data/spec/pingdom-client_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -1
- metadata +5 -5
    
        data/Readme.md
    CHANGED
    
    | @@ -3,24 +3,29 @@ | |
| 3 3 | 
             
            Pingdom now offers a RESTful API, which gives us no reason not to make a decent,
         | 
| 4 4 | 
             
            non-SOAP API client for their services.
         | 
| 5 5 |  | 
| 6 | 
            +
            NOTE: This is a 3rd party gem and not an official product from Pingdom.
         | 
| 7 | 
            +
             | 
| 6 8 | 
             
            ## Usage
         | 
| 7 9 |  | 
| 8 10 | 
             
                client = Pingdom::Client.new :username => u, :password => p
         | 
| 9 11 | 
             
                check = client.checks.first #=> #<Pingdom::Check>
         | 
| 10 | 
            -
                check. | 
| 12 | 
            +
                check.last_response_time    #=> 200 (ms)
         | 
| 11 13 | 
             
                check.status                #=> :up
         | 
| 12 14 | 
             
                check.up?                   #=> true
         | 
| 13 | 
            -
             | 
| 15 | 
            +
                
         | 
| 14 16 | 
             
                result = check.results.first(:probes => [1,2,3], :status => [:up, :down])
         | 
| 15 17 | 
             
                                            #=> #<Pingdom::Result>
         | 
| 16 18 | 
             
                result.status               #=> :up
         | 
| 17 19 | 
             
                result.up?                  #=> true
         | 
| 18 | 
            -
                result. | 
| 20 | 
            +
                result.response_time        #=> 20000 (microsecs)
         | 
| 19 21 |  | 
| 20 22 | 
             
                avg = check.average(:from   => 1.month.ago,
         | 
| 21 23 | 
             
                                    :probes => [1,2,3])
         | 
| 22 24 | 
             
                                            #=> #<Pingdom::Summary::Average>
         | 
| 23 | 
            -
                avg. | 
| 25 | 
            +
                avg.response_time           #=> 200 (ms)
         | 
| 26 | 
            +
                probe_avg = avg.averages.first
         | 
| 27 | 
            +
                probe_avg.response_time     #=> 120 (ms)
         | 
| 28 | 
            +
                probe_avg.probe.name        #=> "Atlanta, GA"
         | 
| 24 29 |  | 
| 25 30 | 
             
            ## License
         | 
| 26 31 |  | 
    
        data/lib/pingdom-client.rb
    CHANGED
    
    
    
        data/lib/pingdom.rb
    CHANGED
    
    
    
        data/lib/pingdom/check.rb
    CHANGED
    
    | @@ -3,7 +3,8 @@ module Pingdom | |
| 3 3 | 
             
              # {"name"=>"Autocomplete", "id"=>259103, "type"=>"http", "lastresponsetime"=>203173, "status"=>"up", "lasttesttime"=>1298102416}
         | 
| 4 4 | 
             
              class Check < Base
         | 
| 5 5 | 
             
                def self.parse(client, response)
         | 
| 6 | 
            -
                   | 
| 6 | 
            +
                  checks = super
         | 
| 7 | 
            +
                  Array.wrap(checks[:checks] || checks[:check]).map do |check|
         | 
| 7 8 | 
             
                    new(client, response, check)
         | 
| 8 9 | 
             
                  end
         | 
| 9 10 | 
             
                end
         | 
    
        data/lib/pingdom/client.rb
    CHANGED
    
    | @@ -5,11 +5,12 @@ module Pingdom | |
| 5 5 |  | 
| 6 6 | 
             
                attr_accessor :limit
         | 
| 7 7 |  | 
| 8 | 
            -
                def initialize( | 
| 8 | 
            +
                def initialize(options = {})
         | 
| 9 | 
            +
                  @options = options.with_indifferent_access
         | 
| 9 10 | 
             
                  @connection = Faraday::Connection.new(:url => "https://api/pingdom.com/api/2.0/") do |builder|
         | 
| 10 11 | 
             
                    builder.url_prefix = "https://api.pingdom.com/api/2.0"
         | 
| 11 12 |  | 
| 12 | 
            -
                    builder.adapter :logger
         | 
| 13 | 
            +
                    builder.adapter :logger, @options[:logger]
         | 
| 13 14 |  | 
| 14 15 | 
             
                    builder.adapter :excon
         | 
| 15 16 |  | 
| @@ -17,7 +18,7 @@ module Pingdom | |
| 17 18 | 
             
                    builder.response :yajl
         | 
| 18 19 | 
             
                    builder.use Tinder::FaradayResponse::WithIndifferentAccess
         | 
| 19 20 |  | 
| 20 | 
            -
                    builder.basic_auth  | 
| 21 | 
            +
                    builder.basic_auth @options[:username], @options[:password]
         | 
| 21 22 | 
             
                  end
         | 
| 22 23 | 
             
                end
         | 
| 23 24 |  | 
| @@ -60,7 +61,7 @@ module Pingdom | |
| 60 61 | 
             
                  Check.parse(self, get("checks", options))
         | 
| 61 62 | 
             
                end
         | 
| 62 63 | 
             
                def check(id)
         | 
| 63 | 
            -
                  Check.parse(self, get("checks/#{id}"))
         | 
| 64 | 
            +
                  Check.parse(self, get("checks/#{id}")).first
         | 
| 64 65 | 
             
                end
         | 
| 65 66 |  | 
| 66 67 | 
             
                # Check ID
         | 
    
        data/pingdom-client.gemspec
    CHANGED
    
    | @@ -1,10 +1,10 @@ | |
| 1 1 | 
             
            Gem::Specification.new do |s|
         | 
| 2 2 | 
             
              s.name = %q{pingdom-client}
         | 
| 3 | 
            -
              s.version = "0.0. | 
| 3 | 
            +
              s.version = "0.0.3.alpha"
         | 
| 4 4 |  | 
| 5 5 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 6 6 | 
             
              s.authors = ["Matt Todd"]
         | 
| 7 | 
            -
              s.date = %q{2011- | 
| 7 | 
            +
              s.date = %q{2011-03-01}
         | 
| 8 8 | 
             
              s.description = %q{Pingdom Ruby Client}
         | 
| 9 9 | 
             
              s.email = %q{chiology@gmail.com}
         | 
| 10 10 | 
             
              s.files = [
         | 
    
        data/spec/pingdom-client_spec.rb
    CHANGED
    
    
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -3,6 +3,8 @@ require 'rubygems' | |
| 3 3 | 
             
            require 'bundler/setup'
         | 
| 4 4 | 
             
            require 'pingdom-client'
         | 
| 5 5 |  | 
| 6 | 
            +
            require 'logger'
         | 
| 6 7 | 
             
            require 'rspec'
         | 
| 7 8 |  | 
| 8 | 
            -
             | 
| 9 | 
            +
            LOGGER      = Logger.new(File.join(File.dirname(__FILE__), 'test.log'))
         | 
| 10 | 
            +
            CREDENTIALS = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'credentials.yml')).with_indifferent_access
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: pingdom-client
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash: - | 
| 4 | 
            +
              hash: -1851332174
         | 
| 5 5 | 
             
              prerelease: 6
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 0
         | 
| 9 | 
            -
              -  | 
| 9 | 
            +
              - 3
         | 
| 10 10 | 
             
              - alpha
         | 
| 11 | 
            -
              version: 0.0. | 
| 11 | 
            +
              version: 0.0.3.alpha
         | 
| 12 12 | 
             
            platform: ruby
         | 
| 13 13 | 
             
            authors: 
         | 
| 14 14 | 
             
            - Matt Todd
         | 
| @@ -16,7 +16,7 @@ autorequire: | |
| 16 16 | 
             
            bindir: bin
         | 
| 17 17 | 
             
            cert_chain: []
         | 
| 18 18 |  | 
| 19 | 
            -
            date: 2011- | 
| 19 | 
            +
            date: 2011-03-01 00:00:00 -05:00
         | 
| 20 20 | 
             
            default_executable: 
         | 
| 21 21 | 
             
            dependencies: 
         | 
| 22 22 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 206 206 | 
             
            requirements: []
         | 
| 207 207 |  | 
| 208 208 | 
             
            rubyforge_project: 
         | 
| 209 | 
            -
            rubygems_version: 1.5. | 
| 209 | 
            +
            rubygems_version: 1.5.3
         | 
| 210 210 | 
             
            signing_key: 
         | 
| 211 211 | 
             
            specification_version: 3
         | 
| 212 212 | 
             
            summary: Pingdom Ruby Client
         |