nephos-server 0.6.4 → 0.6.5
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
 - checksums.yaml.gz.sig +0 -0
 - data.tar.gz.sig +0 -0
 - data/CHANGELOG +6 -0
 - data/DOCUMENTATION/API_RENDER.md +12 -9
 - data/DOCUMENTATION/GUIDE_CONTROLLER.md +28 -8
 - data/DOCUMENTATION/GUIDE_GENERATOR.md +1 -1
 - data/DOCUMENTATION/GUIDE_ROUTER.md +19 -0
 - data/README.md +1 -2
 - data/Rakefile +6 -0
 - data/lib/nephos-server/basic_errors.rb +1 -0
 - data/lib/nephos-server/controller.rb +16 -2
 - data/lib/nephos-server/router/helpers.rb +27 -11
 - data/lib/nephos-server/router/load.rb +11 -3
 - data/lib/nephos-server/router/main.rb +2 -0
 - data/lib/nephos-server/server/responder.rb +2 -1
 - data/nephos-server.gemspec +2 -1
 - data/routes.rb +2 -1
 - data/test/functional/generator.rb +4 -0
 - data/test/functional/router.rb +66 -0
 - data/test/router.rb +46 -1
 - data/version +1 -1
 - metadata +6 -3
 - metadata.gz.sig +0 -0
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: d8bb785df5db4f9f8b7a8e4821582700962d0fe4
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f681de7959a63e202b03f80caf0d730142eaef0d
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ec1e2f6a1d7afe305c39b7664787a31806a60d4f0bc9ed08a1add184f77408b87d09eeb10dbb913662f19ea992a2e3af993584648b0e138f95226c34514f6ac4
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 41f1943b9e313ee1a45e998565e6628e118ba95fcf434cc591c8f993dd633a15b070b076b0fb2cfed1bcde47d059d56b89a284d8c1923785dc6e04045f4a4432
         
     | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | 
         Binary file 
     | 
    
        data.tar.gz.sig
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/CHANGELOG
    CHANGED
    
    | 
         @@ -1,3 +1,9 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            v0.6.5
         
     | 
| 
      
 2 
     | 
    
         
            +
            	* Improve routing helpers (optional url parameter)
         
     | 
| 
      
 3 
     | 
    
         
            +
            	* Add new functional tests (router)
         
     | 
| 
      
 4 
     | 
    
         
            +
            	* Add extension for url (.html, ...)
         
     | 
| 
      
 5 
     | 
    
         
            +
            	* Add improved router helper (simple destination, alias)
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
       1 
7 
     | 
    
         
             
            v0.6.4
         
     | 
| 
       2 
8 
     | 
    
         
             
            	* Fix application generator (replace in the gemfile nephos-server by nephos)
         
     | 
| 
       3 
9 
     | 
    
         
             
                    * Improve guides (more doc, corrections, update)
         
     | 
    
        data/DOCUMENTATION/API_RENDER.md
    CHANGED
    
    | 
         @@ -1,14 +1,18 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Render API
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            ##  
     | 
| 
      
 3 
     | 
    
         
            +
            ## What is the Render API ?
         
     | 
| 
       4 
4 
     | 
    
         
             
            The render API is a simple system to allows you to render HTTP responses to a client.
         
     | 
| 
      
 5 
     | 
    
         
            +
            It is a simple way to render data to the user and choose it's type.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
       5 
7 
     | 
    
         
             
            The API allows you to customize differents parts of the response:
         
     | 
| 
       6 
8 
     | 
    
         | 
| 
       7 
9 
     | 
    
         
             
            - HTTP status
         
     | 
| 
       8 
10 
     | 
    
         
             
            - HTTP Content-Type
         
     | 
| 
       9 
11 
     | 
    
         
             
            - Content
         
     | 
| 
       10 
12 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
            Based on the returns of your Controller's methods, it will render to the user
         
     | 
| 
      
 14 
     | 
    
         
            +
            a HTTP response.
         
     | 
| 
      
 15 
     | 
    
         
            +
            You can actually returns HTML, JSON, or PLAIN text, and custom formats if needed.
         
     | 
| 
       12 
16 
     | 
    
         | 
| 
       13 
17 
     | 
    
         | 
| 
       14 
18 
     | 
    
         
             
            ## Use the API
         
     | 
| 
         @@ -20,14 +24,13 @@ It must contain a class, inheriting from ``Nephos::Controller``. 
     | 
|
| 
       20 
24 
     | 
    
         
             
            Each public method **can** be an entry point, defined in the ``routes.rb`` file.
         
     | 
| 
       21 
25 
     | 
    
         
             
            [Routing documentation](GUIDE_ROUTING.md).
         
     | 
| 
       22 
26 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 27 
     | 
    
         
            +
            Theses methods, described as "entry points" by your routing rules, must **return** a ``Hash``.
         
     | 
| 
      
 28 
     | 
    
         
            +
            It's format will be described in the following parts.
         
     | 
| 
       25 
29 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
            The  
     | 
| 
       27 
     | 
    
         
            -
            It may optionnaly be an ``Integer``, to return only a status, or ``:empty``.
         
     | 
| 
      
 30 
     | 
    
         
            +
            *Notes: The return may optionnaly be an ``Integer``, to return only a status, or ``:empty``.*
         
     | 
| 
       28 
31 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
            ##  
     | 
| 
       30 
     | 
    
         
            -
            The  
     | 
| 
      
 32 
     | 
    
         
            +
            ## Returned hash
         
     | 
| 
      
 33 
     | 
    
         
            +
            The return of a Controller method can include the following keys:
         
     | 
| 
       31 
34 
     | 
    
         | 
| 
       32 
35 
     | 
    
         
             
            - :plain
         
     | 
