exvo-auth 0.9.10 → 0.10.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/.gitignore +2 -21
- data/Gemfile.lock +56 -0
- data/exvo-auth.gemspec +3 -2
- data/lib/exvo-auth.rb +4 -0
- data/lib/exvo_auth/config.rb +4 -0
- data/lib/exvo_auth/models/message.rb +72 -0
- data/lib/exvo_auth/sharing.rb +20 -0
- data/lib/exvo_auth/version.rb +1 -1
- metadata +29 -10
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
exvo-auth (0.9.10)
|
5
|
+
activemodel (> 3.0.0)
|
6
|
+
httparty (~> 0.6.1)
|
7
|
+
oa-oauth (~> 0.0.4)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activemodel (3.0.3)
|
13
|
+
activesupport (= 3.0.3)
|
14
|
+
builder (~> 2.1.2)
|
15
|
+
i18n (~> 0.4)
|
16
|
+
activesupport (3.0.3)
|
17
|
+
addressable (2.2.2)
|
18
|
+
builder (2.1.2)
|
19
|
+
crack (0.1.8)
|
20
|
+
faraday (0.4.6)
|
21
|
+
addressable (>= 2.1.1)
|
22
|
+
rack (>= 1.0.1)
|
23
|
+
httparty (0.6.1)
|
24
|
+
crack (= 0.1.8)
|
25
|
+
i18n (0.4.2)
|
26
|
+
mocha (0.9.9)
|
27
|
+
rake
|
28
|
+
multi_json (0.0.5)
|
29
|
+
nokogiri (1.4.3.1)
|
30
|
+
oa-core (0.0.5)
|
31
|
+
rack (~> 1.1)
|
32
|
+
oa-oauth (0.0.5)
|
33
|
+
multi_json (~> 0.0.2)
|
34
|
+
nokogiri (~> 1.4.2)
|
35
|
+
oa-core (= 0.0.5)
|
36
|
+
oauth (~> 0.4.0)
|
37
|
+
oauth2 (~> 0.0.10)
|
38
|
+
oauth (0.4.4)
|
39
|
+
oauth2 (0.0.13)
|
40
|
+
faraday (~> 0.4.1)
|
41
|
+
multi_json (>= 0.0.4)
|
42
|
+
rack (1.2.1)
|
43
|
+
rake (0.8.7)
|
44
|
+
test-unit (2.1.1)
|
45
|
+
|
46
|
+
PLATFORMS
|
47
|
+
ruby
|
48
|
+
|
49
|
+
DEPENDENCIES
|
50
|
+
activemodel (> 3.0.0)
|
51
|
+
bundler (~> 1.0.0)
|
52
|
+
exvo-auth!
|
53
|
+
httparty (~> 0.6.1)
|
54
|
+
mocha (~> 0.9.8)
|
55
|
+
oa-oauth (~> 0.0.4)
|
56
|
+
test-unit (~> 2.1.0)
|
data/exvo-auth.gemspec
CHANGED
@@ -14,8 +14,9 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.required_rubygems_version = ">= 1.3.6"
|
15
15
|
s.rubyforge_project = "exvo-auth"
|
16
16
|
|
17
|
-
s.add_dependency "oa-oauth",
|
18
|
-
s.add_dependency "httparty",
|
17
|
+
s.add_dependency "oa-oauth", "~> 0.0.4"
|
18
|
+
s.add_dependency "httparty", "~> 0.6.1"
|
19
|
+
s.add_dependency "activemodel", "> 3.0.0"
|
19
20
|
|
20
21
|
s.add_development_dependency "mocha", "~> 0.9.8"
|
21
22
|
s.add_development_dependency "test-unit", "~> 2.1.0"
|
data/lib/exvo-auth.rb
CHANGED
@@ -23,6 +23,10 @@ module ExvoAuth
|
|
23
23
|
autoload :Merb, 'exvo_auth/controllers/merb'
|
24
24
|
end
|
25
25
|
|
26
|
+
module Models
|
27
|
+
autoload :Message, 'exvo_auth/models/message'
|
28
|
+
end
|
29
|
+
|
26
30
|
module Autonomous
|
27
31
|
autoload :Base, 'exvo_auth/autonomous/base'
|
28
32
|
autoload :Consumer, 'exvo_auth/autonomous/consumer'
|
data/lib/exvo_auth/config.rb
CHANGED
@@ -0,0 +1,72 @@
|
|
1
|
+
class ExvoAuth::Models::Message
|
2
|
+
include ActiveModel::Validations
|
3
|
+
include ActiveModel::Serialization
|
4
|
+
|
5
|
+
class RecordInvalid < StandardError; end
|
6
|
+
class RecordNotFound < StandardError; end
|
7
|
+
|
8
|
+
validates :label, :presence => true, :format => /^[_a-z0-9]+$/ix
|
9
|
+
validates :text, :presence => true
|
10
|
+
validates :user_uid, :presence => true, :numericality => true
|
11
|
+
|
12
|
+
attr_accessor :id, :label, :text, :user_uid, :created_at, :read
|
13
|
+
|
14
|
+
def initialize(attributes = {})
|
15
|
+
attributes.each do |name, value|
|
16
|
+
send("#{name}=", value)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.create(attributes = {})
|
21
|
+
message = new(attributes)
|
22
|
+
if message.valid?
|
23
|
+
message.deliver
|
24
|
+
message
|
25
|
+
else
|
26
|
+
raise RecordInvalid, message.errors.full_messages.join(", ")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.all
|
31
|
+
auth = ExvoAuth::Autonomous::Auth.instance
|
32
|
+
response = auth.get("/api/private/app_messages.json")
|
33
|
+
response.map{ |m| new(m) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.find(id)
|
37
|
+
auth = ExvoAuth::Autonomous::Auth.instance
|
38
|
+
response = auth.get("/api/private/app_messages/#{id}.json")
|
39
|
+
if response.code == 200
|
40
|
+
new(response)
|
41
|
+
else
|
42
|
+
raise RecordNotFound, "Couldn't find #{model_name} with ID=#{id}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def deliver
|
47
|
+
auth = ExvoAuth::Autonomous::Auth.instance
|
48
|
+
attributes = {
|
49
|
+
:label => label,
|
50
|
+
:text => text,
|
51
|
+
:user_uid => user_uid
|
52
|
+
}
|
53
|
+
response = auth.post("/api/private/app_messages.json", :body => attributes)
|
54
|
+
case response.code
|
55
|
+
when 201 then
|
56
|
+
response.parsed_response.each do |k, v|
|
57
|
+
send("#{k}=", v)
|
58
|
+
end
|
59
|
+
when 422 then
|
60
|
+
response.parsed_response.each{ |attr, error| errors.add(attr, error) }
|
61
|
+
raise RecordInvalid, errors.full_messages.join(", ")
|
62
|
+
else
|
63
|
+
raise "Unknown error"
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def persisted?
|
69
|
+
!!id
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# TODO: activemodel with validations
|
2
|
+
class ExvoAuth::Sharing
|
3
|
+
def self.create(attrs = {})
|
4
|
+
new(attrs).save
|
5
|
+
end
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
def save
|
10
|
+
if true
|
11
|
+
cfs.post("/sharings", :query => { :document_id => attrs[:document_id], :sharing => { :email => attrs[:email], :user_uid => attrs[:user_uid] } })
|
12
|
+
else
|
13
|
+
# TODO: append errors on errors from cfs too.
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def cfs
|
18
|
+
@cfs ||= Autonomous::Consumer.new(:app_id => Config.cfs_id)
|
19
|
+
end
|
20
|
+
end
|
data/lib/exvo_auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exvo-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 9
|
9
8
|
- 10
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.10.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jacek Becela
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-29 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -51,9 +51,25 @@ dependencies:
|
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
54
|
+
name: activemodel
|
55
55
|
prerelease: false
|
56
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 7
|
62
|
+
segments:
|
63
|
+
- 3
|
64
|
+
- 0
|
65
|
+
- 0
|
66
|
+
version: 3.0.0
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
57
73
|
none: false
|
58
74
|
requirements:
|
59
75
|
- - ~>
|
@@ -65,11 +81,11 @@ dependencies:
|
|
65
81
|
- 8
|
66
82
|
version: 0.9.8
|
67
83
|
type: :development
|
68
|
-
version_requirements: *
|
84
|
+
version_requirements: *id004
|
69
85
|
- !ruby/object:Gem::Dependency
|
70
86
|
name: test-unit
|
71
87
|
prerelease: false
|
72
|
-
requirement: &
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
73
89
|
none: false
|
74
90
|
requirements:
|
75
91
|
- - ~>
|
@@ -81,11 +97,11 @@ dependencies:
|
|
81
97
|
- 0
|
82
98
|
version: 2.1.0
|
83
99
|
type: :development
|
84
|
-
version_requirements: *
|
100
|
+
version_requirements: *id005
|
85
101
|
- !ruby/object:Gem::Dependency
|
86
102
|
name: bundler
|
87
103
|
prerelease: false
|
88
|
-
requirement: &
|
104
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
89
105
|
none: false
|
90
106
|
requirements:
|
91
107
|
- - ~>
|
@@ -97,7 +113,7 @@ dependencies:
|
|
97
113
|
- 0
|
98
114
|
version: 1.0.0
|
99
115
|
type: :development
|
100
|
-
version_requirements: *
|
116
|
+
version_requirements: *id006
|
101
117
|
description: Sign in with Exvo account
|
102
118
|
email:
|
103
119
|
- jacek.becela@gmail.com
|
@@ -110,6 +126,7 @@ extra_rdoc_files: []
|
|
110
126
|
files:
|
111
127
|
- .gitignore
|
112
128
|
- Gemfile
|
129
|
+
- Gemfile.lock
|
113
130
|
- README
|
114
131
|
- Rakefile
|
115
132
|
- exvo-auth.gemspec
|
@@ -126,7 +143,9 @@ files:
|
|
126
143
|
- lib/exvo_auth/controllers/rails.rb
|
127
144
|
- lib/exvo_auth/dejavu.rb
|
128
145
|
- lib/exvo_auth/middleware.rb
|
146
|
+
- lib/exvo_auth/models/message.rb
|
129
147
|
- lib/exvo_auth/oauth2.rb
|
148
|
+
- lib/exvo_auth/sharing.rb
|
130
149
|
- lib/exvo_auth/strategies/base.rb
|
131
150
|
- lib/exvo_auth/strategies/interactive.rb
|
132
151
|
- lib/exvo_auth/strategies/non_interactive.rb
|