stathat 0.0.3 → 0.0.4
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.
- data/LICENSE.txt +1 -1
- data/README.rdoc +2 -3
- data/VERSION +1 -1
- data/lib/stathat.rb +48 -17
- data/stathat.gemspec +3 -4
- data/test/test_stathat.rb +27 -3
- metadata +69 -100
data/LICENSE.txt
CHANGED
data/README.rdoc
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Description goes here.
|
|
4
4
|
|
|
5
5
|
== Contributing to stathat
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
|
8
8
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
|
9
9
|
* Fork the project
|
|
@@ -14,6 +14,5 @@ Description goes here.
|
|
|
14
14
|
|
|
15
15
|
== Copyright
|
|
16
16
|
|
|
17
|
-
Copyright (c) 2011
|
|
18
|
-
further details.
|
|
17
|
+
Copyright (c) 2011-2012 Numerotron Inc. See LICENSE.txt for further details.
|
|
19
18
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.4
|
data/lib/stathat.rb
CHANGED
|
@@ -1,42 +1,73 @@
|
|
|
1
1
|
require 'net/http'
|
|
2
2
|
require 'uri'
|
|
3
|
+
require 'json'
|
|
3
4
|
|
|
4
5
|
module StatHat
|
|
5
6
|
class API
|
|
7
|
+
CLASSIC_VALUE_URL = "http://api.stathat.com/v"
|
|
8
|
+
CLASSIC_COUNT_URL = "http://api.stathat.com/c"
|
|
9
|
+
EZ_URL = "http://api.stathat.com/ez"
|
|
10
|
+
|
|
6
11
|
def self.post_value(stat_key, user_key, value)
|
|
7
12
|
args = { :key => stat_key,
|
|
8
13
|
:ukey => user_key,
|
|
9
14
|
:value => value }
|
|
10
|
-
|
|
11
|
-
return self.response_valid?(resp)
|
|
15
|
+
return self.send_to_stathat(CLASSIC_VALUE_URL, args)
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
def self.post_count(stat_key, user_key, count)
|
|
15
19
|
args = { :key => stat_key,
|
|
16
20
|
:ukey => user_key,
|
|
17
|
-
:value =>
|
|
18
|
-
|
|
19
|
-
return self.response_valid?(resp)
|
|
21
|
+
:value => count }
|
|
22
|
+
return self.send_to_stathat(CLASSIC_COUNT_URL, args)
|
|
20
23
|
end
|
|
21
24
|
|
|
22
|
-
def self.ez_post_value(stat_name,
|
|
23
|
-
args = { :stat => stat_name,
|
|
24
|
-
:
|
|
25
|
+
def self.ez_post_value(stat_name, ezkey, value)
|
|
26
|
+
args = { :stat => stat_name,
|
|
27
|
+
:ezkey => ezkey,
|
|
25
28
|
:value => value }
|
|
26
|
-
|
|
27
|
-
return self.response_valid?(resp)
|
|
29
|
+
return self.send_to_stathat(EZ_URL, args)
|
|
28
30
|
end
|
|
29
31
|
|
|
30
|
-
def self.ez_post_count(stat_name,
|
|
31
|
-
args = { :stat => stat_name,
|
|
32
|
-
:
|
|
32
|
+
def self.ez_post_count(stat_name, ezkey, count)
|
|
33
|
+
args = { :stat => stat_name,
|
|
34
|
+
:ezkey => ezkey,
|
|
33
35
|
:count => count }
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
return self.send_to_stathat(EZ_URL, args)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.send_to_stathat(url, args)
|
|
40
|
+
uri = URI.parse(url)
|
|
41
|
+
uri.query = URI.encode_www_form(args)
|
|
42
|
+
resp = Net::HTTP.get(uri)
|
|
43
|
+
return Response.new(resp)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class Response
|
|
48
|
+
def initialize(body)
|
|
49
|
+
@body = body
|
|
50
|
+
@parsed = nil
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def valid?
|
|
54
|
+
return status == 200
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def status
|
|
58
|
+
parse
|
|
59
|
+
return @parsed['status']
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def msg
|
|
63
|
+
parse
|
|
64
|
+
return @parsed['msg']
|
|
36
65
|
end
|
|
37
66
|
|
|
38
|
-
|
|
39
|
-
|
|
67
|
+
private
|
|
68
|
+
def parse
|
|
69
|
+
return unless @parsed.nil?
|
|
70
|
+
@parsed = JSON.parse(@body)
|
|
40
71
|
end
|
|
41
72
|
end
|
|
42
73
|
end
|
data/stathat.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{stathat}
|
|
8
|
-
s.version = "0.0.
|
|
8
|
+
s.version = "0.0.4"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Patrick Crosby"]
|
|
12
|
-
s.date = %q{
|
|
12
|
+
s.date = %q{2012-05-17}
|
|
13
13
|
s.description = %q{Easily post stats to your StatHat account using this gem. Encapsulates full API.}
|
|
14
14
|
s.email = %q{patrick@xblabs.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
|
32
32
|
s.homepage = %q{http://github.com/patrickxb/stathat}
|
|
33
33
|
s.licenses = ["MIT"]
|
|
34
34
|
s.require_paths = ["lib"]
|
|
35
|
-
s.rubygems_version = %q{1.
|
|
35
|
+
s.rubygems_version = %q{1.5.0}
|
|
36
36
|
s.summary = %q{gem to access StatHat api}
|
|
37
37
|
s.test_files = [
|
|
38
38
|
"test/helper.rb",
|
|
@@ -40,7 +40,6 @@ Gem::Specification.new do |s|
|
|
|
40
40
|
]
|
|
41
41
|
|
|
42
42
|
if s.respond_to? :specification_version then
|
|
43
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
44
43
|
s.specification_version = 3
|
|
45
44
|
|
|
46
45
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/test/test_stathat.rb
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
require 'helper'
|
|
2
2
|
|
|
3
3
|
class TestStathat < MiniTest::Unit::TestCase
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
def test_ez_value
|
|
5
|
+
r = StatHat::API.ez_post_value("test ez value stat", "patrick@stathat.com", 0.92)
|
|
6
|
+
assert(r.valid?, "response was invalid")
|
|
7
|
+
assert_equal(r.msg, "ok", "message should be 'ok'")
|
|
8
|
+
assert_equal(r.status, 200, "status should be 200")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_ez_count
|
|
12
|
+
r = StatHat::API.ez_post_value("test ez count stat", "patrick@stathat.com", 12)
|
|
13
|
+
assert(r.valid?, "response was invalid")
|
|
14
|
+
assert_equal(r.msg, "ok", "message should be 'ok'")
|
|
15
|
+
assert_equal(r.status, 200, "status should be 200")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_classic_count_bad_keys
|
|
19
|
+
r = StatHat::API.post_count("XXXXXXXX", "YYYYYYYY", 12)
|
|
20
|
+
assert_equal(r.valid?, false, "response was valid")
|
|
21
|
+
assert_equal(r.msg, "invalid keys", "incorrect error message")
|
|
22
|
+
assert_equal(r.status, 500, "incorrect status code")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_classic_value_bad_keys
|
|
26
|
+
r = StatHat::API.post_value("ZZZZZZZZ", "YYYYYYYYY", 0.92)
|
|
27
|
+
assert_equal(r.valid?, false, "response was valid")
|
|
28
|
+
assert_equal(r.msg, "invalid keys", "incorrect error message")
|
|
29
|
+
assert_equal(r.status, 500, "incorrect status code")
|
|
30
|
+
end
|
|
7
31
|
end
|
metadata
CHANGED
|
@@ -1,107 +1,81 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stathat
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 0
|
|
9
|
-
- 3
|
|
10
|
-
version: 0.0.3
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.4
|
|
5
|
+
prerelease: !!null
|
|
11
6
|
platform: ruby
|
|
12
|
-
authors:
|
|
7
|
+
authors:
|
|
13
8
|
- Patrick Crosby
|
|
14
|
-
autorequire:
|
|
9
|
+
autorequire: !!null
|
|
15
10
|
bindir: bin
|
|
16
11
|
cert_chain: []
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- !ruby/object:Gem::Dependency
|
|
22
|
-
prerelease: false
|
|
23
|
-
type: :development
|
|
12
|
+
date: 2012-05-17 00:00:00.000000000 -05:00
|
|
13
|
+
default_executable: !!null
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
24
16
|
name: minitest
|
|
25
|
-
|
|
17
|
+
requirement: &2164726900 !ruby/object:Gem::Requirement
|
|
26
18
|
none: false
|
|
27
|
-
requirements:
|
|
28
|
-
- -
|
|
29
|
-
- !ruby/object:Gem::Version
|
|
30
|
-
|
|
31
|
-
segments:
|
|
32
|
-
- 0
|
|
33
|
-
version: "0"
|
|
34
|
-
requirement: *id001
|
|
35
|
-
- !ruby/object:Gem::Dependency
|
|
36
|
-
prerelease: false
|
|
19
|
+
requirements:
|
|
20
|
+
- - ! '>='
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '0'
|
|
37
23
|
type: :development
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: *2164726900
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
38
27
|
name: bundler
|
|
39
|
-
|
|
28
|
+
requirement: &2164726240 !ruby/object:Gem::Requirement
|
|
40
29
|
none: false
|
|
41
|
-
requirements:
|
|
30
|
+
requirements:
|
|
42
31
|
- - ~>
|
|
43
|
-
- !ruby/object:Gem::Version
|
|
44
|
-
hash: 23
|
|
45
|
-
segments:
|
|
46
|
-
- 1
|
|
47
|
-
- 0
|
|
48
|
-
- 0
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
49
33
|
version: 1.0.0
|
|
50
|
-
requirement: *id002
|
|
51
|
-
- !ruby/object:Gem::Dependency
|
|
52
|
-
prerelease: false
|
|
53
34
|
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: *2164726240
|
|
37
|
+
- !ruby/object:Gem::Dependency
|
|
54
38
|
name: jeweler
|
|
55
|
-
|
|
39
|
+
requirement: &2164725140 !ruby/object:Gem::Requirement
|
|
56
40
|
none: false
|
|
57
|
-
requirements:
|
|
41
|
+
requirements:
|
|
58
42
|
- - ~>
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
hash: 7
|
|
61
|
-
segments:
|
|
62
|
-
- 1
|
|
63
|
-
- 5
|
|
64
|
-
- 2
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
65
44
|
version: 1.5.2
|
|
66
|
-
requirement: *id003
|
|
67
|
-
- !ruby/object:Gem::Dependency
|
|
68
|
-
prerelease: false
|
|
69
45
|
type: :development
|
|
46
|
+
prerelease: false
|
|
47
|
+
version_requirements: *2164725140
|
|
48
|
+
- !ruby/object:Gem::Dependency
|
|
70
49
|
name: rcov
|
|
71
|
-
|
|
50
|
+
requirement: &2164724040 !ruby/object:Gem::Requirement
|
|
72
51
|
none: false
|
|
73
|
-
requirements:
|
|
74
|
-
- -
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
|
|
77
|
-
segments:
|
|
78
|
-
- 0
|
|
79
|
-
version: "0"
|
|
80
|
-
requirement: *id004
|
|
81
|
-
- !ruby/object:Gem::Dependency
|
|
82
|
-
prerelease: false
|
|
52
|
+
requirements:
|
|
53
|
+
- - ! '>='
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
83
56
|
type: :development
|
|
57
|
+
prerelease: false
|
|
58
|
+
version_requirements: *2164724040
|
|
59
|
+
- !ruby/object:Gem::Dependency
|
|
84
60
|
name: rocco
|
|
85
|
-
|
|
61
|
+
requirement: &2164723120 !ruby/object:Gem::Requirement
|
|
86
62
|
none: false
|
|
87
|
-
requirements:
|
|
88
|
-
- -
|
|
89
|
-
- !ruby/object:Gem::Version
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
63
|
+
requirements:
|
|
64
|
+
- - ! '>='
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '0'
|
|
67
|
+
type: :development
|
|
68
|
+
prerelease: false
|
|
69
|
+
version_requirements: *2164723120
|
|
70
|
+
description: Easily post stats to your StatHat account using this gem. Encapsulates
|
|
71
|
+
full API.
|
|
96
72
|
email: patrick@xblabs.com
|
|
97
73
|
executables: []
|
|
98
|
-
|
|
99
74
|
extensions: []
|
|
100
|
-
|
|
101
|
-
extra_rdoc_files:
|
|
75
|
+
extra_rdoc_files:
|
|
102
76
|
- LICENSE.txt
|
|
103
77
|
- README.rdoc
|
|
104
|
-
files:
|
|
78
|
+
files:
|
|
105
79
|
- .document
|
|
106
80
|
- Gemfile
|
|
107
81
|
- Gemfile.lock
|
|
@@ -115,38 +89,33 @@ files:
|
|
|
115
89
|
- test/test_stathat.rb
|
|
116
90
|
has_rdoc: true
|
|
117
91
|
homepage: http://github.com/patrickxb/stathat
|
|
118
|
-
licenses:
|
|
92
|
+
licenses:
|
|
119
93
|
- MIT
|
|
120
|
-
post_install_message:
|
|
94
|
+
post_install_message: !!null
|
|
121
95
|
rdoc_options: []
|
|
122
|
-
|
|
123
|
-
require_paths:
|
|
96
|
+
require_paths:
|
|
124
97
|
- lib
|
|
125
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
99
|
none: false
|
|
127
|
-
requirements:
|
|
128
|
-
- -
|
|
129
|
-
- !ruby/object:Gem::Version
|
|
130
|
-
|
|
131
|
-
segments:
|
|
100
|
+
requirements:
|
|
101
|
+
- - ! '>='
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
segments:
|
|
132
105
|
- 0
|
|
133
|
-
|
|
134
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
|
+
hash: 4543194583590350390
|
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
108
|
none: false
|
|
136
|
-
requirements:
|
|
137
|
-
- -
|
|
138
|
-
- !ruby/object:Gem::Version
|
|
139
|
-
|
|
140
|
-
segments:
|
|
141
|
-
- 0
|
|
142
|
-
version: "0"
|
|
109
|
+
requirements:
|
|
110
|
+
- - ! '>='
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: '0'
|
|
143
113
|
requirements: []
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
signing_key:
|
|
114
|
+
rubyforge_project: !!null
|
|
115
|
+
rubygems_version: 1.5.0
|
|
116
|
+
signing_key: !!null
|
|
148
117
|
specification_version: 3
|
|
149
118
|
summary: gem to access StatHat api
|
|
150
|
-
test_files:
|
|
119
|
+
test_files:
|
|
151
120
|
- test/helper.rb
|
|
152
121
|
- test/test_stathat.rb
|