arkaan 0.5.13 → 0.6.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.
- checksums.yaml +4 -4
- data/lib/arkaan.rb +2 -0
- data/lib/arkaan/utils.rb +7 -0
- data/lib/arkaan/utils/controller.rb +30 -0
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eebe941e4b49edb670452878122f9fdaab8f5d8a
|
4
|
+
data.tar.gz: 2499a92b741d4a6caf46a72b8cd01ea6a2cd561b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c707fd2f08439d13c3b309aabb506977fdfb6dfdf458ae19d850e256c577c38f92acc9857488cec7b7360990bff4ea528abb924116edc9ca76dd21ad710d3f4c
|
7
|
+
data.tar.gz: bd34382eeaa742be1e29ed5d6b839ddb954d6984aa78ddfd1778a721555138d6eeb13726b50425e2c70d179b778a3fe7a69280df10d3ba66d17dce3bb99d1920
|
data/lib/arkaan.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'mongoid'
|
2
2
|
require 'active_model'
|
3
3
|
require 'active_support'
|
4
|
+
require 'sinatra/base'
|
4
5
|
|
5
6
|
# Main module of the application, holding all the subsequent classes.
|
6
7
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
@@ -11,4 +12,5 @@ module Arkaan
|
|
11
12
|
autoload :Monitoring , 'arkaan/monitoring'
|
12
13
|
autoload :OAuth , 'arkaan/oauth'
|
13
14
|
autoload :Permissions , 'arkaan/permissions'
|
15
|
+
autoload :Utils , 'arkaan/utils'
|
14
16
|
end
|
data/lib/arkaan/utils.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Utils
|
3
|
+
# Base controller to handle the standard error when accessing the API.
|
4
|
+
# @author Vincent Courtois <courtois.vincenet@outlook.com>
|
5
|
+
class Controller < Sinatra::Base
|
6
|
+
before do
|
7
|
+
@parameters = JSON.parse(request.body.read.to_s) rescue {}
|
8
|
+
if get_param('app_key').nil? || get_param('token').nil?
|
9
|
+
halt 400, {message: 'bad_request'}.to_json
|
10
|
+
end
|
11
|
+
gateway = Arkaan::Monitoring::Gateway.where(token: get_param('token')).first
|
12
|
+
application = Arkaan::OAuth::Application.where(key: get_param('app_key')).first
|
13
|
+
if gateway.nil?
|
14
|
+
halt 404, {message: 'gateway_not_found'}.to_json
|
15
|
+
elsif application.nil?
|
16
|
+
halt 404, {message: 'application_not_found'}.to_json
|
17
|
+
elsif !application.premium?
|
18
|
+
halt 401, {message: 'application_not_authorized'}.to_json
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Gets a parameters from the parsed body hash, or the parsed querystring hash.
|
23
|
+
# @param [String] key - the key of the parameter to get.
|
24
|
+
# @return [any] the value associated with the key.
|
25
|
+
def get_param(key)
|
26
|
+
return (params.nil? || params[key].nil? ? @parameters[key] : params[key])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arkaan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Courtois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rack-test
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.7.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: factory_girl
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +164,20 @@ dependencies:
|
|
150
164
|
- - '='
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: 3.1.11
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: sinatra
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 2.0.0
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 2.0.0
|
153
181
|
description: This gem holds the model layer for my table-top RPG games application.
|
154
182
|
email: courtois.vincent@outlook.com
|
155
183
|
executables: []
|
@@ -179,6 +207,8 @@ files:
|
|
179
207
|
- lib/arkaan/permissions/category.rb
|
180
208
|
- lib/arkaan/permissions/group.rb
|
181
209
|
- lib/arkaan/permissions/right.rb
|
210
|
+
- lib/arkaan/utils.rb
|
211
|
+
- lib/arkaan/utils/controller.rb
|
182
212
|
homepage: https://rubygems.org/gems/arkaan
|
183
213
|
licenses:
|
184
214
|
- MIT
|