alexa 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/README.rdoc +1 -1
- data/alexa.gemspec +0 -2
- data/lib/alexa/version.rb +1 -1
- data/test/config_test.rb +9 -10
- data/test/helper.rb +5 -9
- data/test/url_info_test.rb +43 -52
- metadata +6 -28
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
data/alexa.gemspec
CHANGED
data/lib/alexa/version.rb
CHANGED
data/test/config_test.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require "helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
# Config is singleton
|
3
|
+
describe "Alexa::Config" do
|
4
|
+
before do
|
6
5
|
Alexa.config.access_key_id = nil
|
7
6
|
Alexa.config.secret_access_key = nil
|
8
7
|
end
|
9
8
|
|
10
|
-
should
|
11
|
-
|
9
|
+
it "should raise argumment error if access key id is not present" do
|
10
|
+
assert_raises ArgumentError do
|
12
11
|
Alexa::UrlInfo.new(
|
13
12
|
:secret_access_key => "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDF",
|
14
13
|
:host => "some.host"
|
@@ -16,8 +15,8 @@ class ConfigTest < Test::Unit::TestCase
|
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
|
-
should
|
20
|
-
|
18
|
+
it "should raise argumment error if secret access key is not present" do
|
19
|
+
assert_raises ArgumentError do
|
21
20
|
Alexa::UrlInfo.new(
|
22
21
|
:access_key_id => "12345678901234567890",
|
23
22
|
:host => "some.host"
|
@@ -25,8 +24,8 @@ class ConfigTest < Test::Unit::TestCase
|
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
28
|
-
should
|
29
|
-
|
27
|
+
it "should raise argumment error if host is not present" do
|
28
|
+
assert_raises ArgumentError do
|
30
29
|
Alexa::UrlInfo.new(
|
31
30
|
:access_key_id => "12345678901234567890",
|
32
31
|
:secret_access_key => "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDF"
|
data/test/helper.rb
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
Bundler.setup
|
2
|
-
|
2
|
+
|
3
|
+
require "minitest/autorun"
|
3
4
|
require "mocha"
|
4
|
-
require "shoulda"
|
5
5
|
|
6
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
6
|
require "alexa"
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
File.read(file_path)
|
14
|
-
end
|
8
|
+
def fixture_file(filename)
|
9
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
|
10
|
+
File.read(file_path)
|
15
11
|
end
|
data/test/url_info_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
describe "Alexa::UlrInfo" do
|
4
|
+
before do
|
5
5
|
@alexa = Alexa::UrlInfo.new(
|
6
6
|
:access_key_id => "12345678901234567890",
|
7
7
|
:secret_access_key => "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDF",
|
@@ -9,12 +9,12 @@ class UrlInfoTest < Test::Unit::TestCase
|
|
9
9
|
)
|
10
10
|
end
|
11
11
|
|
12
|
-
should
|
12
|
+
it "should Generate signature" do
|
13
13
|
@alexa.stubs(:timestamp).returns("2009-07-03T07:22:24.000Z")
|
14
14
|
assert_equal "I1mPdBy+flhhzqqUaamNq9gq190=", @alexa.send(:signature)
|
15
15
|
end
|
16
16
|
|
17
|
-
should
|
17
|
+
it "should Generate url" do
|
18
18
|
@alexa.stubs(:timestamp).returns("2009-07-03T07:22:24.000Z")
|
19
19
|
@alexa.response_group = "Rank,ContactInfo,AdultContent,Speed,Language,Keywords,OwnedDomains,LinksInCount,SiteData,RelatedLinks"
|
20
20
|
@alexa.host = "heroku.com"
|
@@ -23,166 +23,157 @@ class UrlInfoTest < Test::Unit::TestCase
|
|
23
23
|
assert_equal "awis.amazonaws.com", @alexa.send(:url).host
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
describe "parsing xml returned by options LinksInCount,SiteData" do
|
27
|
+
before do
|
28
28
|
@alexa.response_group = "Rank,LinksInCount,SiteData"
|
29
29
|
xml = fixture_file('polsl_small.xml')
|
30
30
|
@alexa.parse_xml(xml)
|
31
31
|
end
|
32
32
|
|
33
|
-
should
|
33
|
+
it "should return rank" do
|
34
34
|
assert_equal 86020, @alexa.rank
|
35
35
|
end
|
36
36
|
|
37
|
-
should
|
37
|
+
it "should return data url" do
|
38
38
|
assert_equal "polsl.pl/", @alexa.data_url
|
39
39
|
end
|
40
40
|
|
41
|
-
should
|
41
|
+
it "should return site title" do
|
42
42
|
assert_equal "Silesian University of Technology", @alexa.site_title
|
43
43
|
end
|
44
44
|
|
45
|
-
should
|
45
|
+
it "should return site description" do
|
46
46
|
assert_equal "About the university, studies, faculties and departments, photo gallery.", @alexa.site_description
|
47
47
|
end
|
48
48
|
|
49
|
-
should
|
50
|
-
assert_nothing_raised do
|
51
|
-
@alexa.language_locale
|
52
|
-
end
|
49
|
+
it "should not crash" do
|
53
50
|
assert_nil @alexa.language_locale
|
54
51
|
end
|
55
52
|
end
|
56
53
|
|
57
|
-
|
58
|
-
|
54
|
+
describe "parsing xml with all options" do
|
55
|
+
before do
|
59
56
|
xml = fixture_file('polsl.xml')
|
60
57
|
@alexa.parse_xml(xml)
|
61
58
|
end
|
62
59
|
|
63
|
-
should
|
60
|
+
it "should return rank" do
|
64
61
|
assert_equal 86020, @alexa.rank
|
65
62
|
end
|
66
63
|
|
67
|
-
should
|
64
|
+
it "should return data url" do
|
68
65
|
assert_equal "polsl.pl", @alexa.data_url
|
69
66
|
end
|
70
67
|
|
71
|
-
should
|
68
|
+
it "should return site title" do
|
72
69
|
assert_equal "Silesian University of Technology", @alexa.site_title
|
73
70
|
end
|
74
71
|
|
75
|
-
should
|
72
|
+
it "should return site description" do
|
76
73
|
assert_equal "About the university, studies, faculties and departments, photo gallery.", @alexa.site_description
|
77
74
|
end
|
78
75
|
|
79
|
-
should
|
76
|
+
it "should return language locale" do
|
80
77
|
assert_equal "pl-PL", @alexa.language_locale
|
81
78
|
end
|
82
79
|
|
83
|
-
should
|
80
|
+
it "should return language encoding" do
|
84
81
|
assert_equal "iso-8859-2", @alexa.language_encoding
|
85
82
|
end
|
86
83
|
|
87
|
-
should
|
84
|
+
it "should return links in count" do
|
88
85
|
assert_equal 281, @alexa.links_in_count
|
89
86
|
end
|
90
87
|
|
91
|
-
should
|
88
|
+
it "should return keywords" do
|
92
89
|
assert_equal ["Polska", "Regionalne", "Gliwice"], @alexa.keywords
|
93
90
|
end
|
94
91
|
|
95
|
-
should
|
92
|
+
it "should return related links" do
|
96
93
|
assert_equal 10, @alexa.related_links.size
|
97
94
|
end
|
98
95
|
|
99
|
-
should
|
96
|
+
it "should return speed_median load time" do
|
100
97
|
assert_equal 266, @alexa.speed_median_load_time
|
101
98
|
end
|
102
99
|
|
103
|
-
should
|
100
|
+
it "should return speed percentile" do
|
104
101
|
assert_equal 98, @alexa.speed_percentile
|
105
102
|
end
|
106
103
|
|
107
|
-
should
|
104
|
+
it "should return rank by country" do
|
108
105
|
assert_equal 3, @alexa.rank_by_country.size
|
109
106
|
end
|
110
107
|
|
111
|
-
should
|
108
|
+
it "should return rank by city" do
|
112
109
|
assert_equal 68, @alexa.rank_by_city.size
|
113
110
|
end
|
114
111
|
|
115
|
-
should
|
112
|
+
it "should return usage statistics" do
|
116
113
|
assert_equal 4, @alexa.usage_statistics.size
|
117
114
|
end
|
118
115
|
end
|
119
116
|
|
120
|
-
|
121
|
-
|
117
|
+
describe "parsing empty xml response" do
|
118
|
+
before do
|
122
119
|
xml = fixture_file('empty.xml')
|
123
120
|
@alexa.parse_xml(xml)
|
124
121
|
end
|
125
122
|
|
126
|
-
should
|
123
|
+
it "should return nil from rank" do
|
127
124
|
assert_nil @alexa.rank
|
128
125
|
end
|
129
126
|
|
130
|
-
should
|
127
|
+
it "should return nil from data_url" do
|
131
128
|
assert_equal "404", @alexa.data_url
|
132
129
|
end
|
133
130
|
|
134
|
-
should
|
131
|
+
it "should return nil from site_title" do
|
135
132
|
assert_equal "404", @alexa.site_title
|
136
133
|
end
|
137
134
|
|
138
|
-
should
|
135
|
+
it "should return nil from site_description" do
|
139
136
|
assert_nil @alexa.site_description
|
140
137
|
end
|
141
138
|
|
142
|
-
should
|
139
|
+
it "should return nil from language_locale" do
|
143
140
|
assert_nil @alexa.language_locale
|
144
141
|
end
|
145
142
|
|
146
|
-
should
|
143
|
+
it "should return nil from language_encoding" do
|
147
144
|
assert_nil @alexa.language_encoding
|
148
145
|
end
|
149
146
|
|
150
|
-
should
|
147
|
+
it "should return nil from links_in_count" do
|
151
148
|
assert_nil @alexa.links_in_count
|
152
149
|
end
|
153
150
|
|
154
|
-
should
|
151
|
+
it "should return nil from keywords" do
|
155
152
|
assert_nil @alexa.keywords
|
156
153
|
end
|
157
154
|
|
158
|
-
should
|
155
|
+
it "should return nil from related_links" do
|
159
156
|
assert_nil @alexa.related_links
|
160
157
|
end
|
161
158
|
|
162
|
-
should
|
159
|
+
it "should return nil from speed_median_load_time" do
|
163
160
|
assert_nil @alexa.speed_median_load_time
|
164
161
|
end
|
165
162
|
|
166
|
-
should
|
163
|
+
it "should return nil from speed_percentile" do
|
167
164
|
assert_nil @alexa.speed_percentile
|
168
165
|
end
|
169
166
|
|
170
|
-
should
|
167
|
+
it "should return nil from rank_by_country" do
|
171
168
|
assert_nil @alexa.rank_by_country
|
172
169
|
end
|
173
170
|
|
174
|
-
should
|
171
|
+
it "should return nil from rank_by_city" do
|
175
172
|
assert_nil @alexa.rank_by_city
|
176
173
|
end
|
177
174
|
|
178
|
-
should
|
175
|
+
it "should return nil from usage_statistics" do
|
179
176
|
assert_nil @alexa.usage_statistics
|
180
177
|
end
|
181
178
|
end
|
182
|
-
|
183
|
-
should "not raise error when response is OK" do
|
184
|
-
assert_nothing_raised do
|
185
|
-
@alexa.send :handle_response, Net::HTTPOK.new("1.1", "200", "OK")
|
186
|
-
end
|
187
|
-
end
|
188
179
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: alexa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Wojciech Wn\xC4\x99trzak"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-05 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: xml-simple
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
27
|
+
name: mocha
|
28
28
|
requirement: &id002 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
@@ -34,28 +34,6 @@ dependencies:
|
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: *id002
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: shoulda
|
39
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
|
-
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: "0"
|
45
|
-
type: :development
|
46
|
-
prerelease: false
|
47
|
-
version_requirements: *id003
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: mocha
|
50
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: "0"
|
56
|
-
type: :development
|
57
|
-
prerelease: false
|
58
|
-
version_requirements: *id004
|
59
37
|
description: Alexa Web Information Service library (AWIS)
|
60
38
|
email:
|
61
39
|
- w.wnetrzak@gmail.com
|
@@ -95,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
73
|
requirements:
|
96
74
|
- - ">="
|
97
75
|
- !ruby/object:Gem::Version
|
98
|
-
hash: -
|
76
|
+
hash: -3761737575741442318
|
99
77
|
segments:
|
100
78
|
- 0
|
101
79
|
version: "0"
|
@@ -104,14 +82,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
82
|
requirements:
|
105
83
|
- - ">="
|
106
84
|
- !ruby/object:Gem::Version
|
107
|
-
hash: -
|
85
|
+
hash: -3761737575741442318
|
108
86
|
segments:
|
109
87
|
- 0
|
110
88
|
version: "0"
|
111
89
|
requirements: []
|
112
90
|
|
113
91
|
rubyforge_project: alexa
|
114
|
-
rubygems_version: 1.
|
92
|
+
rubygems_version: 1.8.0
|
115
93
|
signing_key:
|
116
94
|
specification_version: 3
|
117
95
|
summary: Alexa Web Information Service library
|