gauges-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/gauges_api.rb +103 -0
  2. metadata +45 -0
@@ -0,0 +1,103 @@
1
+ require 'json'
2
+ require 'open-uri'
3
+
4
+ module Gauges
5
+ class Client
6
+ BASE_URL = "https://secure.gaug.es"
7
+ attr_accessor :token
8
+ #TOKEN = "b078b3daa71689977fbbf6037fcd71bf"
9
+
10
+ def initialize token
11
+ raise ArgumentError if token.nil?
12
+
13
+ @token = token
14
+ end
15
+
16
+ # Gets user information
17
+ def me
18
+ uri = "#{BASE_URL}/me"
19
+ fetch uri
20
+ end
21
+
22
+ # Gets API clients
23
+ def clients
24
+ uri = "#{BASE_URL}/clients"
25
+ fetch uri
26
+ end
27
+
28
+ # Gets gauges list
29
+ def gauges page = 1
30
+ uri = "#{BASE_URL}/gauges?page=#{page}"
31
+ fetch uri
32
+ end
33
+
34
+ # Gets gauges share information
35
+ def shares id
36
+ uri = "#{BASE_URL}/gauges/#{id}/shares"
37
+ fetch uri
38
+ end
39
+
40
+ # Gets gauges content
41
+ # optional date and page parameters with default values
42
+ def content id, date = Date.today.to_s, page = 1
43
+ uri = "#{BASE_URL}/gauges/#{id}/content?date=#{date}&page=#{page}"
44
+ fetch uri
45
+ end
46
+
47
+ # Gets gauges referrers
48
+ # optional date and page parameters with default values
49
+ def referrers id, date = Date.today.to_s, page = 1
50
+ uri = "#{BASE_URL}/gauges/#{id}/referrers?date=#{date}&page=#{page}"
51
+ fetch uri
52
+ end
53
+
54
+ # Gets gauges traffic
55
+ # optional date parameter with default value
56
+ def traffic id, date = Date.today.to_s
57
+ uri = "#{BASE_URL}/gauges/#{id}/traffic?date=#{date}"
58
+ fetch uri
59
+ end
60
+
61
+ # Gets gauges resolutions
62
+ # optional date parameter with default value
63
+ def resolutions id, date = Date.today.to_s
64
+ uri = "#{BASE_URL}/gauges/#{id}/resolutions?date=#{date}"
65
+ fetch uri
66
+ end
67
+
68
+ # Gets gauges technology
69
+ # optional date parameter with default value
70
+ def technology id, date = Date.today.to_s
71
+ uri = "#{BASE_URL}/gauges/#{id}/technology?date=#{date}"
72
+ fetch uri
73
+ end
74
+
75
+ # Gets gauges terms
76
+ # optional date and page parameters with default values
77
+ def terms id, date = Date.today.to_s, page = 1
78
+ uri = "#{BASE_URL}/gauges/#{id}/terms?date=#{date}&page=#{page}}"
79
+ fetch uri
80
+ end
81
+
82
+ # Gets gauges engines
83
+ # optional date parameter with default value
84
+ def engines id, date = Date.today.to_s
85
+ uri = "#{BASE_URL}/gauges/#{id}/engines?date=#{date}"
86
+ fetch uri
87
+ end
88
+
89
+ # Gets gauges locations
90
+ # optional date parameter with default value
91
+ def locations id, date = Date.today.to_s
92
+ uri = "#{BASE_URL}/gauges/#{id}/locations?date=#{date}"
93
+ fetch uri
94
+ end
95
+
96
+ private
97
+
98
+ def fetch uri
99
+ JSON.parse open(uri, "X-Gauges-Token" => @token).gets
100
+ end
101
+
102
+ end
103
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gauges-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Emre Kılınç
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-29 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Very simplistic, usable gaug.es api gem for using inside ruby applications.
15
+ email: emre@nitro.io
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/gauges_api.rb
21
+ homepage: http://rubygems.org/gems/gauges-api
22
+ licenses: []
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 1.8.24
42
+ signing_key:
43
+ specification_version: 3
44
+ summary: Very simple Gauges Analytics API
45
+ test_files: []