pas 0.0.1 → 0.0.2
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.
- data/.gitignore +2 -1
- data/lib/pas.rb +29 -11
- data/lib/pas/connection.rb +36 -0
- data/lib/pas/member.rb +13 -3
- data/lib/pas/member_tracker.rb +13 -3
- data/lib/pas/resource.rb +12 -20
- data/lib/pas/session.rb +19 -0
- data/lib/pas/version.rb +2 -2
- data/pas.gemspec +2 -1
- data/spec/pas_spec.rb +15 -0
- data/{test/helper.rb → spec/spec_helper.rb} +4 -7
- metadata +25 -8
- data/VERSION +0 -1
- data/test/test_pas.rb +0 -7
data/.gitignore
CHANGED
data/lib/pas.rb
CHANGED
@@ -1,13 +1,31 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require 'pas/resource'
|
7
|
-
require 'pas/member'
|
8
|
-
require 'pas/member_tracker'
|
1
|
+
module PAS
|
2
|
+
require 'active_resource'
|
3
|
+
require 'active_support'
|
4
|
+
require 'openssl'
|
5
|
+
require 'base64'
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
autoload :Connection, 'pas/connection'
|
8
|
+
autoload :Resource, 'pas/resource'
|
9
|
+
autoload :Session, 'pas/session'
|
10
|
+
autoload :Member, 'pas/member'
|
11
|
+
autoload :MemberTracker, 'pas/member_tracker'
|
12
|
+
|
13
|
+
class << self
|
14
|
+
|
15
|
+
def config
|
16
|
+
@config ||= {
|
17
|
+
:api_access_key => "",
|
18
|
+
:api_token => "",
|
19
|
+
:domain_name => "https://publisher.pokeraffiliatesolutions.com/"
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
class Error < RuntimeError; end
|
26
|
+
class DisabledMethodError < PAS::Error
|
27
|
+
def initialize
|
28
|
+
super "This method is disabled for this Resource"
|
29
|
+
end
|
30
|
+
end
|
13
31
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module PAS
|
2
|
+
class Connection < ActiveResource::Connection
|
3
|
+
|
4
|
+
def get(path, headers = {})
|
5
|
+
super(merge_signature_to_path(:get, path), headers)
|
6
|
+
end
|
7
|
+
|
8
|
+
def delete(path, headers = {})
|
9
|
+
super(merge_signature_to_path(:delete, path), headers)
|
10
|
+
end
|
11
|
+
|
12
|
+
def put(path, body = '', headers = {})
|
13
|
+
super(merge_signature_to_path(:put, path), body, headers)
|
14
|
+
end
|
15
|
+
|
16
|
+
def post(path, body = '', headers = {})
|
17
|
+
super(merge_signature_to_path(:post, path), body, headers)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def merge_signature_to_path(request_method, path)
|
22
|
+
path, query = path.split("?")
|
23
|
+
timestamp = Time.now.to_i.to_s
|
24
|
+
signature = CGI::escape(generate_signature(request_method, path, timestamp))
|
25
|
+
params = "?#{query.blank? ? "" : "#{query}&" }api_token=#{PAS.config[:api_token].to_s}×tamp=#{timestamp}&signature=#{signature}"
|
26
|
+
|
27
|
+
path + params
|
28
|
+
end
|
29
|
+
|
30
|
+
def generate_signature(request_method, path, timestamp)
|
31
|
+
data = PAS.config[:api_token].to_s + request_method.to_s.upcase + path + timestamp
|
32
|
+
signature = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, PAS.config[:api_access_key].to_s, data)
|
33
|
+
Base64.encode64(signature).chomp
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/pas/member.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
|
-
|
2
|
-
class Member < Resource
|
3
|
-
self.
|
1
|
+
module PAS
|
2
|
+
class Member < PAS::Resource
|
3
|
+
self.collection_name = "publisher_members"
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def delete(*args)
|
7
|
+
raise PAS::DisabledMethodError
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def destroy
|
12
|
+
raise PAS::DisabledMethodError
|
13
|
+
end
|
4
14
|
end
|
5
15
|
end
|
data/lib/pas/member_tracker.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
|
-
|
2
|
-
class MemberTracker < Resource
|
3
|
-
self.
|
1
|
+
module PAS
|
2
|
+
class MemberTracker < PAS::Resource
|
3
|
+
self.collection_name = "publisher_member_trackers"
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def delete(*args)
|
7
|
+
raise PAS::DisabledMethodError
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def destroy
|
12
|
+
raise PAS::DisabledMethodError
|
13
|
+
end
|
4
14
|
end
|
5
15
|
end
|
data/lib/pas/resource.rb
CHANGED
@@ -1,26 +1,18 @@
|
|
1
|
-
|
1
|
+
module PAS
|
2
2
|
class Resource < ActiveResource::Base
|
3
|
-
self.site =
|
3
|
+
self.site = PAS.config[:domain_name]
|
4
4
|
|
5
5
|
class << self
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
path = element_path(scope, prefix_options, query_options)
|
17
|
-
instantiate_record(connection.get(path, headers), prefix_options)
|
18
|
-
end
|
19
|
-
|
20
|
-
def generate_signature(request_method, request_path, timestamp)
|
21
|
-
data = PAS.api_token.to_s + request_method + request_path + timestamp
|
22
|
-
signature = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, PAS.api_access_key.to_s, data)
|
23
|
-
Base64.encode64(signature).chomp
|
6
|
+
def connection(refresh = false)
|
7
|
+
if defined?(@connection) || superclass == Object
|
8
|
+
@connection = PAS::Connection.new(site, format) if refresh || @connection.nil?
|
9
|
+
@connection.user = user if user
|
10
|
+
@connection.password = password if password
|
11
|
+
@connection.timeout = timeout if timeout
|
12
|
+
@connection
|
13
|
+
else
|
14
|
+
superclass.connection
|
15
|
+
end
|
24
16
|
end
|
25
17
|
end
|
26
18
|
end
|
data/lib/pas/session.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module PAS
|
2
|
+
class Session < PAS::Resource
|
3
|
+
self.collection_name = "member_remote_sessions"
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def delete(*args)
|
7
|
+
raise PAS::DisabledMethodError
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def destroy
|
12
|
+
raise PAS::DisabledMethodError
|
13
|
+
end
|
14
|
+
|
15
|
+
def update
|
16
|
+
raise PAS::DisabledMethodError
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/pas/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0.
|
1
|
+
module PAS
|
2
|
+
VERSION = "0.0.2"
|
3
3
|
end
|
data/pas.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = "jfernandez@fourcubed.com"
|
10
10
|
s.homepage = "http://github.com/jfernandez/pas"
|
11
11
|
s.summary = "Poker Affiliate Solutions API Wrapper Gem"
|
12
|
-
s.description = "This gem allows you to communicate with the PokerAffiliateSolutions.com REST API"
|
12
|
+
s.description = "This gem allows you to communicate with the PokerAffiliateSolutions.com REST API [Alpha]"
|
13
13
|
|
14
14
|
s.required_rubygems_version = ">= 1.3.6"
|
15
15
|
s.rubyforge_project = "pas"
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_dependency("activesupport", "~> 2.3.5")
|
19
19
|
|
20
20
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
21
|
+
s.add_development_dependency "rspec", "2.0.0"
|
21
22
|
|
22
23
|
s.files = `git ls-files`.split("\n")
|
23
24
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
data/spec/pas_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PAS do
|
4
|
+
it "has a default blank value for config[:api_access_key]" do
|
5
|
+
PAS.config[:api_access_key].should be_blank
|
6
|
+
end
|
7
|
+
|
8
|
+
it "has a default blank value for config[:api_token]" do
|
9
|
+
PAS.config[:api_token].should be_blank
|
10
|
+
end
|
11
|
+
|
12
|
+
it "has PAS's SSL domain name as the default value for config[:domain_name]" do
|
13
|
+
PAS.config[:domain_name].should == "https://publisher.pokeraffiliatesolutions.com/"
|
14
|
+
end
|
15
|
+
end
|
@@ -1,10 +1,7 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/unit'
|
3
|
-
require 'shoulda'
|
4
|
-
|
5
1
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
-
require 'pas'
|
8
3
|
|
9
|
-
|
10
|
-
|
4
|
+
require 'rubygems'
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'rspec'
|
7
|
+
require 'pas'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jose Fernandez
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-17 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -66,7 +66,23 @@ dependencies:
|
|
66
66
|
version: 1.0.0
|
67
67
|
type: :development
|
68
68
|
version_requirements: *id003
|
69
|
-
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - "="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 15
|
78
|
+
segments:
|
79
|
+
- 2
|
80
|
+
- 0
|
81
|
+
- 0
|
82
|
+
version: 2.0.0
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
85
|
+
description: This gem allows you to communicate with the PokerAffiliateSolutions.com REST API [Alpha]
|
70
86
|
email: jfernandez@fourcubed.com
|
71
87
|
executables: []
|
72
88
|
|
@@ -80,15 +96,16 @@ files:
|
|
80
96
|
- LICENSE
|
81
97
|
- README.rdoc
|
82
98
|
- Rakefile
|
83
|
-
- VERSION
|
84
99
|
- lib/pas.rb
|
100
|
+
- lib/pas/connection.rb
|
85
101
|
- lib/pas/member.rb
|
86
102
|
- lib/pas/member_tracker.rb
|
87
103
|
- lib/pas/resource.rb
|
104
|
+
- lib/pas/session.rb
|
88
105
|
- lib/pas/version.rb
|
89
106
|
- pas.gemspec
|
90
|
-
-
|
91
|
-
-
|
107
|
+
- spec/pas_spec.rb
|
108
|
+
- spec/spec_helper.rb
|
92
109
|
has_rdoc: true
|
93
110
|
homepage: http://github.com/jfernandez/pas
|
94
111
|
licenses: []
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.0
|