ourkudos 0.0.29 → 0.0.30
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/VERSION +1 -1
- data/lib/ourkudos/acts/client.rb +49 -0
- data/lib/ourkudos/strategies/strategy.rb +41 -0
- data/lib/ourkudos.rb +4 -5
- data/ourkudos.gemspec +5 -8
- metadata +16 -19
- data/lib/ourkudos/extensions.rb +0 -8
- data/lib/ourkudos/our_kudos.rb +0 -112
- data/lib/ourkudos/railtie.rb +0 -10
- data/lib/ourkudos/resource_editor.rb +0 -30
- data/lib/ourkudos/tasks/ourkudos.rb +0 -25
- /data/lib/ourkudos/{response_codes.rb → server/response_codes.rb} +0 -0
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.30
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module OurKudos
|
2
|
+
module Acts
|
3
|
+
module Client
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend AddActsAsOurKudosClient
|
7
|
+
end
|
8
|
+
|
9
|
+
module AddActsAsOurKudosClient
|
10
|
+
def acts_as_ourkudos_client(options = {:token => :authentication_token})
|
11
|
+
|
12
|
+
cattr_reader :application_id, :application_secret, :ourkudos_host
|
13
|
+
|
14
|
+
class_eval <<-RUBY
|
15
|
+
include OurKudos::Acts::Client::InstanceMethods
|
16
|
+
|
17
|
+
if defined?(Devise) && Devise.omniauth_configs[:ourkudos]
|
18
|
+
@@application_id, @@application_secret = Devise.omniauth_configs[:ourkudos].args[0..1]
|
19
|
+
@@ourkudos_host = Devise.omniauth_configs[:ourkudos].args[2][:site]
|
20
|
+
else
|
21
|
+
raise "Please put correct config in devise initializer i.e. config.omniauth :ourkduos 'app_id', 'app_secret'"
|
22
|
+
end
|
23
|
+
RUBY
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
module InstanceMethods
|
30
|
+
|
31
|
+
def client
|
32
|
+
@client ||= OAuth2::Client.new self.application_id, self.application_secret, :site => self.ourkudos_host
|
33
|
+
end
|
34
|
+
|
35
|
+
def ourkudos
|
36
|
+
@ourkudos ||= OAuth2::AccessToken.new(client, self.authentication_token)
|
37
|
+
end
|
38
|
+
|
39
|
+
module ClassMethods
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Ourkudos < OAuth2
|
7
|
+
|
8
|
+
include OmniAuth::Strategy
|
9
|
+
def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
|
10
|
+
super app, :ourkudos, client_id, client_secret, {:site => 'http://localhost:3000'}, options, &block
|
11
|
+
end
|
12
|
+
|
13
|
+
def request_phase
|
14
|
+
options[:response_type] ||= 'code'
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def user_data
|
19
|
+
@data ||= MultiJson.decode(@access_token.get(client.site + '/oauth/user', {'oauth_token' => @access_token.token}))
|
20
|
+
end
|
21
|
+
|
22
|
+
def user_info
|
23
|
+
{
|
24
|
+
'email' => (user_data["email"] if user_data["email"]),
|
25
|
+
'first_name' => user_data["first_name"],
|
26
|
+
'last_name' => user_data["last_name"],
|
27
|
+
'name' => "#{user_data['first_name']} #{user_data['last_name']}"
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def auth_hash
|
32
|
+
OmniAuth::Utils.deep_merge(super, {
|
33
|
+
'uid' => user_data["user"]["id"],
|
34
|
+
'user_info' => user_info,
|
35
|
+
'extra' => {'user_hash' => user_data}
|
36
|
+
})
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/ourkudos.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
require 'ourkudos/
|
3
|
-
require '
|
4
|
-
|
1
|
+
require 'ourkduos/server/response_codes'
|
2
|
+
require 'ourkudos/acts/client'
|
3
|
+
require 'ourkduos/strategies/strategy'
|
4
|
+
ActiveRecord::Base.send :include, OurKudos::Acts::Client
|
5
5
|
|
6
|
-
require 'ourkudos/railtie' if defined?(Rails)
|
data/ourkudos.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ourkudos}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.30"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marcin Walczak"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-23}
|
13
13
|
s.description = %q{OurKudos client api gem}
|
14
14
|
s.email = %q{marcin.walczak@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -25,12 +25,9 @@ Gem::Specification.new do |s|
|
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
27
|
"lib/ourkudos.rb",
|
28
|
-
"lib/ourkudos/
|
29
|
-
"lib/ourkudos/
|
30
|
-
"lib/ourkudos/
|
31
|
-
"lib/ourkudos/resource_editor.rb",
|
32
|
-
"lib/ourkudos/response_codes.rb",
|
33
|
-
"lib/ourkudos/tasks/ourkudos.rb",
|
28
|
+
"lib/ourkudos/acts/client.rb",
|
29
|
+
"lib/ourkudos/server/response_codes.rb",
|
30
|
+
"lib/ourkudos/strategies/strategy.rb",
|
34
31
|
"ourkudos.gemspec",
|
35
32
|
"spec/our_kudos_spec.rb",
|
36
33
|
"spec/spec_helper.rb"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ourkudos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.30
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-05-
|
12
|
+
date: 2011-05-23 00:00:00.000000000 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nestful
|
17
|
-
requirement: &
|
17
|
+
requirement: &14372560 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *14372560
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec
|
28
|
-
requirement: &
|
28
|
+
requirement: &14371760 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 2.3.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *14371760
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
-
requirement: &
|
39
|
+
requirement: &14370780 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.0.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *14370780
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: jeweler
|
50
|
-
requirement: &
|
50
|
+
requirement: &14370020 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *14370020
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: rcov
|
61
|
-
requirement: &
|
61
|
+
requirement: &14369240 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *14369240
|
70
70
|
description: OurKudos client api gem
|
71
71
|
email: marcin.walczak@gmail.com
|
72
72
|
executables: []
|
@@ -83,12 +83,9 @@ files:
|
|
83
83
|
- Rakefile
|
84
84
|
- VERSION
|
85
85
|
- lib/ourkudos.rb
|
86
|
-
- lib/ourkudos/
|
87
|
-
- lib/ourkudos/
|
88
|
-
- lib/ourkudos/
|
89
|
-
- lib/ourkudos/resource_editor.rb
|
90
|
-
- lib/ourkudos/response_codes.rb
|
91
|
-
- lib/ourkudos/tasks/ourkudos.rb
|
86
|
+
- lib/ourkudos/acts/client.rb
|
87
|
+
- lib/ourkudos/server/response_codes.rb
|
88
|
+
- lib/ourkudos/strategies/strategy.rb
|
92
89
|
- ourkudos.gemspec
|
93
90
|
- spec/our_kudos_spec.rb
|
94
91
|
- spec/spec_helper.rb
|
@@ -108,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
105
|
version: '0'
|
109
106
|
segments:
|
110
107
|
- 0
|
111
|
-
hash: -
|
108
|
+
hash: -3180763327117112311
|
112
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
110
|
none: false
|
114
111
|
requirements:
|
data/lib/ourkudos/extensions.rb
DELETED
data/lib/ourkudos/our_kudos.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
require 'nestful'
|
2
|
-
module OurKudos
|
3
|
-
|
4
|
-
class << self
|
5
|
-
|
6
|
-
#alias method
|
7
|
-
def api_key
|
8
|
-
OurKudos::Client.api_key
|
9
|
-
end
|
10
|
-
|
11
|
-
#alias methods
|
12
|
-
def base_uri
|
13
|
-
OurKudos::Client.base_uri
|
14
|
-
end
|
15
|
-
|
16
|
-
#alias method
|
17
|
-
def api_key= api_key
|
18
|
-
OurKudos::Client.api_key = api_key
|
19
|
-
end
|
20
|
-
|
21
|
-
#alias method
|
22
|
-
def base_uri= uri
|
23
|
-
OurKudos::Client.base_uri = uri
|
24
|
-
end
|
25
|
-
|
26
|
-
def config_file_path
|
27
|
-
File.join(Rails.root, 'config', 'ourkudos.yml') rescue ''
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
class Client
|
35
|
-
|
36
|
-
cattr_accessor :api_key, :base_uri
|
37
|
-
attr_accessor :resource
|
38
|
-
include OurKudos::ResourceEditor
|
39
|
-
|
40
|
-
#configuration hash
|
41
|
-
OurKudosClientOptions = { :api_key => nil,
|
42
|
-
:base_uri => "http://localhost:3000/api/" } if !Object.const_defined? :ClientOptions # :nodoc:
|
43
|
-
|
44
|
-
|
45
|
-
#load settings from yaml file, if file is found
|
46
|
-
if File.exists? OurKudos.config_file_path
|
47
|
-
config = YAML.load_file OurKudos.config_file_path
|
48
|
-
@@base_uri = OurKudosClientOptions[:base_uri] = config[:base_uri]
|
49
|
-
@@api_key = OurKudosClientOptions[:api_key] = config[:api_key]
|
50
|
-
end
|
51
|
-
|
52
|
-
# CLASS METHODS #
|
53
|
-
class << self
|
54
|
-
|
55
|
-
#sets new api key
|
56
|
-
def api_key= api_key = nil
|
57
|
-
return @@api_key unless api_key
|
58
|
-
|
59
|
-
@@api_key = OurKudosClientOptions[:api_key] = api_key
|
60
|
-
end
|
61
|
-
|
62
|
-
#sets base url
|
63
|
-
def base_uri= base_uri = nil
|
64
|
-
return @@base_uri unless base_uri
|
65
|
-
|
66
|
-
@@base_uri = OurKudosClientOptions[:base_uri] = base_uri
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
# INSTANCE METHODS #
|
72
|
-
|
73
|
-
#sets resource to read/edit/delete
|
74
|
-
def resource= resource
|
75
|
-
OurKudos::ResourceEditor.resource = resource
|
76
|
-
end
|
77
|
-
|
78
|
-
#displays current resource
|
79
|
-
def resource
|
80
|
-
OurKudos::ResourceEditor.resource
|
81
|
-
end
|
82
|
-
|
83
|
-
# general restuful post method - creates an item
|
84
|
-
def post(options = {})
|
85
|
-
Nestful.post OurKudos.base_uri + options[:path], :params => {:api_key => OurKudos.api_key}.merge(options[:params]),
|
86
|
-
:format => :json
|
87
|
-
end
|
88
|
-
|
89
|
-
# retrieves item
|
90
|
-
def get(options = {})
|
91
|
-
Nestful.get OurKudos.base_uri + options[:path], :params => {:api_key => OurKudos.api_key}.merge(options[:params]),
|
92
|
-
:format => :json
|
93
|
-
end
|
94
|
-
|
95
|
-
# updates item
|
96
|
-
def put(options = {})
|
97
|
-
Nestful.put OurKudos.base_uri + options[:path], :params => {:api_key => OurKudos.api_key}.merge(options[:params]),
|
98
|
-
:format => :json
|
99
|
-
end
|
100
|
-
|
101
|
-
# deletes item
|
102
|
-
def delete(options = {})
|
103
|
-
Nestful.delete OurKudos.base_uri + options[:path], :params => {:api_key => OurKudos.api_key}.merge(options[:params]),
|
104
|
-
:format => :json
|
105
|
-
end
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
112
|
-
end
|
data/lib/ourkudos/railtie.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
module OurKudos
|
2
|
-
module ResourceEditor
|
3
|
-
|
4
|
-
def self.resource= name
|
5
|
-
@@resource = name
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.resource
|
9
|
-
@@resource
|
10
|
-
end
|
11
|
-
|
12
|
-
def create fields = {}
|
13
|
-
post(:path => "#{self.resource}s.json", :params => {resource.to_sym => fields})
|
14
|
-
end
|
15
|
-
|
16
|
-
def update(id, fields = {})
|
17
|
-
put(:path => "#{self.resource}s/#{id.to_s}.json", :params => {resource.to_sym => fields })
|
18
|
-
end
|
19
|
-
|
20
|
-
def read id
|
21
|
-
get(:path => "#{self.resource}s/#{id.to_s}.json", :params => {})
|
22
|
-
end
|
23
|
-
|
24
|
-
def destroy id
|
25
|
-
delete(:path => "#{self.resource}s/#{id.to_s}.json", :params => {})
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
namespace :ourkudos do
|
3
|
-
namespace :config do
|
4
|
-
task :generate => :environment do
|
5
|
-
|
6
|
-
config = {:base_uri => "http://ourkudos.com",
|
7
|
-
:api_key => "your api key"
|
8
|
-
}
|
9
|
-
|
10
|
-
file_path = File.join(Rails.root,'config', 'ourkudos.yml')
|
11
|
-
|
12
|
-
puts "Generating config file to #{file_path}. \nPlease update it with correct api key"
|
13
|
-
|
14
|
-
File.open(file_path, 'w') do |f|
|
15
|
-
method = config.respond_to?(:ya2yaml) ? :ya2yaml : :to_yaml
|
16
|
-
string = config.deep_stringify_keys.send(method)
|
17
|
-
f.write string.gsub("!ruby/symbol ", ":").gsub("---","").split("\n").map(&:rstrip).join("\n").strip
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
end
|
File without changes
|