| 
       33 
36 
     | 
    
         
             
            - :html
         
     | 
| 
         @@ -52,7 +55,7 @@ class MyController < Nephos::Controller 
     | 
|
| 
       52 
55 
     | 
    
         
             
            end
         
     | 
| 
       53 
56 
     | 
    
         
             
            ```
         
     | 
| 
       54 
57 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
            The following sections will describe how each key works and modify the HTTP response.
         
     | 
| 
      
 58 
     | 
    
         
            +
            The following sections will describe how each key works, and modify the HTTP response.
         
     | 
| 
       56 
59 
     | 
    
         | 
| 
       57 
60 
     | 
    
         
             
            ### Content
         
     | 
| 
       58 
61 
     | 
    
         
             
            The ``:content`` key must be associated with a ``String`` (or ``Hash`` is json).
         
     | 
| 
         @@ -5,28 +5,48 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
            ### Cookies
         
     | 
| 
       6 
6 
     | 
    
         
             
            You can set cookies and get them via ``cookies`` in the body of any controller.
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
      
 8 
     | 
    
         
            +
            Example:
         
     | 
| 
      
 9 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 10 
     | 
    
         
            +
                cookies["a"] = "b" # add a cookie named "a"
         
     | 
| 
      
 11 
     | 
    
         
            +
                cookies.delete("b") # remove a cookie named "b"
         
     | 
| 
      
 12 
     | 
    
         
            +
            ```
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       8 
14 
     | 
    
         
             
            ### Params
         
     | 
| 
       9 
15 
     | 
    
         
             
            You can access to the parameters (defined by http or via the URI, based on your
         
     | 
| 
       10 
16 
     | 
    
         
             
            routing rules).
         
     | 
| 
       11 
17 
     | 
    
         
             
            They are accessible via ``params`` in the body of every controller.
         
     | 
| 
       12 
18 
     | 
    
         | 
| 
      
 19 
     | 
    
         
            +
            Example:
         
     | 
| 
      
 20 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 21 
     | 
    
         
            +
                params[:id] # access to the :id value, for exemple in the url /show/:id
         
     | 
| 
      
 22 
     | 
    
         
            +
            ```
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            ### Requested format
         
     | 
| 
      
 25 
     | 
    
         
            +
            You can request a format by adding a ``.ext`` to the url you request.
         
     | 
| 
      
 26 
     | 
    
         
            +
            This format is accessible via the ``format`` method. (alias for ``extension``)
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            It is also provided few helpers ``html?`` ``json?`` ``plain?``
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       13 
31 
     | 
    
         
             
            ### Hooks
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            A hook is a method, triggered automatically after an action.
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            Actually, NephosServer allows you to create 2 kinds of triggers for your hooks:
         
     | 
| 
       16 
36 
     | 
    
         | 
| 
       17 
37 
     | 
    
         
             
            - after_action
         
     | 
| 
       18 
38 
     | 
    
         
             
            - before_action
         
     | 
| 
       19 
39 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
            It means that the cookies are not saved yet (so you can change them, etc.)
         
     | 
| 
      
 40 
     | 
    
         
            +
            Your hooks will be called just before/after calling the method requested.
         
     | 
| 
      
 41 
     | 
    
         
            +
            It means that the cookies are not saved yet (so you can change them, etc.) for example.
         
     | 
| 
       22 
42 
     | 
    
         | 
| 
       23 
43 
     | 
    
         
             
            The hooks are defined by calling the methods ``after_action`` or
         
     | 
| 
       24 
44 
     | 
    
         
             
            ``before_action``, out of a method, usually on the top of the controller.
         
     | 
| 
       25 
45 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
            - The first is the name of the  
     | 
| 
       28 
     | 
    
         
            -
            - The second 
     | 
| 
       29 
     | 
    
         
            -
              keys, associated to an Array  
     | 
| 
      
 46 
     | 
    
         
            +
            Triggers take 1 or 2 arguments.
         
     | 
| 
      
 47 
     | 
    
         
            +
            - The first is the name of the Hook to use. **This is a required argument**.
         
     | 
| 
      
 48 
     | 
    
         
            +
            - The second **is optional**. It should be a hash, containing ``:only`` or ``:except``
         
     | 
| 
      
 49 
     | 
    
         
            +
              keys, associated to an Array of Symbols, or one Symbol. Each symbol represents
         
     | 
| 
       30 
50 
     | 
    
         
             
              a method triggering the hook.
         
     | 
| 
       31 
51 
     | 
    
         | 
| 
       32 
52 
     | 
    
         
             
            **Note: If there is no 2sd argument, then the hook is triggered every times.**
         
     | 
| 
         @@ -1,3 +1,4 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
       1 
2 
     | 
    
         
             
            # Routing Guide
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         
             
            ### How the routes are inputed by the client ?
         
     | 
| 
         @@ -41,6 +42,13 @@ As example, yuo can write: 
     | 
|
| 
       41 
42 
     | 
    
         
             
            add_route "GET", url: "/tmp", controller: "MyController", method: "tmp"
         
     | 
| 
       42 
43 
     | 
    
         
             
            ```
         
     | 
| 
       43 
44 
     | 
    
         | 
| 
      
 45 
     | 
    
         
            +
            **Note: if you are as lazy as me, you also can specifie the url out of the hash (option).
         
     | 
| 
      
 46 
     | 
    
         
            +
            It can be done by putting the url as second argument, like in the following example.
         
     | 
| 
      
 47 
     | 
    
         
            +
            This note is also valid for the next helpers (get, post, put)**
         
     | 
| 
      
 48 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 49 
     | 
    
         
            +
            add_route "GET", "/tmp", controller: "MyController", method: "tmp"
         
     | 
