sappy 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/{README.markdown → README.md} +4 -0
- data/VERSION +1 -1
- data/lib/sappy.rb +1 -0
- data/lib/sappy/monitor.rb +6 -6
- data/lib/sappy/responses.rb +7 -1
- data/lib/sappy/responses/annual_statistics.rb +11 -0
- data/lib/sappy/responses/daily_statistics.rb +11 -0
- data/lib/sappy/responses/monthly_statistics.rb +11 -0
- data/lib/sappy/statistics.rb +3 -0
- data/lib/sappy/statistics/annual.rb +15 -0
- data/lib/sappy/statistics/daily.rb +15 -0
- data/lib/sappy/statistics/monthly.rb +17 -0
- data/spec/sappy/monitor_bacon.rb +26 -0
- metadata +11 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/sappy.rb
CHANGED
data/lib/sappy/monitor.rb
CHANGED
@@ -132,16 +132,16 @@ module Sappy
|
|
132
132
|
@account.request('removemonitor', "MonitorId" => id)
|
133
133
|
end
|
134
134
|
|
135
|
-
def daily_statistics
|
136
|
-
|
135
|
+
def daily_statistics(year, month, day)
|
136
|
+
Statistics::Daily.new(@account.request('dailystatistics', "MonitorId" => id, "Year" => year, "Month" => month, "Day" => day).statistics)
|
137
137
|
end
|
138
138
|
|
139
|
-
def monthly_statistics
|
140
|
-
|
139
|
+
def monthly_statistics(year, month)
|
140
|
+
Statistics::Monthly.new(@account.request('monthlystatistics', "MonitorId" => id, "Year" => year, "Month" => month).statistics)
|
141
141
|
end
|
142
142
|
|
143
|
-
def annual_statistics
|
144
|
-
|
143
|
+
def annual_statistics(year = "")
|
144
|
+
Statistics::Annual.new(@account.request('annualstatistics', "MonitorId" => id, "Year" => year).statistics)
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
data/lib/sappy/responses.rb
CHANGED
@@ -7,6 +7,9 @@ require 'sappy/responses/edit_monitor'
|
|
7
7
|
require 'sappy/responses/remove_monitor'
|
8
8
|
require 'sappy/responses/enable_monitor'
|
9
9
|
require 'sappy/responses/disable_monitor'
|
10
|
+
require 'sappy/responses/daily_statistics'
|
11
|
+
require 'sappy/responses/monthly_statistics'
|
12
|
+
require 'sappy/responses/annual_statistics'
|
10
13
|
|
11
14
|
module Sappy
|
12
15
|
module Responses
|
@@ -19,7 +22,10 @@ module Sappy
|
|
19
22
|
"editmonitor" => EditMonitor,
|
20
23
|
"removemonitor" => RemoveMonitor,
|
21
24
|
"enablemonitor" => EnableMonitor,
|
22
|
-
"disablemonitor" => DisableMonitor
|
25
|
+
"disablemonitor" => DisableMonitor,
|
26
|
+
"dailystatistics" => DailyStatistics,
|
27
|
+
"monthlystatistics" => MonthlyStatistics,
|
28
|
+
"annualstatistics" => AnnualStatistics
|
23
29
|
}
|
24
30
|
|
25
31
|
def self.for(action)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Sappy
|
2
|
+
module Statistics
|
3
|
+
class Annual
|
4
|
+
attr_reader :checks, :failures, :timezone, :total, :uptime
|
5
|
+
|
6
|
+
def initialize(attributes = {})
|
7
|
+
@checks = attributes['numchecks']
|
8
|
+
@failures = attributes['numfailures']
|
9
|
+
@timezone = attributes['timezone']
|
10
|
+
@total = attributes['total']
|
11
|
+
@uptime = attributes['uptime']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Sappy
|
2
|
+
module Statistics
|
3
|
+
class Daily
|
4
|
+
attr_reader :checks, :failures, :timezone, :total, :uptime
|
5
|
+
|
6
|
+
def initialize(attributes = {})
|
7
|
+
@checks = attributes[:numchecks]
|
8
|
+
@failures = attributes[:numfailures]
|
9
|
+
@timezone = attributes[:timezone]
|
10
|
+
@total = attributes[:total]
|
11
|
+
@uptime = attributes[:uptime]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Sappy
|
2
|
+
module Statistics
|
3
|
+
class Monthly
|
4
|
+
attr_reader :checks, :failures, :month, :timezone, :total, :uptime, :year
|
5
|
+
|
6
|
+
def initialize(attributes = {})
|
7
|
+
@checks = attributes[:numchecks]
|
8
|
+
@failures = attributes[:numfailures]
|
9
|
+
@month = attributes[:month]
|
10
|
+
@timezone = attributes[:timezone]
|
11
|
+
@total = attributes[:total]
|
12
|
+
@uptime = attributes[:uptime]
|
13
|
+
@year = attributes[:year]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/sappy/monitor_bacon.rb
CHANGED
@@ -45,6 +45,32 @@ module Sappy
|
|
45
45
|
end
|
46
46
|
@account.monitors.size.should == 0
|
47
47
|
end
|
48
|
+
|
49
|
+
describe "statistics" do
|
50
|
+
before do
|
51
|
+
unless ENV['LIVE_SPECS']
|
52
|
+
FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&Month=11&method=siteuptime.dailystatistics&Day=28&Year=2006&MonitorId=84043", :response => cached_page('dailystatistics'))
|
53
|
+
FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&Month=6&method=siteuptime.monthlystatistics&Year=2007&MonitorId=84043", :response => cached_page('monthlystatistics'))
|
54
|
+
FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.annualstatistics&Year=&MonitorId=84043", :response => cached_page('annualstatistics'))
|
55
|
+
end
|
56
|
+
@monitor = @account.add_monitor({:name => "New Monitor", :service => "http", :location => "sf", :host => "engineyard.com", :period => "60"})
|
57
|
+
end
|
58
|
+
|
59
|
+
# it "should provide daily" do
|
60
|
+
# @monitor.daily_statistics(2006, 11, 28).should.be.instance_of Statistics::Daily
|
61
|
+
# end
|
62
|
+
it "should raise error for daily (due to malformed XML from SiteUptime)" do
|
63
|
+
lambda { @monitor.daily_statistics(2006, 11, 28) }.should.raise REXML::ParseException
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should provide monthly" do
|
67
|
+
@monitor.monthly_statistics(2007, 6).should.be.instance_of Statistics::Monthly
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should provide annual" do
|
71
|
+
@monitor.annual_statistics.should.be.instance_of Statistics::Annual
|
72
|
+
end
|
73
|
+
end
|
48
74
|
end
|
49
75
|
end
|
50
76
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sappy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Egan
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-10-
|
13
|
+
date: 2009-10-09 00:00:00 +11:00
|
14
14
|
default_executable: shell
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -52,9 +52,8 @@ executables:
|
|
52
52
|
extensions: []
|
53
53
|
|
54
54
|
extra_rdoc_files:
|
55
|
-
- README.
|
55
|
+
- README.md
|
56
56
|
files:
|
57
|
-
- README.markdown
|
58
57
|
- Rakefile
|
59
58
|
- VERSION
|
60
59
|
- lib/core_ext.rb
|
@@ -67,14 +66,22 @@ files:
|
|
67
66
|
- lib/sappy/responses.rb
|
68
67
|
- lib/sappy/responses/account_info.rb
|
69
68
|
- lib/sappy/responses/add_monitor.rb
|
69
|
+
- lib/sappy/responses/annual_statistics.rb
|
70
70
|
- lib/sappy/responses/auth.rb
|
71
|
+
- lib/sappy/responses/daily_statistics.rb
|
71
72
|
- lib/sappy/responses/disable_monitor.rb
|
72
73
|
- lib/sappy/responses/edit_monitor.rb
|
73
74
|
- lib/sappy/responses/enable_monitor.rb
|
74
75
|
- lib/sappy/responses/error.rb
|
75
76
|
- lib/sappy/responses/monitors.rb
|
77
|
+
- lib/sappy/responses/monthly_statistics.rb
|
76
78
|
- lib/sappy/responses/remove_monitor.rb
|
77
79
|
- lib/sappy/responses/summary_statistics.rb
|
80
|
+
- lib/sappy/statistics.rb
|
81
|
+
- lib/sappy/statistics/annual.rb
|
82
|
+
- lib/sappy/statistics/daily.rb
|
83
|
+
- lib/sappy/statistics/monthly.rb
|
84
|
+
- README.md
|
78
85
|
has_rdoc: true
|
79
86
|
homepage: http://github.com/abcde/sappy
|
80
87
|
licenses: []
|