nephos-server 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/nephos-server +3 -0
- data/lib/nephos-server/routing/load.rb +21 -6
- data/lib/nephos-server/server/basic_errors.rb +1 -1
- data/version +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b13edc23b32693d79a6ff436f805f2ac7a57d941
|
4
|
+
data.tar.gz: a25a361fe88d7763e4f7aee48a92cea306855197
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66d81d163d29377255e3a5c866fdc4076e70e8d70d8276798152f03bee4900615b20010429c79831448c78597026ea5035bd1449babffeabebf517408881bff3
|
7
|
+
data.tar.gz: f63d4ede65f21ad854d88b5d4ff02d50552be506c3e347a087eafb09339dca12d40f87325b433fee0cb42aab7c0a27e5b57958ee5826bb603a8aae6f6376a0ff
|
data/bin/nephos-server
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
class RoutingError <
|
1
|
+
class RoutingError < StandardError; end
|
2
2
|
class InvalidRoute < RoutingError; end
|
3
|
-
class
|
3
|
+
class InvalidRouteUrl < InvalidRoute; end
|
4
|
+
class InvalidRouteController < InvalidRoute; end
|
5
|
+
class InvalidRouteMethod < InvalidRoute; end
|
4
6
|
|
5
7
|
module Nephos
|
6
8
|
module Route
|
@@ -11,10 +13,20 @@ module Nephos
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def self.check!(what)
|
14
|
-
raise
|
15
|
-
raise
|
16
|
-
raise
|
17
|
-
|
16
|
+
raise InvalidRouteUrl, "Missing URL" unless what.keys.include? :url
|
17
|
+
raise InvalidRouteController, "Missing Controller" unless what.keys.include? :controller
|
18
|
+
raise InvalidRouteMethod, "Missing Method" unless what.keys.include? :method
|
19
|
+
begin
|
20
|
+
controller = Module.const_get(what[:controller])
|
21
|
+
rescue
|
22
|
+
raise InvalidRouteController, "Controller \"#{what[:controller]}\" doesn't exists"
|
23
|
+
end
|
24
|
+
if not controller.ancestors.include? Nephos::Controller
|
25
|
+
raise InvalidRouteController, "Class \"#{what[:controller]}\" is not a Nephos::Controller"
|
26
|
+
end
|
27
|
+
if not controller.new({}, {}).respond_to? what[:method]
|
28
|
+
raise InvalidRouteMethod, "No method named \"#{what[:method]}\""
|
29
|
+
end rescue raise InvalidRouteController, "Cannot initialize controller"
|
18
30
|
end
|
19
31
|
|
20
32
|
end
|
@@ -27,6 +39,7 @@ end
|
|
27
39
|
|
28
40
|
# @params what [Hash]
|
29
41
|
def get what
|
42
|
+
raise InvalidRoute unless what.is_a? Hash
|
30
43
|
what[:url] = File.expand_path File.join(route_prefix, what[:url])
|
31
44
|
Nephos::Route.check!(what)
|
32
45
|
Nephos::Route.add(what, "GET")
|
@@ -34,6 +47,7 @@ end
|
|
34
47
|
|
35
48
|
# @params what [Hash]
|
36
49
|
def post what
|
50
|
+
raise InvalidRoute unless what.is_a? Hash
|
37
51
|
what[:url] = File.join(route_prefix, what[:url])
|
38
52
|
Nephos::Route.check!(what)
|
39
53
|
Nephos::Route.add(what, "POST")
|
@@ -41,6 +55,7 @@ end
|
|
41
55
|
|
42
56
|
# @params what [Hash]
|
43
57
|
def put what
|
58
|
+
raise InvalidRoute unless what.is_a? Hash
|
44
59
|
what[:url] = File.join(route_prefix, what[:url])
|
45
60
|
Nephos::Route.check!(what)
|
46
61
|
Nephos::Route.add(what, "PUT")
|
@@ -1 +1 @@
|
|
1
|
-
class InvalidApplicationError < RuntimeError
|
1
|
+
class InvalidApplicationError < RuntimeError; end
|
data/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|