rest-more 3.3.3 → 3.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32c5362d391691b06bfb77244d5e676d9c72264e
4
- data.tar.gz: c8150b6a7c9a2f26ec9104f41f2e30e68077c0be
3
+ metadata.gz: ab435e1b0b7117a382c7428c0225a6d2f97f79d2
4
+ data.tar.gz: 676394586c1415ac9650a032f410b47571594816
5
5
  SHA512:
6
- metadata.gz: be08c056e98bc4534749886286390f999d88ae45929bf68025eb082183672278df8780c5fb1513daa178a1c8b4ee6d9d367088863fa17199fe81376f52f76867
7
- data.tar.gz: 011e7d20ab8e6fe521e3b3c69abd4b357cb918017e41c75bb23dfcb848b698f5f4ff5f8de3107c122dbb8def8b81abe8f97d0236cba11a078d6d6c58d64fb1c5
6
+ metadata.gz: 66932c197c76174e7686fdbd34b6489c230f91442d64cb176adff5965b326cc924d9380967b9b330a52054e5e7d925a2ded9579ad9c236f9573540dc95d1a10d
7
+ data.tar.gz: ed2ead251cbd3828c83b2ddd2fe8f3271b7478bab361e808f699ca543c1721e6ff4403ff6fa6b9e65ae3a333baf8674e74b95f237289111c6e527911fe6d3843
data/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGES
2
2
 
3
+ ## rest-more 3.3.4 -- 2015-10-15
4
+
5
+ * [`Dropbox`] Updated content API server. Thanks khoa nguyen (@khoan)
6
+ * [`Github`] Introduced `RC::Github::Error` replacing `RuntimeError`
7
+
3
8
  ## rest-more 3.3.3 -- 2015-02-26
4
9
 
5
10
  * Try to adopt StackExchange's inconsistency
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # rest-more [![Build Status](https://secure.travis-ci.org/godfat/rest-more.png?branch=master)](http://travis-ci.org/godfat/rest-more) [![Coverage Status](https://coveralls.io/repos/godfat/rest-more/badge.png)](https://coveralls.io/r/godfat/rest-more)
1
+ # rest-more [![Build Status](https://secure.travis-ci.org/godfat/rest-more.png?branch=master)](http://travis-ci.org/godfat/rest-more) [![Coverage Status](https://coveralls.io/repos/godfat/rest-more/badge.png)](https://coveralls.io/r/godfat/rest-more) [![Join the chat at https://gitter.im/godfat/rest-more](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/godfat/rest-more)
2
2
 
