sistrix 1.0.0

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.
Files changed (87) hide show
  1. data/.document +5 -0
  2. data/Gemfile +12 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.rdoc +59 -0
  5. data/Rakefile +49 -0
  6. data/VERSION +1 -0
  7. data/lib/sistrix.rb +28 -0
  8. data/lib/sistrix/base.rb +23 -0
  9. data/lib/sistrix/config.rb +15 -0
  10. data/lib/sistrix/domain.rb +60 -0
  11. data/lib/sistrix/domain/age.rb +32 -0
  12. data/lib/sistrix/domain/competitors/sem.rb +50 -0
  13. data/lib/sistrix/domain/competitors/seo.rb +52 -0
  14. data/lib/sistrix/domain/competitors/us.rb +53 -0
  15. data/lib/sistrix/domain/kwcount/sem.rb +54 -0
  16. data/lib/sistrix/domain/kwcount/seo.rb +54 -0
  17. data/lib/sistrix/domain/overview.rb +71 -0
  18. data/lib/sistrix/domain/pagerank.rb +51 -0
  19. data/lib/sistrix/domain/pages.rb +51 -0
  20. data/lib/sistrix/domain/sichtbarkeitsindex.rb +49 -0
  21. data/lib/sistrix/domain/social/latest.rb +52 -0
  22. data/lib/sistrix/domain/social/overview.rb +36 -0
  23. data/lib/sistrix/domain/social/top.rb +52 -0
  24. data/lib/sistrix/domain/social/url.rb +63 -0
  25. data/lib/sistrix/keyword.rb +60 -0
  26. data/lib/sistrix/keyword/domain/sem.rb +59 -0
  27. data/lib/sistrix/keyword/domain/seo.rb +65 -0
  28. data/lib/sistrix/keyword/domain/us.rb +61 -0
  29. data/lib/sistrix/keyword/sem.rb +58 -0
  30. data/lib/sistrix/keyword/seo.rb +57 -0
  31. data/lib/sistrix/keyword/us.rb +56 -0
  32. data/lib/sistrix/links/linktargets.rb +57 -0
  33. data/lib/sistrix/links/linktexts.rb +61 -0
  34. data/lib/sistrix/links/list.rb +53 -0
  35. data/lib/sistrix/links/overview.rb +36 -0
  36. data/lib/sistrix/monitoring/folders.rb +53 -0
  37. data/lib/sistrix/monitoring/projects.rb +51 -0
  38. data/lib/sistrix/monitoring/report.rb +74 -0
  39. data/lib/sistrix/monitoring/report/download.rb +60 -0
  40. data/lib/sistrix/monitoring/reports.rb +52 -0
  41. data/lib/sistrix/record.rb +13 -0
  42. data/sistrix.gemspec +146 -0
  43. data/spec/sistrix_domain_spec.rb +685 -0
  44. data/spec/sistrix_keyword_spec.rb +216 -0
  45. data/spec/sistrix_links_spec.rb +221 -0
  46. data/spec/sistrix_monitoring_spec.rb +190 -0
  47. data/spec/spec_helper.rb +33 -0
  48. data/spec/xml/domain.age.xml +19 -0
  49. data/spec/xml/domain.competitors.sem.xml +23 -0
  50. data/spec/xml/domain.competitors.seo.xml +23 -0
  51. data/spec/xml/domain.competitors.us.xml +23 -0
  52. data/spec/xml/domain.kwcount.sem.xml +19 -0
  53. data/spec/xml/domain.kwcount.seo.xml +19 -0
  54. data/spec/xml/domain.overview.xml +24 -0
  55. data/spec/xml/domain.pagerank.xml +19 -0
  56. data/spec/xml/domain.pages.xml +19 -0
  57. data/spec/xml/domain.sichtbarkeitsindex.xml +19 -0
  58. data/spec/xml/domain.social.latest.xml +28 -0
  59. data/spec/xml/domain.social.overview.xml +21 -0
  60. data/spec/xml/domain.social.top.xml +28 -0
  61. data/spec/xml/domain.social.url.xml +19 -0
  62. data/spec/xml/domain.social.url_with_history.xml +23 -0
  63. data/spec/xml/domain.xml +29 -0
  64. data/spec/xml/keyword.domain.sem.xml +24 -0
  65. data/spec/xml/keyword.domain.seo.xml +24 -0
  66. data/spec/xml/keyword.domain.us.xml +24 -0
  67. data/spec/xml/keyword.sem.xml +22 -0
  68. data/spec/xml/keyword.sem_with_domain.xml +212 -0
  69. data/spec/xml/keyword.sem_with_domain2.xml +20 -0
  70. data/spec/xml/keyword.seo.xml +29 -0
  71. data/spec/xml/keyword.seo_with_url.xml +20 -0
  72. data/spec/xml/keyword.us.xml +28 -0
  73. data/spec/xml/keyword.us_nodate.xml +19 -0
  74. data/spec/xml/keyword.xml +21 -0
  75. data/spec/xml/links.linktargets.xml +118 -0
  76. data/spec/xml/links.linktexts.xml +28 -0
  77. data/spec/xml/links.list.xml +10018 -0
  78. data/spec/xml/links.overview.xml +23 -0
  79. data/spec/xml/monitoring.folders.xml +20 -0
  80. data/spec/xml/monitoring.projects.xml +37 -0
  81. data/spec/xml/monitoring.report.download.pdf +0 -0
  82. data/spec/xml/monitoring.report.download_error.xml +18 -0
  83. data/spec/xml/monitoring.report.xml +181 -0
  84. data/spec/xml/monitoring.reports.xml +19 -0
  85. data/test/helper.rb +18 -0
  86. data/test/test_sistrix.rb +7 -0
  87. metadata +232 -0
@@ -0,0 +1,52 @@
1
+ module Sistrix
2
+
3
+ require 'sistrix/base'
4
+ class Monitoring
5
+ class Reports
6
+
7
+ include ::Sistrix::Base
8
+
9
+ attr_reader :credits, :reports
10
+
11
+ def initialize(options = {})
12
+ @options = {
13
+ 'project' => nil,
14
+ 'api_key' => Sistrix.config.api_key,
15
+ }.merge(options)
16
+
17
+ if Sistrix.config.proxy
18
+ RestClient.proxy = Sistrix.config.proxy
19
+ end
20
+ end
21
+
22
+ def call(options = {})
23
+ data = fetch(options)
24
+
25
+ @credits = data.xpath('/response/credits').first['used'].to_i
26
+
27
+ @reports = []
28
+ data.xpath('/response/answer/report').each do |r|
29
+ @reports << Record.new(r)
30
+ end
31
+
32
+ self
33
+ end
34
+
35
+ class Record
36
+ require 'sistrix/record'
37
+ include ::Sistrix::Record
38
+
39
+ def initialize(xml_node)
40
+ @data = {}
41
+
42
+ @data[:name] = xml_node['name'].to_s.strip
43
+ @data[:id] = xml_node['id'].to_s.strip
44
+ end
45
+ end
46
+
47
+
48
+ end
49
+
50
+ end
51
+ end
52
+
@@ -0,0 +1,13 @@
1
+ module Sistrix
2
+ module Record
3
+ def keys
4
+ @data.keys
5
+ end
6
+
7
+ def method_missing(name)
8
+ raise Sistrix::ArgumentException.new("there is no data field called \"#{name}\" here!") unless @data.has_key?(name.to_sym)
9
+
10
+ @data[name]
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,146 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{sistrix}
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Tobias Begalke"]
12
+ s.date = %q{2012-04-13}
13
+ s.description = %q{A ruby libary for the Sistrix web API}
14
+ s.email = %q{elcamino@spyz.org}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "LICENSE.txt",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/sistrix.rb",
27
+ "lib/sistrix/base.rb",
28
+ "lib/sistrix/config.rb",
29
+ "lib/sistrix/domain.rb",
30
+ "lib/sistrix/domain/age.rb",
31
+ "lib/sistrix/domain/competitors/sem.rb",
32
+ "lib/sistrix/domain/competitors/seo.rb",
33
+ "lib/sistrix/domain/competitors/us.rb",
34
+ "lib/sistrix/domain/kwcount/sem.rb",
35
+ "lib/sistrix/domain/kwcount/seo.rb",
36
+ "lib/sistrix/domain/overview.rb",
37
+ "lib/sistrix/domain/pagerank.rb",
38
+ "lib/sistrix/domain/pages.rb",
39
+ "lib/sistrix/domain/sichtbarkeitsindex.rb",
40
+ "lib/sistrix/domain/social/latest.rb",
41
+ "lib/sistrix/domain/social/overview.rb",
42
+ "lib/sistrix/domain/social/top.rb",
43
+ "lib/sistrix/domain/social/url.rb",
44
+ "lib/sistrix/keyword.rb",
45
+ "lib/sistrix/keyword/domain/sem.rb",
46
+ "lib/sistrix/keyword/domain/seo.rb",
47
+ "lib/sistrix/keyword/domain/us.rb",
48
+ "lib/sistrix/keyword/sem.rb",
49
+ "lib/sistrix/keyword/seo.rb",
50
+ "lib/sistrix/keyword/us.rb",
51
+ "lib/sistrix/links/linktargets.rb",
52
+ "lib/sistrix/links/linktexts.rb",
53
+ "lib/sistrix/links/list.rb",
54
+ "lib/sistrix/links/overview.rb",
55
+ "lib/sistrix/monitoring/folders.rb",
56
+ "lib/sistrix/monitoring/projects.rb",
57
+ "lib/sistrix/monitoring/report.rb",
58
+ "lib/sistrix/monitoring/report/download.rb",
59
+ "lib/sistrix/monitoring/reports.rb",
60
+ "lib/sistrix/record.rb",
61
+ "sistrix.gemspec",
62
+ "spec/sistrix_domain_spec.rb",
63
+ "spec/sistrix_keyword_spec.rb",
64
+ "spec/sistrix_links_spec.rb",
65
+ "spec/sistrix_monitoring_spec.rb",
66
+ "spec/spec_helper.rb",
67
+ "spec/xml/domain.age.xml",
68
+ "spec/xml/domain.competitors.sem.xml",
69
+ "spec/xml/domain.competitors.seo.xml",
70
+ "spec/xml/domain.competitors.us.xml",
71
+ "spec/xml/domain.kwcount.sem.xml",
72
+ "spec/xml/domain.kwcount.seo.xml",
73
+ "spec/xml/domain.overview.xml",
74
+ "spec/xml/domain.pagerank.xml",
75
+ "spec/xml/domain.pages.xml",
76
+ "spec/xml/domain.sichtbarkeitsindex.xml",
77
+ "spec/xml/domain.social.latest.xml",
78
+ "spec/xml/domain.social.overview.xml",
79
+ "spec/xml/domain.social.top.xml",
80
+ "spec/xml/domain.social.url.xml",
81
+ "spec/xml/domain.social.url_with_history.xml",
82
+ "spec/xml/domain.xml",
83
+ "spec/xml/keyword.domain.sem.xml",
84
+ "spec/xml/keyword.domain.seo.xml",
85
+ "spec/xml/keyword.domain.us.xml",
86
+ "spec/xml/keyword.sem.xml",
87
+ "spec/xml/keyword.sem_with_domain.xml",
88
+ "spec/xml/keyword.sem_with_domain2.xml",
89
+ "spec/xml/keyword.seo.xml",
90
+ "spec/xml/keyword.seo_with_url.xml",
91
+ "spec/xml/keyword.us.xml",
92
+ "spec/xml/keyword.us_nodate.xml",
93
+ "spec/xml/keyword.xml",
94
+ "spec/xml/links.linktargets.xml",
95
+ "spec/xml/links.linktexts.xml",
96
+ "spec/xml/links.list.xml",
97
+ "spec/xml/links.overview.xml",
98
+ "spec/xml/monitoring.folders.xml",
99
+ "spec/xml/monitoring.projects.xml",
100
+ "spec/xml/monitoring.report.download.pdf",
101
+ "spec/xml/monitoring.report.download_error.xml",
102
+ "spec/xml/monitoring.report.xml",
103
+ "spec/xml/monitoring.reports.xml",
104
+ "test/helper.rb",
105
+ "test/test_sistrix.rb"
106
+ ]
107
+ s.homepage = %q{http://github.com/elcamino/sistrix}
108
+ s.licenses = ["MIT"]
109
+ s.require_paths = ["lib"]
110
+ s.rubygems_version = %q{1.6.2}
111
+ s.summary = %q{Sistrix web API library for ruby}
112
+
113
+ if s.respond_to? :specification_version then
114
+ s.specification_version = 3
115
+
116
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
117
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
118
+ s.add_runtime_dependency(%q<rest-client>, [">= 1.0"])
119
+ s.add_development_dependency(%q<rspec>, [">= 1.3.2"])
120
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
121
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
122
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
123
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
124
+ s.add_development_dependency(%q<webmock>, [">= 1.8.6"])
125
+ else
126
+ s.add_dependency(%q<nokogiri>, [">= 0"])
127
+ s.add_dependency(%q<rest-client>, [">= 1.0"])
128
+ s.add_dependency(%q<rspec>, [">= 1.3.2"])
129
+ s.add_dependency(%q<shoulda>, [">= 0"])
130
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
131
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
132
+ s.add_dependency(%q<simplecov>, [">= 0"])
133
+ s.add_dependency(%q<webmock>, [">= 1.8.6"])
134
+ end
135
+ else
136
+ s.add_dependency(%q<nokogiri>, [">= 0"])
137
+ s.add_dependency(%q<rest-client>, [">= 1.0"])
138
+ s.add_dependency(%q<rspec>, [">= 1.3.2"])
139
+ s.add_dependency(%q<shoulda>, [">= 0"])
140
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
141
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
142
+ s.add_dependency(%q<simplecov>, [">= 0"])
143
+ s.add_dependency(%q<webmock>, [">= 1.8.6"])
144
+ end
145
+ end
146
+
@@ -0,0 +1,685 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'sistrix'
5
+ require 'pp'
6
+
7
+ WebMock.disable_net_connect!
8
+ include WebMock::API
9
+
10
+ xml_base = File.join(File.dirname(__FILE__), 'xml')
11
+ domain = 'zeit.de'
12
+ keyword = 'auto'
13
+
14
+ #
15
+ # Sistrix.domain()
16
+ #
17
+
18
+ describe "Sistrix.domain(:domain => '#{domain}') returns a list of available domain API calls for the given domain" do
19
+
20
+ subject {
21
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain?api_key=&domain=#{domain}").to_return(File.new(File.join(xml_base, 'domain.xml')))
22
+ Sistrix.domain(:domain => domain)
23
+ }
24
+
25
+ it { should be }
26
+
27
+ its(:credits) { should == 0 }
28
+ its(:"options.size") { should == 11 }
29
+
30
+ it "domain.sichtbarkeitsindex" do
31
+ subject.options.find { |o| o.method == 'domain.sichtbarkeitsindex' }.should be
32
+ end
33
+
34
+ it "domain.pagerank" do
35
+ subject.options.find { |o| o.method == 'domain.pagerank' }.should be
36
+ end
37
+
38
+ it "domain.pages" do
39
+ subject.options.find { |o| o.method == 'domain.pages' }.should be
40
+ end
41
+
42
+ it "domain.age" do
43
+ subject.options.find { |o| o.method == 'domain.age' }.should be
44
+ end
45
+
46
+ it "domain.kwcount.seo" do
47
+ subject.options.find { |o| o.method == 'domain.kwcount.seo' }.should be
48
+ end
49
+
50
+ it "domain.kwcount.sem" do
51
+ subject.options.find { |o| o.method == 'domain.kwcount.sem' }.should be
52
+ end
53
+
54
+ it "domain.social.overview" do
55
+ subject.options.find { |o| o.method == 'domain.social.overview' }.should be
56
+ end
57
+
58
+ it "domain.social.url" do
59
+ subject.options.find { |o| o.method == 'domain.social.url' }.should be
60
+ end
61
+
62
+ it "domain.social.top" do
63
+ subject.options.find { |o| o.method == 'domain.social.top' }.should be
64
+ end
65
+
66
+ it "domain.social.latest" do
67
+ subject.options.find { |o| o.method == 'domain.social.latest' }.should be
68
+ end
69
+ end
70
+
71
+ #
72
+ # Sistrix.domain_overview
73
+ #
74
+
75
+ describe "Sistrix.domain_overview(:domain => '#{domain}') returns an overview of the domain" do
76
+
77
+ subject {
78
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.overview?api_key=&domain=#{domain}").to_return(File.new(File.join(xml_base, 'domain.overview.xml')))
79
+ Sistrix.domain_overview(:domain => domain)
80
+ }
81
+
82
+ it { should be }
83
+
84
+ its(:credits) { should == 6 }
85
+
86
+ its(:age) { should be }
87
+ its(:"age.domain") { should == domain }
88
+ its(:"age.date") { should be_nil }
89
+ its(:"age.value") { should == Time.parse('1998-02-13T00:00:00+01:00') }
90
+
91
+ its(:kwcount_sem) { should be }
92
+ its(:"kwcount_sem.domain") { should == domain }
93
+ its(:"kwcount_sem.date") { should == Time.parse('2012-04-09T00:00:00+02:00') }
94
+ its(:"kwcount_sem.value") { should == 15 }
95
+
96
+ its(:kwcount_seo) { should be }
97
+ its(:"kwcount_seo.domain") { should == domain }
98
+ its(:"kwcount_seo.date") { should == Time.parse('2012-04-09T00:00:00+02:00') }
99
+ its(:"kwcount_seo.value") { should == 85893 }
100
+
101
+ its(:pagerank) { should be }
102
+ its(:"pagerank.domain") { should == domain }
103
+ its(:"pagerank.date") { should == Time.parse('2009-04-11T00:00:00+02:00') }
104
+ its(:"pagerank.value") { should == 8 }
105
+
106
+ its(:pages) { should be }
107
+ its(:"pages.domain") { should == domain }
108
+ its(:"pages.date") { should == Time.parse('2012-04-11T00:00:00+02:00') }
109
+ its(:"pages.value") { should == 3710000 }
110
+
111
+ its(:sichtbarkeitsindex) { should be }
112
+ its(:"sichtbarkeitsindex.domain") { should == domain }
113
+ its(:"sichtbarkeitsindex.date") { should == Time.parse('2012-04-09T00:00:00+02:00') }
114
+ its(:"sichtbarkeitsindex.value") { should == 108.6181 }
115
+
116
+
117
+ end
118
+
119
+ #
120
+ # Sistrix.domain_pages()
121
+ #
122
+
123
+ describe "Sistrix.domain_pages(:domain => '#{domain}', :history => [true|false]) returns the number of pages in the index" do
124
+ subject {
125
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.pages?api_key=&domain=#{domain}&history=").to_return(File.new(File.join(xml_base, 'domain.pages.xml')))
126
+ Sistrix.domain_pages(:domain => domain)
127
+ }
128
+
129
+ it { should be }
130
+
131
+ its(:credits) { should == 1 }
132
+
133
+ its(:pages) { should be }
134
+ its(:"pages.size") { should == 1 }
135
+
136
+ it "pages[0] exists" do
137
+ subject.pages[0].should be
138
+ end
139
+
140
+ it "pages[0].domain == #{domain}" do
141
+ subject.pages[0].domain.should == domain
142
+ end
143
+
144
+ it "pages[0].value == 3710000" do
145
+ subject.pages[0].value.should == 3710000
146
+ end
147
+
148
+ it "pages[0].date == 2012-04-11T00:00:00+02:00" do
149
+ subject.pages[0].date.should == Time.parse('2012-04-11T00:00:00+02:00')
150
+ end
151
+ end
152
+
153
+ #
154
+ # Sistrix.domain_pagerank()
155
+ #
156
+
157
+ describe "Sistrix.domain_pagerank(:domain => '#{domain}', :history => [true|false]) returns the pagerank of the given domain" do
158
+ subject {
159
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.pagerank?api_key=&domain=#{domain}&history=").to_return(File.new(File.join(xml_base, 'domain.pagerank.xml')))
160
+ Sistrix.domain_pagerank(:domain => domain)
161
+ }
162
+
163
+ it { should be }
164
+
165
+ its(:credits) { should == 1 }
166
+
167
+ its(:pageranks) { should be }
168
+ its(:"pageranks.size") { should == 1 }
169
+
170
+ it "pageranks[0].domain == #{domain}" do
171
+ subject.pageranks[0].domain.should == domain
172
+ end
173
+
174
+ it "pageranks[0].date == 2009-04-11T00:00:00+02:00" do
175
+ subject.pageranks[0].date.should == Time.parse('2009-04-11T00:00:00+02:00')
176
+ end
177
+
178
+ it "pageranks[0].value == 8" do
179
+ subject.pageranks[0].value.should == 8
180
+ end
181
+
182
+ end
183
+
184
+ #
185
+ # Sistrix.domain_age()
186
+ #
187
+
188
+ describe "Sistrix.domain_age(:domain => '#{domain}') returns the age of the given domain" do
189
+ subject {
190
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.age?api_key=&domain=#{domain}").to_return(File.new(File.join(xml_base, 'domain.age.xml')))
191
+ res = Sistrix.domain_age(:domain => domain)
192
+ }
193
+
194
+ its(:credits) { should == 1 }
195
+ its(:age) { should == Time.parse('1998-02-13T00:00:00+01:00') }
196
+ its(:domain) { should == domain }
197
+ end
198
+
199
+ #
200
+ # Sistrix.domain_kwcount_sem()
201
+ #
202
+
203
+ describe "Sistrix.domain_kwcount_sem(:domain => '#{domain}', :history => [true|false]) returns the number of SEM keywords for the given domain" do
204
+ subject {
205
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.kwcount.sem?api_key=&domain=#{domain}&history=").to_return(File.new(File.join(xml_base, 'domain.kwcount.sem.xml')))
206
+ Sistrix.domain_kwcount_sem(:domain => domain)
207
+ }
208
+
209
+ its(:credits) { should == 1 }
210
+ its('kwcount.size') { should == 1 }
211
+
212
+ its('kwcount.first.domain') { should == domain }
213
+ its('kwcount.first.date') { should == Time.parse('2012-04-09T00:00:00+02:00') }
214
+ its('kwcount.first.value') { should == 15 }
215
+ end
216
+
217
+ #
218
+ # Sistrix.domain_kwcount_seo()
219
+ #
220
+
221
+ describe "Sistrix.domain_kwcount_seo(:domain => '#{domain}', :history => [true|false]) returns the number of SEO keywords for the given domain" do
222
+ subject {
223
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.kwcount.seo?api_key=&domain=#{domain}&history=").to_return(File.new(File.join(xml_base, 'domain.kwcount.seo.xml')))
224
+ res = Sistrix.domain_kwcount_seo(:domain => domain)
225
+ }
226
+
227
+ its(:credits) { should == 1 }
228
+ its('kwcount.size') { should == 1 }
229
+
230
+ its('kwcount.first.domain') { should == domain }
231
+ its('kwcount.first.date') { should == Time.parse('2012-04-09T00:00:00+02:00') }
232
+ its('kwcount.first.value') { should == 85893 }
233
+ end
234
+
235
+ #
236
+ # Sistrix.domain_competitors_us
237
+ #
238
+
239
+ describe "Sistrix.domain_competitors_us(:domain => '#{domain}', :num => [number_of_results]) returns a list of Universal Search competitors for the given domain" do
240
+ subject {
241
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.competitors.us?api_key=&domain=#{domain}&num=5").to_return(File.new(File.join(xml_base, 'domain.competitors.us.xml')))
242
+ res = Sistrix.domain_competitors_us(:domain => domain, :num => 5)
243
+ }
244
+
245
+ its(:credits) { should == 5 }
246
+ its("competitors.size") { should == 5 }
247
+
248
+ describe "competitor youtube.com" do
249
+ let(:comp) { subject.competitors.find { |c| c.domain == 'youtube.com' } }
250
+
251
+ it do
252
+ comp.should be
253
+ end
254
+
255
+ it "domain should be 'youtube.com'" do
256
+ comp.domain { should == 'youtube.com' }
257
+ end
258
+
259
+ it "match should be 100" do
260
+ comp.match { should == 100 }
261
+ end
262
+ end
263
+
264
+ describe "competitor wikimedia.org" do
265
+ let(:comp) { subject.competitors.find { |c| c.domain == 'wikimedia.org' } }
266
+
267
+ it do
268
+ comp.should be
269
+ end
270
+
271
+ it "domain should be 'wikimedia.org'" do
272
+ comp.domain { should == 'wikimedia.org' }
273
+ end
274
+
275
+ it "match should be 65" do
276
+ comp.match { should == 65 }
277
+ end
278
+ end
279
+
280
+ describe "competitor focus.de" do
281
+ let(:comp) { subject.competitors.find { |c| c.domain == 'focus.de' } }
282
+
283
+ it do
284
+ comp.should be
285
+ end
286
+
287
+ it "domain should be 'focus.de'" do
288
+ comp.domain { should == 'focus.de' }
289
+ end
290
+
291
+ it "match should be 43" do
292
+ comp.match { should == 43 }
293
+ end
294
+ end
295
+
296
+ describe "competitor welt.de" do
297
+ let(:comp) { subject.competitors.find { |c| c.domain == 'welt.de' } }
298
+
299
+ it do
300
+ comp.should be
301
+ end
302
+
303
+ it "domain should be 'welt.de'" do
304
+ comp.domain { should == 'welt.de' }
305
+ end
306
+
307
+ it "match should be 19" do
308
+ comp.match { should == 19 }
309
+ end
310
+ end
311
+
312
+ describe "competitor bild.de" do
313
+ let(:comp) { subject.competitors.find { |c| c.domain == 'bild.de' } }
314
+
315
+ it do
316
+ comp.should be
317
+ end
318
+
319
+ it "domain should be 'bild.de'" do
320
+ comp.domain { should == 'bild.de' }
321
+ end
322
+
323
+ it "match should be 18" do
324
+ comp.match { should == 18 }
325
+ end
326
+ end
327
+
328
+ end
329
+
330
+ #
331
+ # Sistrix.domain_competitors_sem
332
+ #
333
+
334
+ describe "Sistrix.domain_competitors_sem(:domain => '#{domain}', :num => [number_of_results]) returns a list of SEM competitors for the given domain" do
335
+ subject {
336
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.competitors.sem?api_key=&domain=#{domain}&num=5").to_return(File.new(File.join(xml_base, 'domain.competitors.sem.xml')))
337
+ Sistrix.domain_competitors_sem(:domain => domain, :num => 5)
338
+ }
339
+
340
+ its(:credits) { should == 5 }
341
+ its("competitors.size") { should == 5 }
342
+
343
+ describe "competitor stepstone.de" do
344
+ let(:comp) { subject.competitors.find { |c| c.domain == 'stepstone.de' } }
345
+
346
+ it do
347
+ comp.should be
348
+ end
349
+
350
+ it "domain should be 'stepstone.de'" do
351
+ comp.domain { should == 'stepstone.de' }
352
+ end
353
+
354
+ it "match should be 100" do
355
+ comp.match { should == 100 }
356
+ end
357
+ end
358
+
359
+ describe "competitor jobscout24.de" do
360
+ let(:comp) { subject.competitors.find { |c| c.domain == 'jobscout24.de' } }
361
+
362
+ it do
363
+ comp.should be
364
+ end
365
+
366
+ it "domain should be 'jobscout24.de'" do
367
+ comp.domain { should == 'jobscout24.de' }
368
+ end
369
+
370
+ it "match should be 49" do
371
+ comp.match { should == 49 }
372
+ end
373
+ end
374
+
375
+ describe "competitor monster.de" do
376
+ let(:comp) { subject.competitors.find { |c| c.domain == 'monster.de' } }
377
+
378
+ it do
379
+ comp.should be
380
+ end
381
+
382
+ it "domain should be 'monster.de'" do
383
+ comp.domain { should == 'monster.de' }
384
+ end
385
+
386
+ it "match should be 48" do
387
+ comp.match { should == 48 }
388
+ end
389
+ end
390
+
391
+ describe "competitor caritas.de" do
392
+ let(:comp) { subject.competitors.find { |c| c.domain == 'caritas.de' } }
393
+
394
+ it do
395
+ comp.should be
396
+ end
397
+
398
+ it "domain should be 'caritas.de'" do
399
+ comp.domain { should == 'caritas.de' }
400
+ end
401
+
402
+ it "match should be 37" do
403
+ comp.match { should == 37 }
404
+ end
405
+ end
406
+
407
+ describe "competitor fazjob.net" do
408
+ let(:comp) { subject.competitors.find { |c| c.domain == 'fazjob.net' } }
409
+
410
+ it do
411
+ comp.should be
412
+ end
413
+
414
+ it "domain should be 'fazjob.net'" do
415
+ comp.domain { should == 'fazjob.net' }
416
+ end
417
+
418
+ it "match should be 29" do
419
+ comp.match { should == 29 }
420
+ end
421
+ end
422
+
423
+ end
424
+
425
+ #
426
+ # Sistrix.domain_competitors_seo
427
+ #
428
+
429
+ describe "Sistrix.domain_competitors_seo(:domain => '#{domain}', :num => [number_of_results]) returns a list of SEO competitors for the given domain" do
430
+ subject {
431
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.competitors.seo?api_key=&domain=#{domain}&num=5").to_return(File.new(File.join(xml_base, 'domain.competitors.seo.xml')))
432
+ Sistrix.domain_competitors_seo(:domain => domain, :num => 5)
433
+ }
434
+
435
+ its(:credits) { should == 5 }
436
+ its("competitors.size") { should == 5 }
437
+
438
+ describe "competitor facebook.com" do
439
+ let(:comp) { subject.competitors.find { |c| c.domain == 'facebook.com' } }
440
+
441
+ it do
442
+ comp.should be
443
+ end
444
+
445
+ it "domain should be 'facebook.com'" do
446
+ comp.domain { should == 'facebook.com' }
447
+ end
448
+
449
+ it "match should be 100" do
450
+ comp.match { should == 100 }
451
+ end
452
+ end
453
+
454
+ describe "competitor amazon.de" do
455
+ let(:comp) { subject.competitors.find { |c| c.domain == 'amazon.de' } }
456
+
457
+ it do
458
+ comp.should be
459
+ end
460
+
461
+ it "domain should be 'amazon.de'" do
462
+ comp.domain { should == 'amazon.de' }
463
+ end
464
+
465
+ it "match should be 87" do
466
+ comp.match { should == 87 }
467
+ end
468
+ end
469
+
470
+ describe "competitor spiegel.de" do
471
+ let(:comp) { subject.competitors.find { |c| c.domain == 'spiegel.de' } }
472
+
473
+ it do
474
+ comp.should be
475
+ end
476
+
477
+ it "domain should be 'spiegel.de'" do
478
+ comp.domain { should == 'spiegel.de' }
479
+ end
480
+
481
+ it "match should be 54" do
482
+ comp.match { should == 54 }
483
+ end
484
+ end
485
+
486
+ describe "competitor focus.de" do
487
+ let(:comp) { subject.competitors.find { |c| c.domain == 'focus.de' } }
488
+
489
+ it do
490
+ comp.should be
491
+ end
492
+
493
+ it "domain should be 'focus.de'" do
494
+ comp.domain { should == 'focus.de' }
495
+ end
496
+
497
+ it "match should be 50" do
498
+ comp.match { should == 50 }
499
+ end
500
+ end
501
+
502
+ describe "competitor welt.de" do
503
+ let(:comp) { subject.competitors.find { |c| c.domain == 'welt.de' } }
504
+
505
+ it do
506
+ comp.should be
507
+ end
508
+
509
+ it "domain should be 'welt.de'" do
510
+ comp.domain { should == 'welt.de' }
511
+ end
512
+
513
+ it "match should be 38" do
514
+ comp.match { should == 38 }
515
+ end
516
+ end
517
+
518
+ end
519
+
520
+ #
521
+ # Sistrix.domain_sichtbarkeitsindex
522
+ #
523
+
524
+ describe "Sistrix.domain_sichtbarkeitsindex(:domain => '#{domain}', :history => [true|false]) returns the Sichtbarkeitsindex for the given domain" do
525
+ subject {
526
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.sichtbarkeitsindex?api_key=&domain=#{domain}&history=").to_return(File.new(File.join(xml_base, 'domain.sichtbarkeitsindex.xml')))
527
+ Sistrix.domain_sichtbarkeitsindex(:domain => domain)
528
+ }
529
+
530
+ its(:credits) { should == 1 }
531
+ its("sichtbarkeitsindex.size") { should == 1 }
532
+ its("sichtbarkeitsindex.first.domain") { should == domain }
533
+ its("sichtbarkeitsindex.first.date") { should == Time.parse('2012-04-09T00:00:00+02:00') }
534
+ its("sichtbarkeitsindex.first.value") { should == 108.6181 }
535
+ end
536
+
537
+ #
538
+ # Sistrix.domain_social_overview
539
+ #
540
+
541
+ describe "Sistrix.domain_social_overview(:domain => '#{domain}') returns the social network stats for the given domain" do
542
+ subject {
543
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.social.overview?api_key=&domain=#{domain}").to_return(File.new(File.join(xml_base, 'domain.social.overview.xml')))
544
+ Sistrix.domain_social_overview(:domain => domain)
545
+ }
546
+
547
+ its(:credits) { should == 3 }
548
+ its(:twitter) { should == 557071 }
549
+ its(:facebook) { should == 1335512 }
550
+ its(:googleplus) { should == 27531 }
551
+ end
552
+
553
+ #
554
+ # Sistrix.domain_social_top
555
+ #
556
+
557
+ describe "Sistrix.domain_social_top(:domain => '#{domain}', :network => [facebook|twitter|googleplus], :num => [number_of_results]) returns a list of the urls with the most social network votes for the given domain" do
558
+ subject {
559
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.social.top?api_key=&domain=#{domain}&network=&num=10").to_return(File.new(File.join(xml_base, 'domain.social.top.xml')))
560
+ Sistrix.domain_social_top(:domain => domain, :num => 10)
561
+ }
562
+
563
+ its(:credits) { should == 10 }
564
+
565
+ its("urls.size") { should == 10 }
566
+
567
+ describe "url 'http://www.zeit.de/datenschutz/malte-spitz-vorratsdaten'" do
568
+ let (:url) { subject.urls.find { |u| u.url == 'http://www.zeit.de/datenschutz/malte-spitz-vorratsdaten' } }
569
+
570
+ it "should be" do
571
+ url.should be
572
+ end
573
+
574
+ it "votes should be 109822" do
575
+ url.votes.should == 109822
576
+ end
577
+
578
+ it "network should be 'total'" do
579
+ url.network.should == 'total'
580
+ end
581
+ end
582
+
583
+
584
+ describe "url 'http://www.zeit.de/2011/22/DOS-G8'" do
585
+ let (:url) { subject.urls.find { |u| u.url == 'http://www.zeit.de/2011/22/DOS-G8' } }
586
+
587
+ it "should be" do
588
+ url.should be
589
+ end
590
+
591
+ it "votes should be 82933" do
592
+ url.votes.should == 82933
593
+ end
594
+
595
+ it "network should be 'total'" do
596
+ url.network.should == 'total'
597
+ end
598
+ end
599
+
600
+ end
601
+
602
+ #
603
+ # Sistrix.domain_social_latest
604
+ #
605
+
606
+ describe "Sistrix.domain_social_latest(:domain => '#{domain}', :network => [facebook|twitter|googleplus], :num => [number_of_results]) returns a list of the most recent urls that have received a social network vote for the given domain" do
607
+ subject {
608
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.social.latest?api_key=&domain=#{domain}&network=&num=10").to_return(File.new(File.join(xml_base, 'domain.social.latest.xml')))
609
+ Sistrix.domain_social_latest(:domain => domain, :num => 10)
610
+ }
611
+
612
+ its(:credits) { should == 10 }
613
+
614
+ its("urls.size") { should == 10 }
615
+
616
+ describe "url 'http://www.zeit.de/2011/38/P-Fahrrad'" do
617
+ let (:url) { subject.urls.find { |u| u.url == 'http://www.zeit.de/2011/38/P-Fahrrad' } }
618
+
619
+ it "should be" do
620
+ url.should be
621
+ end
622
+
623
+ it "date should be 2012-04-10T14:29:42+02:00" do
624
+ url.date.should == Time.parse('2012-04-10T14:29:42+02:00')
625
+ end
626
+ end
627
+
628
+
629
+ describe "url 'http://www.zeit.de/politik/2012-04/grass-gedicht-israel-debatte'" do
630
+ let (:url) { subject.urls.find { |u| u.url == 'http://www.zeit.de/politik/2012-04/grass-gedicht-israel-debatte' } }
631
+
632
+ it "should be" do
633
+ url.should be
634
+ end
635
+
636
+ it "date should be 2012-04-10T15:51:23+02:00" do
637
+ url.date.should == Time.parse('2012-04-10T15:51:23+02:00')
638
+ end
639
+
640
+ end
641
+ end
642
+
643
+ describe "Sistrix.domain_social_url(:domain => '#{domain}', :history => [true|false]) returns a list of social network votes for one url of the given domain" do
644
+ subject {
645
+ stub_request(:get, Sistrix::SERVICE_HOST + "/domain.social.url?api_key=&domain=#{domain}&history=true").to_return(File.new(File.join(xml_base, 'domain.social.url_with_history.xml')))
646
+ Sistrix.domain_social_url(:domain => domain, :history => true)
647
+ }
648
+
649
+ its(:credits) { should == 3 }
650
+ its(:url) { should == 'http://www.zeit.de/2011/38/P-Fahrrad' }
651
+ its(:total) { should == 408 }
652
+ its(:facebook) { should == 260 }
653
+ its(:twitter) { should == 144 }
654
+ its(:googleplus) { should == 4 }
655
+ its("history.size") { should == 2 }
656
+
657
+ describe "history[0]" do
658
+ let(:history) { subject.history[0] }
659
+
660
+ it "should be" do
661
+ history.should be
662
+ end
663
+
664
+ it "date should be '2012-04-11T16:56:19+02:00'" do
665
+ history.date.should == Time.parse('2012-04-11T16:56:19+02:00')
666
+ end
667
+
668
+ it "total should be 408" do
669
+ history.total.should == 408
670
+ end
671
+
672
+ it "facebook should be 260" do
673
+ history.facebook.should == 260
674
+ end
675
+
676
+ it "twitter should be 144" do
677
+ history.twitter.should == 144
678
+ end
679
+
680
+ it "googleplus should be 4" do
681
+ history.googleplus.should == 4
682
+ end
683
+ end
684
+
685
+ end