| 
      
 50 
     | 
    
         
            +
            ```
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
       44 
52 
     | 
    
         
             
            ### get post put
         
     | 
| 
       45 
53 
     | 
    
         
             
            Theses 3 helpers allows you to use ``add_route`` without the first argument.
         
     | 
| 
       46 
54 
     | 
    
         | 
| 
         @@ -86,6 +94,17 @@ resource "static" do 
     | 
|
| 
       86 
94 
     | 
    
         
             
            end
         
     | 
| 
       87 
95 
     | 
    
         
             
            ```
         
     | 
| 
       88 
96 
     | 
    
         | 
| 
      
 97 
     | 
    
         
            +
            ## Alias
         
     | 
| 
      
 98 
     | 
    
         
            +
            You can create many routes to the same entry point. Each of theses rules can be
         
     | 
| 
      
 99 
     | 
    
         
            +
            specified simply by placing an Array of String instead of a simple String in the
         
     | 
| 
      
 100 
     | 
    
         
            +
            hash passed to the helper (get, ... , add_route).
         
     | 
| 
      
 101 
     | 
    
         
            +
            Example:
         
     | 
| 
      
 102 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 103 
     | 
    
         
            +
            get url: ["/", "/index"], controller: "UserController", method: "show" # / and /index
         
     | 
| 
      
 104 
     | 
    
         
            +
            ```
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
       89 
106 
     | 
    
         
             
            ## Notes
         
     | 
| 
       90 
107 
     | 
    
         | 
| 
       91 
108 
     | 
    
         
             
            * When a request is done, duplicate / are not counted. So, ``/resource/id`` is equivalent to ``////resource//id`` etc.
         
     | 
| 
      
 109 
     | 
    
         
            +
            * It is possible, by default, to add a postfixed extension (like .html) to your rules. It is accessible via the controller (``extension`` method). It can be disabled by adding the option ``postfix: false``
         
     | 
| 
      
 110 
     | 
    
         
            +
            * You can replace the both keys ``:controller`` and ``:method`` by ``:to``, which has to be associated with a string like ``Controller#method``
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -100,6 +100,7 @@ put url: "/rm/:url", controller: "MainController", method: "rm_url"   # /rm with 
     | 
|
| 
       100 
100 
     | 
    
         
             
            resource "infos" do
         
     | 
| 
       101 
101 
     | 
    
         
             
              get url: "/", controller: "MainController", method: "root" # generate /infos
         
     | 
| 
       102 
102 
     | 
    
         
             
              get url: "/about", controller: "MainController", method: "root" # generate /infos/about
         
     | 
| 
      
 103 
     | 
    
         
            +
              get url: "/notice", to: "MainController#notice" # generate /infos/notice
         
     | 
| 
       103 
104 
     | 
    
         
             
            end
         
     | 
| 
       104 
105 
     | 
    
         
             
            ```
         
     | 
| 
       105 
106 
     | 
    
         | 
| 
         @@ -107,9 +108,7 @@ end 
     | 
|
| 
       107 
108 
     | 
    
         
             
            # Developers: Roadmap
         
     | 
| 
       108 
109 
     | 
    
         | 
| 
       109 
110 
     | 
    
         
             
            ## TODO v0.6
         
     | 
| 
       110 
     | 
    
         
            -
            - Alias for routing
         
     | 
| 
       111 
111 
     | 
    
         
             
            - functionnal tests
         
     | 
| 
       112 
     | 
    
         
            -
            - extension for urls (optional .xxx, with controller effect)
         
     | 
| 
       113 
112 
     | 
    
         | 
| 
       114 
113 
     | 
    
         
             
            ## TODO v0.7
         
     | 
| 
       115 
114 
     | 
    
         
             
            - feature to change HTTP header from controller
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -1,5 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            require 'colorize'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       3 
5 
     | 
    
         
             
            task :default => [:test]
         
     | 
| 
       4 
6 
     | 
    
         | 
| 
       5 
7 
     | 
    
         
             
            task :test do
         
     | 
| 
         @@ -10,11 +12,15 @@ namespace :test do 
     | 
|
| 
       10 
12 
     | 
    
         | 
| 
       11 
13 
     | 
    
         
             
              desc "Unitary tests. Fasts and on the sources."
         
     | 
| 
       12 
14 
     | 
    
         
             
              task :test do
         
     | 
| 
      
 15 
     | 
    
         
            +
                puts
         
     | 
| 
       13 
16 
     | 
    
         
             
                ruby "test/test.rb"
         
     | 
| 
       14 
17 
     | 
    
         
             
              end
         
     | 
| 
       15 
18 
     | 
    
         | 
| 
       16 
19 
     | 
    
         
             
              desc "Functional tests. Slow, test real the features under real conditions of usage."
         
     | 
| 
       17 
20 
     | 
    
         
             
              task :functional do
         
     | 
| 
      
 21 
     | 
    
         
            +
                puts "!!! Important !!!".yellow
         
     | 
| 
      
 22 
     | 
    
         
            +
                puts "You have to access to internet to test the generator.".yellow
         
     | 
| 
      
 23 
     | 
    
         
            +
                puts
         
     | 
| 
       18 
24 
     | 
    
         
             
                ruby "test/functional.rb"
         
     | 
| 
       19 
25 
     | 
    
         
             
              end
         
     | 
| 
       20 
26 
     | 
    
         
             
            end
         
     | 
| 
         @@ -6,11 +6,13 @@ module Nephos 
     | 
|
| 
       6 
6 
     | 
    
         
             
              # and the parameters.
         
     | 
| 
       7 
7 
     | 
    
         
             
              class Controller
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                attr_reader :req, :callpath, :params, :cookies
         
     | 
