tzispa 0.5.4 → 0.5.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: deec1c9dafa50296d745e6299f14f6b7c64a582e
4
- data.tar.gz: f66ce54490b77c65d4ed3dba5021cc5f54974742
3
+ metadata.gz: 854b76c406ea8c9fa9742f2e4cd8daa7ec4fea16
4
+ data.tar.gz: 604cb924b0d88785ac2c9f7808eecb594bda3534
5
5
  SHA512:
6
- metadata.gz: 5fe4b90a3e2ebb6b3da3f8c6e505ddeeb7173fc43e99af76a64af86627a302c274ca4a7f1ff5b5e9ac9d648ff026dbfe0a80b02a451363f5cff07b452ca01e50
7
- data.tar.gz: 0cb5ce7bf33ccc60205f404fc0020167dffbb544429d2d212c23d57c221d45e78180c8c52b05e0ffb84d37c4b86c390f5d7f7cd666f81ae58c6e1081836e6428
6
+ metadata.gz: 5703eafce64f5b86c2de1e2dd7c9d8235a692a84ffd0fa2ac40c63c37a6de495c559b89f7ec46f29bfe1f7a31a69427d1a8c204551eaf6dc321019e45f8ffad1
7
+ data.tar.gz: bd6804a30b18b86fa577ca6f2a70c8efe433124caeeaf86f76e43a9d26853bd24ffde5f4985813f9b49cf70793f8afc3ebf4973c114551af694ecb8daf1c5d7f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@ Tzispa
2
2
 
3
3
  General purpose web framework
4
4
 
5
+ ## v0.5.6
6
+ - more application DSL usage improvements
7
+ - application builder passed in the run method
8
+ - fix router to response http error 404 when no route match is found
9
+
10
+ ## v0.5.5
11
+ - Changes in application initialize to improve DSL usage
12
+ - Application mount removed
13
+
5
14
  ## v0.5.3
6
15
  - Add basic inter-app operability for api and url calls
7
16
 
data/lib/tzispa/app.rb CHANGED
@@ -20,8 +20,8 @@ module Tzispa
20
20
  class Application
21
21
  extend Forwardable
22
22
 
23
- attr_reader :domain, :config, :middleware, :repository, :engine, :logger
24
- attr_accessor :routes
23
+ attr_reader :domain, :config, :middleware, :repository, :engine,
24
+ :logger, :mount_path, :routes
25
25
 
26
26
  def_delegator :@middleware, :use
27
27
  def_delegator :@domain, :name
@@ -45,19 +45,6 @@ module Tzispa
45
45
  applications[name]
46
46
  end
47
47
 
48
- def mount(path, builder)
49
- self.new.tap { |app|
50
- add(app)
51
- app.routes ||= Routes.new(app, path)
52
- yield(app.routes) if block_given?
53
- builder.map path do
54
- run app.middleware.builder
55
- end
56
- }
57
- end
58
-
59
- private
60
-
61
48
  def add(app)
62
49
  synchronize do
63
50
  raise DuplicateDomain.new("You have try to add an app with a duplicate domain name #{app.name}") if applications.has_key? app.name
@@ -67,10 +54,25 @@ module Tzispa
67
54
 
68
55
  end
69
56
 
70
- def initialize(domain_name)
57
+ def initialize(domain_name, mount_path: nil, &block)
71
58
  @domain = Domain.new(domain_name)
72
59
  @config = Config::AppConfig.new(@domain).load!
73
60
  @middleware = Middleware.new self
61
+ @routes ||= Routes.new(self, mount_path)
62
+ self.class.add(self)
63
+ instance_eval(&block) if block
64
+ end
65
+
66
+ def run(builder=nil)
67
+ builder ||= ::Rack::Builder.new
68
+ if routes.map_path
69
+ this_app = self
70
+ builder.map routes.map_path do
71
+ run this_app.middleware.builder
72
+ end
73
+ else
74
+ builder.run middleware.builder
75
+ end
74
76
  end
75
77
 
76
78
  def load!
@@ -13,7 +13,7 @@ module Tzispa
13
13
  def initialize(app, environment)
14
14
  @env = environment
15
15
  @app = app
16
- I18n.locale = config.locales.default.to_sym if config.respond_to?(:locales)
16
+ I18n.locale = app.config.locales.default.to_sym if app.config&.respond_to?(:locales)
17
17
  end
18
18
 
19
19
  end
@@ -28,7 +28,7 @@ module Tzispa
28
28
  super(app, environment)
29
29
  @request = Tzispa::Http::Request.new(environment)
30
30
  @response = Tzispa::Http::Response.new
31
- session[:id] ||= SecureRandom.uuid if app.config.sessions.enabled
31
+ session[:id] ||= SecureRandom.uuid if app&.config&.sessions&.enabled
32
32
  end
33
33
 
34
34
  def router_params
@@ -14,12 +14,12 @@ module Tzispa
14
14
  end
15
15
 
16
16
  def builder
17
- mw = self
17
+ midw = self
18
18
  @builder ||= ::Rack::Builder.new do
19
19
  #mw.load_default_stack
20
- app = mw.application.load!
21
- mw.stack.each { |m, args, block| use mw.load(m), *args, &block }
22
- run app.routes.router
20
+ midw.application.load!
21
+ midw.stack.each { |m, args, block| use midw.load(m), *args, &block }
22
+ run midw.application.routes.router
23
23
  end
24
24
  end
25
25
 
@@ -38,7 +38,7 @@ module Tzispa
38
38
 
39
39
  def load_default_stack
40
40
  @default_stack_loaded ||= begin
41
- app = application.load!
41
+ application.load!
42
42
  #use TzispaEnv, app
43
43
  end
44
44
  end
data/lib/tzispa/routes.rb CHANGED
@@ -17,7 +17,7 @@ module Tzispa
17
17
  def initialize(app, root=nil)
18
18
  @router = HttpRouter.new
19
19
  @app = app
20
- @router.default Tzispa::Controller::HttpError.new('error_404')
20
+ @router.default Tzispa::Controller::HttpError.new(app, :error_404)
21
21
  @map_path = root unless root=='/'
22
22
  end
23
23
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tzispa
4
- VERSION = '0.5.4'
4
+ VERSION = '0.5.6'
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.5.4
4
+ version: 0.5.6
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-10-14 00:00:00.000000000 Z
11
+ date: 2016-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack