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.
@@ -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../) ? response : nil
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
@@ -1,3 +1,3 @@
1
1
  module Protolink
2
- VERSION = '0.2.4' unless defined?(::Protolink::VERSION)
2
+ VERSION = '0.2.5' unless defined?(::Protolink::VERSION)
3
3
  end
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: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 4
10
- version: 0.2.4
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-29 00:00:00 +02:00
19
+ date: 2011-08-30 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency