box_view 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/box_view/http.rb +7 -5
- data/lib/box_view/version.rb +1 -1
- data/spec/http_spec.rb +15 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWQwZTBhYzY4NTBiMjhmZGM2ZTA5MjM2YzY3YTk3NGU0MmJmNDNkMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTAxMDM1NWQ2ZjIyZWVlZmRiYTVmOTMyOGVmY2MzOWFkYzI1ZDI2Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Zjg5M2EyMWJkMTYyNmE2ZjhhMzNhZjBhMDExOTg1Y2RjNjE2MTM5ZTI2Njdi
|
10
|
+
MjcyNWRkMzg5OTNmY2M0OWZkYjA0NzMxMzA3N2NjMjdlMWM5OWJmNDM5M2E4
|
11
|
+
NjVmMmUwYzVkMWJkOTc1Yjg0OTU2NDAxMzJkOWQzMGI1NjI5Nzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2UyMGY0MWJlNTEyYTE2YWU0ZmNmZTBiMWMyMGEzY2YzNmZmNzBmZjRjMzU0
|
14
|
+
OGIxYWUxNjc3ODI1ZDVhODUyMzM4YjA5YjU1NjIwMWIwMGY5MDVjYmJjMTY5
|
15
|
+
YTg0MWVmY2NmZjZlZjRlM2ViZDIwMjgwMWMxOGE5YmZlNTc0YmU=
|
data/lib/box_view/http.rb
CHANGED
@@ -40,7 +40,6 @@ module BoxView
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def make_api_request(req, uri, parse=true)
|
43
|
-
puts "BoxView::Http#make_api_request token not availble #{uri}" if self.token.nil? || self.token.empty?
|
44
43
|
return if self.token.nil? || self.token.empty?
|
45
44
|
req.add_field("Authorization", "Token #{self.token}")
|
46
45
|
make_request(req, uri, parse)
|
@@ -53,12 +52,15 @@ module BoxView
|
|
53
52
|
res = n.start do |http|
|
54
53
|
http.request(req)
|
55
54
|
end
|
56
|
-
|
57
|
-
parse_response(res, parse)
|
55
|
+
parse ? parse_response(res) : res.body
|
58
56
|
end
|
59
57
|
|
60
|
-
def parse_response(res
|
61
|
-
|
58
|
+
def parse_response(res)
|
59
|
+
begin
|
60
|
+
JSON.parse(res.body)
|
61
|
+
rescue JSON::ParserError
|
62
|
+
nil
|
63
|
+
end
|
62
64
|
end
|
63
65
|
|
64
66
|
def convert_params(params)
|
data/lib/box_view/version.rb
CHANGED
data/spec/http_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BoxView::Http do
|
4
|
+
let(:http) { BoxView::Session.new }
|
5
|
+
|
6
|
+
describe "#parse_response" do
|
7
|
+
context "when given ill-formed JSON" do
|
8
|
+
let(:response) { response = double("Net::HTTPResponse", body: "foo") }
|
9
|
+
|
10
|
+
it "should return nil" do
|
11
|
+
expect(http.parse_response(response)).to be_nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: box_view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reilly Forshaw
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- spec/api/actions/listable_spec.rb
|
70
70
|
- spec/api/base_spec.rb
|
71
71
|
- spec/api/document_spec.rb
|
72
|
+
- spec/http_spec.rb
|
72
73
|
- spec/models/base_spec.rb
|
73
74
|
- spec/models/document_spec.rb
|
74
75
|
- spec/session_spec.rb
|
@@ -105,6 +106,7 @@ test_files:
|
|
105
106
|
- spec/api/actions/listable_spec.rb
|
106
107
|
- spec/api/base_spec.rb
|
107
108
|
- spec/api/document_spec.rb
|
109
|
+
- spec/http_spec.rb
|
108
110
|
- spec/models/base_spec.rb
|
109
111
|
- spec/models/document_spec.rb
|
110
112
|
- spec/session_spec.rb
|