pingdom-client 0.0.2.alpha → 0.0.3.alpha

Sign up to get free protection for your applications and to get access to all the features.
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.lastresponsetime #=> 200 (ms)
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.responsetime #=> 200 (ms)
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.responsetime.avgresponse
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
 
@@ -14,7 +14,6 @@ require 'active_support/core_ext/hash/slice'
14
14
  require 'pingdom'
15
15
  require 'pingdom/client'
16
16
  require 'pingdom/base'
17
- require 'pingdom/base'
18
17
  require 'pingdom/check'
19
18
  require 'pingdom/result'
20
19
  require 'pingdom/probe'
data/lib/pingdom.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Pingdom
2
2
 
3
- VERSION = '0.0.2.alpha'
3
+ VERSION = '0.0.3.alpha'
4
4
 
5
5
  class Error < RuntimeError
6
6
  end
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
- super[:checks].map do |check|
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
@@ -5,11 +5,12 @@ module Pingdom
5
5
 
6
6
  attr_accessor :limit
7
7
 
8
- def initialize(credentials = {})
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 credentials[:username], credentials[:password]
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
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{pingdom-client}
3
- s.version = "0.0.2.alpha"
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-02-24}
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 = [
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Pingdom::Client do
4
- let(:client){ Pingdom::Client.new(CREDENTIALS) }
4
+ let(:client){ Pingdom::Client.new(CREDENTIALS.merge(:logger => LOGGER)) }
5
5
 
6
6
  describe "#test!" do
7
7
  it "should test a single endpoint" do
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
- CREDENTIALS = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'credentials.yml')).inject({}){ |h,(k,v)| h[k.to_sym] = v; h }
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: -1851332170
4
+ hash: -1851332174
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
9
+ - 3
10
10
  - alpha
11
- version: 0.0.2.alpha
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-02-24 00:00:00 -05:00
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.2
209
+ rubygems_version: 1.5.3
210
210
  signing_key:
211
211
  specification_version: 3
212
212
  summary: Pingdom Ruby Client