rest-more 3.3.0 → 3.3.1

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: 8b39d49bb082449d7cc14d9c296b5b11b464eefe
4
- data.tar.gz: c329a58ec85fea8020a2e72b0461da6df5d48651
3
+ metadata.gz: 8d94a93481cb47814a0fe9e40aa939c0511b8972
4
+ data.tar.gz: 3e51315c98ffe426c74e37e6d3384d60e7a0563a
5
5
  SHA512:
6
- metadata.gz: 6f390c57bc49b63ba559056cc1b51d2ca32484a1d5100354084ef89d740b53138029260311b9a8bbb70c644eec70ea53d3fdc3b82e96b75d8852d1376b0e01ad
7
- data.tar.gz: 94171dcccda4f3e7821da7b009e0ab776b97f115dc0d294656e93fc6b83b1bc7a1557eeb8fb1f61b243d6b7729ab7b73adf848b2ad5faafc43c2c38711a5c723
6
+ metadata.gz: 2c5c2ccbaff604f3272cb7db82620635a92772f6f7350059e3bff697044ca3bd4e6cca1e7a23600ebfbdb9070d19ba449aa0f5cca31148a55161f196774cae57
7
+ data.tar.gz: fd1fa8e8c101fca082a8a59584ea85bc740c8d09c276ce04a156299626c0d65cdebc69bf652d0c3246ce73a3d7c7fad1676ea1d5d753cf137d9c013b18250226
data/CHANGES.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # CHANGES
2
2
 
3
+ ## rest-more 3.3.1 -- 2014-10-08
4
+
5
+ * Made `RC::Facebook#authorize_url` accepts the second argument as the option.
6
+ #5 khoa nguyen (@khoan)
7
+
8
+ * The same fix applied to `RC::Facebook#authorize!`. #5 khoa nguyen (@khoan)
9
+
10
+ * `RC::Github` now accepts `:client_id`, `:client_secret` as options, and
11
+ `RC::Github#authorize_url` and `RC::Github#authorize!` and
12
+ `RC::Github#authorized?` are now implemented. Lin Jen-Shin (@godfat)
13
+
3
14
  ## rest-more 3.3.0 -- 2014-08-25
4
15
 
5
16
  * Adopted rest-core 3.3.0
data/README.md CHANGED
@@ -14,7 +14,6 @@ talk is in Mandarin.
14
14
  * [github](https://github.com/godfat/rest-more)
15
15
  * [rubygems](https://rubygems.org/gems/rest-more)
16
16
  * [rdoc](http://rdoc.info/projects/godfat/rest-more)
17
- * [mailing list](http://groups.google.com/group/rest-core/topics)
18
17
 
19
18
  ## DESCRIPTION:
20
19
 
@@ -214,15 +214,15 @@ module RestCore::Facebook::Client
214
214
 
215
215
  # oauth related
216
216
 
217
- def authorize_url opts={}
217
+ def authorize_url query={}, opts={}
218
218
  url('dialog/oauth',
219
- {:client_id => app_id, :access_token => nil}.merge(opts),
220
- :site => 'https://www.facebook.com/')
219
+ {:client_id => app_id, :access_token => nil}.merge(query),
220
+ {:site => 'https://www.facebook.com/'}.merge(opts))
221
221
  end
222
222
 
223
- def authorize! opts={}
224
- payload = {:client_id => app_id, :client_secret => secret}.merge(opts)
225
- args = ['oauth/access_token', payload, {},
223
+ def authorize! payload={}, opts={}
224
+ p = {:client_id => app_id, :client_secret => secret}.merge(payload)
225
+ args = ['oauth/access_token', p, {},
226
226
  {:json_response => false}.merge(opts)]
227
227
 
228
228
  if block_given?
@@ -3,7 +3,7 @@ require 'rest-core'
3
3
 
4
4
  # http://developer.github.com/v3/
5
5
  module RestCore
6
- Github = Builder.client do
6
+ Github = Builder.client(:client_id, :client_secret, :data) do
7
7
  use Timeout , 10
8
8
 
9
9
  use DefaultSite , 'https://api.github.com/'
@@ -28,6 +28,37 @@ module RestCore::Github::Client
28
28
  get('user', query, opts, &cb)
29
29
  end
30
30
 
31
+ def access_token
32
+ data['access_token']
33
+ end
34
+
35
+ def access_token= token
36
+ data['access_token'] = token
37
+ end
38
+
39
+ def authorize_url query={}, opts={}
40
+ url('https://github.com/login/oauth/authorize',
41
+ {:client_id => client_id}.merge(query),
42
+ {:access_token => false}.merge(opts))
43
+ end
44
+
45
+ def authorize! payload={}, query={}, opts={}
46
+ p = {:client_id => client_id, :client_secret => client_secret}.
47
+ merge(payload)
48
+ args = ['https://github.com/login/oauth/access_token',
49
+ p, query, {:access_token => false}.merge(opts)]
50
+
51
+ if block_given?
52
+ post(*args){ |r| yield(self.data = r) }
53
+ else
54
+ self.data = post(*args)
55
+ end
56
+ end
57
+
58
+ def authorized?
59
+ !!access_token
60
+ end
61
+
31
62
  def all path, query={}, opts={}
32
63
  q = {:per_page => MAX_PER_PAGE}.merge(query)
33
64
  r = get(path, q, opts.merge(RESPONSE_KEY => PROMISE)).then{ |response|
@@ -47,6 +78,10 @@ module RestCore::Github::Client
47
78
  end
48
79
 
49
80
  private
81
+ def default_data
82
+ {}
83
+ end
84
+
50
85
  def page_range response
51
86
  from = (parse_current_page(response) || 1).to_i + 1
52
87
  to = (parse_last_page(response) || from - 1).to_i
@@ -1,4 +1,4 @@
1
1
 
2
2
  module RestMore
3
- VERSION = '3.3.0'
3
+ VERSION = '3.3.1'
4
4
  end
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: rest-more 3.3.0 ruby lib
2
+ # stub: rest-more 3.3.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rest-more"
6
- s.version = "3.3.0"
6
+ s.version = "3.3.1"
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 = "2014-08-25"
11
+ s.date = "2014-10-08"
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.1"
86
+ s.rubygems_version = "2.4.2"
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",
@@ -13,8 +13,13 @@ describe RC::Facebook do
13
13
 
14
14
  would 'return correct oauth url' do
15
15
  @rg.authorize_url(:redirect_uri => @uri).
16
- should.eq 'https://www.facebook.com/dialog/oauth?' \
17
- 'client_id=29&redirect_uri=http%3A%2F%2Fzzz.tw'
16
+ should.eq 'https://www.facebook.com/dialog/oauth?' \
17
+ 'client_id=29&redirect_uri=http%3A%2F%2Fzzz.tw'
18
+ end
19
+
20
+ would 'change the site for authorize_url' do
21
+ @rg.authorize_url({}, :site => 'https://example.com/').
22
+ should.eq 'https://example.com/dialog/oauth?client_id=29'
18
23
  end
19
24
 
20
25
  would 'do authorizing and parse result and save it in data' do
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.0
4
+ version: 3.3.1
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: 2014-08-25 00:00:00.000000000 Z
11
+ date: 2014-10-08 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.1
126
+ rubygems_version: 2.4.2
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Various REST clients such as Facebook and Twitter built with [rest-core][].