protolink 0.2.4 → 0.2.5
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/lib/protolink/protonet.rb +7 -2
- data/lib/protolink/version.rb +1 -1
- data/test/all_tests.rb +5 -1
- metadata +4 -4
data/lib/protolink/protonet.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
|
3
3
|
module Protolink
|
4
|
-
|
4
|
+
|
5
5
|
# protonet = Protolink::Protonet.new 'domain', :user => 'john.doe', :password => 'secret', :token => 'xyz'
|
6
6
|
#
|
7
7
|
# channel = protonet.find_channel_by_name 'home'
|
8
8
|
# channel.speak 'Hello world!'
|
9
9
|
class Protonet
|
10
10
|
include HTTParty
|
11
|
+
class ApiException < RuntimeError; end
|
11
12
|
|
12
13
|
# Create a new connection to the account with the given +uri+.
|
13
14
|
#
|
@@ -128,7 +129,11 @@ module Protolink
|
|
128
129
|
class_eval <<-EOS
|
129
130
|
def #{method}(uri, options = {})
|
130
131
|
response = self.class.#{method}(uri, options)
|
131
|
-
response.code.to_s.match(/2../)
|
132
|
+
if response.code.to_s.match(/2../)
|
133
|
+
response
|
134
|
+
else
|
135
|
+
response['errors'] ? raise(ApiException, response['errors']) : nil
|
136
|
+
end
|
132
137
|
end
|
133
138
|
EOS
|
134
139
|
end
|
data/lib/protolink/version.rb
CHANGED
data/test/all_tests.rb
CHANGED
@@ -41,7 +41,11 @@ class TestAll < Test::Unit::TestCase
|
|
41
41
|
assert_equal 'test@test.com', user_1.email
|
42
42
|
assert_equal 'http://www.google.de', user_1.external_profile_url
|
43
43
|
assert user_1.auth_token.match(/\w+/)
|
44
|
-
|
44
|
+
|
45
|
+
assert_raise(Protolink::Protonet::ApiException) {
|
46
|
+
protonet.create_user(:login => 'test', :email => 'test@test.com', :external_profile_url => 'http://www.google.de')
|
47
|
+
}
|
48
|
+
|
45
49
|
user_2 = protonet.find_or_create_user_by_login('test', :email => 'test@test.com')
|
46
50
|
assert_equal user_1.id, user_2.id
|
47
51
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protolink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 5
|
10
|
+
version: 0.2.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Bj\xC3\xB6rn B. Dorra"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-08-
|
19
|
+
date: 2011-08-30 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|