nephos-server 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c470980b6da991d95c060efa740e0a89cc82eb30
4
- data.tar.gz: d7236c0810fd2c019e5d1a180b63270d950e0a06
3
+ metadata.gz: 6614ca080db76bc887198e14fbbc3fa3ef84f0dd
4
+ data.tar.gz: 60be81fc08845a9849e950454b9f58301a866e93
5
5
  SHA512:
6
- metadata.gz: d9d1b932659d821538bc1dd5d706cd9581fb19e6ccc9ab688d96cd745e9be9d2c80b6c6cb39c6bd34209b74d817d93d10f2fabeac6c1cfe7cdd10e68541e3a6a
7
- data.tar.gz: a267ce338cc75df3ca25e91e71dd29473bb952dccb6244ed99ccaf5dfccd35d80bcb2c15a492225506192d16e336890b0dfad48882e4b2093e808b45d8169fb8
6
+ metadata.gz: 08eba5967d682ab43a0fd4448d21cfa6727d3ecbd3bc1538ff7b6ab60de04aedce8d79d49ea0a1e54e5f53909220806540c15784c916d3eba9b01ba336448a3f
7
+ data.tar.gz: b258e7da003700bc8e1e8fec72806126b12cb334bfd1f14e20fe38edd8d6e5d338541162659e3d6ba47e21d3d1ab4e79b9c61af004430d75adef4cf2ee10b3fc
data/README.md CHANGED
@@ -19,7 +19,6 @@ This is a simple web server, based on rack and puma, with a minimal help:
19
19
  - html support
20
20
  - Routing
21
21
  - improve get with arguments
22
- - add post and put (like get)
23
22
  - add ressource (elarge urls)
24
23
  - Database connection
25
24
 
@@ -65,7 +64,10 @@ return :empty
65
64
  Like in ``/routes.rb``, you have to route manually the api.
66
65
 
67
66
  ```ruby
68
- get url: "/", controller: "MainController", method: "root"
69
- get url: "/add", controller: "MainController", method: "add_url"
70
- get url: "/rm", controller: "MainController", method: "rm_url"
67
+ get url: "/", controller: "MainController", method: "root" # /
68
+ get url: "/add", controller: "MainController", method: "add_url" # /add
69
+ get url: "/rm", controller: "MainController", method: "rm_url" # /rm
70
+ resource "infos" do
71
+ get url: "/", controller: "MainController", method: "root" # generate /infos
72
+ end
71
73
  ```
@@ -19,7 +19,7 @@ module Nephos
19
19
  # @params: path [Array]
20
20
  # find the right route to use from the url
21
21
  def self.parse_path path, verb
22
- route = "/" + path.join("/")
22
+ route = File.join(["/"] + path)
23
23
  return ALL.find{|e| e[:url] == route and e[:verb] == verb}
24
24
  end
25
25
 
@@ -20,23 +20,38 @@ module Nephos
20
20
  end
21
21
  end
22
22
 
23
+ def route_prefix
24
+ @route_prefix ||= []
25
+ File.join(["/"] + @route_prefix)
26
+ end
27
+
23
28
  # @params: what [Hash]
24
29
  def get what
30
+ what[:url] = File.expand_path File.join(route_prefix, what[:url])
25
31
  Nephos::Route.check!(what)
26
32
  Nephos::Route.add(what, "GET")
27
33
  end
28
34
 
29
35
  # @params: what [Hash]
30
36
  def post what
37
+ what[:url] = File.join(route_prefix, what[:url])
31
38
  Nephos::Route.check!(what)
32
39
  Nephos::Route.add(what, "POST")
33
40
  end
34
41
 
35
42
  # @params: what [Hash]
36
43
  def put what
44
+ what[:url] = File.join(route_prefix, what[:url])
37
45
  Nephos::Route.check!(what)
38
46
  Nephos::Route.add(what, "PUT")
39
47
  end
40
48
 
49
+ def resource(name, &block)
50
+ @route_prefix ||= []
51
+ @route_prefix << name
52
+ block.call
53
+ @route_prefix.pop
54
+ end
55
+
41
56
  load 'routes.rb'
42
57
  puts
data/version CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nephos-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - poulet_a
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-22 00:00:00.000000000 Z
11
+ date: 2015-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nomorebeer