pingdom-faraday 0.1.0 → 1.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa96c1175616b82619fba002ec6a4493108d3aca
4
- data.tar.gz: 53fac53b292cbba616bad035aa74feb0f918c292
3
+ metadata.gz: 17120abbb07cb5352739b88aa1f1a227136af271
4
+ data.tar.gz: 83222645593d8e9e518b6d2476fbe1a7e96c6ab1
5
5
  SHA512:
6
- metadata.gz: 290fbac49bf000aaf91c61048394b2bc4c2824203d6d77a6a18e52576531dffcee170c965068d60250e47f9f6ce71d3f7a0b9d6dfa345e44a65620e9b320a021
7
- data.tar.gz: 4e595fb326c3dd7a9237a761140fd2b0c5d579aa180e10c22253ada438ccf6614f97f05043f239c821f16d4b20a3e2d7a061902b92af8bf115bc07d871f2ddfe
6
+ metadata.gz: 8a19d2c9a785e3dcd4e08ace68d7d750f99f2b2e278948a6a74df205f074dfd28238d9d2cc1f07e4780ea5e587cda388ef01093d0886fd29e0158236dce4dfb7
7
+ data.tar.gz: 9602328b2febb41b68005090ba7e61355a1ff5ed34f6cc86e03aced80020c4cba275ee264309de556997abfa8851d836f9e5cb6f2f86cc233cadaedc2ae2c58f
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 Jason Straughan.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md CHANGED
@@ -6,51 +6,50 @@ NOTE: This is a 3rd party gem and not an official product from Pingdom.
6
6
 
7
7
  ## Usage
8
8
 
9
- client = Pingdom::Client.new :username => u, :password => p, :key => k
10
- check = client.checks.first #=> #<Pingdom::Check>
11
- check.last_response_time #=> 200 (ms)
12
- check.status #=> "up"
13
-
14
- result = check.results.first(:probes => [1,2,3], :status => [:up, :down])
15
- #=> #<Pingdom::Result>
16
- result.status #=> :up
17
- result.up? #=> true
18
- result.response_time #=> 20000 (microsecs)
19
-
20
- avg = check.summary.average(:from => 1.month.ago,
21
- :probes => [1,2,3])
22
- #=> #<Pingdom::Summary::Average>
23
- avg.response_time #=> 200 (ms)
24
- probe_avg = avg.averages.first
25
- probe_avg.response_time #=> 120 (ms)
26
- probe_avg.probe.name #=> "Atlanta, GA"
9
+ ```ruby
10
+ client = Pingdom::Client.new username: u, password: p, key: k
11
+ check = client.checks.first #=> #<Pingdom::Check>
12
+ check.last_response_time #=> 200 (ms)
13
+ check.status #=> "up"
14
+
15
+ result = check.results.first(probes: [1,2,3], status: [:up, :down])
16
+ #=> #<Pingdom::Result>
17
+ result.status #=> :up
18
+ result.up? #=> true
19
+ result.response_time #=> 20000 (ms)
20
+
21
+ avg = check.summary.average(from: 1.month.ago,
22
+ probes: [1,2,3])
23
+ #=> #<Pingdom::Summary::Average>
24
+ avg.response_time #=> 200 (ms)
25
+ probe_avg = avg.averages.first
26
+ probe_avg.response_time #=> 120 (ms)
27
+ probe_avg.probe.name #=> "Atlanta, GA"
28
+
29
+ tms = client.tms_recipes.first
30
+ #=> #<Pingdom::TMSRecipe>
31
+ tms.status #=> "SUCCESSFUL"
32
+
33
+ tms_avg = tms.summary.average from: 1.week.ago
34
+ #=> #<Pingdom::TMSSummary::Average>
35
+ tms_avg.response_time #=> 2760 (ms)
36
+ ```
37
+
38
+ ## Testing
39
+
40
+ Create a `credentials.yml` file in the gem's base directory containing your Pingdom credentials:
41
+
42
+ ```yaml
43
+ username: u
44
+ password: p
45
+ key: k
46
+ ```
47
+
48
+ Run tests with `bundle exec rake`.
27
49
 
