Class: Chartbeat

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/chartbeat.rb

Constant Summary collapse

YESTERDAY =

historical calls

Time.now.to_i - 86400

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Chartbeat

c = Chartbeat.new :apikey => ‘yourkey’, :host => ‘yourdomain.com’



10
11
12
13
# File 'lib/chartbeat.rb', line 10

def initialize(opts = {})
  self.class.default_params :apikey => opts[:apikey]
  self.class.default_params :host => opts[:host]
end

Instance Method Details

#alerts(opts = {}) ⇒ Object

defaults to yesterday



64
65
66
67
68
69
# File 'lib/chartbeat.rb', line 64

def alerts(opts = {})
  q = { :since => YESTERDAY 
      }.merge!(opts)
      
  self.class.get("/dashapi/alerts/", :query => q)
end

#data_series(opts = {}) ⇒ Object

NOT WORKING, “We’re most likely pushing out some new changes.”



83
84
85
86
87
88
89
90
91
92
# File 'lib/chartbeat.rb', line 83

def data_series(opts = {})
  q = { :timestamp => YESTERDAY,
        :days => 1,
        :minutes => 20,
        :type => 'path',
        :val => nil
      }.merge!(opts)
  
  self.class.get("/dashapi/data_series/", :query => q)
end

#day_data_series(opts = {}) ⇒ Object



94
95
96
97
98
99
100
# File 'lib/chartbeat.rb', line 94

def day_data_series(opts = {})
  q = { :timestamp => YESTERDAY,
        :type => 'paths'
      }.merge!(opts)
 
 self.class.get("/dashapi/day_data_series/", :query => q) 
end

#histogram(opts = {}) ⇒ Object

other calls



106
107
108
109
110
111
112
113
# File 'lib/chartbeat.rb', line 106

def histogram(opts = {})
  q = { :keys => 'n',
        :breaks => 'n',
        :path => nil
      }.merge!(opts)

  self.class.get('/histogram/', :query => q)
end

#pages(opts = {}) ⇒ Object

c.pages :path => ‘/’



20
21
22
23
24
25
# File 'lib/chartbeat.rb', line 20

def pages(opts = {})
  q = { :path => nil
      }.merge!(opts)
      
  self.class.get("/pages/", :query => q)
end

#pathsummary(opts = {}) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/chartbeat.rb', line 27

def pathsummary(opts = {})
  q = { :keys => 'n',
        :types => 'n'
      }.merge!(opts)
  
  self.class.get("/pathsummary/", :query => q)
end

#recent(opts = {}) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/chartbeat.rb', line 35

def recent(opts = {})
  q = { :limit => nil,
        :path => '/' 
       }.merge!(opts)
  
  self.class.get("/recent/", :query => q)
end

#snapshots(opts = {}) ⇒ Object



71
72
73
74
75
76
# File 'lib/chartbeat.rb', line 71

def snapshots(opts = {})
  q = { :timestamp => YESTERDAY
      }.merge!(opts)
      
  self.class.get("/dashapi/snapshots/", :query => q)
end

#statsObject



78
79
80
# File 'lib/chartbeat.rb', line 78

def stats
  self.class.get("/dashapi/stats/")
end

#summary(opts = {}) ⇒ Object



115
116
117
118
119
120
121
122
# File 'lib/chartbeat.rb', line 115

def summary(opts = {})
  q = { :keys => 'n',
        :types => 'n',
        :path => nil
      }.merge!(opts)
  
  self.class.get('/summary/', :query => q)
end

#summize(opts = {}) ⇒ Object



43
44
45
46
47
48
# File 'lib/chartbeat.rb', line 43

def summize(opts = {})
  q = { :path => '/'
      }.merge!(opts)
      
  self.class.get("/summize/", :query => q)
end

#toppages(opts = {}) ⇒ Object



50
51
52
53
54
55
# File 'lib/chartbeat.rb', line 50

def toppages(opts = {})
  q = { :limit => nil
      }.merge!(opts)
      
  self.class.get("/toppages/", :query => q)
end