circleci 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/circleci/http.rb +16 -9
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ff9c6775d04a8eff90cb6fd00dc57c93c928b65
4
- data.tar.gz: 9f6c1dc808c57752a19dc38aa13d5fc9c7dd1c9a
3
+ metadata.gz: 56752aa45d0cbe1900d78d9c28cd8853bd2b2ce1
4
+ data.tar.gz: 69ed9d12c41bf0c91a6f786e437ba9e39e280ab1
5
5
  SHA512:
6
- metadata.gz: 85165a924c57188cb13b2bdf1b670a88eaec784ffd012282ad2cd6ce569eebf9440626799273333b06f5c088d559fbf9e8fcaa216572a3f2e21b5296c2185ad5
7
- data.tar.gz: 42dc404d38907f0ee4e5adcc32a990d9581ac593b55ea0472cd6ea011327c4c9eaa2c77160d57fdb15048d22c806ea2003e33cef46d12e5ee227a95d10abcec6
6
+ metadata.gz: 0cb8afeb58f84945beb66d68366c7030405b82d8e45646270a3c8bc49104df777eba1386ccd993597f6e5535e41510efb3c5ac729cfcf1b8e9b696babfec9bf1
7
+ data.tar.gz: 8b08af6be955cd0a5f62cbd5ec652e70d2da52fcbdedeebfce20870a440c6c7a4b65a09bb61322e914cfb3d38b7dc8c40c05573d034bed753328bdf2e04574c2
data/README.md CHANGED
@@ -2,7 +2,7 @@ circleci
2
2
  ========
3
3
 
4
4
  [![Build Status](https://travis-ci.org/mtchavez/circleci.png)](https://travis-ci.org/mtchavez/circleci)
5
- [![endorse](http://api.coderwall.com/mtchavez/endorsecount.png)](http://coderwall.com/mtchavez)
5
+ [![Code Climate](https://codeclimate.com/github/mtchavez/circleci.png)](https://codeclimate.com/github/mtchavez/circleci)
6
6
 
7
7
  Circle CI API Wrapper
8
8
 
data/lib/circleci/http.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CircleCi
2
4
 
3
5
  class Http # @private
@@ -32,24 +34,29 @@ module CircleCi
32
34
  url = "#{@config.host}#{path}"
33
35
  args = [http_verb, url, headers]
34
36
 
35
- response = RestClient.send *args do |res, req, raw_res|
36
- body = res.body
37
+ RestClient.send(*args) do |res, req, raw_res|
38
+ body = res.body.to_s
39
+ body.force_encoding(Encoding::UTF_8)
37
40
  code = raw_res.code.to_i
38
41
 
39
42
  self.response = body
40
43
  self.errors = []
41
44
 
42
- if code == 200
43
- self.response = JSON.parse(body) rescue body
44
- self.success = true
45
- else
46
- self.errors << RequestError.new(body, code, path)
47
- end
48
-
45
+ handle_response(body, code, path)
49
46
  Response.new(self, code, path)
50
47
  end
51
48
  end
52
49
 
50
+ def handle_response(body, code, path)
51
+ parsed = JSON.parse(body) rescue nil
52
+ if parsed && code == 200
53
+ self.response = parsed
54
+ self.success = true
55
+ else
56
+ self.errors << RequestError.new(body, code, path)
57
+ end
58
+ end
59
+
53
60
  end
54
61
 
55
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circleci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chavez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-29 00:00:00.000000000 Z
11
+ date: 2014-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie