rest-more 0.7.0 → 0.7.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.
- data/.gitmodules +3 -0
- data/.travis.yml +1 -1
- data/CHANGES.md +19 -0
- data/Rakefile +5 -1
- data/lib/rest-core/client/facebook.rb +2 -2
- data/lib/rest-core/client/flurry.rb +2 -2
- data/lib/rest-core/client/mixi.rb +7 -4
- data/lib/rest-core/client/twitter.rb +1 -1
- data/lib/rest-core/util/config.rb +55 -0
- data/lib/rest-core/util/rails_util_util.rb +19 -0
- data/lib/rest-more.rb +2 -0
- data/lib/rest-more/test.rb +3 -0
- data/lib/rest-more/version.rb +1 -1
- data/rest-more.gemspec +7 -2
- data/test/client/facebook/test_api.rb +1 -1
- data/test/client/facebook/test_cache.rb +1 -1
- data/test/client/facebook/test_default.rb +1 -1
- data/test/client/facebook/test_error.rb +1 -1
- data/test/client/facebook/test_handler.rb +1 -1
- data/test/client/facebook/test_load_config.rb +1 -1
- data/test/client/facebook/test_misc.rb +1 -1
- data/test/client/facebook/test_oauth.rb +1 -1
- data/test/client/facebook/test_old.rb +1 -1
- data/test/client/facebook/test_page.rb +1 -1
- data/test/client/facebook/test_parse.rb +1 -1
- data/test/client/facebook/test_serialize.rb +1 -1
- data/test/client/facebook/test_timeout.rb +1 -1
- data/test/client/flurry/test_metrics.rb +1 -2
- data/test/client/mixi/test_api.rb +20 -0
- data/test/client/twitter/test_api.rb +1 -1
- metadata +9 -4
data/.gitmodules
CHANGED
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,7 +1,26 @@
|
|
1
1
|
# CHANGES
|
2
2
|
|
3
|
+
## rest-more 0.7.1 -- 2011-10-31
|
4
|
+
|
5
|
+
### Bugs fixes
|
6
|
+
|
7
|
+
* [Mixi] Fixed `RC::Mixi.new(:access_token => 'access_token')` which is not
|
8
|
+
working before.
|
9
|
+
|
10
|
+
### Enhancement
|
11
|
+
|
12
|
+
* [Mixi] `RC::Mixi#authorize!` now works like `RC::Facebook#authorize!`
|
13
|
+
That is now we pass code like this: `mixi.authorize!(:code => code)`
|
14
|
+
|
15
|
+
* `RestCore::Config` and `RestCore::RailsUtilUtil` are now moved to rest-more
|
16
|
+
|
3
17
|
## rest-more 0.7.0 -- 2011-10-08
|
4
18
|
|
5
19
|
* Extracted from [rest-core][] 0.4.0
|
20
|
+
* [Facebook] Added `RC::Facebook#parse_fbsr!` which can parse Facebook's new
|
21
|
+
cookie. Also, `RC::Facebook#parse_cookies!` would look for that too.
|
22
|
+
* [Facebook] Fixed that parsing an invalid signed_request would raise an
|
23
|
+
error. From now on it would simply ignore it and wipe out the data.
|
24
|
+
* [Flurry] Some minor updates.
|
6
25
|
|
7
26
|
[rest-core]: https://github.com/cardinalblue/rest-core
|
data/Rakefile
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
require "#{dir = File.dirname(__FILE__)}/task/gemgem"
|
4
4
|
Gemgem.dir = dir
|
5
5
|
|
6
|
-
($LOAD_PATH << File.expand_path("#{Gemgem.dir}/lib" )
|
6
|
+
($LOAD_PATH << File.expand_path("#{Gemgem.dir}/lib" ) <<
|
7
|
+
File.expand_path("#{Gemgem.dir}/rest-core/lib")).uniq!
|
7
8
|
|
8
9
|
desc 'Generate gemspec'
|
9
10
|
task 'gem:spec' do
|
@@ -17,6 +18,9 @@ task 'gem:spec' do
|
|
17
18
|
|
18
19
|
s.authors = ['Cardinal Blue', 'Lin Jen-Shin (godfat)']
|
19
20
|
s.email = ['dev (XD) cardinalblue.com']
|
21
|
+
|
22
|
+
# exclude rest-core
|
23
|
+
s.files.reject!{ |f| f.start_with?('rest-core/') }
|
20
24
|
end
|
21
25
|
|
22
26
|
Gemgem.write
|
@@ -73,7 +73,7 @@ module RestCore::Facebook::Client
|
|
73
73
|
data['access_token'] || data['oauth_token'] if data.kind_of?(Hash)
|
74
74
|
end
|
75
75
|
|
76
|
-
def access_token=
|
76
|
+
def access_token= token
|
77
77
|
data['access_token'] = token if data.kind_of?(Hash)
|
78
78
|
end
|
79
79
|
|
@@ -247,7 +247,7 @@ module RestCore::Facebook::Client
|
|
247
247
|
end
|
248
248
|
|
249
249
|
def fbs_without_sig cookies
|
250
|
-
cookies.reject{ |(k,
|
250
|
+
cookies.reject{ |(k, _)| k == 'sig' }.sort.map{ |a| a.join('=') }
|
251
251
|
end
|
252
252
|
|
253
253
|
def merge_data lhs, rhs
|
@@ -68,7 +68,7 @@ module RestCore::Flurry::Client
|
|
68
68
|
- (current - start) / (86400*7)
|
69
69
|
# calling .last to discard week numbers created by group_by
|
70
70
|
}.sort.map(&:last).map{ |week|
|
71
|
-
week.map{ |(
|
71
|
+
week.map{ |(_, num)| num }.inject(&:+) }
|
72
72
|
end
|
73
73
|
|
74
74
|
# >> f.sum(f.weekly(f.metrics('ActiveUsers', {}, :weeks => 4)))
|
@@ -98,7 +98,7 @@ module RestCore::Flurry::Client
|
|
98
98
|
|
99
99
|
[query.merge(:startDate => startDate,
|
100
100
|
:endDate => endDate),
|
101
|
-
opts.reject{ |k| [:days, :weeks, :months].include?(k) }]
|
101
|
+
opts.reject{ |k, _| [:days, :weeks, :months].include?(k) }]
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -16,7 +16,7 @@ RestCore::Mixi = RestCore::Builder.client(
|
|
16
16
|
use s::JsonDecode , true
|
17
17
|
end
|
18
18
|
|
19
|
-
use s::Defaults , :data
|
19
|
+
use s::Defaults , :data => lambda{{}}
|
20
20
|
end
|
21
21
|
|
22
22
|
module RestCore::Mixi::Client
|
@@ -26,6 +26,10 @@ module RestCore::Mixi::Client
|
|
26
26
|
data['access_token'] if data.kind_of?(Hash)
|
27
27
|
end
|
28
28
|
|
29
|
+
def access_token= token
|
30
|
+
data['access_token'] = token if data.kind_of?(Hash)
|
31
|
+
end
|
32
|
+
|
29
33
|
def authorize_url queries={}
|
30
34
|
url('https://mixi.jp/connect_authorize.pl',
|
31
35
|
{:client_id => consumer_key,
|
@@ -33,12 +37,11 @@ module RestCore::Mixi::Client
|
|
33
37
|
:scope => 'r_profile'}.merge(queries))
|
34
38
|
end
|
35
39
|
|
36
|
-
def authorize!
|
40
|
+
def authorize! payload={}, opts={}
|
37
41
|
pl = {:client_id => consumer_key ,
|
38
42
|
:client_secret => consumer_secret,
|
39
43
|
:redirect_uri => redirect_uri ,
|
40
|
-
:grant_type => 'authorization_code'
|
41
|
-
:code => code}.merge(payload)
|
44
|
+
:grant_type => 'authorization_code'}.merge(payload)
|
42
45
|
|
43
46
|
self.data = post('https://secure.mixi-platform.com/2/token', pl, {}, opts)
|
44
47
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
|
2
|
+
require 'erb'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module RestCore; end
|
6
|
+
module RestCore::Config
|
7
|
+
extend self
|
8
|
+
|
9
|
+
DefaultModuleName = 'DefaultAttributes'
|
10
|
+
|
11
|
+
def load_for_rails klass, namespace=nil, app=Rails
|
12
|
+
root = File.expand_path(app.root)
|
13
|
+
path = ["#{root}/config/rest-core.yaml", # YAML should use .yaml
|
14
|
+
"#{root}/config/rest-core.yml" ].find{|p| File.exist?(p)}
|
15
|
+
return if path.nil?
|
16
|
+
RestCore::Config.load(klass, path, app.env, namespace)
|
17
|
+
end
|
18
|
+
|
19
|
+
def load klass, path, env, namespace=nil
|
20
|
+
config = YAML.load(ERB.new(File.read(path)).result(binding))
|
21
|
+
defaults = config[env]
|
22
|
+
return false unless defaults
|
23
|
+
return false unless defaults[namespace] if namespace
|
24
|
+
data = if namespace
|
25
|
+
defaults[namespace]
|
26
|
+
else
|
27
|
+
defaults
|
28
|
+
end
|
29
|
+
raise ArgumentError.new("#{data} is not a hash") unless
|
30
|
+
data.kind_of?(Hash)
|
31
|
+
|
32
|
+
mod = if klass.const_defined?(DefaultModuleName)
|
33
|
+
klass.const_get(DefaultModuleName)
|
34
|
+
else
|
35
|
+
klass.send(:const_set, DefaultModuleName, Module.new)
|
36
|
+
end
|
37
|
+
|
38
|
+
singleton_class = if klass.respond_to?(:singleton_class)
|
39
|
+
klass.singleton_class
|
40
|
+
else
|
41
|
+
class << klass; self; end
|
42
|
+
end
|
43
|
+
|
44
|
+
klass.send(:extend, mod) unless singleton_class < mod
|
45
|
+
|
46
|
+
mod.module_eval(data.inject(["extend self\n"]){ |r, (k, v)|
|
47
|
+
# quote strings, leave others free (e.g. false, numbers, etc)
|
48
|
+
r << <<-RUBY
|
49
|
+
def default_#{k}
|
50
|
+
#{v.kind_of?(String) ? "'#{v}'" : v}
|
51
|
+
end
|
52
|
+
RUBY
|
53
|
+
}.join, __FILE__, __LINE__)
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
module RestCore; end
|
3
|
+
module RestCore::RailsUtilUtil
|
4
|
+
module Cache
|
5
|
+
def [] key ; read(key) ; end
|
6
|
+
def []= key, value; write(key, value) ; end
|
7
|
+
def store key, value,
|
8
|
+
options={}; write(key, value, options); end
|
9
|
+
end
|
10
|
+
|
11
|
+
module_function
|
12
|
+
def extract_options members, options, method
|
13
|
+
# Hash[] is for ruby 1.8.7
|
14
|
+
# map(&:to_sym) is for ruby 1.8.7
|
15
|
+
Hash[options.send(method){ |(k, v)| members.map(&:to_sym).member?(k) }]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ActiveSupport::Cache::Store.send(:include, RestCore::RailsUtilUtil::Cache)
|
data/lib/rest-more.rb
CHANGED
data/lib/rest-more/version.rb
CHANGED
data/rest-more.gemspec
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "rest-more"
|
5
|
-
s.version = "0.7.
|
5
|
+
s.version = "0.7.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = [
|
9
9
|
"Cardinal Blue",
|
10
10
|
"Lin Jen-Shin (godfat)"]
|
11
|
-
s.date = "2011-10-
|
11
|
+
s.date = "2011-10-31"
|
12
12
|
s.description = "Various REST clients such as Facebook and Twitter built with [rest-core][]\n\n[rest-core]: https://github.com/cardinalblue/rest-core"
|
13
13
|
s.email = ["dev (XD) cardinalblue.com"]
|
14
14
|
s.files = [
|
@@ -71,7 +71,10 @@ Gem::Specification.new do |s|
|
|
71
71
|
"lib/rest-core/client/simple.rb",
|
72
72
|
"lib/rest-core/client/twitter.rb",
|
73
73
|
"lib/rest-core/client/universal.rb",
|
74
|
+
"lib/rest-core/util/config.rb",
|
75
|
+
"lib/rest-core/util/rails_util_util.rb",
|
74
76
|
"lib/rest-more.rb",
|
77
|
+
"lib/rest-more/test.rb",
|
75
78
|
"lib/rest-more/version.rb",
|
76
79
|
"rest-more.gemspec",
|
77
80
|
"task/.gitignore",
|
@@ -91,6 +94,7 @@ Gem::Specification.new do |s|
|
|
91
94
|
"test/client/facebook/test_serialize.rb",
|
92
95
|
"test/client/facebook/test_timeout.rb",
|
93
96
|
"test/client/flurry/test_metrics.rb",
|
97
|
+
"test/client/mixi/test_api.rb",
|
94
98
|
"test/client/twitter/test_api.rb"]
|
95
99
|
s.homepage = "https://github.com/cardinalblue/rest-more"
|
96
100
|
s.require_paths = ["lib"]
|
@@ -111,6 +115,7 @@ Gem::Specification.new do |s|
|
|
111
115
|
"test/client/facebook/test_serialize.rb",
|
112
116
|
"test/client/facebook/test_timeout.rb",
|
113
117
|
"test/client/flurry/test_metrics.rb",
|
118
|
+
"test/client/mixi/test_api.rb",
|
114
119
|
"test/client/twitter/test_api.rb"]
|
115
120
|
|
116
121
|
if s.respond_to? :specification_version then
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
require 'rest-
|
2
|
+
require 'rest-more/test'
|
3
3
|
|
4
4
|
require 'time'
|
5
5
|
|
@@ -70,7 +70,6 @@ describe RestCore::Flurry do
|
|
70
70
|
|
71
71
|
should 'metrics("ActiveUsers")' do
|
72
72
|
@flurry.metrics('ActiveUsers', {}, :weeks => 4).should.eq @active_users
|
73
|
-
|
74
73
|
end
|
75
74
|
|
76
75
|
should 'weekly(metrics("ActiveUsers"))' do
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
require 'rest-more/test'
|
3
|
+
|
4
|
+
describe RC::Mixi do
|
5
|
+
after do
|
6
|
+
WebMock.reset!
|
7
|
+
RR.verify
|
8
|
+
end
|
9
|
+
|
10
|
+
should 'get right' do
|
11
|
+
stub_request(:get, 'http://api.mixi-platform.com/me').
|
12
|
+
to_return(:body => '{"status": "OK"}')
|
13
|
+
|
14
|
+
RC::Mixi.new.get('me').should.eq({'status' => 'OK'})
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'be able to set access_token' do
|
18
|
+
RC::Mixi.new(:access_token => 'QQ').access_token.should.eq 'QQ'
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-more
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-10-
|
13
|
+
date: 2011-10-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-core
|
17
|
-
requirement: &
|
17
|
+
requirement: &2160851080 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2160851080
|
26
26
|
description: ! 'Various REST clients such as Facebook and Twitter built with [rest-core][]
|
27
27
|
|
28
28
|
|
@@ -92,7 +92,10 @@ files:
|
|
92
92
|
- lib/rest-core/client/simple.rb
|
93
93
|
- lib/rest-core/client/twitter.rb
|
94
94
|
- lib/rest-core/client/universal.rb
|
95
|
+
- lib/rest-core/util/config.rb
|
96
|
+
- lib/rest-core/util/rails_util_util.rb
|
95
97
|
- lib/rest-more.rb
|
98
|
+
- lib/rest-more/test.rb
|
96
99
|
- lib/rest-more/version.rb
|
97
100
|
- rest-more.gemspec
|
98
101
|
- task/.gitignore
|
@@ -112,6 +115,7 @@ files:
|
|
112
115
|
- test/client/facebook/test_serialize.rb
|
113
116
|
- test/client/facebook/test_timeout.rb
|
114
117
|
- test/client/flurry/test_metrics.rb
|
118
|
+
- test/client/mixi/test_api.rb
|
115
119
|
- test/client/twitter/test_api.rb
|
116
120
|
homepage: https://github.com/cardinalblue/rest-more
|
117
121
|
licenses: []
|
@@ -152,4 +156,5 @@ test_files:
|
|
152
156
|
- test/client/facebook/test_serialize.rb
|
153
157
|
- test/client/facebook/test_timeout.rb
|
154
158
|
- test/client/flurry/test_metrics.rb
|
159
|
+
- test/client/mixi/test_api.rb
|
155
160
|
- test/client/twitter/test_api.rb
|