| 
      
 9 
     | 
    
         
            +
                attr_reader :req, :callpath, :params, :cookies, :extension
         
     | 
| 
      
 10 
     | 
    
         
            +
                alias :format :extension
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
       11 
12 
     | 
    
         
             
                # @param env [Hash] env extracted from the http request
         
     | 
| 
       12 
13 
     | 
    
         
             
                # @param parsed [Hash] pre-parsed env with parameters, ...
         
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
      
 14 
     | 
    
         
            +
                # @param extension [String] extension ".json", ".html", ...
         
     | 
| 
      
 15 
     | 
    
         
            +
                def initialize req, callpath, extension=nil
         
     | 
| 
       14 
16 
     | 
    
         
             
                  raise ArgumentError, "req must be a Rack::Request" unless req.is_a? Rack::Request
         
     | 
| 
       15 
17 
     | 
    
         
             
                  raise ArgumentError, "call must be a Hash" unless callpath.is_a? Hash
         
     | 
| 
       16 
18 
     | 
    
         
             
                  @req= req
         
     | 
| 
         @@ -24,6 +26,18 @@ module Nephos 
     | 
|
| 
       24 
26 
     | 
    
         | 
| 
       25 
27 
     | 
    
         
             
                  @params = Params.new(@params)
         
     | 
| 
       26 
28 
     | 
    
         
             
                  @cookies = Params.new(@req.cookies)
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  @extension = extension.to_s.split(".").last
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                def html?
         
     | 
| 
      
 34 
     | 
    
         
            +
                  %w(htm html xhtml).include? extension
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
                def json?
         
     | 
| 
      
 37 
     | 
    
         
            +
                  %w(json).include? extension
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
                def plain?
         
     | 
| 
      
 40 
     | 
    
         
            +
                  %w(txt raw).include? extension
         
     | 
| 
       27 
41 
     | 
    
         
             
                end
         
     | 
| 
       28 
42 
     | 
    
         | 
| 
       29 
43 
     | 
    
         
             
                @@before_action = {:'*' =>  []}
         
     | 
| 
         @@ -4,6 +4,9 @@ def route_prefix 
     | 
|
| 
       4 
4 
     | 
    
         
             
            end
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            # @param verb [String] has to be a valid http verb, so a string uppercase
         
     | 
| 
      
 7 
     | 
    
         
            +
            # @param url [String] if an url is provided, then it will be put in the hash
         
     | 
| 
      
 8 
     | 
    
         
            +
            #   to have the same behavior as if it was specified in the what hash
         
     | 
| 
      
 9 
     | 
    
         
            +
            #   \\{url: URL}
         
     | 
| 
       7 
10 
     | 
    
         
             
            # @param what [Hash] has to contain the following keys:
         
     | 
| 
       8 
11 
     | 
    
         
             
            #   - :url
         
     | 
| 
       9 
12 
     | 
    
         
             
            #   - :controller
         
     | 
| 
         @@ -14,27 +17,35 @@ end 
     | 
|
| 
       14 
17 
     | 
    
         
             
            # if the client request match with the verb and the url provided.
         
     | 
| 
       15 
18 
     | 
    
         
             
            #
         
     | 
| 
       16 
19 
     | 
    
         
             
            # Checkout the documentation about the parameters and API for more informations
         
     | 
| 
       17 
     | 
    
         
            -
            def add_route(verb, what)
         
     | 
| 
      
 20 
     | 
    
         
            +
            def add_route(verb, url=nil, what)
         
     | 
| 
       18 
21 
     | 
    
         
             
              raise InvalidRoute, "what must be a hash" unless what.is_a? Hash
         
     | 
| 
       19 
     | 
    
         
            -
              what[:url]  
     | 
| 
       20 
     | 
    
         
            -
               
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
              what[:url] ||= url
         
     | 
| 
      
 23 
     | 
    
         
            +
              Array(what[:url]).each do |url|
         
     | 
| 
      
 24 
     | 
    
         
            +
                route = what.dup
         
     | 
| 
      
 25 
     | 
    
         
            +
                route[:url] = url
         
     | 
| 
      
 26 
     | 
    
         
            +
                route[:url] = File.expand_path File.join(route_prefix, route[:url])
         
     | 
| 
      
 27 
     | 
    
         
            +
                Nephos::Router.check!(route)
         
     | 
| 
      
 28 
     | 
    
         
            +
                Nephos::Router.add_params!(route)
         
     | 
| 
      
 29 
     | 
    
         
            +
                Nephos::Router.add(route, verb)
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
       23 
31 
     | 
    
         
             
            end
         
     | 
| 
       24 
32 
     | 
    
         | 
| 
      
 33 
     | 
    
         
            +
            # @param url [String] see {#add_route}
         
     | 
| 
       25 
34 
     | 
    
         
             
            # @param what [Hash] see {#add_route}
         
     | 
| 
       26 
     | 
    
         
            -
            def get what
         
     | 
| 
       27 
     | 
    
         
            -
              add_route "GET", what
         
     | 
| 
      
 35 
     | 
    
         
            +
            def get url=nil, what
         
     | 
| 
      
 36 
     | 
    
         
            +
              add_route "GET", url, what
         
     | 
| 
       28 
37 
     | 
    
         
             
            end
         
     | 
| 
       29 
38 
     | 
    
         | 
| 
      
 39 
     | 
    
         
            +
            # @param url [String] see {#add_route}
         
     | 
| 
       30 
40 
     | 
    
         
             
            # @param what [Hash] see {#add_route}
         
     | 
| 
       31 
     | 
    
         
            -
            def post what
         
     | 
| 
       32 
     | 
    
         
            -
              add_route "POST", what
         
     | 
