tzispa 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/lib/tzispa/app.rb +10 -3
- data/lib/tzispa/command/app.rb +7 -3
- data/lib/tzispa/config/appconfig.rb +1 -0
- data/lib/tzispa/context.rb +2 -0
- data/lib/tzispa/controller/api.rb +1 -1
- data/lib/tzispa/domain.rb +14 -0
- data/lib/tzispa/http/context.rb +5 -4
- data/lib/tzispa/middleware.rb +2 -2
- data/lib/tzispa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1782a5ef50e95d6fd833efd6eacd2e29215e0ba5
|
4
|
+
data.tar.gz: b20ac80acf812c7a8c0479ebc7d23645829fddba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5d2e25ffec6c8e87a6830edc5bafe4fc80d60e704b90f08c620a01e052c40a247c490420f434dab7470cbd187b3ec527bb5afd263ff5e79d70dac8136872e61
|
7
|
+
data.tar.gz: 93e818f963d31eaeec5f6d001940d1baf0b44f692989abd9c17d95f38e94674c90124e6fad315baa417086f28b44d747a134f85acbd38fa6c1e497d277118373
|
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,11 @@ Tzispa
|
|
2
2
|
|
3
3
|
General purpose web framework
|
4
4
|
|
5
|
+
## v0.4.2
|
6
|
+
- Preload api and helper modules an classes in app.load
|
7
|
+
|
5
8
|
## v0.4.1
|
6
|
-
- Add support to generate canonical urls
|
9
|
+
- Add support to generate canonical urls
|
7
10
|
|
8
11
|
## v0.4.0
|
9
12
|
- Added basic cli command engine
|
data/lib/tzispa/app.rb
CHANGED
@@ -62,7 +62,6 @@ module Tzispa
|
|
62
62
|
def initialize(domain_name)
|
63
63
|
@domain = Domain.new(domain_name)
|
64
64
|
@middleware = Middleware.new self
|
65
|
-
I18n.load_path = Dir["config/locales/*.yml"]
|
66
65
|
@config = Config::AppConfig.new(@domain).load!
|
67
66
|
end
|
68
67
|
|
@@ -74,13 +73,14 @@ module Tzispa
|
|
74
73
|
def load!
|
75
74
|
unless @loaded
|
76
75
|
Mutex.new.synchronize {
|
76
|
+
load_locales
|
77
77
|
@middleware.load!
|
78
78
|
@repository = Data::Repository.new(@config.repository.to_h).load! if @config.respond_to? :repository
|
79
79
|
@engine = Rig::Engine.new(self, true, 32)
|
80
80
|
@logger = Logger.new("logs/#{@domain.name}.log", 'weekly')
|
81
81
|
@logger.level = @config.respond_to?(:developing) && @config.developing ? Logger::DEBUG : Logger::INFO
|
82
|
-
|
83
|
-
|
82
|
+
@domain.require_dir 'helpers'
|
83
|
+
@domain.require_dir 'api'
|
84
84
|
@loaded = true
|
85
85
|
}
|
86
86
|
end
|
@@ -89,6 +89,13 @@ module Tzispa
|
|
89
89
|
|
90
90
|
private
|
91
91
|
|
92
|
+
def load_locales
|
93
|
+
if @config.respond_to?(:locales)
|
94
|
+
I18n.load_path = Dir["config/locales/*.yml"]
|
95
|
+
I18n.load_path += Dir["#{@domain.path}/config/locales/*.yml"]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
92
99
|
|
93
100
|
end
|
94
101
|
end
|
data/lib/tzispa/command/app.rb
CHANGED
@@ -15,6 +15,7 @@ module Tzispa
|
|
15
15
|
'config',
|
16
16
|
'config/locales',
|
17
17
|
'error',
|
18
|
+
'helpers',
|
18
19
|
'rig',
|
19
20
|
'rig/block',
|
20
21
|
'rig/layout',
|
@@ -37,6 +38,10 @@ module Tzispa
|
|
37
38
|
|
38
39
|
private
|
39
40
|
|
41
|
+
def app_class_name
|
42
|
+
@app_class_name ||= "#{TzString.camelize domain.name}App"
|
43
|
+
end
|
44
|
+
|
40
45
|
def update_project
|
41
46
|
prj = Project.open
|
42
47
|
raise "Application '#{domain.name}' already exist in this project" if prj.apps.include?(domain.name)
|
@@ -52,14 +57,13 @@ module Tzispa
|
|
52
57
|
end
|
53
58
|
|
54
59
|
def new_app_code(mount_path)
|
55
|
-
appclass = "#{TzString.camelize domain.name}App"
|
56
60
|
Tzispa::Utils::Indenter.new(2).tap { |code|
|
57
|
-
code << "\nclass #{
|
61
|
+
code << "\nclass #{app_class_name} < Tzispa::Application\n\n"
|
58
62
|
code.indent << "def initialize\n"
|
59
63
|
code.indent << "super(:#{domain.name})\n"
|
60
64
|
code.unindent << "end\n\n"
|
61
65
|
code.unindent << "end\n\n"
|
62
|
-
code << "#{
|
66
|
+
code << "#{app_class_name}.mount '/#{mount_path}', self do |route|\n"
|
63
67
|
code.indent << "route.index '/', [:get, :head]\n"
|
64
68
|
code << "route.api '/__api_:sign/:handler/:verb(~:predicate)(/:sufix)', [:get, :head, :post]\n"
|
65
69
|
code << "route.site '/:title(/@:id0)(@:id1)(@~:id2)(@@:id3)(@@~:id4)(@@@:id5)/:layout.:format', [:get, :head]\n"
|
data/lib/tzispa/context.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'forwardable'
|
2
|
+
require 'i18n'
|
2
3
|
|
3
4
|
module Tzispa
|
4
5
|
|
@@ -13,6 +14,7 @@ module Tzispa
|
|
13
14
|
@env = environment
|
14
15
|
@app = environment[:tzispa__app]
|
15
16
|
@repository = @app.repository.dup if @app.repository
|
17
|
+
I18n.locale = config.locales.default.to_sym if config.respond_to?(:locales)
|
16
18
|
end
|
17
19
|
|
18
20
|
end
|
data/lib/tzispa/domain.rb
CHANGED
@@ -22,10 +22,24 @@ module Tzispa
|
|
22
22
|
Kernel.require "./#{path}/#{file}"
|
23
23
|
end
|
24
24
|
|
25
|
+
def require_dir(dir)
|
26
|
+
Dir["./#{path}/#{dir}/*.rb"].each { |file|
|
27
|
+
name = file.split('/').last.split('.').first
|
28
|
+
Kernel.require "./#{path}/#{dir}/#{name}"
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
25
32
|
def load(file)
|
26
33
|
Kernel.load "./#{path}/#{file}.rb"
|
27
34
|
end
|
28
35
|
|
36
|
+
def load_dir(dir)
|
37
|
+
Dir["./#{path}/#{dir}/*.rb"].each { |file|
|
38
|
+
name = file.split('/').last
|
39
|
+
Kernel.load "./#{path}/#{dir}/#{name}"
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
29
43
|
def self.require(domain, file)
|
30
44
|
self.new(name: domain).require(file)
|
31
45
|
end
|
data/lib/tzispa/http/context.rb
CHANGED
@@ -28,6 +28,7 @@ module Tzispa
|
|
28
28
|
super(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
32
|
end
|
32
33
|
|
33
34
|
def router_params
|
@@ -63,17 +64,17 @@ module Tzispa
|
|
63
64
|
end
|
64
65
|
|
65
66
|
def path(path_id, params={})
|
66
|
-
|
67
|
+
app.class.routes.path path_id, params
|
67
68
|
end
|
68
69
|
|
69
70
|
def canonical_url(path_id, params={})
|
70
|
-
|
71
|
+
app.config.canonical_url + path(path_id, params)
|
71
72
|
end
|
72
73
|
|
73
74
|
def api(handler, verb, predicate, sufix)
|
74
75
|
raise ArgumentError.new('missing parameter in api call') unless handler && verb
|
75
|
-
sign = sign_array [handler, verb, predicate],
|
76
|
-
|
76
|
+
sign = sign_array [handler, verb, predicate], app.config.salt
|
77
|
+
app.class.routes.path :api, {sign: sign, handler: handler, verb: verb, predicate: predicate, sufix: sufix}
|
77
78
|
end
|
78
79
|
|
79
80
|
end
|
data/lib/tzispa/middleware.rb
CHANGED
@@ -57,8 +57,8 @@ module Tzispa
|
|
57
57
|
def _load_session_middleware
|
58
58
|
if @application.config.sessions.enabled
|
59
59
|
use Rack::Session::Moneta,
|
60
|
-
store: Moneta.new(:HashFile, dir:
|
61
|
-
key: "_#{@application.config.id}__",
|
60
|
+
store: Moneta.new(:HashFile, dir: @application.config.sessions.store_path, expires: true, threadsafe: true),
|
61
|
+
key: "_#{@application.config.id}__",
|
62
62
|
domain: @application.config.host_name,
|
63
63
|
path: '/',
|
64
64
|
expire_after: @application.config.sessions.timeout,
|
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.2
|
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-04-
|
11
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|