rixi 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +42 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/dammy.rb +9 -0
- data/lib/rixi.rb +116 -0
- data/rixi.gemspec +69 -0
- data/sample_safari.rb +68 -0
- data/sample_sinatra.rb +45 -0
- data/spec/rixi_spec.rb +46 -0
- data/spec/spec_helper.rb +14 -0
- metadata +131 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", ">= 2.3.0"
|
10
|
+
gem "bundler", ">= 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.6.4"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
14
|
+
|
15
|
+
gem "oauth2"
|
16
|
+
gem "json"
|
17
|
+
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.2.6)
|
5
|
+
diff-lcs (1.1.2)
|
6
|
+
faraday (0.7.4)
|
7
|
+
addressable (~> 2.2.6)
|
8
|
+
multipart-post (~> 1.1.0)
|
9
|
+
rack (>= 1.1.0, < 2)
|
10
|
+
git (1.2.5)
|
11
|
+
jeweler (1.6.4)
|
12
|
+
bundler (~> 1.0)
|
13
|
+
git (>= 1.2.5)
|
14
|
+
rake
|
15
|
+
json (1.5.3)
|
16
|
+
multi_json (1.0.3)
|
17
|
+
multipart-post (1.1.3)
|
18
|
+
oauth2 (0.5.0)
|
19
|
+
faraday (< 0.8, >= 0.6.1)
|
20
|
+
multi_json (~> 1.0.0)
|
21
|
+
rack (1.3.2)
|
22
|
+
rake (0.9.2)
|
23
|
+
rcov (0.9.10)
|
24
|
+
rspec (2.3.0)
|
25
|
+
rspec-core (~> 2.3.0)
|
26
|
+
rspec-expectations (~> 2.3.0)
|
27
|
+
rspec-mocks (~> 2.3.0)
|
28
|
+
rspec-core (2.3.1)
|
29
|
+
rspec-expectations (2.3.0)
|
30
|
+
diff-lcs (~> 1.1.2)
|
31
|
+
rspec-mocks (2.3.0)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
bundler (>= 1.0.0)
|
38
|
+
jeweler (~> 1.6.4)
|
39
|
+
json
|
40
|
+
oauth2
|
41
|
+
rcov
|
42
|
+
rspec (>= 2.3.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 ainame
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= rixi
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to rixi
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 ainame . See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "rixi"
|
18
|
+
gem.homepage = "http://github.com/ainame/rixi"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Rixi is a simply library for mixi graph api in Ruby.}
|
21
|
+
gem.description = %Q{Rixi is a simply library for mixi graph api in Ruby.}
|
22
|
+
gem.email = "ainame954@facebook.com"
|
23
|
+
gem.authors = ["ainame "]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "rixi #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/dammy.rb
ADDED
data/lib/rixi.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'oauth2'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class Rixi
|
6
|
+
class APIError < StandardError
|
7
|
+
attr_reader :response
|
8
|
+
def initialize(msg, response = nil)
|
9
|
+
super(msg)
|
10
|
+
@response = response
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :consumer_key, :consumer_secret, :redirect_uri, :token, :client
|
15
|
+
|
16
|
+
SITE = 'http://api.mixi-platform.com'
|
17
|
+
AUTH_URL ='https://mixi.jp/connect_authorize.pl'
|
18
|
+
TOKEN_URL ='https://secure.mixi-platform.com/2/token'
|
19
|
+
|
20
|
+
def initialize(params = { })
|
21
|
+
if params[:consumer_key] == nil && params[:consumer_secret] == nil
|
22
|
+
raise "Rixi needs a consumer_key or consumer_secret."
|
23
|
+
end
|
24
|
+
|
25
|
+
@consumer_key = params[:consumer_key]
|
26
|
+
@consumer_secret = params[:consumer_secret]
|
27
|
+
@redirect_uri = params[:redirect_uri]
|
28
|
+
@scope = scope_to_query(params[:scope])
|
29
|
+
@client = OAuth2::Client.new(
|
30
|
+
@consumer_key,
|
31
|
+
@consumer_secret,
|
32
|
+
:site => SITE,
|
33
|
+
:authorize_url => AUTH_URL,
|
34
|
+
:token_url => TOKEN_URL
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
#スコープ未設定の時はとりあえずプロフィールだけで
|
39
|
+
def scope_to_query(scope)
|
40
|
+
if scope.kind_of?(Hash)
|
41
|
+
return scope.map {|key, value|
|
42
|
+
key.to_s if value
|
43
|
+
}.join(" ")
|
44
|
+
else
|
45
|
+
return scope || "r_profile"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def authorized_uri
|
50
|
+
@client.auth_code.authorize_url(:scope => @scope)
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_token(code)
|
54
|
+
@token = @client.auth_code
|
55
|
+
.get_token(code,
|
56
|
+
{:redirect_uri => @redirect_uri})
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.api_settings
|
60
|
+
# method name, path for API endpoints, http method
|
61
|
+
"people /2/people/%s/%s get
|
62
|
+
user_timeline /2/voice/statuses/%s/user_timeline get
|
63
|
+
friends_timeline /2/voice/statuses/%s/user_timeline get
|
64
|
+
show_status /2/voice/statuses/show/%s get
|
65
|
+
update_status /2/voice/statuses/update post
|
66
|
+
delete_status /2/voice/statuses/destroy/%s post
|
67
|
+
create_reply /2/voice/statuses/replies/create/%s post
|
68
|
+
delete_reply /2/voice/replies/destroy/%s/%s post
|
69
|
+
show_favorites_on_voice /2/voice/favorites/show/%s get
|
70
|
+
favorite_to_voice /2/voice/favorites/create/%s post
|
71
|
+
delete_favorite_to_voice /2/voice/favorites/destory/%s/%s post
|
72
|
+
".strip.split("\n").map {|l| l.strip.split(/\s+/)}
|
73
|
+
end
|
74
|
+
|
75
|
+
api_settings.each do |api|
|
76
|
+
method_name, path, http_method = *api
|
77
|
+
http_method ||= 'get'
|
78
|
+
if /%s/ =~ path
|
79
|
+
define_method method_name do |*args|
|
80
|
+
params = args.last.kind_of?(Hash) ? args.pop : { }
|
81
|
+
send http_method, path % args, params
|
82
|
+
end
|
83
|
+
else
|
84
|
+
define_method method_name do |params = { }|
|
85
|
+
send http_method, path, params
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# define_methodで定義されたメソッドは最終的に
|
91
|
+
# これらのメソッドを呼ぶ
|
92
|
+
def get(path, params = { })
|
93
|
+
@token.refresh! if @token.expired?
|
94
|
+
parse_response(@token.get(path,
|
95
|
+
{:mode => :query,
|
96
|
+
:params => params.merge({:oauth_token => @token.token})}))
|
97
|
+
end
|
98
|
+
|
99
|
+
def post(path, params = { })
|
100
|
+
@token.refresh! if @token.expired?
|
101
|
+
parse_response(@token.post(path,
|
102
|
+
{:mode => :body,
|
103
|
+
:params => params.merge({:oauth_token => @token.token})}))
|
104
|
+
end
|
105
|
+
|
106
|
+
def parse_response(res)
|
107
|
+
res = res.response.env
|
108
|
+
case res[:status].to_i
|
109
|
+
when 400...600
|
110
|
+
raise APIError.new("API Error", res)
|
111
|
+
else
|
112
|
+
JSON.parse(res[:body])
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
data/rixi.gemspec
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rixi}
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = [%q{ainame }]
|
12
|
+
s.date = %q{2011-08-17}
|
13
|
+
s.description = %q{Rixi is a simply library for mixi graph api in Ruby.}
|
14
|
+
s.email = %q{ainame954@facebook.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"dammy.rb",
|
29
|
+
"lib/rixi.rb",
|
30
|
+
"rixi.gemspec",
|
31
|
+
"sample_safari.rb",
|
32
|
+
"sample_sinatra.rb",
|
33
|
+
"spec/rixi_spec.rb",
|
34
|
+
"spec/spec_helper.rb"
|
35
|
+
]
|
36
|
+
s.homepage = %q{http://github.com/ainame/rixi}
|
37
|
+
s.licenses = [%q{MIT}]
|
38
|
+
s.require_paths = [%q{lib}]
|
39
|
+
s.rubygems_version = %q{1.8.8}
|
40
|
+
s.summary = %q{Rixi is a simply library for mixi graph api in Ruby.}
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<oauth2>, [">= 0"])
|
47
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
48
|
+
s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
|
49
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
50
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
51
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<oauth2>, [">= 0"])
|
54
|
+
s.add_dependency(%q<json>, [">= 0"])
|
55
|
+
s.add_dependency(%q<rspec>, [">= 2.3.0"])
|
56
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
58
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<oauth2>, [">= 0"])
|
62
|
+
s.add_dependency(%q<json>, [">= 0"])
|
63
|
+
s.add_dependency(%q<rspec>, [">= 2.3.0"])
|
64
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
65
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
66
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
data/sample_safari.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'oauth2'
|
3
|
+
require 'yaml'
|
4
|
+
require_relative 'lib/rixi'
|
5
|
+
require 'safariwatir' # WindowsやLinux環境では別のwatir等のgemを使う
|
6
|
+
require 'open-uri'
|
7
|
+
|
8
|
+
#
|
9
|
+
# irbで各種メソッドを試したい時に使うツール
|
10
|
+
# usage:
|
11
|
+
# 1. Sinatra等で簡単にcallbackに指定するURLに対応するページを
|
12
|
+
# 作成して起動しておく
|
13
|
+
# --app.rb--
|
14
|
+
# require 'sinatra'
|
15
|
+
# get '/callback' do
|
16
|
+
# "hoge"
|
17
|
+
# end
|
18
|
+
# ----------
|
19
|
+
# $ ruby app.rb
|
20
|
+
#
|
21
|
+
# 2. 次にirbを立ち上げてこのファイルをloadする
|
22
|
+
# $ irb
|
23
|
+
# ruby-1.9.2-p180 :001 > load "sample_safari.rb"
|
24
|
+
#
|
25
|
+
# 3.各種操作の実行が終わるまで暫く待つ。ブラウザ上に、
|
26
|
+
# Sinatraのcallback画面表示されたらcodeが取得できる。
|
27
|
+
#
|
28
|
+
# 4.irb上で定数の「M」にrixiのインスタンスが代入されているので
|
29
|
+
# 定数Mを通して各種APIを叩くメソッドを試す。
|
30
|
+
# 例:
|
31
|
+
# ruby-1.9.2-p180 :002 > M.people "@me", "@self"
|
32
|
+
#
|
33
|
+
|
34
|
+
|
35
|
+
# scopeはハッシュ形式でも文字列を自前で連結してもOK
|
36
|
+
scope = {
|
37
|
+
:r_profile => true,
|
38
|
+
:w_profile => true,
|
39
|
+
:r_profile_status => true,
|
40
|
+
:r_voice => true,
|
41
|
+
:w_voice => true,
|
42
|
+
:w_share => true,
|
43
|
+
:r_photo => true,
|
44
|
+
:w_photo => true,
|
45
|
+
:r_message => true,
|
46
|
+
:w_message => true,
|
47
|
+
:w_diary => true,
|
48
|
+
:r_checkin => true,
|
49
|
+
:w_checkin => true,
|
50
|
+
:r_updates => true
|
51
|
+
}
|
52
|
+
|
53
|
+
config = YAML.load_file("setting.yml")
|
54
|
+
M = Rixi.new( :consumer_key => config['consumer_key'],
|
55
|
+
:consumer_secret => config['consumer_secret'],
|
56
|
+
:redirect_uri => 'http://0.0.0.0:4567/callback',
|
57
|
+
:scope => scope)
|
58
|
+
|
59
|
+
browser = Watir::Safari.new
|
60
|
+
browser.goto M.authorized_uri
|
61
|
+
sleep 1 #ブラウザ上でちゃんとページ遷移できてないとエラーとなる
|
62
|
+
browser.button(:name, "accept").click
|
63
|
+
sleep 1
|
64
|
+
code = URI.parse(browser.url).query.split("=").at(1)
|
65
|
+
# codeが取得出来てるか確認
|
66
|
+
pp code
|
67
|
+
|
68
|
+
M.get_token(code)
|
data/sample_sinatra.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'oauth2'
|
3
|
+
require 'sinatra'
|
4
|
+
require 'sinatra/reloader'
|
5
|
+
require 'yaml'
|
6
|
+
require_relative 'lib/rixi'
|
7
|
+
enable :sessions
|
8
|
+
|
9
|
+
# コンシューマキーとシークレットを設定
|
10
|
+
# 設定ファイルにyaml形式でconsumer_keyとか書いてる
|
11
|
+
configure do
|
12
|
+
config = YAML.load_file("setting.yml")
|
13
|
+
@@mixi = Rixi.new( :consumer_key => config['consumer_key'],
|
14
|
+
:consumer_secret => config['consumer_secret'],
|
15
|
+
:redirect_uri => 'http://0.0.0.0:4567/callback',
|
16
|
+
:scope => "r_profile r_voice w_voice r_updates" )
|
17
|
+
end
|
18
|
+
|
19
|
+
# セッションにトークンが存在してればAPIへアクセス
|
20
|
+
get '/' do
|
21
|
+
if session[:login]
|
22
|
+
res = @@mixi.people "@me", "@self"
|
23
|
+
"ようこそ<br />#{res['entry']['displayName']}さん!"+
|
24
|
+
"<br /><a href='/logout'>ログアウト</a>"
|
25
|
+
else
|
26
|
+
"ようこそ!<br /><a href='/login'>ログイン</a>"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# 認証ページへ飛ぶ、スコープの設定もここ
|
31
|
+
get '/login' do
|
32
|
+
redirect @@mixi.authorized_uri
|
33
|
+
end
|
34
|
+
|
35
|
+
get '/logout' do
|
36
|
+
session[:login] = false
|
37
|
+
redirect '/'
|
38
|
+
end
|
39
|
+
|
40
|
+
# コールバックでアクセストークンを取得(コールバックURLを指定)
|
41
|
+
get '/callback' do
|
42
|
+
#@@mixi.get_token(params["code"])
|
43
|
+
session[:login] = true
|
44
|
+
redirect '/'
|
45
|
+
end
|
data/spec/rixi_spec.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
3
|
+
|
4
|
+
describe Rixi do
|
5
|
+
before do
|
6
|
+
scope = {
|
7
|
+
:r_profile => true,
|
8
|
+
:w_profile => true,
|
9
|
+
:r_profile_status => true,
|
10
|
+
:r_voice => true,
|
11
|
+
:w_voice => true,
|
12
|
+
:w_share => true,
|
13
|
+
:r_photo => true,
|
14
|
+
:w_photo => true,
|
15
|
+
:r_message => true,
|
16
|
+
:w_message => true,
|
17
|
+
:w_diary => true,
|
18
|
+
:r_checkin => true,
|
19
|
+
:w_checkin => true,
|
20
|
+
:r_updates => true
|
21
|
+
}
|
22
|
+
|
23
|
+
config = YAML.load_file("setting.yml")
|
24
|
+
@mixi = Rixi.new( :consumer_key => config['consumer_key'],
|
25
|
+
:consumer_secret => config['consumer_secret'],
|
26
|
+
:redirect_uri => 'http://0.0.0.0:4567/callback',
|
27
|
+
:scope => scope)
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "Rixi#authorize_uri" do
|
31
|
+
it "authorize_uriの設定が正しいかどうか" do
|
32
|
+
uri = URI.parse(@mixi.authorize_uri)
|
33
|
+
uri.host.should == "mixi.jp"
|
34
|
+
uri.path.should == "connect_authorize.pl"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "consumer_key等がただしくquery内に代入されてるか" do
|
38
|
+
uri.query.match(config['consumer_key']).should_not be_nil
|
39
|
+
uri.query.match(config['consumer_secret']).should_not be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'rixi'
|
5
|
+
require 'open-uri'
|
6
|
+
|
7
|
+
|
8
|
+
# Requires supporting files with custom matchers and macros, etc,
|
9
|
+
# in ./support/ and its subdirectories.
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rixi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- ! 'ainame '
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-17 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: oauth2
|
16
|
+
requirement: &70231599481800 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70231599481800
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: json
|
27
|
+
requirement: &70231599480420 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70231599480420
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70231599479420 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.3.0
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70231599479420
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: &70231599478440 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70231599478440
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: jeweler
|
60
|
+
requirement: &70231599477400 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.6.4
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70231599477400
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rcov
|
71
|
+
requirement: &70231599473880 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70231599473880
|
80
|
+
description: Rixi is a simply library for mixi graph api in Ruby.
|
81
|
+
email: ainame954@facebook.com
|
82
|
+
executables: []
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files:
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.rdoc
|
87
|
+
files:
|
88
|
+
- .document
|
89
|
+
- .rspec
|
90
|
+
- Gemfile
|
91
|
+
- Gemfile.lock
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.rdoc
|
94
|
+
- Rakefile
|
95
|
+
- VERSION
|
96
|
+
- dammy.rb
|
97
|
+
- lib/rixi.rb
|
98
|
+
- rixi.gemspec
|
99
|
+
- sample_safari.rb
|
100
|
+
- sample_sinatra.rb
|
101
|
+
- spec/rixi_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
homepage: http://github.com/ainame/rixi
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
hash: 3290286285413237058
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 1.8.8
|
128
|
+
signing_key:
|
129
|
+
specification_version: 3
|
130
|
+
summary: Rixi is a simply library for mixi graph api in Ruby.
|
131
|
+
test_files: []
|