ruby-box 1.11.0 → 1.11.1
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.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/lib/ruby-box/exceptions.rb +6 -2
- data/lib/ruby-box/session.rb +4 -4
- data/ruby-box.gemspec +2 -2
- data/spec/integration_spec.rb +20 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWRiNTUwYmE4YTFkYzJlN2M4OGQxYTQ2ZDFmZjRhMzEyZTRlMmIwMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDQxMDNjZWYyODc2Njc5MThjNjllYjMzZGE5MmU2OTY5MTc5OGJhNQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWM3MDRmN2E5M2RmZjYxOWJiOWIwY2ZhNzFlNTA4MzZlM2U3ZTc4ZTNjNGY2
|
10
|
+
MzkzMDAwZTcyYjY0OWFhNjM3MWQyNTUyZDgxNzNjODViYTM1MGMyNzY4Njcy
|
11
|
+
ODk1NDNjYzMwZWVjNTJjNTMyMDAwMTY4NTRmOWQ4ZjM3Yzk3ZDI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjA4M2UyZDY4OWIzYzU1YjgyMTFhYmI2MTM1Yjk3NzFmZTRmYzQwMGViOGFk
|
14
|
+
YWQ0Yzg5ODg3NzdhNDE4ODEyNTQzNmVlNTY5YTAyYThlMWY1ZmM0MmQ3ODhk
|
15
|
+
YmMzMjdhZTU5ZjRkZjNhODFlMTk4Nzg1YzFhMWQ1MTc2NWQ3MzQ=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.11.
|
1
|
+
1.11.1
|
data/lib/ruby-box/exceptions.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module RubyBox
|
2
2
|
class RubyBoxError < StandardError
|
3
|
-
|
3
|
+
attr_accessor :body, :status
|
4
|
+
|
5
|
+
def initialize(error_json, status, body)
|
6
|
+
@status = status
|
7
|
+
@body = body
|
4
8
|
@error_json = error_json
|
5
9
|
end
|
6
10
|
|
@@ -12,7 +16,7 @@ module RubyBox
|
|
12
16
|
class ObjectNotFound < StandardError; end
|
13
17
|
class AuthError < RubyBoxError; end
|
14
18
|
class RequestError < RubyBoxError; end
|
15
|
-
class ServerError <
|
19
|
+
class ServerError < RubyBoxError; end
|
16
20
|
class ItemNameInUse < RubyBoxError; end
|
17
21
|
class UnshareableResource < StandardError; end
|
18
22
|
end
|
data/lib/ruby-box/session.rb
CHANGED
@@ -112,11 +112,11 @@ module RubyBox
|
|
112
112
|
|
113
113
|
case status / 100
|
114
114
|
when 4
|
115
|
-
raise(RubyBox::ItemNameInUse.new(parsed_body), parsed_body["message"]) if parsed_body["code"] == "item_name_in_use"
|
116
|
-
raise(RubyBox::AuthError.new(parsed_body), parsed_body["message"]) if parsed_body["code"] == "unauthorized" || status == 401
|
117
|
-
raise(RubyBox::RequestError.new(parsed_body), parsed_body["message"])
|
115
|
+
raise(RubyBox::ItemNameInUse.new(parsed_body, status, body), parsed_body["message"]) if parsed_body["code"] == "item_name_in_use"
|
116
|
+
raise(RubyBox::AuthError.new(parsed_body, status, body), parsed_body["message"]) if parsed_body["code"] == "unauthorized" || status == 401
|
117
|
+
raise(RubyBox::RequestError.new(parsed_body, status, body), parsed_body["message"])
|
118
118
|
when 5
|
119
|
-
raise
|
119
|
+
raise(RubyBox::ServerError.new(parsed_body, status, body), parsed_body["message"])
|
120
120
|
end
|
121
121
|
raw ? body : parsed_body
|
122
122
|
end
|
data/ruby-box.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "ruby-box"
|
8
|
-
s.version = "1.11.
|
8
|
+
s.version = "1.11.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Attachments.me"]
|
12
|
-
s.date = "2013-09-
|
12
|
+
s.date = "2013-09-09"
|
13
13
|
s.description = "ruby gem for box.com 2.0 api"
|
14
14
|
s.email = "ben@attachments.me"
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/integration_spec.rb
CHANGED
@@ -42,12 +42,31 @@ describe RubyBox, :skip => true do
|
|
42
42
|
|
43
43
|
it "raises a RequestError if a badly formed request detected by the server" do
|
44
44
|
stub_request(:get, "https://api.box.com/2.0/folders/0").to_return(:status => 401, :body => '{"type": "error", "status": 401, "message": "baddd req"}', :headers => {})
|
45
|
-
lambda {@client.root_folder}.should raise_error( RubyBox::AuthError )
|
45
|
+
lambda {@client.root_folder}.should raise_error( RubyBox::AuthError )
|
46
|
+
|
47
|
+
# make sure status and body is
|
48
|
+
# set on error object.
|
49
|
+
begin
|
50
|
+
@client.root_folder
|
51
|
+
rescue Exception => e
|
52
|
+
e.body.should == '{"type": "error", "status": 401, "message": "baddd req"}'
|
53
|
+
e.status.should == 401
|
54
|
+
end
|
46
55
|
end
|
47
56
|
|
48
57
|
it "raises a ServerError if the server raises a 500 error" do
|
49
58
|
stub_request(:get, "https://api.box.com/2.0/folders/0").to_return(:status => 503, :body => '{"type": "error", "status": 503, "message": "We messed up! - Box.com"}', :headers => {})
|
50
59
|
lambda {@client.root_folder}.should raise_error( RubyBox::ServerError )
|
60
|
+
|
61
|
+
# make sure status and body is
|
62
|
+
# set on error object.
|
63
|
+
begin
|
64
|
+
@client.root_folder
|
65
|
+
rescue Exception => e
|
66
|
+
e.body.should == '{"type": "error", "status": 503, "message": "We messed up! - Box.com"}'
|
67
|
+
e.status.should == 503
|
68
|
+
end
|
69
|
+
|
51
70
|
end
|
52
71
|
|
53
72
|
describe RubyBox::Folder do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Attachments.me
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multipart-post
|