| 
      
 41 
     | 
    
         
            +
            def post url=nil, what
         
     | 
| 
      
 42 
     | 
    
         
            +
              add_route "POST", url, what
         
     | 
| 
       33 
43 
     | 
    
         
             
            end
         
     | 
| 
       34 
44 
     | 
    
         | 
| 
      
 45 
     | 
    
         
            +
            # @param url [String] see {#add_route}
         
     | 
| 
       35 
46 
     | 
    
         
             
            # @param what [Hash] see {#add_route}
         
     | 
| 
       36 
     | 
    
         
            -
            def put what
         
     | 
| 
       37 
     | 
    
         
            -
              add_route "PUT", what
         
     | 
| 
      
 47 
     | 
    
         
            +
            def put url=nil, what
         
     | 
| 
      
 48 
     | 
    
         
            +
              add_route "PUT", url, what
         
     | 
| 
       38 
49 
     | 
    
         
             
            end
         
     | 
| 
       39 
50 
     | 
    
         | 
| 
       40 
51 
     | 
    
         
             
            # @param name [String]
         
     | 
| 
         @@ -50,3 +61,8 @@ def resource(name, &block) 
     | 
|
| 
       50 
61 
     | 
    
         
             
              block.call
         
     | 
| 
       51 
62 
     | 
    
         
             
              @route_prefix.pop
         
     | 
| 
       52 
63 
     | 
    
         
             
            end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            # An alias is an url which have the same proprieties than the previous route
         
     | 
| 
      
 66 
     | 
    
         
            +
            def alias_route
         
     | 
| 
      
 67 
     | 
    
         
            +
              raise "Not implemented yet"
         
     | 
| 
      
 68 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -16,7 +16,7 @@ module Nephos 
     | 
|
| 
       16 
16 
     | 
    
         
             
                  end
         
     | 
| 
       17 
17 
     | 
    
         
             
                  url = params.map{|e| e[:p]}.join("/+")
         
     | 
| 
       18 
18 
     | 
    
         
             
                  url = "/" if url.empty?
         
     | 
| 
       19 
     | 
    
         
            -
                  what[:match] =  
     | 