28
50
  ## Contributors
29
51
 
30
- * Updated for Ruby 1.9.x/2.0.0 by Jason Straughan ([jdstraughan](http://github.com/jdstraughan))
31
- * Emily Price ([duien](http://github.com/duien))
52
+ * Transaction check (TMS) support by [Hund.io](https://github.com/hundio)
53
+ * Updated for Ruby 1.9.x/2.0.0 by Jason Straughan ([jdstraughan](https://github.com/jdstraughan))
54
+ * Emily Price ([duien](https://github.com/duien))
32
55
  * Based on [pingom-client](https://github.com/mtodd/pingdom-client) by [Matt Todd](https://github.com/mtodd)
33
-
34
- ## License
35
-
36
- The MIT License
37
-
38
- Copyright (c) 2013 Jason Straughan.
39
-
40
- Permission is hereby granted, free of charge, to any person obtaining a copy
41
- of this software and associated documentation files (the "Software"), to deal
42
- in the Software without restriction, including without limitation the rights
43
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
44
- copies of the Software, and to permit persons to whom the Software is
45
- furnished to do so, subject to the following conditions:
46
-
47
- The above copyright notice and this permission notice shall be included in
48
- all copies or substantial portions of the Software.
49
-
50
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
52
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
53
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
54
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
55
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
56
- THE SOFTWARE.
data/Rakefile CHANGED
@@ -3,8 +3,8 @@ require "bundler"
3
3
  begin
4
4
  Bundler.setup(:default, :development)
5
5
  rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
6
+ warn e.message
7
+ warn "Run `bundle install` to install missing gems"
8
8
  exit e.status_code
9
9
  end
10
10
 
@@ -15,7 +15,7 @@ RSpec::Core::RakeTask.new do |t|
15
15
  end
16
16
 
17
17
  task :console do
18
- exec %(ruby -rirb -rubygems -r bundler/setup -r lib/pingdom-ruby -e '$credentials = YAML.load_file("credentials.yml").with_indifferent_access; $client = Pingdom::Client.new($credentials); IRB.start')
18
+ exec %(ruby -rirb -rubygems -r bundler/setup -r yaml -r ./lib/pingdom-faraday -e '$credentials = YAML.load_file("credentials.yml").with_indifferent_access; $client = Pingdom::Client.new($credentials); IRB.start')
19
19
  end
20
20
 
21
21
  task default: :spec
@@ -24,3 +24,8 @@ require "pingdom/summary"
24
24
  require "pingdom/summary/average"
25
25
  require "pingdom/summary/outage"
26
26
  require "pingdom/summary/performance"
27
+ require "pingdom/tms_recipe"
28
+ require "pingdom/tms_summary"
29
+ require "pingdom/tms_summary/average"
30
+ require "pingdom/tms_summary/outage"
31
+ require "pingdom/tms_summary/performance"
data/lib/pingdom.rb CHANGED
@@ -1,6 +1,4 @@
1
1
  module Pingdom
2
- VERSION = "0.0.1"
3
-
4
2
  class Error < RuntimeError
5
3
  end
6
4
  end
data/lib/pingdom/base.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Pingdom
2
2
  class Base
3
3
  def initialize(client, response, attributes = {})
4
- @client = client
5
- @response = response
4
+ @client = client
5
+ @response = response
6
6
  @attributes = attributes
7
7
  end
8
8
 
@@ -21,7 +21,11 @@ module Pingdom
21
21
  end
22
22
 
23
23
  def method_missing(name, *args, &block)
24
- @attributes[name.to_s] or super
24
+ @attributes[name.to_s] || super
25
+ end
26
+
27
+ def respond_to_missing?(name, include_private = false)
28
+ @attributes.key?(name.to_s) || super
25
29
  end
26
30
 
27
31
  def respond_to?(name)
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), "..", "pingdom-ruby") unless defined? Pingdom
1
+ require File.join(File.dirname(__FILE__), "..", "pingdom-faraday") unless defined? Pingdom
2
2
 
3
3
  module Pingdom
4
4
  class Client
@@ -9,14 +9,11 @@ module Pingdom
9
9
 
10
10
  raise ArgumentError, "an application key must be provided (as :key)" unless @options.key?(:key)
11
11
 
12
- @connection = Faraday::Connection.new(url: "https://api/pingdom.com/api/2.0/", ssl: { verify: false }) do |builder|
13
- builder.url_prefix = "https://api.pingdom.com/api/2.0"
14
-
15
- builder.adapter @options[:http_driver]
16
-
12
+ @connection = Faraday::Connection.new(url: "https://api.pingdom.com/api/2.0/", ssl: { verify: false }) do |builder|
17
13
  # builder.use Gzip # TODO: write GZip response handler, add Accept-Encoding: gzip header
18
14
  builder.response :json, content_type: /\bjson$/
19
15
  builder.use Tinder::FaradayResponse::WithIndifferentAccess
16
+ builder.adapter @options[:http_driver]
20
17
 
21
18
  builder.basic_auth @options[:username], @options[:password]
22
19
  builder.headers["App-Key"] = @options[:key]
@@ -67,6 +64,14 @@ module Pingdom
67
64
  Check.parse(self, get("checks/#{id}")).first
68
65
  end
69
66
 
67
+ def tms_recipes(options = {})
68
+ TMSRecipe.parse(self, get("tms.recipes", options))
69
+ end
70
+
71
+ def tms_recipe(id)
72
+ TMSRecipe.parse(self, get("tms.recipes/#{id}")).first
73
+ end
74
+
70
75
  # Check ID
71
76
  def results(id, options = {})
72
77
  options.reverse_merge!(includeanalysis: true)
@@ -84,5 +89,9 @@ module Pingdom
84
89
  def summary(id)
85
90
  Summary.proxy(self, id)
86
91
  end
92
+
93
+ def tms_summary(id)
94
+ TMSSummary.proxy(self, id)
95
+ end
87
96
  end
88
97
  end
@@ -1,21 +1,21 @@
1
1
  module Pingdom
2
2
  class Summary < Base
3
- class Proxy < Struct.new(:client, :check_id)
3
+ class Proxy < Struct.new(:client, :id)
4
4
  def average(options = {})
5
5
  options.reverse_merge!(byprobe: true, includeuptime: true)
6
- Average.parse(client, client.get("summary.average/#{check_id}", options))
6
+ Average.parse(client, client.get("summary.average/#{id}", options))
7
7
  end
8
8
  alias_method :averages, :average
9
9
 
10
10
  def outage(options = {})
11
11
  options.reverse_merge!(byprobe: true, includeuptime: true)
12
- Outage.parse(client, client.get("summary.outage/#{check_id}", options))
12
+ Outage.parse(client, client.get("summary.outage/#{id}", options))
13
13
  end
14
14
  alias_method :outages, :outage
15
15
 
16
16
  def performance(options = {})
17
17
  options.reverse_merge!(resolution: :day, includeuptime: true)
18
- Performance.parse(client, client.get("summary.performance/#{check_id}", options))
18
+ Performance.parse(client, client.get("summary.performance/#{id}", options))
19
19
  end
20
20
  end
21
21
 
@@ -8,8 +8,8 @@ module Pingdom
8
8
  # "status"=>{"totalup"=>5035757, "totalunknown"=>1293069551, "totaldown"=>5078}}
9
9
  class Average < Base
10
10
  def self.parse(client, response)
11
- body = super["summary"]
12
- sum = body["responsetime"]
11
+ body = super["summary"]
12
+ sum = body["responsetime"]
13
13
  attrs = sum.slice("from", "to")
14
14
  attrs["probes"] = (attrs["probes"] || "").gsub(/\w+/, "").split(",").map(&:to_i)
15
15
 
@@ -22,7 +22,7 @@ module Pingdom
22
22
  sum["responsetime"] += avg["avgresponse"]
23
23
  new(client, response, avg)
24
24
  end
25
- sum["responsetime"] = sum["responsetime"] / sum["averages"].size if sum["averages"].size > 0
25
+ sum["responsetime"] = sum["responsetime"] / sum["averages"].size if !sum["averages"].size.empty?
26
26
 
27
27
  when Integer
28
28
  sum["responsetime"] = sum.delete("avgresponse")
@@ -14,14 +14,14 @@ module Pingdom
14
14
  # {"unmonitored"=>0, "downtime"=>0, "starttime"=>1298102400, "uptime"=>8646, "avgresponse"=>223}]}
15
15
  class Performance < Base
16
16
  INTERVALS = {
17
- "hour" => 1.hour,
18
- "day" => 1.day,
19
- "week" => 1.week,
20
- }
17
+ "hour" => 1.hour,
18
+ "day" => 1.day,
19
+ "week" => 1.week,
20
+ }.freeze
21
21
 
22
22
  def self.parse(client, response)
23
- body = super["summary"]
24
- interval = body.keys.detect { |k| INTERVALS.keys.include?(k.chomp("s").to_s) }.chomp("s").to_sym
23
+ body = super["summary"]
24
+ interval = body.keys.detect { |k| INTERVALS.keys.include?(k.chomp("s").to_s) }.chomp("s").to_sym
25
25
  intervals = body[interval.to_s.pluralize]
26
26
 
27
27
  intervals.map do |perf|
@@ -0,0 +1,31 @@
1
+ module Pingdom
2
+ # {"recipes"=>{
3
+ # "12345"=>{
4
+ # "name"=>"Google", "status"=>"SUCCESSFUL", kitchen=>{"id"=>1,"name"=>"us-east"},
5
+ # "ingredients"=>"Go to URL http://google.com\nURL should be http://google.com",
6
+ # "active"=>"YES", "created_at"=>1298102416, "interval"=>10, "notifyvia"=>[],
7
+ # "send_daily_report"=>"NO", "use_legacy_notifications"=>false,
8
+ # "sendnotificationwhendown"=>1, "notifyagainevery"=>0, "contacts"=>[]
9
+ # }
10
+ # }
11
+ class TMSRecipe < Base
12
+ def self.parse(client, response)
13
+ super["recipes"].map do |id, recipe|
14
+ recipe["id"] = id
15
+ new(client, response, recipe)
16
+ end
17
+ end
18
+
19
+ attributes notifyvia: :notify_via,
20
+ sendnotificationwhendown: :send_notification_when_down,
21
+ notifyagainevery: :notify_again_every
22
+
23
+ def summary
24
+ @client.tms_summary(id)
25
+ end
26
+
27
+ def created_at
28
+ Time.at(super)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,40 @@
1
+ module Pingdom
2
+ class TMSSummary < Base
3
+ class Proxy < Struct.new(:client, :id)
4
+ def average(options = {})
5
+ options.reverse_merge!(includeuptime: true)
6
+ Average.parse(client, client.get("tms.summary.average/#{id}", options))
7
+ end
8
+ alias_method :averages, :average
9
+
10
+ def outage(options = {})
11
+ options.reverse_merge!(includeuptime: true)
12
+ Outage.parse(client, client.get("tms.summary.outage/#{id}", options))
13
+ end
14
+ alias_method :outages, :outage
15
+
16
+ def performance(options = {})
17
+ options.reverse_merge!(resolution: :day, includeuptime: true)
18
+ Performance.parse(client, client.get("tms.summary.performance/#{id}", options))
19
+ end
20
+ end
21
+
22
+ def self.proxy(client, recipe)
23
+ Proxy.new(client, recipe)
24
+ end
25
+
26
+ def from
27
+ Time.at(@attributes[:from])
28
+ end
29
+
30
+ def to
31
+ Time.at(@attributes[:to])
32
+ end
33
+
34
+ attributes responsetime: :response_time
35
+
36
+ # {"status"=>{"totalup"=>5035757, "totalunknown"=>1293069551, "totaldown"=>5078}}
37
+ class Status < Base
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,44 @@
1
+ module Pingdom
2
+ class TMSSummary
3
+ # summary.average includeuptime
4
+ # {
5
+ # "responsetime"=>{
6
+ # "#"=>[
7
+ # {"avgresponse"=>994},
8
+ # {"avgresponse"=>6}
9
+ # ],
10
+ # "avgresponse"=>1000,"from"=>0, "to"=>1500000000
11
+ # },
12
+ # "status"=>{"totalup"=>5035757, "totalunknown"=>1293069551, "totaldown"=>5078}
13
+ # }
14
+ class Average < Base
15
+ class Ingredient < Base
16
+ def self.parse(client, response)
17
+ sum = response.dup
18
+ sum["responsetime"] = sum.delete("avgresponse")
19
+ new client, sum
20
+ end
21
+
22
+ attributes responsetime: :response_time
23
+ end
24
+
25
+ def self.parse(client, response)
26
+ body = super["summary"]
27
+ sum = body["responsetime"]
28
+
29
+ sum["status"] = Status.new(client, response, body["status"]) if body.key?("status")
30
+
31
+ sum["responsetime"] = sum.delete("avgresponse")
32
+
33
+ new(client, response, sum)
34
+ end
35
+
36
+ def ingredients
37
+ @attributes["#"].map { |ingredient| Ingredient.new @client, ingredient }
38
+ end
39
+ alias_method :per_ingredient, :ingredients
40
+
41
+ attributes responsetime: :response_time
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,37 @@
1
+ module Pingdom
2
+ class TMSSummary
3
+ # summary.outage
4
+ # {"states"=>[
5
+ # {"actual_timefrom"=>1500000005,"revision"=>12345,"status"=>"up",
6
+ # "timefrom"=>0,"timeto"=>1500005000}
7
+ # ]}
8
+ class Outage < Base
9
+ def self.parse(client, response)
10
+ super["summary"]["states"].select { |s| s["status"] == "down" }.
11
+ map do |outage|
12
+ new(client, response, outage)
13
+ end
14
+ end
15
+
16
+ def downtime
17
+ (@attributes["timeto"] - @attributes["timefrom"]).seconds
18
+ end
19
+
20
+ def timefrom
21
+ Time.at(@attributes["timefrom"])
22
+ end
23
+
24
+ def timeto
25
+ Time.at(@attributes["timeto"])
26
+ end
27
+
28
+ def actual_timefrom
29
+ Time.at(@attributes["actual_timefrom"])
30
+ end
31
+
32
+ attributes timefrom: [:time_from, :from],
33
+ timeto: [:time_to, :to],
34
+ actual_timefrom: [:actual_time_from, :actual_from]
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,78 @@
1
+ module Pingdom
2
+ class TMSSummary
3
+ # summary.performance includeuptime resolution=day
4
+ # {"days"=>[
5
+ # {
6
+ # "#"=>[
7
+ # {"avgresponse"=>994,"command"=>"Go to URL http://google.com"},
8
+ # {"avgresponse"=>6,"command"=>"URL should be http://google.com"}
9
+ # ],
10
+ # "avgresponse"=>1000,"downtime"=>0,"starttime"=>1500000000,"unmonitored"=>0,
11
+ # "uptime"=>86400,"revision"=>12345
12
+ # }
13
+ # ]}
14
+ class Performance < Base
15
+ class Ingredient < Base
16
+ def self.parse(client, response)
17
+ new(client, response, response)
18
+ end
19
+
20
+ attributes avgresponse: :response_time
21
+ end
22
+
23
+ INTERVALS = {
24
+ "hour" => 1.hour,
25
+ "day" => 1.day,
26
+ "week" => 1.week,
27
+ }.freeze
28
+
29
+ def self.parse(client, response)
30
+ body = super["summary"]
31
+ interval = body.keys.detect { |k| INTERVALS.keys.include?(k.chomp("s").to_s) }.chomp("s").to_sym
32
+ intervals = body[interval.to_s.pluralize]
33
+
34
+ intervals.map do |perf|
35
+ perf["interval"] = interval
36
+ new(client, response, perf)
37
+ end
38
+ end
39
+
40
+ def ingredients
41
+ @attributes["#"].map { |ingredient| Ingredient.new @client, ingredient }
42
+ end
43
+ alias_method :per_ingredient, :ingredients
44
+
45
+ def starttime
46
+ Time.at(@attributes["starttime"])
47
+ end
48
+ alias_method :start_at, :starttime
49
+
50
+ def endtime
51
+ starttime + INTERVALS[interval.to_s].to_i
52
+ end
53
+ alias_method :end_at, :endtime
54
+
55
+ def uptime
56
+ @attributes["uptime"].seconds
57
+ end
58
+
59
+ def downtime
60
+ @attributes["downtime"].seconds
61
+ end
62
+
63
+ def unmonitored
64
+ @attributes["unmonitored"].seconds
65
+ end
66
+
67
+ def monitored
68
+ uptime + downtime
69
+ end
70
+
71
+ def period
72
+ monitored + unmonitored
73
+ end
74
+
75
+ attributes avgresponse: :response_time
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,3 @@
1
+ module Pingdom
2
+ VERSION = "1.0.0".freeze
3
+ end
@@ -6,8 +6,8 @@ describe Pingdom::Client do
6
6
  describe "#test!" do
7
7
  it "should test a single endpoint" do
8
8
  response = client.test!(host: "pingdom.com", type: "http")
9
- response.status.should == "up"
10
- response.responsetime.should be_a(Numeric)
9
+ expect(response.status).to eq("up")
10
+ expect(response.responsetime).to be_a(Numeric)
11
11
  end
12
12
  end
13
13
 
@@ -16,8 +16,30 @@ describe Pingdom::Client do
16
16
  checks = client.checks
17
17
 
18
18
  first = checks.first
19
- first.should be_a(Pingdom::Check)
20
- first.last_response_time.should be_a(Numeric)
19
+ expect(first).to be_a(Pingdom::Check)
20
+ expect(first.last_response_time).to be_a(Numeric)
21
+ end
22
+ end
23
+
24
+ describe "#tms_recipes" do
25
+ it "should get a list of transaction check recipes" do
26
+ tms_recipes = client.tms_recipes
27
+
28
+ first = tms_recipes.first
29
+ expect(first).to be_a(Pingdom::TMSRecipe)
30
+ expect(first.name).to be_a(String)
31
+ end
32
+ end
33
+
34
+ describe "#tms_summary" do
35
+ let(:recipe) { client.tms_recipes.first }
36
+
37
+ it "should return a proxy to retrieve an average summary" do
38
+ average = client.tms_summary(recipe.id).average
39
+
40
+ expect(average).to be_a(Pingdom::TMSSummary::Average)
41
+ expect(average.response_time).to be_a(Numeric)
42
+ expect(average.ingredients.first).to be_a(Pingdom::TMSSummary::Average::Ingredient)
21
43
  end
22
44
  end
23
45
 
@@ -31,11 +53,11 @@ describe Pingdom::Client do
31
53
  end
32
54
 
33
55
  it "should indicate how many requests can be made" do
34
- limit[:remaining].should be_a(Numeric)
56
+ expect(limit[:remaining]).to be_a(Numeric)
35
57
  end
36
58
 
37
59
  it "should indicate when the current limit will be reset" do
38
- limit[:resets_at].acts_like?(:time).should be_true
60
+ expect(limit[:resets_at].acts_like?(:time)).to be_truthy
39
61
  end
40
62
  end
41
63
  end
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,7 @@ require "rubygems"
3
3
  require "bundler/setup"
4
4
  require "pingdom-faraday"
5
5
 
6
+ require "byebug"
6
7
  require "logger"
7
8
  require "rspec"
8
9
  require "yaml"
data/spec/test.log ADDED
@@ -0,0 +1 @@
1
+ # Logfile created on 2015-08-11 16:09:38 -0600 by logger.rb/47272
metadata CHANGED
@@ -1,16 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pingdom-faraday
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Brennan
8
+ - Jonathan la Cour
8
9
  - Jason Straughan
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2015-08-11 00:00:00.000000000 Z
13
+ date: 2018-04-04 00:00:00.000000000 Z
13
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '4.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '4.0'
14
29
  - !ruby/object:Gem::Dependency
15
30
  name: faraday
16
31
  requirement: !ruby/object:Gem::Requirement
@@ -40,19 +55,33 @@ dependencies:
40
55
  - !ruby/object:Gem::Version
41
56
  version: '0'
42
57
  - !ruby/object:Gem::Dependency
43
- name: activesupport
58
+ name: byebug
44
59
  requirement: !ruby/object:Gem::Requirement
45
60
  requirements:
46
- - - "~>"
61
+ - - ">="
47
62
  - !ruby/object:Gem::Version
48
- version: '5.0'
49
- type: :runtime
63
+ version: '0'
64
+ type: :development
50
65
  prerelease: false
51
66
  version_requirements: !ruby/object:Gem::Requirement
52
67
  requirements:
53
- - - "~>"
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rake
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
54
83
  - !ruby/object:Gem::Version
55
- version: '5.0'
84
+ version: '0'
56
85
  - !ruby/object:Gem::Dependency
57
86
  name: rspec
58
87
  requirement: !ruby/object:Gem::Requirement
@@ -83,14 +112,14 @@ dependencies:
83
112
  version: '0'
84
113
  description: Pingdom Ruby Client
85
114
  email:
86
- - andyvaldez75@gmail.com
115
+ - andy@hund.io
116
+ - jonathan@hund.io
87
117
  - jasons@grok-interactive.com
88
118
  executables: []
89
119
  extensions: []
90
120
  extra_rdoc_files: []
91
121
  files:
92
- - Gemfile
93
- - Gemfile.lock
122
+ - LICENSE
94
123
  - README.md
95
124
  - Rakefile
96
125
  - lib/pingdom-faraday.rb
@@ -105,11 +134,17 @@ files:
105
134
  - lib/pingdom/summary/average.rb
106
135
  - lib/pingdom/summary/outage.rb
107
136
  - lib/pingdom/summary/performance.rb
137
+ - lib/pingdom/tms_recipe.rb
138
+ - lib/pingdom/tms_summary.rb
139
+ - lib/pingdom/tms_summary/average.rb
140
+ - lib/pingdom/tms_summary/outage.rb
141
+ - lib/pingdom/tms_summary/performance.rb
142
+ - lib/pingdom/version.rb
108
143
  - lib/tinder/faraday_response.rb
109
- - pingdom-faraday.gemspec
110
144
  - spec/pingdom-faraday_spec.rb
111
145
  - spec/spec_helper.rb
112
- homepage: https://github.com/Valdez42/pingdom-faraday
146
+ - spec/test.log
147
+ homepage: https://github.com/hundio/pingdom-faraday
113
148
  licenses:
114
149
  - MIT
115
150
  metadata: {}
@@ -129,10 +164,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
164
  version: '0'
130
165
  requirements: []
131
166
  rubyforge_project:
132
- rubygems_version: 2.5.1
167
+ rubygems_version: 2.5.2
133
168
  signing_key:
134
169
  specification_version: 4
135
170
  summary: Pingdom Ruby Client
136
171
  test_files:
137
- - spec/spec_helper.rb
138
172
  - spec/pingdom-faraday_spec.rb
173
+ - spec/test.log
174
+ - spec/spec_helper.rb
175
+ has_rdoc:
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
data/Gemfile.lock DELETED
@@ -1,66 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- pingdom-faraday (0.1.0)
5
- activesupport (~> 5.0)
6
- faraday
7
- faraday_middleware
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- activesupport (5.0.0.1)
13
- concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (~> 0.7)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- ast (2.1.0)
18
- astrolabe (1.3.1)
19
- parser (~> 2.2)
20
- concurrent-ruby (1.0.2)
21
- diff-lcs (1.2.5)
22
- faraday (0.9.2)
23
- multipart-post (>= 1.2, < 3)
24
- faraday_middleware (0.10.0)
25
- faraday (>= 0.7.4, < 0.10)
26
- i18n (0.7.0)
27
- minitest (5.9.0)
28
- multipart-post (2.0.0)
29
- parser (2.2.2.6)
30
- ast (>= 1.1, < 3.0)
31
- powerpack (0.1.1)
32
- rainbow (2.0.0)
33
- rspec (3.5.0)
34
- rspec-core (~> 3.5.0)
35
- rspec-expectations (~> 3.5.0)
36
- rspec-mocks (~> 3.5.0)
37
- rspec-core (3.5.3)
38
- rspec-support (~> 3.5.0)
39
- rspec-expectations (3.5.0)
40
- diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.5.0)
42
- rspec-mocks (3.5.0)
43
- diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.5.0)
45
- rspec-support (3.5.0)
46
- rubocop (0.33.0)
47
- astrolabe (~> 1.3)
48
- parser (>= 2.2.2.5, < 3.0)
49
- powerpack (~> 0.1)
50
- rainbow (>= 1.99.1, < 3.0)
51
- ruby-progressbar (~> 1.4)
52
- ruby-progressbar (1.7.5)
53
- thread_safe (0.3.5)
54
- tzinfo (1.2.2)
55
- thread_safe (~> 0.1)
56
-
57
- PLATFORMS
58
- ruby
59
-
60
- DEPENDENCIES
61
- pingdom-faraday!
62
- rspec (~> 3.5)
63
- rubocop
64
-
65
- BUNDLED WITH
66
- 1.13.0
@@ -1,44 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = "pingdom-faraday"
3
- s.version = "0.1.0"
4
-
5
- s.authors = ["Andy Brennan", "Jason Straughan"]
6
- s.homepage = "https://github.com/Valdez42/pingdom-faraday"
7
- s.date = "2015-08-11"
8
- s.description = "Pingdom Ruby Client"
9
- s.email = ["andyvaldez75@gmail.com", "jasons@grok-interactive.com"]
10
- s.files = [
11
- "pingdom-faraday.gemspec",
12
- "Gemfile",
13
- "Gemfile.lock",
14
- "lib/pingdom/base.rb",
15
- "lib/pingdom/check.rb",
16
- "lib/pingdom/client.rb",
17
- "lib/pingdom/contact.rb",
18
- "lib/pingdom/probe.rb",
19
- "lib/pingdom/result.rb",
20
- "lib/pingdom/summary/average.rb",
21
- "lib/pingdom/summary/outage.rb",
22
- "lib/pingdom/summary/performance.rb",
23
- "lib/pingdom/summary.rb",
24
- "lib/pingdom-faraday.rb",
25
- "lib/pingdom.rb",
26
- "lib/tinder/faraday_response.rb",
27
- "Rakefile",
28
- "README.md",
29
- "spec/pingdom-faraday_spec.rb",
30
- "spec/spec_helper.rb",
31
- ]
32
- s.licenses = ["MIT"]
33
- s.require_paths = ["lib"]
34
- s.add_dependency "faraday"
35
- s.add_dependency "faraday_middleware"
36
- s.add_dependency "activesupport", "~> 5.0"
37
- s.add_development_dependency "rspec", "~> 3.5"
38
- s.add_development_dependency "rubocop"
39
- s.summary = "Pingdom Ruby Client"
40
- s.test_files = [
41
- "spec/spec_helper.rb",
42
- "spec/pingdom-faraday_spec.rb",
43
- ]
44
- end