3
3
  by Lin Jen-Shin ([godfat](http://godfat.org))
4
4
 
@@ -76,12 +76,12 @@ module RestCore::Dropbox::Client
76
76
  end
77
77
 
78
78
  def download path, query={}, opts={}, &cb
79
- get("https://api-content.dropbox.com/1/files/#{root}/#{path}",
79
+ get("https://content.dropboxapi.com/1/files/#{root}/#{path}",
80
80
  query, {:json_response => false}.merge(opts), &cb)
81
81
  end
82
82
 
83
83
  def upload path, file, query={}, opts={}, &cb
84
- put("https://api-content.dropbox.com/1/files_put/#{root}/#{path}",
84
+ put("https://content.dropboxapi.com/1/files_put/#{root}/#{path}",
85
85
  file, query, opts, &cb)
86
86
  end
87
87
 
@@ -11,14 +11,47 @@ module RestCore
11
11
  use Oauth2Query , nil
12
12
 
13
13
  use CommonLogger , nil
14
- use ErrorHandler , lambda{ |env|
15
- RuntimeError.new(env[RESPONSE_BODY]['message'])}
14
+ use ErrorHandler , lambda{ |env| Github::Error.call(env) }
16
15
  use ErrorDetectorHttp
17
16
  use JsonResponse , true
18
17
  use Cache , nil, 600
19
18
  end
20
19
  end
21
20
 
21
+ class RestCore::Github::Error < RestCore::Error
22
+ include RestCore
23
+ class ServerError < Github::Error; end
24
+ class ClientError < Github::Error; end
25
+
26
+ class BadRequest < Github::Error; end
27
+ class Unauthorized < Github::Error; end
28
+ class Forbidden < Github::Error; end
29
+ class NotFound < Github::Error; end
30
+ class UnprocessableEntity < Github::Error; end
31
+ class InternalServerError < Github::Error::ServerError; end
32
+
33
+ attr_reader :error, :code, :url
34
+ def initialize error, code, url=''
35
+ @error, @code, @url = error, code, url
36
+ super("[#{code}] #{error.inspect} from #{url}")
37
+ end
38
+
39
+ def self.call env
40
+ error, code, url = env[RESPONSE_BODY], env[RESPONSE_STATUS],
41
+ env[REQUEST_URI]
42
+ return new(error, code, url) unless error.kind_of?(Hash)
43
+ case code
44
+ when 400; BadRequest
45
+ when 401; Unauthorized
46
+ when 403; Forbidden
47
+ when 404; NotFound
48
+ when 422; UnprocessableEntity
49
+ when 500; InternalServerError
50
+ else ; self
51
+ end.new(error, code, url)
52
+ end
53
+ end
54
+
22
55
  module RestCore::Github::Client
23
56
  include RestCore
24
57
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module RestMore
3
- VERSION = '3.3.3'
3
+ VERSION = '3.3.4'
4
4
  end
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: rest-more 3.3.3 ruby lib
2
+ # stub: rest-more 3.3.4 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rest-more"
6
- s.version = "3.3.3"
6
+ s.version = "3.3.4"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
10
10
  s.authors = ["Lin Jen-Shin (godfat)"]
11
- s.date = "2015-02-26"
11
+ s.date = "2015-10-15"
12
12
  s.description = "Various REST clients such as Facebook and Twitter built with [rest-core][].\n\n[rest-core]: https://github.com/godfat/rest-core"
13
13
  s.email = ["godfat (XD) godfat.org"]
14
14
  s.executables = ["rib-rest-core"]
@@ -83,7 +83,7 @@ Gem::Specification.new do |s|
83
83
  "test/twitter/test_twitter.rb"]
84
84
  s.homepage = "https://github.com/godfat/rest-more"
85
85
  s.licenses = ["Apache License 2.0"]
86
- s.rubygems_version = "2.4.6"
86
+ s.rubygems_version = "2.4.8"
87
87
  s.summary = "Various REST clients such as Facebook and Twitter built with [rest-core][]."
88
88
  s.test_files = [
89
89
  "test/dropbox/test_dropbox.rb",
@@ -79,6 +79,11 @@ module Gemgem
79
79
  end
80
80
 
81
81
  def gem_check
82
+ unless git('status', '--porcelain').empty?
83
+ puts("\e[35mWorking copy is not clean.\e[0m")
84
+ exit(3)
85
+ end
86
+
82
87
  ver = spec.version.to_s
83
88
 
84
89
  if ENV['VERSION'].nil?
@@ -2,6 +2,11 @@
2
2
  require 'rest-more/test'
3
3
 
4
4
  describe RC::Instagram do
5
+ before do
6
+ @client = RC::Instagram.new(:client_id => 'Z', :client_secret => 'S',
7
+ :access_token => 'X')
8
+ end
9
+
5
10
  after do
6
11
  WebMock.reset!
7
12
  end
@@ -14,11 +19,8 @@ describe RC::Instagram do
14
19
  "access_token":"A"}
15
20
  JSON
16
21
 
17
- client = RC::Instagram.new(:client_id => 'Z', :client_secret => 'S',
18
- :access_token => 'X')
19
-
20
22
  would 'have correct authorize url' do
21
- client.authorize_url.should.eq \
23
+ @client.authorize_url.should.eq \
22
24
  'https://api.instagram.com/oauth/authorize?' \
23
25
  'client_id=Z&response_type=code'
24
26
  end
@@ -29,20 +31,16 @@ describe RC::Instagram do
29
31
  'grant_type' => 'authorization_code', 'code' => 'C'}).
30
32
  to_return(:body => json)
31
33
 
32
- begin
33
- client.authorize!(:code => 'C').should.kind_of?(Hash)
34
- client.access_token. should.eq 'A'
35
- ensure
36
- client.data = nil
37
- end
34
+ @client.authorize!(:code => 'C').should.kind_of?(Hash)
35
+ @client.access_token. should.eq 'A'
38
36
  end
39
37
 
40
38
  would 'retrieve user profile based on username' do
41
39
  stub_request(:get, 'https://api.instagram.com/v1/users/search?' \
42
- 'client_id=Z&q=restmore').
40
+ 'client_id=Z&q=restmore&access_token=X').
43
41
  to_return(:body => json)
44
42
 
45
- client.get('v1/users/search', :q => 'restmore').should.eq(
43
+ @client.get('v1/users/search', :q => 'restmore').should.eq(
46
44
  {'meta' => {'code' => 200},
47
45
  'data' => [{'username' => 'restmore',
48
46
  'profile_picture' =>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest-more
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.3
4
+ version: 3.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lin Jen-Shin (godfat)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-26 00:00:00.000000000 Z
11
+ date: 2015-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-core
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.4.6
126
+ rubygems_version: 2.4.8
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Various REST clients such as Facebook and Twitter built with [rest-core][].