nov-iknow 0.0.4 → 0.1.0
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/README +4 -23
- data/Rakefile +5 -2
- data/examples/pure_ruby.rb +52 -10
- data/lib/ext/hash.rb +29 -0
- data/lib/iknow/core/config.rb +1 -1
- data/lib/iknow/core/version.rb +2 -2
- data/lib/iknow/core.rb +2 -1
- data/lib/iknow/model/list.rb +31 -18
- data/lib/iknow/rest_client/base.rb +66 -49
- data/lib/iknow/rest_client/item.rb +5 -5
- data/lib/iknow/rest_client/list.rb +9 -7
- metadata +13 -39
- data/examples/iknow_on_rails/app/controllers/application.rb +0 -15
- data/examples/iknow_on_rails/app/controllers/iknow_oauth_controller.rb +0 -24
- data/examples/iknow_on_rails/app/controllers/users_controller.rb +0 -10
- data/examples/iknow_on_rails/app/helpers/application_helper.rb +0 -3
- data/examples/iknow_on_rails/app/helpers/iknow_oauth_helper.rb +0 -3
- data/examples/iknow_on_rails/app/helpers/users_helper.rb +0 -2
- data/examples/iknow_on_rails/app/models/iknow_oauth_token.rb +0 -37
- data/examples/iknow_on_rails/config/boot.rb +0 -109
- data/examples/iknow_on_rails/config/environment.rb +0 -76
- data/examples/iknow_on_rails/config/environments/development.rb +0 -17
- data/examples/iknow_on_rails/config/environments/production.rb +0 -22
- data/examples/iknow_on_rails/config/environments/test.rb +0 -22
- data/examples/iknow_on_rails/config/initializers/inflections.rb +0 -10
- data/examples/iknow_on_rails/config/initializers/mime_types.rb +0 -5
- data/examples/iknow_on_rails/config/initializers/new_rails_defaults.rb +0 -17
- data/examples/iknow_on_rails/config/routes.rb +0 -44
- data/examples/iknow_on_rails/db/migrate/20081017012212_create_iknow_oauth_tokens.rb +0 -15
- data/examples/iknow_on_rails/db/schema.rb +0 -23
- data/examples/iknow_on_rails/lib/iknow_oauth_system.rb +0 -26
- data/examples/iknow_on_rails/public/dispatch.rb +0 -10
- data/examples/iknow_on_rails/test/functional/iknow_oauth_controller_test.rb +0 -7
- data/examples/iknow_on_rails/test/functional/users_controller_test.rb +0 -8
- data/examples/iknow_on_rails/test/test_helper.rb +0 -38
- data/examples/iknow_on_rails/test/unit/iknow_oauth_token_test.rb +0 -7
- data/generators/iknow_oauth/USAGE +0 -12
- data/generators/iknow_oauth/iknow_oauth_generator.rb +0 -22
- data/generators/iknow_oauth/templates/iknow_oauth_controller.rb +0 -24
- data/generators/iknow_oauth/templates/iknow_oauth_controller_test.rb +0 -7
- data/generators/iknow_oauth/templates/iknow_oauth_helper.rb +0 -3
- data/generators/iknow_oauth/templates/iknow_oauth_system.rb +0 -26
- data/generators/iknow_oauth/templates/iknow_oauth_token.rb +0 -37
- data/generators/iknow_oauth/templates/iknow_oauth_token_test.rb +0 -7
- data/generators/iknow_oauth/templates/iknow_oauth_tokens_migration.rb +0 -15
- data/generators/iknow_oauth/templates/index.rhtml +0 -4
@@ -1,26 +0,0 @@
|
|
1
|
-
module IknowOauthSystem
|
2
|
-
|
3
|
-
protected
|
4
|
-
|
5
|
-
def require_iknow_oauth
|
6
|
-
unless iknow_username_exists?
|
7
|
-
redirect_to(:controller => 'iknow_oauth', :action => 'index')
|
8
|
-
return false
|
9
|
-
end
|
10
|
-
|
11
|
-
iknow_oauth_token = IknowOauthToken.find_by_username(session[:iknow_username])
|
12
|
-
unless iknow_oauth_token
|
13
|
-
redirect_to(:controller => 'iknow_oauth', :action => 'new_request')
|
14
|
-
return false
|
15
|
-
end
|
16
|
-
|
17
|
-
true
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def iknow_username_exists?
|
23
|
-
!session[:iknow_username].blank?
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'oauth/consumer'
|
2
|
-
|
3
|
-
class IknowOauthToken < ActiveRecord::Base
|
4
|
-
|
5
|
-
def self.consumer
|
6
|
-
@@consumer ||= OAuth::Consumer.new(
|
7
|
-
Iknow::Config.oauth_consumer_key,
|
8
|
-
Iknow::Config.oauth_consumer_secret,
|
9
|
-
:site => Iknow::Config.iknow_api_base_url,
|
10
|
-
:authorize_url => "#{Iknow::Config.iknow_base_url}/oauth/authorize"
|
11
|
-
)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.new_request_token
|
15
|
-
begin
|
16
|
-
self.consumer.get_request_token
|
17
|
-
rescue Exception => e
|
18
|
-
nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.establish_auth_token(iknow_username, request_token)
|
23
|
-
access_token = request_token.get_access_token
|
24
|
-
|
25
|
-
auth_token = IknowAuthToken.new
|
26
|
-
auth_token.username = iknow_username
|
27
|
-
auth_token.token = access_token.token
|
28
|
-
auth_token.secret = access_token.secret
|
29
|
-
auth_token.save!
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_access_token
|
33
|
-
OAuth::AccessToken.new(self.class.consumer, self.token, self.secret)
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class CreateIknowOauthTokens < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :iknow_oauth_tokens do |t|
|
4
|
-
t.column :iknow_username, :string, :null => false
|
5
|
-
t.column :token, :string, :unique => true
|
6
|
-
t.column :secret, :string
|
7
|
-
end
|
8
|
-
add_index :iknow_oauth_tokens, :token, :unique => true
|
9
|
-
add_index :iknow_oauth_tokens, :iknow_username
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.down
|
13
|
-
drop_table :iknow_oauth_tokens
|
14
|
-
end
|
15
|
-
end
|