sistrix 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ A ruby library for the Sistrix web API
6
6
 
7
7
  Use RubyGems to install sistrix:
8
8
 
9
- $ gem install elcamino-sistrix
9
+ $ gem install sistrix
10
10
 
11
11
  Require the library:
12
12
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -0,0 +1,29 @@
1
+ module Sistrix
2
+
3
+ require 'sistrix/base'
4
+
5
+ class Credits
6
+ include ::Sistrix::Base
7
+
8
+ attr_reader :credits, :credits_available
9
+
10
+ def initialize(options = {})
11
+ @options = {
12
+ 'api_key' => Sistrix.config.api_key,
13
+ }
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('/response/credits').first['used'].to_i
24
+ @credits_available = data.xpath('/response/answer/credits').first['value'].to_s.strip.to_i
25
+
26
+ self
27
+ end
28
+ end
29
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sistrix}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tobias Begalke"]
12
- s.date = %q{2012-04-13}
12
+ s.date = %q{2012-04-16}
13
13
  s.description = %q{A ruby libary for the Sistrix web API}
14
14
  s.email = %q{elcamino@spyz.org}
15
15
  s.extra_rdoc_files = [
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  "lib/sistrix.rb",
27
27
  "lib/sistrix/base.rb",
28
28
  "lib/sistrix/config.rb",
29
+ "lib/sistrix/credits.rb",
29
30
  "lib/sistrix/domain.rb",
30
31
  "lib/sistrix/domain/age.rb",
31
32
  "lib/sistrix/domain/competitors/sem.rb",
@@ -59,11 +60,13 @@ Gem::Specification.new do |s|
59
60
  "lib/sistrix/monitoring/reports.rb",
60
61
  "lib/sistrix/record.rb",
61
62
  "sistrix.gemspec",
63
+ "spec/sistrix_credits.rb",
62
64
  "spec/sistrix_domain_spec.rb",
63
65
  "spec/sistrix_keyword_spec.rb",
64
66
  "spec/sistrix_links_spec.rb",
65
67
  "spec/sistrix_monitoring_spec.rb",
66
68
  "spec/spec_helper.rb",
69
+ "spec/xml/credits.xml",
67
70
  "spec/xml/domain.age.xml",
68
71
  "spec/xml/domain.competitors.sem.xml",
69
72
  "spec/xml/domain.competitors.seo.xml",
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'sistrix'
5
+
6
+ WebMock.disable_net_connect!
7
+ include WebMock::API
8
+
9
+ xml_base = File.join(File.dirname(__FILE__), 'xml')
10
+
11
+
12
+ describe "Sistrix.credits() returns the current number of credits for the current API_KEY" do
13
+
14
+ subject {
15
+ stub_request(:get, Sistrix::SERVICE_HOST + "/credits?api_key=").to_return(File.new(File.join(xml_base, 'credits.xml')))
16
+ Sistrix.credits()
17
+ }
18
+
19
+ it { should be }
20
+
21
+ its(:credits) { should == 0 }
22
+ its(:credits_available) { should == 40000 }
23
+
24
+ end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'spec_helper'
4
4
  require 'sistrix'
5
- require 'pp'
6
5
 
7
6
  WebMock.disable_net_connect!
8
7
  include WebMock::API
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'spec_helper'
4
4
  require 'sistrix'
5
- require 'pp'
6
5
 
7
6
  WebMock.disable_net_connect!
8
7
  include WebMock::API
@@ -2,9 +2,6 @@
2
2
 
3
3
  require 'spec_helper'
4
4
  require 'sistrix'
5
- require 'pp'
6
-
7
-
8
5
 
9
6
  WebMock.disable_net_connect!
10
7
  include WebMock::API
@@ -3,7 +3,6 @@
3
3
  require 'spec_helper'
4
4
  require 'sistrix'
5
5
  require 'digest/md5'
6
- require 'pp'
7
6
 
8
7
 
9
8
 
@@ -0,0 +1,19 @@
1
+ HTTP/1.1 200 OK
2
+ Date: Mon, 16 Apr 2012 07:23:56 GMT
3
+ Server: Apache
4
+ X-Robots-Tag: noarchive
5
+ X-Answer: 42
6
+ Vary: Accept-Encoding
7
+ Content-Length: 176
8
+ Connection: close
9
+ Content-Type: text/xml; charset=utf-8
10
+
11
+ <?xml version="1.0" encoding="UTF-8"?>
12
+ <response>
13
+ <api_key/>
14
+ <method>credits</method>
15
+ <answer>
16
+ <credits value="40000"/>
17
+ </answer>
18
+ <credits used="0"/>
19
+ </response>
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sistrix
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tobias Begalke
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-04-13 00:00:00 +02:00
13
+ date: 2012-04-16 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -120,6 +120,7 @@ files:
120
120
  - lib/sistrix.rb
121
121
  - lib/sistrix/base.rb
122
122
  - lib/sistrix/config.rb
123
+ - lib/sistrix/credits.rb
123
124
  - lib/sistrix/domain.rb
124
125
  - lib/sistrix/domain/age.rb
125
126
  - lib/sistrix/domain/competitors/sem.rb
@@ -153,11 +154,13 @@ files:
153
154
  - lib/sistrix/monitoring/reports.rb
154
155
  - lib/sistrix/record.rb
155
156
  - sistrix.gemspec
157
+ - spec/sistrix_credits.rb
156
158
  - spec/sistrix_domain_spec.rb
157
159
  - spec/sistrix_keyword_spec.rb
158
160
  - spec/sistrix_links_spec.rb
159
161
  - spec/sistrix_monitoring_spec.rb
160
162
  - spec/spec_helper.rb
163
+ - spec/xml/credits.xml
161
164
  - spec/xml/domain.age.xml
162
165
  - spec/xml/domain.competitors.sem.xml
163
166
  - spec/xml/domain.competitors.seo.xml
@@ -211,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
211
214
  requirements:
212
215
  - - ">="
213
216
  - !ruby/object:Gem::Version
214
- hash: 1412740378428900138
217
+ hash: -416293129965611199
215
218
  segments:
216
219
  - 0
217
220
  version: "0"