tzispa 0.4.12 → 0.4.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/tzispa/controller/http_error.rb +21 -0
- data/lib/tzispa/routes.rb +14 -11
- data/lib/tzispa/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66048b167e117a0e35891d812844488310535da8
|
4
|
+
data.tar.gz: ad48d4adaf70d9353ff78c7229d0b72e079bb861
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a548b5e37b99b24c77a75753f576b383d51a651ec7279cd5097bf007305e23a0e85ff987a8c113507e6012c88ad6c7f6d6136b4dacc3c0bff28bbeef09dbf306
|
7
|
+
data.tar.gz: bf61ee7c9d5a82e684d81025a4936b95c00a4c128d887a355a13ca35fada8c164c668c5711fc8fe99fa369b13de9eea6fe8d82b5035fee23e8fd4d0217f993a6
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tzispa/controller/base'
|
4
|
+
require 'tzispa/helpers/response'
|
5
|
+
|
6
|
+
module Tzispa
|
7
|
+
module Controller
|
8
|
+
|
9
|
+
class HttpError < Base
|
10
|
+
|
11
|
+
include Tzispa::Helpers::Response
|
12
|
+
|
13
|
+
def error_404
|
14
|
+
not_found
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/tzispa/routes.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'http_router'
|
5
5
|
require 'tzispa/utils/string'
|
6
|
+
require 'tzispa/controller/http_error'
|
6
7
|
|
7
8
|
module Tzispa
|
8
9
|
|
@@ -14,6 +15,7 @@ module Tzispa
|
|
14
15
|
|
15
16
|
def initialize(map_path=nil)
|
16
17
|
@router = HttpRouter.new
|
18
|
+
@router.default Tzispa::Controller::HttpError.new('error_404')
|
17
19
|
@map_path = map_path unless map_path=='/'
|
18
20
|
end
|
19
21
|
|
@@ -21,33 +23,34 @@ module Tzispa
|
|
21
23
|
"#{@map_path}#{@router.path path_id, params}"
|
22
24
|
end
|
23
25
|
|
24
|
-
def add(route_id, path,
|
26
|
+
def add(route_id, path, methods, controller)
|
25
27
|
spec_control, callmethod = controller.to_s.split(':')
|
26
28
|
mpath = spec_control.split('#')
|
27
|
-
|
29
|
+
req_controller = mpath.pop
|
30
|
+
controller = TzString.camelize(req_controller).to_s
|
28
31
|
if mpath.count > 1
|
29
32
|
controller_module = mpath.collect!{ |w| w.capitalize }.join('::')
|
30
|
-
require_relative "./controller/#{
|
33
|
+
require_relative "./controller/#{req_controller}"
|
31
34
|
else
|
32
35
|
controller_module = CONTROLLERS_BASE
|
33
|
-
require "tzispa/controller/#{
|
36
|
+
require "tzispa/controller/#{req_controller}"
|
34
37
|
end
|
35
|
-
@router.add(path, {request_method: methods}).tap { |rule|
|
38
|
+
@router.add(path, methods ? {request_method: methods} : nil ).tap { |rule|
|
36
39
|
rule.to TzString.constantize("#{controller_module}::#{controller}").new(callmethod)
|
37
40
|
rule.name = route_id
|
38
41
|
}
|
39
42
|
end
|
40
43
|
|
41
|
-
def index(path, methods, controller=nil)
|
42
|
-
add :index, path, controller || 'layout:render!'
|
44
|
+
def index(path, methods=nil, controller=nil)
|
45
|
+
add :index, path, methods, controller || 'layout:render!'
|
43
46
|
end
|
44
47
|
|
45
|
-
def api(path, methods, controller=nil)
|
46
|
-
add :api, path, controller || 'api:dispatch!'
|
48
|
+
def api(path, methods=nil, controller=nil)
|
49
|
+
add :api, path, methods, controller || 'api:dispatch!'
|
47
50
|
end
|
48
51
|
|
49
|
-
def site(path, methods, controller=nil)
|
50
|
-
add :site, path, controller || 'layout:render!'
|
52
|
+
def site(path, methods=nil, controller=nil)
|
53
|
+
add :site, path, methods, controller || 'layout:render!'
|
51
54
|
end
|
52
55
|
|
53
56
|
end
|
data/lib/tzispa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzispa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Antonio Piñero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- lib/tzispa/controller/api.rb
|
180
180
|
- lib/tzispa/controller/base.rb
|
181
181
|
- lib/tzispa/controller/exceptions.rb
|
182
|
+
- lib/tzispa/controller/http_error.rb
|
182
183
|
- lib/tzispa/controller/layout.rb
|
183
184
|
- lib/tzispa/data/entity.rb
|
184
185
|
- lib/tzispa/domain.rb
|