| 
      
 19 
     | 
    
         
            +
                  what[:match] = what[:postfix] != false ? /^(?<url>#{url})(?<extension>\.\w+)?\/*$/ : /^(?<url>#{url})\/*$/
         
     | 
| 
       20 
20 
     | 
    
         
             
                  # remove : in :param, and / in /param
         
     | 
| 
       21 
21 
     | 
    
         
             
                  what[:params] = params.map{|e| e[:name] && e[:name][1..-1]}[1..-1] || []
         
     | 
| 
       22 
22 
     | 
    
         
             
                end
         
     | 
| 
         @@ -29,8 +29,16 @@ module Nephos 
     | 
|
| 
       29 
29 
     | 
    
         
             
                # - :method
         
     | 
| 
       30 
30 
     | 
    
         
             
                def self.check_keys! what
         
     | 
| 
       31 
31 
     | 
    
         
             
                  raise InvalidRouteUrl, "Missing URL" unless what.keys.include? :url
         
     | 
| 
       32 
     | 
    
         
            -
                   
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
                  if what.keys.include? :to
         
     | 
| 
      
 33 
     | 
    
         
            +
                    match = what[:to].match(/(?<controller>\w+)\#(?<method>\w+)/)
         
     | 
| 
      
 34 
     | 
    
         
            +
                    raise InvalidRouteTo, "Invalid Controller#Method" unless match
         
     | 
| 
      
 35 
     | 
    
         
            +
                    what[:controller] = match["controller"]
         
     | 
| 
      
 36 
     | 
    
         
            +
                    what[:method] = match["method"]
         
     | 
| 
      
 37 
     | 
    
         
            +
                    what.delete :to
         
     | 
| 
      
 38 
     | 
    
         
            +
                  else
         
     | 
| 
      
 39 
     | 
    
         
            +
                    raise InvalidRouteController, "Missing Controller" unless what.keys.include? :controller
         
     | 
| 
      
 40 
     | 
    
         
            +
                    raise InvalidRouteMethod, "Missing Method" unless what.keys.include? :method
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
       34 
42 
     | 
    
         
             
                end
         
     | 
| 
       35 
43 
     | 
    
         | 
| 
       36 
44 
     | 
    
         
             
                # @param what [Hash]
         
     | 
| 
         @@ -67,6 +67,8 @@ module Nephos 
     | 
|
| 
       67 
67 
     | 
    
         
             
                  env = req.env
         
     | 
| 
       68 
68 
     | 
    
         
             
                  puts "#{req.env["REMOTE_ADDR"]} [#{req.request_method}] \t ---> \t #{req.path}" unless @silent
         
     | 
| 
       69 
69 
     | 
    
         
             
                  call = find_route(req)
         
     | 
| 
      
 70 
     | 
    
         
            +
                  # require 'pry'
         
     | 
| 
      
 71 
     | 
    
         
            +
                  # binding.pry
         
     | 
| 
       70 
72 
     | 
    
         
             
                  return error_404(req) if call.nil?
         
     | 
| 
       71 
73 
     | 
    
         
             
                  begin
         
     | 
| 
       72 
74 
     | 
    
         
             
                    return render_controller(req, call)
         
     | 
| 
         @@ -69,7 +69,8 @@ module Nephos 
     | 
|
| 
       69 
69 
     | 
    
         
             
                end
         
     | 
| 
       70 
70 
     | 
    
         | 
| 
       71 
71 
     | 
    
         
             
                def render_from_controller req, call
         
     | 
| 
       72 
     | 
    
         
            -
                   
     | 
| 
      
 72 
     | 
    
         
            +
                  extension = req.path.match(call[:match])['extension']
         
     | 
| 
      
 73 
     | 
    
         
            +
                  controller = Module.const_get(call[:controller]).new(req, call, extension)
         
     | 
| 
       73 
74 
     | 
    
         
             
                  method_to_call = call[:method]
         
     | 
| 
       74 
75 
     | 
    
         | 
| 
       75 
76 
     | 
    
         
             
                  controller.execute_before_action(method_to_call)
         
     | 
    
        data/nephos-server.gemspec
    CHANGED
    
    | 
         @@ -41,9 +41,10 @@ test/router.rb 
     | 
|
| 
       41 
41 
     | 
    
         
             
            test/params.rb
         
     | 
| 
       42 
42 
     | 
    
         
             
            test/controller.rb
         
     | 
| 
       43 
43 
     | 
    
         
             
            test/functional.rb
         
     | 
| 
       44 
     | 
    
         
            -
            test/functional/server.rb
         
     | 
| 
       45 
44 
     | 
    
         
             
            test/functional/generator.rb
         
     | 
| 
       46 
45 
     | 
    
         
             
            test/functional/global.rb
         
     | 
| 
      
 46 
     | 
    
         
            +
            test/functional/router.rb
         
     | 
| 
      
 47 
     | 
    
         
            +
            test/functional/server.rb
         
     | 
| 
       47 
48 
     | 
    
         
             
            routes.rb
         
     | 
| 
       48 
49 
     | 
    
         | 
| 
       49 
50 
     | 
    
         
             
            app/dataset.rb
         
     | 
    
        data/routes.rb
    CHANGED
    
    | 
         @@ -23,4 +23,5 @@ get url: "img/:image", controller: "MainController", method: "image" 
     | 
|
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
            get url: "/get_cookies", controller: "MainController", method: "get_cookies"
         
     | 
| 
       25 
25 
     | 
    
         
             
            get url: "/add_cookie", controller: "MainController", method: "add_cookie"
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            get "/err500", controller: "MainController", method: "err500"
         
     | 
| 
         @@ -23,9 +23,13 @@ class TestNephosServerGenerator < Test::Unit::TestCase 
     | 
|
| 
       23 
23 
     | 
    
         
             
                assert(Dir.exists? "/tmp/nephos-server-test/app")
         
     | 
| 
       24 
24 
     | 
    
         
             
                gemfile_data = File.read("/tmp/nephos-server-test/Gemfile").split("\n")
         
     | 
| 
       25 
25 
     | 
    
         
             
                assert(gemfile_data.include? "gem 'nephos'")
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                # if connected to internet only
         
     | 
| 
      
 28 
     | 
    
         
            +
                assert(File.exists? "/tmp/nephos-server-test/Gemfile.lock")
         
     | 
| 
       26 
29 
     | 
    
         
             
                gemfile_lock_data = File.read("/tmp/nephos-server-test/Gemfile.lock").split
         
     | 
| 
       27 
30 
     | 
    
         
             
                assert(gemfile_lock_data.include? "nephos")
         
     | 
| 
       28 
31 
     | 
    
         
             
                assert(gemfile_lock_data.include? "nephos-server")
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
       29 
33 
     | 
    
         
             
                `rm -rf /tmp/nephos-server-test 2> /tmp/null`
         
     | 
| 
       30 
34 
     | 
    
         
             
              end
         
     | 
| 
       31 
35 
     | 
    
         | 
| 
         @@ -0,0 +1,66 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class TestNephosServerAppRouter < Test::Unit::TestCase
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              ENV_ALL_VALID_ROUTES = [
         
     | 
| 
      
 4 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/home/index"},
         
     | 
| 
      
 5 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/home/index/"},
         
     | 
| 
      
 6 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/home/index//"},
         
     | 
| 
      
 7 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"POST", "PATH_INFO"=>"/home/index/add"},
         
     | 
| 
      
 8 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"POST", "PATH_INFO"=>"/home/index/add/"},
         
     | 
| 
      
 9 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"POST", "PATH_INFO"=>"/home/index/add//"},
         
     | 
| 
      
 10 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"PUT", "PATH_INFO"=>"/home/index/rm"},
         
     | 
| 
      
 11 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"PUT", "PATH_INFO"=>"/home/index/rm/"},
         
     | 
| 
      
 12 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"PUT", "PATH_INFO"=>"/home/index/rm//"},
         
     | 
| 
      
 13 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/home"},
         
     | 
| 
      
 14 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/home/"},
         
     | 
| 
      
 15 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/home//"},
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/homes"},
         
     | 
| 
      
 18 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/homes/"},
         
     | 
| 
      
 19 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/homes//"},
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/"},
         
     | 
| 
      
 22 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/add"},
         
     | 
| 
      
 23 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/rm"},
         
     | 
| 
      
 24 
     | 
    
         
            +
                # {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/debug"},
         
     | 
| 
      
 25 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/hello"},
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                # {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/image"},
         
     | 
| 
      
 28 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/image/image.jpg"},
         
     | 
| 
      
 29 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/img/image.jpg"},
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/get_cookies"},
         
     | 
| 
      
 32 
     | 
    
         
            +
                {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/add_cookie"},
         
     | 
| 
      
 33 
     | 
    
         
            +
                # {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/err500"},
         
     | 
| 
      
 34 
     | 
    
         
            +
              ]
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              def test_router_all_valid_routes
         
     | 
| 
      
 37 
     | 
    
         
            +
                router = Nephos::Router.new(silent: true)
         
     | 
| 
      
 38 
     | 
    
         
            +
                r = []
         
     | 
| 
      
 39 
     | 
    
         
            +
                ENV_ALL_VALID_ROUTES.each do |env|
         
     | 
| 
      
 40 
     | 
    
         
            +
                  r << router.execute(Rack::Request.new(env))
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                r.each_with_index do |rep, idx|
         
     | 
| 
      
 44 
     | 
    
         
            +
                  # puts ENV_ALL_VALID_ROUTES[idx]
         
     | 
| 
      
 45 
     | 
    
         
            +
                  # puts rep
         
     | 
| 
      
 46 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 47 
     | 
    
         
            +
                    assert_equal(200, rep.status)
         
     | 
| 
      
 48 
     | 
    
         
            +
                  rescue => err
         
     | 
| 
      
 49 
     | 
    
         
            +
                    puts rep
         
     | 
| 
      
 50 
     | 
    
         
            +
                    puts err
         
     | 
| 
      
 51 
     | 
    
         
            +
                    raise
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              def test_router_on_invalid
         
     | 
| 
      
 57 
     | 
    
         
            +
                router = Nephos::Router.new(silent: true)
         
     | 
| 
      
 58 
     | 
    
         
            +
                not_valid = {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/not_a_valid_route"}
         
     | 
| 
      
 59 
     | 
    
         
            +
                almost_valid = {"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/get_cookie"}
         
     | 
| 
      
 60 
     | 
    
         
            +
                bad_verb = {"REQUEST_METHOD"=>"POST", "PATH_INFO"=>"/get_cookies"}
         
     | 
| 
      
 61 
     | 
    
         
            +
                assert_equal(404, router.execute(Rack::Request.new(not_valid)).status)
         
     | 
| 
      
 62 
     | 
    
         
            +
                assert_equal(404, router.execute(Rack::Request.new(almost_valid)).status)
         
     | 
| 
      
 63 
     | 
    
         
            +
                assert_equal(404, router.execute(Rack::Request.new(bad_verb)).status)
         
     | 
| 
      
 64 
     | 
    
         
            +
              end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            end
         
     | 
    
        data/test/router.rb
    CHANGED
    
    | 
         @@ -187,7 +187,6 @@ class TestNephosServerRouter < Test::Unit::TestCase 
     | 
|
| 
       187 
187 
     | 
    
         
             
              REQ_POST_INDEX_XXX_ID = Rack::Request.new({"REQUEST_METHOD"=>"POST", "PATH_INFO"=>"/index/XXX/id"})
         
     | 
| 
       188 
188 
     | 
    
         
             
              REQ_POST_INDEX_XXX_XXX = Rack::Request.new({"REQUEST_METHOD"=>"POST", "PATH_INFO"=>"/index/XXX/XXX"})
         
     | 
| 
       189 
189 
     | 
    
         | 
| 
       190 
     | 
    
         
            -
              # TODO : FIX
         
     | 
| 
       191 
190 
     | 
    
         
             
              def test_routing_matching_simple_with_arguments2
         
     | 
| 
       192 
191 
     | 
    
         
             
                reset_routes!
         
     | 
| 
       193 
192 
     | 
    
         
             
                get url: "/index", controller: "TestController", method: "method1", silent: true
         
     | 
| 
         @@ -208,4 +207,50 @@ class TestNephosServerRouter < Test::Unit::TestCase 
     | 
|
| 
       208 
207 
     | 
    
         
             
                assert(!Nephos::Router.new.find_route(REQ_POST_INDEX_XXX_XXX))
         
     | 
| 
       209 
208 
     | 
    
         
             
              end
         
     | 
| 
       210 
209 
     | 
    
         | 
| 
      
 210 
     | 
    
         
            +
              def test_routing_extension
         
     | 
| 
      
 211 
     | 
    
         
            +
                reset_routes!
         
     | 
| 
      
 212 
     | 
    
         
            +
                get url: "/index", controller: "TestController", method: "method1", silent: true
         
     | 
| 
      
 213 
     | 
    
         
            +
                get url: "/indexno", controller: "TestController", method: "method1", silent: true, postfix: false
         
     | 
| 
      
 214 
     | 
    
         
            +
                ok1 = Rack::Request.new({"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/index"})
         
     | 
| 
      
 215 
     | 
    
         
            +
                ok2 = Rack::Request.new({"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/index.html"})
         
     | 
| 
      
 216 
     | 
    
         
            +
                ok3 = Rack::Request.new({"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/index.json"})
         
     | 
| 
      
 217 
     | 
    
         
            +
                ok4 = Rack::Request.new({"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/index.xhr"})
         
     | 
| 
      
 218 
     | 
    
         
            +
                ok5 = Rack::Request.new({"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/indexno"})
         
     | 
| 
      
 219 
     | 
    
         
            +
                ko1 = Rack::Request.new({"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/index/html"})
         
     | 
| 
      
 220 
     | 
    
         
            +
                ko2 = Rack::Request.new({"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/indexno.html"})
         
     | 
| 
      
 221 
     | 
    
         
            +
                ko3 = Rack::Request.new({"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/indexno.json"})
         
     | 
| 
      
 222 
     | 
    
         
            +
                ko4 = Rack::Request.new({"REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/indexno.xhr"})
         
     | 
| 
      
 223 
     | 
    
         
            +
                assert(Nephos::Router.new.find_route(ok1))
         
     | 
| 
      
 224 
     | 
    
         
            +
                assert(Nephos::Router.new.find_route(ok2))
         
     | 
| 
      
 225 
     | 
    
         
            +
                assert(Nephos::Router.new.find_route(ok3))
         
     | 
| 
      
 226 
     | 
    
         
            +
                assert(Nephos::Router.new.find_route(ok4))
         
     | 
| 
      
 227 
     | 
    
         
            +
                assert(Nephos::Router.new.find_route(ok5))
         
     | 
| 
      
 228 
     | 
    
         
            +
                assert(!Nephos::Router.new.find_route(ko1))
         
     | 
| 
      
 229 
     | 
    
         
            +
                assert(!Nephos::Router.new.find_route(ko2))
         
     | 
| 
      
 230 
     | 
    
         
            +
                assert(!Nephos::Router.new.find_route(ko3))
         
     | 
| 
      
 231 
     | 
    
         
            +
                assert(!Nephos::Router.new.find_route(ko4))
         
     | 
| 
      
 232 
     | 
    
         
            +
              end
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
              def test_routing_eze_router
         
     | 
| 
      
 235 
     | 
    
         
            +
                reset_routes!
         
     | 
| 
      
 236 
     | 
    
         
            +
                get url: "/index", controller: "TestController", method: "method1", silent: true
         
     | 
| 
      
 237 
     | 
    
         
            +
                get url: "/index", to: "TestController#method1", method: "method1", silent: true
         
     | 
| 
      
 238 
     | 
    
         
            +
                assert_equal Nephos::Router::ROUTES[0], Nephos::Router::ROUTES[1]
         
     | 
| 
      
 239 
     | 
    
         
            +
              end
         
     | 
| 
      
 240 
     | 
    
         
            +
             
     | 
| 
      
 241 
     | 
    
         
            +
              def test_routing_multiple_url
         
     | 
| 
      
 242 
     | 
    
         
            +
                reset_routes!
         
     | 
| 
      
 243 
     | 
    
         
            +
                get url: ["/index"], controller: "TestController", method: "method1", silent: true
         
     | 
| 
      
 244 
     | 
    
         
            +
                get url: "/index", controller: "TestController", method: "method1", silent: true
         
     | 
| 
      
 245 
     | 
    
         
            +
                reset_routes!
         
     | 
| 
      
 246 
     | 
    
         
            +
                get url: ["/index", "/index"], controller: "TestController", method: "method1"
         
     | 
| 
      
 247 
     | 
    
         
            +
                get url: ["/index", "/index"], controller: "TestController", method: "method1"
         
     | 
| 
      
 248 
     | 
    
         
            +
                assert_equal Nephos::Router::ROUTES[0], Nephos::Router::ROUTES[1]
         
     | 
| 
      
 249 
     | 
    
         
            +
                assert_equal Nephos::Router::ROUTES[1], Nephos::Router::ROUTES[2]
         
     | 
| 
      
 250 
     | 
    
         
            +
                assert_equal Nephos::Router::ROUTES[2], Nephos::Router::ROUTES[3]
         
     | 
| 
      
 251 
     | 
    
         
            +
                reset_routes!
         
     | 
| 
      
 252 
     | 
    
         
            +
                get url: ["/index", "/me", "/other"], controller: "TestController", method: "method1"
         
     | 
| 
      
 253 
     | 
    
         
            +
                assert_equal 3, Nephos::Router::ROUTES.size
         
     | 
| 
      
 254 
     | 
    
         
            +
              end
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
       211 
256 
     | 
    
         
             
            end
         
     | 
    
        data/version
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.6. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.6.5
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: nephos-server
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.6. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.6.5
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - poulet_a
         
     | 
| 
         @@ -31,7 +31,7 @@ cert_chain: 
     | 
|
| 
       31 
31 
     | 
    
         
             
              tcYkgfqUJPitIJx1RvWZpIyH5uJhRUYK3+vU9nMOxez5WbIlC1TtpByKAPMX+sht
         
     | 
| 
       32 
32 
     | 
    
         
             
              gib3AoIT8jh/2w==
         
     | 
| 
       33 
33 
     | 
    
         
             
              -----END CERTIFICATE-----
         
     | 
| 
       34 
     | 
    
         
            -
            date: 2015-10- 
     | 
| 
      
 34 
     | 
    
         
            +
            date: 2015-10-09 00:00:00.000000000 Z
         
     | 
| 
       35 
35 
     | 
    
         
             
            dependencies:
         
     | 
| 
       36 
36 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       37 
37 
     | 
    
         
             
              name: nomorebeer
         
     | 
| 
         @@ -135,6 +135,7 @@ files: 
     | 
|
| 
       135 
135 
     | 
    
         
             
            - test/functional.rb
         
     | 
| 
       136 
136 
     | 
    
         
             
            - test/functional/generator.rb
         
     | 
| 
       137 
137 
     | 
    
         
             
            - test/functional/global.rb
         
     | 
| 
      
 138 
     | 
    
         
            +
            - test/functional/router.rb
         
     | 
| 
       138 
139 
     | 
    
         
             
            - test/functional/server.rb
         
     | 
| 
       139 
140 
     | 
    
         
             
            - test/params.rb
         
     | 
| 
       140 
141 
     | 
    
         
             
            - test/responder.rb
         
     | 
| 
         @@ -164,6 +165,8 @@ rubyforge_project: 
     | 
|
| 
       164 
165 
     | 
    
         
             
            rubygems_version: 2.4.8
         
     | 
| 
       165 
166 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       166 
167 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       167 
     | 
    
         
            -
            summary: "*  
     | 
| 
      
 168 
     | 
    
         
            +
            summary: "* Improve routing helpers (optional url parameter) * Add new functional
         
     | 
| 
      
 169 
     | 
    
         
            +
              tests (router) * Add extension for url (.html, ...) * Add improved router helper
         
     | 
| 
      
 170 
     | 
    
         
            +
              (simple destination, alias)"
         
     | 
| 
       168 
171 
     | 
    
         
             
            test_files: []
         
     | 
| 
       169 
172 
     | 
    
         
             
            has_rdoc: 
         
     | 
    
        metadata.gz.sig
    CHANGED
    
    | 
         Binary file 
     |