postrank-api 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/postrank-api/api.rb +17 -0
- data/postrank-api.gemspec +5 -2
- data/spec/api_spec.rb +27 -0
- metadata +15 -3
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/postrank-api/api.rb
CHANGED
@@ -79,6 +79,23 @@ module PostRank
|
|
79
79
|
parse(http.response)
|
80
80
|
end
|
81
81
|
|
82
|
+
def domain_activity(domains, opts = {})
|
83
|
+
opts[:start_time] ||= '1 month ago'
|
84
|
+
opts[:end_time] ||= 'today'
|
85
|
+
|
86
|
+
req = {
|
87
|
+
:query => {
|
88
|
+
:appkey => @appkey,
|
89
|
+
:start_time => Chronic.parse(opts[:start_time]).to_i,
|
90
|
+
:end_time => Chronic.parse(opts[:end_time]).to_i
|
91
|
+
},
|
92
|
+
:body => build_body(domains, 'domain')
|
93
|
+
}
|
94
|
+
|
95
|
+
http = post("#{V2_API_BASE}/domain/activity", req)
|
96
|
+
parse(http.response)
|
97
|
+
end
|
98
|
+
|
82
99
|
def metrics(urls, opts = {})
|
83
100
|
reverse = {}
|
84
101
|
urls = [urls].flatten.map do |url|
|
data/postrank-api.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{postrank-api}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ilya Grigorik"]
|
12
|
-
s.date = %q{2010-06-
|
12
|
+
s.date = %q{2010-06-24}
|
13
13
|
s.description = %q{PostRank API Wrapper}
|
14
14
|
s.email = %q{ilya@igvita.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -43,15 +43,18 @@ Gem::Specification.new do |s|
|
|
43
43
|
s.add_runtime_dependency(%q<eventmachine>, [">= 0.12.9"])
|
44
44
|
s.add_runtime_dependency(%q<em-http-request>, [">= 0"])
|
45
45
|
s.add_runtime_dependency(%q<em-synchrony>, [">= 0"])
|
46
|
+
s.add_runtime_dependency(%q<yajl-ruby>, [">= 0"])
|
46
47
|
else
|
47
48
|
s.add_dependency(%q<eventmachine>, [">= 0.12.9"])
|
48
49
|
s.add_dependency(%q<em-http-request>, [">= 0"])
|
49
50
|
s.add_dependency(%q<em-synchrony>, [">= 0"])
|
51
|
+
s.add_dependency(%q<yajl-ruby>, [">= 0"])
|
50
52
|
end
|
51
53
|
else
|
52
54
|
s.add_dependency(%q<eventmachine>, [">= 0.12.9"])
|
53
55
|
s.add_dependency(%q<em-http-request>, [">= 0"])
|
54
56
|
s.add_dependency(%q<em-synchrony>, [">= 0"])
|
57
|
+
s.add_dependency(%q<yajl-ruby>, [">= 0"])
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
data/spec/api_spec.rb
CHANGED
@@ -140,6 +140,33 @@ describe PostRank::API do
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
+
describe "Domain API" do
|
144
|
+
it "should fetch metrics for a collection of domains" do
|
145
|
+
EM.synchrony do
|
146
|
+
activity = api.domain_activity('igvita.com')
|
147
|
+
activity.keys.size.should == 1
|
148
|
+
activity['igvita.com'].class.should == Hash
|
149
|
+
|
150
|
+
EM.stop
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should fetch daily activity for multiple domains" do
|
155
|
+
EM.synchrony do
|
156
|
+
act = api.domain_activity(['igvita.com', 'techcrunch.com'], {
|
157
|
+
:start_time => 'yesterday',
|
158
|
+
:end_time => 'today'
|
159
|
+
})
|
160
|
+
|
161
|
+
act.class.should == Hash
|
162
|
+
act.keys.size.should == 2
|
163
|
+
|
164
|
+
EM.stop
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
143
170
|
it "should invoke and kill EM reactor transparently" do
|
144
171
|
metrics = api.metrics('1c1a5357e8bd00128db845b2595d5ebe')
|
145
172
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ilya Grigorik
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-24 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -55,6 +55,18 @@ dependencies:
|
|
55
55
|
version: "0"
|
56
56
|
type: :runtime
|
57
57
|
version_requirements: *id003
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: yajl-ruby
|
60
|
+
prerelease: false
|
61
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
type: :runtime
|
69
|
+
version_requirements: *id004
|
58
70
|
description: PostRank API Wrapper
|
59
71
|
email: ilya@igvita.com
|
60
72
|
executables: []
|