ralexa 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +35 -26
- data/lib/ralexa/abstract_service.rb +11 -0
- data/lib/ralexa/lazy_collection.rb +2 -18
- data/lib/ralexa/result.rb +30 -0
- data/lib/ralexa/session.rb +6 -0
- data/lib/ralexa/url_info.rb +19 -0
- data/lib/ralexa/version.rb +1 -1
- data/lib/ralexa.rb +2 -0
- data/spec/fixtures/rank.xml +8 -0
- data/spec/session_spec.rb +6 -0
- data/spec/top_sites_spec.rb +3 -3
- data/spec/url_info_spec.rb +28 -0
- metadata +40 -39
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7cf3a967f413ff08f51c5becbe7df4e6bc20fda3
|
4
|
+
data.tar.gz: 92d1e853bcd2bbadb4862ef25d3461e7c1631412
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 848a42c1b198bb0b482f455c14376e657d463069d8320d18faca74e6d1238bc54cfbc3bbefa6cd2cd0c63d5c46ab0e86c6833d3dab996db071ca70523c145783
|
7
|
+
data.tar.gz: ac3c77176cdc9df7299baed7d3fa94d2059e8302af6853cfb46124be4c050c05d528636f95a766c38aca02c2dfd38b2a7806a80ce5beaf4dfafb42ac03689e13
|
data/README.md
CHANGED
@@ -58,6 +58,10 @@ session.top_sites.country("AU", 10).each do |s|
|
|
58
58
|
puts "#{s.url} (#{s.page_views} pageviews)"
|
59
59
|
end
|
60
60
|
|
61
|
+
# rank of an individual site
|
62
|
+
puts "Rank of Flippa.com"
|
63
|
+
puts session.url_info.rank("http://flippa.com")
|
64
|
+
|
61
65
|
puts "bam!"
|
62
66
|
```
|
63
67
|
|
@@ -73,46 +77,51 @@ Status
|
|
73
77
|
<th>Supported</th>
|
74
78
|
</tr>
|
75
79
|
<tr>
|
76
|
-
<td rowspan="3">Alexa Top Sites</
|
77
|
-
<td>TopSites</
|
78
|
-
<td>Global</
|
79
|
-
<td>Yes</
|
80
|
+
<td rowspan="3">Alexa Top Sites</td>
|
81
|
+
<td>TopSites</td>
|
82
|
+
<td>Global</td>
|
83
|
+
<td>Yes</td>
|
84
|
+
</tr>
|
85
|
+
<tr>
|
86
|
+
<td></td>
|
87
|
+
<td>Country</td>
|
88
|
+
<td>Yes</td>
|
80
89
|
</tr>
|
81
90
|
<tr>
|
82
|
-
<td></
|
83
|
-
<td>
|
84
|
-
<td>Yes</
|
91
|
+
<td></td>
|
92
|
+
<td>ListCountries</td>
|
93
|
+
<td>Yes</td>
|
85
94
|
</tr>
|
86
95
|
<tr>
|
87
|
-
<td
|
88
|
-
<td>
|
89
|
-
<td>
|
96
|
+
<td rowspan="7">Alexa Web Information Services</td>
|
97
|
+
<td>UrlInfo</td>
|
98
|
+
<td>Rank</td>
|
99
|
+
<td>Yes</td>
|
90
100
|
</tr>
|
91
101
|
<tr>
|
92
|
-
<td
|
93
|
-
<td>
|
94
|
-
<td
|
95
|
-
<td>Send a pull request!</th>
|
102
|
+
<td></td>
|
103
|
+
<td>*</td>
|
104
|
+
<td>Send a pull request!</td>
|
96
105
|
</tr>
|
97
106
|
<tr>
|
98
|
-
<td>TrafficHistory</
|
99
|
-
<td>*</
|
100
|
-
<td>Send a pull request!</
|
107
|
+
<td>TrafficHistory</td>
|
108
|
+
<td>*</td>
|
109
|
+
<td>Send a pull request!</td>
|
101
110
|
</tr>
|
102
111
|
<tr>
|
103
|
-
<td>CategoryBrowse</
|
104
|
-
<td>*</
|
105
|
-
<td>Send a pull request!</
|
112
|
+
<td>CategoryBrowse</td>
|
113
|
+
<td>*</td>
|
114
|
+
<td>Send a pull request!</td>
|
106
115
|
</tr>
|
107
116
|
<tr>
|
108
|
-
<td>CategoryListings</
|
109
|
-
<td>*</
|
110
|
-
<td>Send a pull request!</
|
117
|
+
<td>CategoryListings</td>
|
118
|
+
<td>*</td>
|
119
|
+
<td>Send a pull request!</td>
|
111
120
|
</tr>
|
112
121
|
<tr>
|
113
|
-
<td>SitesLinkingIn</
|
114
|
-
<td>*</
|
115
|
-
<td>Send a pull request!</
|
122
|
+
<td>SitesLinkingIn</td>
|
123
|
+
<td>*</td>
|
124
|
+
<td>Send a pull request!</td>
|
116
125
|
</tr>
|
117
126
|
</table>
|
118
127
|
|
@@ -7,6 +7,17 @@ module Ralexa
|
|
7
7
|
|
8
8
|
private
|
9
9
|
|
10
|
+
# a single result value
|
11
|
+
def result(*params, &parser)
|
12
|
+
Result.new(
|
13
|
+
@client,
|
14
|
+
host,
|
15
|
+
path,
|
16
|
+
merged_params(*params),
|
17
|
+
&parser
|
18
|
+
).result
|
19
|
+
end
|
20
|
+
|
10
21
|
# A lazy collection which fetches records on demand.
|
11
22
|
def collection(*params, &parser)
|
12
23
|
LazyCollection.new(
|
@@ -1,16 +1,12 @@
|
|
1
1
|
require "nokogiri"
|
2
2
|
|
3
3
|
module Ralexa
|
4
|
-
class LazyCollection
|
4
|
+
class LazyCollection < Result
|
5
5
|
|
6
6
|
include Enumerable
|
7
7
|
|
8
8
|
def initialize(client, host, path, parameters, &parser)
|
9
|
-
|
10
|
-
@host = host
|
11
|
-
@path = path
|
12
|
-
@parameters = parameters
|
13
|
-
@parser = parser
|
9
|
+
super(client, host, path, parameters, &parser)
|
14
10
|
end
|
15
11
|
|
16
12
|
def each
|
@@ -19,17 +15,5 @@ module Ralexa
|
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
22
|
-
private
|
23
|
-
|
24
|
-
def fetch(parameters)
|
25
|
-
@client.get(@host, @path, parameters)
|
26
|
-
end
|
27
|
-
|
28
|
-
def parse(response_body)
|
29
|
-
@parser.call(
|
30
|
-
Nokogiri::XML.parse(response_body).remove_namespaces!
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
18
|
end
|
35
19
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module Ralexa
|
4
|
+
class Result
|
5
|
+
|
6
|
+
def initialize(client, host, path, parameters, &parser)
|
7
|
+
@client = client
|
8
|
+
@host = host
|
9
|
+
@path = path
|
10
|
+
@parameters = parameters
|
11
|
+
@parser = parser
|
12
|
+
end
|
13
|
+
|
14
|
+
def result
|
15
|
+
parse(fetch(@parameters))
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def fetch(parameters)
|
21
|
+
@client.get(@host, @path, parameters)
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse(response_body)
|
25
|
+
@parser.call(
|
26
|
+
Nokogiri::XML.parse(response_body).remove_namespaces!
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/ralexa/session.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Ralexa
|
2
|
+
class UrlInfo < AbstractService
|
3
|
+
|
4
|
+
# The site's Alexa rank
|
5
|
+
def rank(url, params = {})
|
6
|
+
result({"ResponseGroup" => "Rank", "Url" => url}, params) do |document|
|
7
|
+
document.at("//UrlInfoResult/Alexa/TrafficData/Rank").text.to_i
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def host; "awis.amazonaws.com" end
|
15
|
+
def path; "/" end
|
16
|
+
def default_params; {"Action" => "UrlInfo"}; end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/ralexa/version.rb
CHANGED
data/lib/ralexa.rb
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<aws:UrlInfoResponse xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/"><aws:Response xmlns:aws="http://awis.amazonaws.com/doc/2005-07-11"><aws:OperationRequest><aws:RequestId>bb3746dc-fe13-aae7-8058-a98caf283873</aws:RequestId></aws:OperationRequest><aws:UrlInfoResult><aws:Alexa>
|
3
|
+
|
4
|
+
<aws:TrafficData>
|
5
|
+
<aws:DataUrl type="canonical">google.com/</aws:DataUrl>
|
6
|
+
<aws:Rank>1</aws:Rank>
|
7
|
+
</aws:TrafficData>
|
8
|
+
</aws:Alexa></aws:UrlInfoResult><aws:ResponseStatus xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/"><aws:StatusCode>Success</aws:StatusCode></aws:ResponseStatus></aws:Response></aws:UrlInfoResponse>
|
data/spec/session_spec.rb
CHANGED
data/spec/top_sites_spec.rb
CHANGED
@@ -90,9 +90,9 @@ module Ralexa
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "fetches, parses and returns countries" do
|
93
|
-
countries = top_sites.list_countries
|
94
|
-
countries.
|
95
|
-
a, u = countries
|
93
|
+
countries = top_sites.list_countries.to_a
|
94
|
+
countries.size.must_equal 2
|
95
|
+
a, u = countries
|
96
96
|
|
97
97
|
u.name.must_equal "United States"
|
98
98
|
u.code.must_equal "US"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
module Ralexa
|
4
|
+
describe UrlInfo do
|
5
|
+
|
6
|
+
let(:url_info) { UrlInfo.new(client) }
|
7
|
+
let(:client) { MiniTest::Mock.new }
|
8
|
+
|
9
|
+
describe "#rank" do
|
10
|
+
def expected_params
|
11
|
+
{
|
12
|
+
"Action" => "UrlInfo",
|
13
|
+
"ResponseGroup" => "Rank",
|
14
|
+
"Url" => "google.com"
|
15
|
+
}
|
16
|
+
end
|
17
|
+
before do
|
18
|
+
client.expect :get, fixture("rank.xml"),
|
19
|
+
["awis.amazonaws.com", "/", expected_params]
|
20
|
+
end
|
21
|
+
it "fetches, parses, and returns the site's rank" do
|
22
|
+
rank = url_info.rank("google.com")
|
23
|
+
rank.must_equal 1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,60 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ralexa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Paul Annesley
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-05-21 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: addressable
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 2.2.7
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.2.7
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: nokogiri
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: minitest
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- -
|
45
|
+
- - '>='
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '0'
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: rake
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
description: Ruby client for Amazon Alexa APIs.
|
59
70
|
email:
|
60
71
|
- paul@annesley.cc
|
@@ -74,9 +85,11 @@ files:
|
|
74
85
|
- lib/ralexa/lazy_collection.rb
|
75
86
|
- lib/ralexa/paginating_collection.rb
|
76
87
|
- lib/ralexa/paginator.rb
|
88
|
+
- lib/ralexa/result.rb
|
77
89
|
- lib/ralexa/session.rb
|
78
90
|
- lib/ralexa/top_sites.rb
|
79
91
|
- lib/ralexa/uri_signer.rb
|
92
|
+
- lib/ralexa/url_info.rb
|
80
93
|
- lib/ralexa/version.rb
|
81
94
|
- ralexa.gemspec
|
82
95
|
- spec/canonicalized_query_string_spec.rb
|
@@ -85,47 +98,35 @@ files:
|
|
85
98
|
- spec/fixtures/global-page2.xml
|
86
99
|
- spec/fixtures/global-top10.xml
|
87
100
|
- spec/fixtures/list_countries.xml
|
101
|
+
- spec/fixtures/rank.xml
|
88
102
|
- spec/paginator_spec.rb
|
89
103
|
- spec/ralexa_spec.rb
|
90
104
|
- spec/session_spec.rb
|
91
105
|
- spec/spec_helper.rb
|
92
106
|
- spec/top_sites_spec.rb
|
93
107
|
- spec/uri_signer_spec.rb
|
108
|
+
- spec/url_info_spec.rb
|
94
109
|
homepage: https://github.com/flippa/ralexa
|
95
110
|
licenses: []
|
111
|
+
metadata: {}
|
96
112
|
post_install_message:
|
97
113
|
rdoc_options: []
|
98
114
|
require_paths:
|
99
115
|
- lib
|
100
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
117
|
requirements:
|
103
|
-
- -
|
118
|
+
- - '>='
|
104
119
|
- !ruby/object:Gem::Version
|
105
120
|
version: '0'
|
106
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
122
|
requirements:
|
109
|
-
- -
|
123
|
+
- - '>='
|
110
124
|
- !ruby/object:Gem::Version
|
111
125
|
version: '0'
|
112
126
|
requirements: []
|
113
127
|
rubyforge_project:
|
114
|
-
rubygems_version:
|
128
|
+
rubygems_version: 2.0.2
|
115
129
|
signing_key:
|
116
|
-
specification_version:
|
130
|
+
specification_version: 4
|
117
131
|
summary: Ruby client for Amazon Alexa APIs such as TopSites.
|
118
|
-
test_files:
|
119
|
-
- spec/canonicalized_query_string_spec.rb
|
120
|
-
- spec/client_spec.rb
|
121
|
-
- spec/fixtures/global-page1.xml
|
122
|
-
- spec/fixtures/global-page2.xml
|
123
|
-
- spec/fixtures/global-top10.xml
|
124
|
-
- spec/fixtures/list_countries.xml
|
125
|
-
- spec/paginator_spec.rb
|
126
|
-
- spec/ralexa_spec.rb
|
127
|
-
- spec/session_spec.rb
|
128
|
-
- spec/spec_helper.rb
|
129
|
-
- spec/top_sites_spec.rb
|
130
|
-
- spec/uri_signer_spec.rb
|
131
|
-
has_rdoc:
|
132
|
+
test_files: []
|