kuaipan-example 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source :gemcutter
2
+ gem "sinatra"
3
+ gem "haml"
4
+ #gem "kuaipan", :path => "~/codespace/ruby_space/kuaipan/"
5
+ #gem 'kuaipan', :path => "~/.rvm/gems/ruby-1.9.3-p125/gems/kuaipan-0.0.0/"
6
+ gem "kuaipan", :git => "git://github.com/tiemei/kuaipan.git", :ref => 'b836570e59e'
data/Gemfile.lock ADDED
@@ -0,0 +1,27 @@
1
+ GIT
2
+ remote: git://github.com/tiemei/kuaipan.git
3
+ revision: b836570e59eaf40767eaa4d470631ba4a8766c07
4
+ ref: b836570e59e
5
+ specs:
6
+ kuaipan (0.0.1.beta.11)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ haml (3.1.4)
12
+ rack (1.4.1)
13
+ rack-protection (1.2.0)
14
+ rack
15
+ sinatra (1.3.2)
16
+ rack (~> 1.3, >= 1.3.6)
17
+ rack-protection (~> 1.2)
18
+ tilt (~> 1.3, >= 1.3.3)
19
+ tilt (1.3.3)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ haml
26
+ kuaipan!
27
+ sinatra
data/README.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ = kuaipan-example
2
+ A example that show how to use kuaipan.gem
3
+ You can run it.Then you show input your account info of kuaipan.
4
+ ruby example.rb
5
+
data/example.rb ADDED
@@ -0,0 +1,37 @@
1
+ require 'sinatra'
2
+ require 'kuaipan'
3
+ require 'haml'
4
+ enable :sessions
5
+ get '/' do
6
+ session[:k_session] = nil
7
+ haml :index
8
+ end
9
+
10
+ extend Kuaipan::OpenAPI
11
+
12
+ consumer_token = "xcWcZhCNKFJz1H8p"
13
+ consumer_secret = "8RvkM0aGYiQF5kJF"
14
+ input_config consumer_token, consumer_secret
15
+
16
+ get '/connect' do
17
+ extend Kuaipan::OpenAPI
18
+ k_session = g_session :oauth_callback => "http://#{request.env["HTTP_HOST"]}/callback" # here get rtoken
19
+ authorize_url = k_session[:authorize_url]
20
+ session[:k_session] = k_session
21
+ redirect authorize_url
22
+ end
23
+
24
+ get '/callback' do
25
+ oauth_verifier = params[:oauth_verifier]
26
+ # parse oauth_verifier client code
27
+ session[:k_session].set_atoken oauth_verifier # here set accesstoken
28
+ redirect '/user_info'
29
+ end
30
+
31
+ get '/user_info' do
32
+ haml :index
33
+ end
34
+
35
+ get '/logout' do
36
+ p 'logou'
37
+ end
@@ -0,0 +1,20 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'kuaipan-example'
3
+ s.version = '0.0.1'
4
+ s.date = '2012-04-27'
5
+ s.summary = "a simple demo which use kuaipan.gem"
6
+ s.description = "enjoy kuaipan.gem! enjoy it! enjoy life!"
7
+ s.authors = ["tiemei"]
8
+ s.email = 'jiadongkai@gmail.com'
9
+ s.files = [
10
+ "Gemfile",
11
+ "Gemfile.lock",
12
+ "README.rdoc",
13
+ "example.rb",
14
+ "kuaipan-example.gemspec",
15
+ "views/index.haml",
16
+ "views/layout.haml"
17
+ ]
18
+ s.require_paths = ["lib"]
19
+ s.homepage = 'http://rubygems.org/gems/kuaipan-examlple'
20
+ end
data/views/index.haml ADDED
@@ -0,0 +1,2 @@
1
+ - if session[:k_session]
2
+ = session[:k_session].account_info['user_id']
data/views/layout.haml ADDED
@@ -0,0 +1,9 @@
1
+ !!!
2
+ %html(xml:lang='en' lang='en' xmlns='http://www.w3.org/1999/xhtml')
3
+ %head
4
+ %meta(content='text/html;charset=UTF-8' http-equiv='content-type')
5
+ %title="kuaipan gem example"
6
+ %body
7
+ %h2="kuaipan gem example"
8
+ %a{:href => (session[:k_session] ? "/logout" : "/connect")}=(session[:k_session] ? "logout" : "connect")
9
+ = yield
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kuaipan-example
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - tiemei
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-27 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: enjoy kuaipan.gem! enjoy it! enjoy life!
15
+ email: jiadongkai@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Gemfile
21
+ - Gemfile.lock
22
+ - README.rdoc
23
+ - example.rb
24
+ - kuaipan-example.gemspec
25
+ - views/index.haml
26
+ - views/layout.haml
27
+ homepage: http://rubygems.org/gems/kuaipan-examlple
28
+ licenses: []
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 1.8.11
48
+ signing_key:
49
+ specification_version: 3
50
+ summary: a simple demo which use kuaipan.gem
51
+ test_files: []