badgerkit 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,18 +1,18 @@
1
- # Badgerkit
1
+ # badgerkit
2
2
 
3
3
  [![Gem Version](http://img.shields.io/gem/v/badgerkit.svg)][gem]
4
- [![Build Status](http://img.shields.io/travis/saladdays-nl/badgerkit.rb.svg)][travis]
5
- [![Coverage Status](http://img.shields.io/coveralls/saladdays-nl/badgerkit.rb.svg)][coveralls]
6
- [![Code Climate](http://img.shields.io/codeclimate/github/saladdays-nl/badgerkit.rb.svg)][codeclimate]
7
- [![Dependency Status](http://img.shields.io/gemnasium/saladdays-nl/badgerkit.rb.svg)][gemnasium]
4
+ [![Build Status](http://img.shields.io/travis/badgerhq/badgerkit.rb.svg)][travis]
5
+ [![Coverage Status](http://img.shields.io/coveralls/badgerhq/badgerkit.rb.svg)][coveralls]
6
+ [![Code Climate](http://img.shields.io/codeclimate/github/badgerhq/badgerkit.rb.svg)][codeclimate]
7
+ [![Dependency Status](http://img.shields.io/gemnasium/badgerhq/badgerkit.rb.svg)][gemnasium]
8
8
 
9
9
  [gem]: https://rubygems.org/gems/badgerkit
10
- [travis]: http://travis-ci.org/saladdays-nl/badgerkit.rb
11
- [coveralls]: https://coveralls.io/r/saladdays-nl/badgerkit.rb
12
- [codeclimate]: https://codeclimate.com/github/saladdays-nl/badgerkit.rb
13
- [gemnasium]: https://gemnasium.com/saladdays-nl/badgerkit.rb
10
+ [travis]: http://travis-ci.org/badgerhq/badgerkit.rb
11
+ [coveralls]: https://coveralls.io/r/badgerhq/badgerkit.rb
12
+ [codeclimate]: https://codeclimate.com/github/badgerhq/badgerkit.rb
13
+ [gemnasium]: https://gemnasium.com/badgerhq/badgerkit.rb
14
14
 
15
- Simple api wrapper for submitting data to http://badgerhq.com
15
+ Simple api wrapper for submitting data to https://badgerhq.com
16
16
 
17
17
  ## Installation
18
18
 
@@ -34,7 +34,7 @@ Without environment variables:
34
34
  client = Badgerkit.new(
35
35
  :access_token => '0dbce1478e94053d4282ccd4ace154c82a3475d5',
36
36
  :source => 'github',
37
- :repo => 'saladdays-nl/badgerkit.rb'
37
+ :repo => 'badgerhq/badgerkit.rb'
38
38
  )
39
39
 
40
40
  client.post('Documentation',
@@ -50,7 +50,7 @@ With the following environment variables:
50
50
  ```ruby
51
51
  ENV['BADGER_ACCESS_TOKEN'] = '0dbce1478e94053d4282ccd4ace154c82a3475d5'
52
52
  ENV['BADGER_SOURCE'] = 'github'
53
- ENV['BADGER_REPO'] = 'saladdays/badgerkit.rb'
53
+ ENV['BADGER_REPO'] = 'badgerhq/badgerkit.rb'
54
54
 
55
55
  Badgerkit.post('Documentation',
56
56
  :value => 80,
@@ -76,3 +76,7 @@ implementations:
76
76
  3. Commit your changes (`git commit -am 'Add some feature'`)
77
77
  4. Push to the branch (`git push origin my-new-feature`)
78
78
  5. Create new Pull Request
79
+
80
+ ---
81
+
82
+ <a href="https://badgerhq.com"><img src="https://d87fcfg6nirfp.cloudfront.net/logo-medium.png" height="40"></a>
@@ -12,7 +12,7 @@ module Badgerkit
12
12
  ##
13
13
  # The base uri the perform requests to.
14
14
  #
15
- BASE_URI = 'https://badgerhq.com/'
15
+ BASE_URI = 'https://badgerhq.com/api/v1/'
16
16
 
17
17
  ##
18
18
  # Construct a new Badgerkit::Client
@@ -0,0 +1,77 @@
1
+ module Badgerkit
2
+ # Custom error class for rescuing from all Badgerkit errors
3
+ class Error < StandardError
4
+
5
+ # Returns the appropriate Badgerkit::Error sublcass based
6
+ # on status and response message
7
+ #
8
+ # @param response [Hashie::Mash] response HTTP response
9
+ # @return [Badgerkit::Error]
10
+ #
11
+ def self.from_response(response)
12
+ status = response[:status].to_i
13
+ body = response[:body].to_s
14
+ headers = response[:response_headers]
15
+
16
+ if klass = case status
17
+ when 400 then Octokit::BadRequest
18
+ when 401 then error_for_401(headers)
19
+ when 403 then error_for_403(body)
20
+ when 404 then Octokit::NotFound
21
+ when 406 then Octokit::NotAcceptable
22
+ when 409 then Octokit::Conflict
23
+ when 415 then Octokit::UnsupportedMediaType
24
+ when 422 then Octokit::UnprocessableEntity
25
+ when 400..499 then Octokit::ClientError
26
+ when 500 then Octokit::InternalServerError
27
+ when 501 then Octokit::NotImplemented
28
+ when 502 then Octokit::BadGateway
29
+ when 503 then Octokit::ServiceUnavailable
30
+ when 500..599 then Octokit::ServerError
31
+ end
32
+ klass.new(response)
33
+ end
34
+ end
35
+
36
+ end # Error
37
+
38
+ # Raised on errors in the 400-499 range
39
+ class ClientError < Error; end
40
+
41
+ # Raised when Badgerhq returns a 400 HTTP status code
42
+ class BadRequest < ClientError; end
43
+
44
+ # Raised when Badgerhq returns a 401 HTTP status code
45
+ class Unauthorized < ClientError; end
46
+
47
+ # Raised when Badgerhq returns a 403 HTTP status code
48
+ class Forbidden < ClientError; end
49
+
50
+ # Raised when Badgerhq returns a 404 HTTP status code
51
+ class NotFound < ClientError; end
52
+
53
+ # Raised when Badgerhq returns a 406 HTTP status code
54
+ class NotAcceptable < ClientError; end
55
+
56
+ # Raised when Badgerhq returns a 409 HTTP status code
57
+ class Conflict < ClientError; end
58
+
59
+ # Raised when Badgerhq returns a 422 HTTP status code
60
+ class UnprocessableEntity < ClientError; end
61
+
62
+ # Raised on errors in the 500-599 range
63
+ class ServerError < Error; end
64
+
65
+ # Raised when Badgerhq returns a 500 HTTP status code
66
+ class InternalServerError < ServerError; end
67
+
68
+ # Raised when Badgerhq returns a 502 HTTP status code
69
+ class BadGateway < ServerError; end
70
+
71
+ # Raised when Badgerhq returns a 503 HTTP status code
72
+ class ServiceUnavailable < ServerError; end
73
+
74
+ # Raised when a method requires an application client_id
75
+ # and secret but none is provided
76
+ class ApplicationCredentialsRequired < StandardError; end
77
+ end # Badgerkit
@@ -1,4 +1,4 @@
1
1
  module Badgerkit
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end # Badgerkit
4
4
 
@@ -40,7 +40,7 @@ describe Badgerkit::Client do
40
40
  )
41
41
 
42
42
  HTTMultiParty.stub(:post).and_return(ResponseProxy.new)
43
- HTTMultiParty.should_receive(:post).with("http://badgerhq.com/github/saladdays/badgerkit.rb/Documentation",
43
+ HTTMultiParty.should_receive(:post).with("https://badgerhq.com/api/v1/github/saladdays/badgerkit.rb/Documentation",
44
44
  :body => {
45
45
  :value => {
46
46
  :value => 90,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badgerkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-03 00:00:00.000000000 Z
12
+ date: 2014-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -173,6 +173,7 @@ files:
173
173
  - lib/badgerkit.rb
174
174
  - lib/badgerkit/archive.rb
175
175
  - lib/badgerkit/client.rb
176
+ - lib/badgerkit/error.rb
176
177
  - lib/badgerkit/version.rb
177
178
  - spec/badgerkit/archive_spec.rb
178
179
  - spec/badgerkit/client_spec.rb