sistrix 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +59 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/sistrix.rb +28 -0
- data/lib/sistrix/base.rb +23 -0
- data/lib/sistrix/config.rb +15 -0
- data/lib/sistrix/domain.rb +60 -0
- data/lib/sistrix/domain/age.rb +32 -0
- data/lib/sistrix/domain/competitors/sem.rb +50 -0
- data/lib/sistrix/domain/competitors/seo.rb +52 -0
- data/lib/sistrix/domain/competitors/us.rb +53 -0
- data/lib/sistrix/domain/kwcount/sem.rb +54 -0
- data/lib/sistrix/domain/kwcount/seo.rb +54 -0
- data/lib/sistrix/domain/overview.rb +71 -0
- data/lib/sistrix/domain/pagerank.rb +51 -0
- data/lib/sistrix/domain/pages.rb +51 -0
- data/lib/sistrix/domain/sichtbarkeitsindex.rb +49 -0
- data/lib/sistrix/domain/social/latest.rb +52 -0
- data/lib/sistrix/domain/social/overview.rb +36 -0
- data/lib/sistrix/domain/social/top.rb +52 -0
- data/lib/sistrix/domain/social/url.rb +63 -0
- data/lib/sistrix/keyword.rb +60 -0
- data/lib/sistrix/keyword/domain/sem.rb +59 -0
- data/lib/sistrix/keyword/domain/seo.rb +65 -0
- data/lib/sistrix/keyword/domain/us.rb +61 -0
- data/lib/sistrix/keyword/sem.rb +58 -0
- data/lib/sistrix/keyword/seo.rb +57 -0
- data/lib/sistrix/keyword/us.rb +56 -0
- data/lib/sistrix/links/linktargets.rb +57 -0
- data/lib/sistrix/links/linktexts.rb +61 -0
- data/lib/sistrix/links/list.rb +53 -0
- data/lib/sistrix/links/overview.rb +36 -0
- data/lib/sistrix/monitoring/folders.rb +53 -0
- data/lib/sistrix/monitoring/projects.rb +51 -0
- data/lib/sistrix/monitoring/report.rb +74 -0
- data/lib/sistrix/monitoring/report/download.rb +60 -0
- data/lib/sistrix/monitoring/reports.rb +52 -0
- data/lib/sistrix/record.rb +13 -0
- data/sistrix.gemspec +146 -0
- data/spec/sistrix_domain_spec.rb +685 -0
- data/spec/sistrix_keyword_spec.rb +216 -0
- data/spec/sistrix_links_spec.rb +221 -0
- data/spec/sistrix_monitoring_spec.rb +190 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/xml/domain.age.xml +19 -0
- data/spec/xml/domain.competitors.sem.xml +23 -0
- data/spec/xml/domain.competitors.seo.xml +23 -0
- data/spec/xml/domain.competitors.us.xml +23 -0
- data/spec/xml/domain.kwcount.sem.xml +19 -0
- data/spec/xml/domain.kwcount.seo.xml +19 -0
- data/spec/xml/domain.overview.xml +24 -0
- data/spec/xml/domain.pagerank.xml +19 -0
- data/spec/xml/domain.pages.xml +19 -0
- data/spec/xml/domain.sichtbarkeitsindex.xml +19 -0
- data/spec/xml/domain.social.latest.xml +28 -0
- data/spec/xml/domain.social.overview.xml +21 -0
- data/spec/xml/domain.social.top.xml +28 -0
- data/spec/xml/domain.social.url.xml +19 -0
- data/spec/xml/domain.social.url_with_history.xml +23 -0
- data/spec/xml/domain.xml +29 -0
- data/spec/xml/keyword.domain.sem.xml +24 -0
- data/spec/xml/keyword.domain.seo.xml +24 -0
- data/spec/xml/keyword.domain.us.xml +24 -0
- data/spec/xml/keyword.sem.xml +22 -0
- data/spec/xml/keyword.sem_with_domain.xml +212 -0
- data/spec/xml/keyword.sem_with_domain2.xml +20 -0
- data/spec/xml/keyword.seo.xml +29 -0
- data/spec/xml/keyword.seo_with_url.xml +20 -0
- data/spec/xml/keyword.us.xml +28 -0
- data/spec/xml/keyword.us_nodate.xml +19 -0
- data/spec/xml/keyword.xml +21 -0
- data/spec/xml/links.linktargets.xml +118 -0
- data/spec/xml/links.linktexts.xml +28 -0
- data/spec/xml/links.list.xml +10018 -0
- data/spec/xml/links.overview.xml +23 -0
- data/spec/xml/monitoring.folders.xml +20 -0
- data/spec/xml/monitoring.projects.xml +37 -0
- data/spec/xml/monitoring.report.download.pdf +0 -0
- data/spec/xml/monitoring.report.download_error.xml +18 -0
- data/spec/xml/monitoring.report.xml +181 -0
- data/spec/xml/monitoring.reports.xml +19 -0
- data/test/helper.rb +18 -0
- data/test/test_sistrix.rb +7 -0
- metadata +232 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
gem 'nokogiri'
|
3
|
+
gem 'rest-client', '>= 1.0'
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem "rspec", ">= 1.3.2"
|
7
|
+
gem "shoulda", ">= 0"
|
8
|
+
gem "bundler", "~> 1.0.0"
|
9
|
+
gem "jeweler", "~> 1.6.4"
|
10
|
+
gem "simplecov", ">= 0"
|
11
|
+
gem "webmock", ">=1.8.6"
|
12
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Tobias Begalke
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
= sistrix
|
2
|
+
|
3
|
+
A ruby library for the Sistrix web API
|
4
|
+
|
5
|
+
== How to use Sistrix
|
6
|
+
|
7
|
+
Use RubyGems to install sistrix:
|
8
|
+
|
9
|
+
$ gem install elcamino-sistrix
|
10
|
+
|
11
|
+
Require the library:
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'sistrix'
|
15
|
+
|
16
|
+
Provide your API credentials:
|
17
|
+
|
18
|
+
Sistrix.config do |c|
|
19
|
+
c.api_key = YOUR_API_KEY
|
20
|
+
end
|
21
|
+
|
22
|
+
Call individual functions, e.g.
|
23
|
+
|
24
|
+
data = Sistrix.domain(:domain => 'zeit.de')
|
25
|
+
sichtbarkeitsindex = Sistrix.domain_sichtbarkeitsindex(:domain => 'zeit.de')
|
26
|
+
number_of_pages = Sistrix.domain_pages(:domain => 'zeit.de')
|
27
|
+
pagerank = Sistrix.domain_pagerank(:domain => 'zeit.de')
|
28
|
+
age = Sistrix.domain_age(:domain => 'zeit.de')
|
29
|
+
seo_competitors = Sistrix.domain_competitors_seo(:domain => 'zeit.de')
|
30
|
+
sem_competitors = Sistrix.domain_competitors_sem(:domain => 'zeit.de')
|
31
|
+
us_competitors = Sistrix.domain_competitors_us(:domain => 'zeit.de')
|
32
|
+
kwcount_seo = Sistrix.domain_kwcount_seo(:domain => 'zeit.de')
|
33
|
+
kwcount_sem = Sistrix.domain_kwcount_sem(:domain => 'zeit.de')
|
34
|
+
|
35
|
+
You can see all available methods in the rspec test files "spec/*_spec.rb"
|
36
|
+
|
37
|
+
This library supports all available methods. Please refer to the
|
38
|
+
documentation at http://www.sistrix.de/service/docs/api. The API
|
39
|
+
method domain.overview can be called through
|
40
|
+
Sistrix.domain_overview(). Replace the dot in the original method name
|
41
|
+
by an underscore (_) and call the method statically on the Sistrix
|
42
|
+
class.
|
43
|
+
|
44
|
+
|
45
|
+
== Contributing to sistrix
|
46
|
+
|
47
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
48
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
49
|
+
* Fork the project
|
50
|
+
* Start a feature/bugfix branch
|
51
|
+
* Commit and push until you are happy with your contribution
|
52
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
53
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
54
|
+
|
55
|
+
== Copyright
|
56
|
+
|
57
|
+
Copyright (c) 2011-2012 Tobias Begalke. See LICENSE.txt for
|
58
|
+
further details.
|
59
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "sistrix"
|
18
|
+
gem.homepage = "http://github.com/elcamino/sistrix"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Sistrix web API library for ruby}
|
21
|
+
gem.description = %Q{A ruby libary for the Sistrix web API}
|
22
|
+
gem.email = "elcamino@spyz.org"
|
23
|
+
gem.authors = ["Tobias Begalke"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'rdoc/task'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "sistrix #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
46
|
+
|
47
|
+
require 'rspec/core/rake_task'
|
48
|
+
RSpec::Core::RakeTask.new(:spec)
|
49
|
+
task :default => :spec
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/lib/sistrix.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Sistrix
|
2
|
+
require 'sistrix/config'
|
3
|
+
|
4
|
+
SERVICE_HOST = 'api.sistrix.net'
|
5
|
+
|
6
|
+
|
7
|
+
def self.method_missing(sym, *args, &block)
|
8
|
+
clazz_name = 'Sistrix::' + sym.to_s.split(/_/).map { |w| w[0].upcase + w[1..w.length] }.join('::')
|
9
|
+
lib_name = 'sistrix/' + sym.to_s.gsub(/_/, '/')
|
10
|
+
require lib_name
|
11
|
+
|
12
|
+
clazz = class_from_string(clazz_name)
|
13
|
+
return clazz.new(args[0]).call
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def self.class_from_string(str)
|
19
|
+
str.split('::').inject(Object) do |mod, class_name|
|
20
|
+
mod.const_get(class_name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class ArgumentException < Exception
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
data/lib/sistrix/base.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Sistrix
|
2
|
+
module Base
|
3
|
+
require 'rest-client'
|
4
|
+
require 'nokogiri'
|
5
|
+
|
6
|
+
def fetch(options = {})
|
7
|
+
@options.merge!(options)
|
8
|
+
|
9
|
+
response = RestClient.get(base_uri, { :params => @options })
|
10
|
+
Nokogiri::XML(response.to_s)
|
11
|
+
end
|
12
|
+
|
13
|
+
def method_name
|
14
|
+
# derive the method name from the class name
|
15
|
+
#
|
16
|
+
self.class.to_s.downcase.sub(/^.+?::/, '').gsub(/::/, '.')
|
17
|
+
end
|
18
|
+
|
19
|
+
def base_uri
|
20
|
+
'http://' + ::Sistrix::SERVICE_HOST + '/' + method_name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Sistrix
|
2
|
+
|
3
|
+
require 'sistrix/base'
|
4
|
+
|
5
|
+
class Domain
|
6
|
+
include ::Sistrix::Base
|
7
|
+
|
8
|
+
attr_reader :credits, :options
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
@options = {
|
12
|
+
'domain' => nil,
|
13
|
+
'api_key' => Sistrix.config.api_key,
|
14
|
+
}.merge(options)
|
15
|
+
|
16
|
+
if Sistrix.config.proxy
|
17
|
+
RestClient.proxy = Sistrix.config.proxy
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(options = {})
|
22
|
+
data = fetch(options)
|
23
|
+
|
24
|
+
@credits = data.xpath('//credits').first['used'].to_i
|
25
|
+
@options = []
|
26
|
+
data.xpath('//answer/option').each do |o|
|
27
|
+
@options << Record.new(o)
|
28
|
+
end
|
29
|
+
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
class Record
|
34
|
+
require 'sistrix/record'
|
35
|
+
include ::Sistrix::Record
|
36
|
+
|
37
|
+
def method
|
38
|
+
@data[:method]
|
39
|
+
end
|
40
|
+
|
41
|
+
def url
|
42
|
+
@data[:url]
|
43
|
+
end
|
44
|
+
|
45
|
+
def name
|
46
|
+
@data[:name]
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize(xml_node)
|
50
|
+
@data = {}
|
51
|
+
|
52
|
+
@data[:method] = xml_node['method']
|
53
|
+
@data[:url] = xml_node['url']
|
54
|
+
@data[:name] = xml_node['name']
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Sistrix
|
2
|
+
require 'sistrix/base'
|
3
|
+
|
4
|
+
class Domain
|
5
|
+
class Age
|
6
|
+
include ::Sistrix::Base
|
7
|
+
attr_reader :credits, :age, :domain
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@options = {
|
11
|
+
'domain' => nil,
|
12
|
+
'api_key' => Sistrix.config.api_key,
|
13
|
+
}.merge(options)
|
14
|
+
|
15
|
+
if Sistrix.config.proxy
|
16
|
+
RestClient.proxy = Sistrix.config.proxy
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(options = {})
|
21
|
+
data = fetch(options)
|
22
|
+
|
23
|
+
@credits = data.xpath('//credits').first['used'].to_i
|
24
|
+
age_node = data.xpath('//answer/age').first
|
25
|
+
@age = Time.parse(age_node['value'])
|
26
|
+
@domain = age_node['domain']
|
27
|
+
|
28
|
+
self
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Sistrix
|
2
|
+
|
3
|
+
require 'sistrix/base'
|
4
|
+
|
5
|
+
class Domain
|
6
|
+
class Competitors
|
7
|
+
class Sem
|
8
|
+
include ::Sistrix::Base
|
9
|
+
|
10
|
+
attr_reader :credits, :competitors
|
11
|
+
|
12
|
+
def initialize(options = {})
|
13
|
+
@options = {
|
14
|
+
'num' => 5,
|
15
|
+
'domain' => nil,
|
16
|
+
'api_key' => Sistrix.config.api_key,
|
17
|
+
}.merge(options)
|
18
|
+
|
19
|
+
if Sistrix.config.proxy
|
20
|
+
RestClient.proxy = Sistrix.config.proxy
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def call(options = {})
|
25
|
+
data = fetch(options)
|
26
|
+
|
27
|
+
@credits = data.xpath('//credits').first['used'].to_i
|
28
|
+
@competitors = []
|
29
|
+
data.xpath('//answer/result').each do |r|
|
30
|
+
@competitors << Record.new(r)
|
31
|
+
end
|
32
|
+
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
class Record
|
37
|
+
require 'sistrix/record'
|
38
|
+
include ::Sistrix::Record
|
39
|
+
|
40
|
+
def initialize(xml_node)
|
41
|
+
@data = {}
|
42
|
+
|
43
|
+
@data[:domain] = xml_node['domain'].strip
|
44
|
+
@data[:match] = xml_node['match'].strip.to_i
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Sistrix
|
2
|
+
|
3
|
+
require 'sistrix/base'
|
4
|
+
|
5
|
+
class Domain
|
6
|
+
class Competitors
|
7
|
+
class Seo
|
8
|
+
include ::Sistrix::Base
|
9
|
+
|
10
|
+
attr_reader :credits, :competitors
|
11
|
+
|
12
|
+
def initialize(options = {})
|
13
|
+
@options = {
|
14
|
+
'num' => 5,
|
15
|
+
'domain' => nil,
|
16
|
+
'api_key' => Sistrix.config.api_key,
|
17
|
+
}.merge(options)
|
18
|
+
|
19
|
+
if Sistrix.config.proxy
|
20
|
+
RestClient.proxy = Sistrix.config.proxy
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def call(options = {})
|
25
|
+
data = fetch(options)
|
26
|
+
|
27
|
+
@credits = data.xpath('//credits').first['used'].to_i
|
28
|
+
@competitors = []
|
29
|
+
data.xpath('//answer/result').each do |r|
|
30
|
+
@competitors << Record.new(r)
|
31
|
+
end
|
32
|
+
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
class Record
|
37
|
+
require 'sistrix/record'
|
38
|
+
include ::Sistrix::Record
|
39
|
+
|
40
|
+
def initialize(xml_node)
|
41
|
+
@data = {}
|
42
|
+
|
43
|
+
@data[:domain] = xml_node['domain'].strip
|
44
|
+
@data[:match] = xml_node['match'].strip.to_i
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Sistrix
|
2
|
+
|
3
|
+
require 'sistrix/base'
|
4
|
+
|
5
|
+
class Domain
|
6
|
+
class Competitors
|
7
|
+
class Us
|
8
|
+
include ::Sistrix::Base
|
9
|
+
|
10
|
+
attr_reader :credits, :competitors
|
11
|
+
|
12
|
+
def initialize(options = {})
|
13
|
+
@options = {
|
14
|
+
'num' => 5,
|
15
|
+
'domain' => nil,
|
16
|
+
'api_key' => Sistrix.config.api_key,
|
17
|
+
}.merge(options)
|
18
|
+
|
19
|
+
if Sistrix.config.proxy
|
20
|
+
RestClient.proxy = Sistrix.config.proxy
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def call(options = {})
|
25
|
+
data = fetch(options)
|
26
|
+
|
27
|
+
@credits = data.xpath('//credits').first['used'].to_i
|
28
|
+
@competitors = []
|
29
|
+
data.xpath('//answer/result').each do |r|
|
30
|
+
@competitors << Record.new(r)
|
31
|
+
end
|
32
|
+
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
class Record
|
37
|
+
require 'sistrix/record'
|
38
|
+
include ::Sistrix::Record
|
39
|
+
|
40
|
+
def initialize(xml_node)
|
41
|
+
@data = {}
|
42
|
+
|
43
|
+
@data[:domain] = xml_node['domain'].strip
|
44
|
+
@data[:match] = xml_node['match'].strip.to_i
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|