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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10e8927b2000c2316f242eac3dd30516cdc177dc
4
- data.tar.gz: 62f875ae215df9b1b409063021289256837ebaf0
3
+ metadata.gz: 66048b167e117a0e35891d812844488310535da8
4
+ data.tar.gz: ad48d4adaf70d9353ff78c7229d0b72e079bb861
5
5
  SHA512:
6
- metadata.gz: 5ecd98c3795c4581974fbe71a5ae219ed5b728f41410a9550a38aedb86354233a72246ed1bc3a88d3877c1f06675877f1b7e543ba45b7af06fad563de1013503
7
- data.tar.gz: 8ba5244fc0bd592f2b2acb4418f4511a2481aa1174498ac3a9da9594aea2d68acc0807b529736d3053342f661e1da8c2e423a35a8178dce65e83d7d466912ca2
6
+ metadata.gz: a548b5e37b99b24c77a75753f576b383d51a651ec7279cd5097bf007305e23a0e85ff987a8c113507e6012c88ad6c7f6d6136b4dacc3c0bff28bbeef09dbf306
7
+ data.tar.gz: bf61ee7c9d5a82e684d81025a4936b95c00a4c128d887a355a13ca35fada8c164c668c5711fc8fe99fa369b13de9eea6fe8d82b5035fee23e8fd4d0217f993a6
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@ Tzispa
2
2
 
3
3
  General purpose web framework
4
4
 
5
+ ## v0.4.13
6
+ - Set router default app to http_error 404
7
+
5
8
  ## v0.4.12
6
9
  - Fix controller/base all errors go to error 500
7
10
 
@@ -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, controller, methods)
26
+ def add(route_id, path, methods, controller)
25
27
  spec_control, callmethod = controller.to_s.split(':')
26
28
  mpath = spec_control.split('#')
27
- controller = TzString.camelize(mpath.pop).to_s
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/#{controller.downcase}"
33
+ require_relative "./controller/#{req_controller}"
31
34
  else
32
35
  controller_module = CONTROLLERS_BASE
33
- require "tzispa/controller/#{controller.downcase}"
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!', methods
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!', methods
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!', methods
52
+ def site(path, methods=nil, controller=nil)
53
+ add :site, path, methods, controller || 'layout:render!'
51
54
  end
52
55
 
53
56
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tzispa
4
- VERSION = '0.4.12'
4
+ VERSION = '0.4.13'
5
5
  FRAMEWORK_NAME = 'Tzispa'
6
6
  GEM_NAME = 'tzispa'
7
7
  end
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.12
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-23 00:00:00.000000000 Z
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