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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzUzNTg4MTQ1MGI3M2RjNmYyMTM4NzYyOTIyMjMwNmU1NGZhOTAyMw==
4
+ ZWQwZTBhYzY4NTBiMjhmZGM2ZTA5MjM2YzY3YTk3NGU0MmJmNDNkMA==
5
5
  data.tar.gz: !binary |-
6
- YzE1MWI0MDExZDBkOThjOGM2OTQzNmE3ZjhmMGQ5NTg4ZjRkZjcwMg==
6
+ YTAxMDM1NWQ2ZjIyZWVlZmRiYTVmOTMyOGVmY2MzOWFkYzI1ZDI2Mw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZDlmODk3MTMwYTk4MTEzODA5ODAwMzExYTkzMmJhZjk0ODc5NjdlN2RhMDIw
10
- ZTBlMjdkNWMyMDMxZjE2ODRiMDAyN2RmNjM2YWMyNjVkYTE3ZTc3ZmIzNmVl
11
- YWU5MWYzY2M1OTc5NWY2MGYxMDRkYjE2NmJhODE0NTU2MTdlZmQ=
9
+ Zjg5M2EyMWJkMTYyNmE2ZjhhMzNhZjBhMDExOTg1Y2RjNjE2MTM5ZTI2Njdi
10
+ MjcyNWRkMzg5OTNmY2M0OWZkYjA0NzMxMzA3N2NjMjdlMWM5OWJmNDM5M2E4
11
+ NjVmMmUwYzVkMWJkOTc1Yjg0OTU2NDAxMzJkOWQzMGI1NjI5Nzk=
12
12
  data.tar.gz: !binary |-
13
- MTc4N2U4ZjYzZjljOThlMDQzNzcyMzkyODNjMmZhOGUzZDU0NzVlNGUxYTAw
14
- NDUwOGI2NDYwMGI2Y2NlMjliYjc1MWZjNzI1YTFlZTNiNDVkMWQ3YmZjMTFj
15
- ZTQwYWU1NzdmNzUyNGNlMzI3MTQ3YzMyZmQ1OTYyNDhlMDk4ZGU=
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
- puts "BoxView::Http#make_request #{uri} response: #{res.body}#{" Parsing" if parse}"
57
- parse_response(res, parse)
55
+ parse ? parse_response(res) : res.body
58
56
  end
59
57
 
60
- def parse_response(res, parse=true)
61
- parse ? JSON.parse(res.body) : res.body
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)
@@ -1,3 +1,3 @@
1
1
  module BoxView
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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-10 00:00:00.000000000 Z
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