tzispa 0.5.2 → 0.5.3
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/app.rb +27 -9
- data/lib/tzispa/http/context.rb +21 -5
- 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: 5aaff71883d0b89db28bc7727a27444804d79081
|
4
|
+
data.tar.gz: bf58b21bba595c299eb6148420b01184f3b54a07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ed1dcd8ef017e2a3ff31655f0ddb110cf37aaf02af048822363a02fe3cbc355bcb3701335348aecbb2d3b23291996343e089140ebae0f4ebaaa92cd72b9be72
|
7
|
+
data.tar.gz: 42447d848724c471e471f0c3ce8a7ef3fc6a3c56b78631585df10ccaa2bf5ece5487c1a9df7e32bb98b3217d95f68ab765f337414d4b9b7552dc9867e6fd5895
|
data/CHANGELOG.md
CHANGED
data/lib/tzispa/app.rb
CHANGED
@@ -28,18 +28,10 @@ module Tzispa
|
|
28
28
|
|
29
29
|
|
30
30
|
class << self
|
31
|
-
def inherited(base)
|
32
|
-
super
|
33
|
-
base.class_eval do
|
34
|
-
synchronize do
|
35
|
-
applications.add(base)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
31
|
|
40
32
|
def applications
|
41
33
|
synchronize do
|
42
|
-
@@applications ||=
|
34
|
+
@@applications ||= Hash.new{ |hash, key| raise UnknownApplication.new("#{key}") }
|
43
35
|
end
|
44
36
|
end
|
45
37
|
|
@@ -49,8 +41,13 @@ module Tzispa
|
|
49
41
|
}
|
50
42
|
end
|
51
43
|
|
44
|
+
def [](name)
|
45
|
+
applications[name]
|
46
|
+
end
|
47
|
+
|
52
48
|
def mount(path, builder)
|
53
49
|
self.new.tap { |app|
|
50
|
+
add(app)
|
54
51
|
app.routes ||= Routes.new(app, path)
|
55
52
|
yield(app.routes) if block_given?
|
56
53
|
builder.map path do
|
@@ -58,6 +55,16 @@ module Tzispa
|
|
58
55
|
end
|
59
56
|
}
|
60
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def add(app)
|
62
|
+
synchronize do
|
63
|
+
raise DuplicateDomain.new("You have try to add an app with a duplicate domain name #{app.name}") if applications.has_key? app.name
|
64
|
+
applications[app.name] = app
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
61
68
|
end
|
62
69
|
|
63
70
|
def initialize(domain_name)
|
@@ -81,6 +88,10 @@ module Tzispa
|
|
81
88
|
self
|
82
89
|
end
|
83
90
|
|
91
|
+
def [](domain)
|
92
|
+
self.class[domain]
|
93
|
+
end
|
94
|
+
|
84
95
|
private
|
85
96
|
|
86
97
|
def load_locales
|
@@ -90,5 +101,12 @@ module Tzispa
|
|
90
101
|
end
|
91
102
|
end
|
92
103
|
|
104
|
+
public
|
105
|
+
|
106
|
+
class ApplicationError < StandardError; end
|
107
|
+
class UnknownApplication < ApplicationError; end
|
108
|
+
class DuplicateDomain < ApplicationError; end
|
109
|
+
|
110
|
+
|
93
111
|
end
|
94
112
|
end
|
data/lib/tzispa/http/context.rb
CHANGED
@@ -77,19 +77,35 @@ module Tzispa
|
|
77
77
|
app.routes.path path_id, params
|
78
78
|
end
|
79
79
|
|
80
|
+
def app_path(app_name, path_id, params={})
|
81
|
+
app[app_name].routes.path path_id, params
|
82
|
+
end
|
83
|
+
|
80
84
|
def canonical_url(path_id, params={})
|
81
85
|
app.config.canonical_url + path(path_id, params)
|
82
86
|
end
|
83
87
|
|
84
|
-
def
|
85
|
-
canonical_url
|
88
|
+
def app_canonical_url(app_name, path_id, params={})
|
89
|
+
app[app_name].config.canonical_url + app_path(app_name, path_id, params)
|
86
90
|
end
|
87
91
|
|
88
|
-
def
|
89
|
-
|
90
|
-
|
92
|
+
def api(handler, verb, predicate, sufix, app_name)
|
93
|
+
unless app_name
|
94
|
+
canonical_url :api, handler: handler, verb: verb, predicate: predicate, sufix: sufix
|
95
|
+
else
|
96
|
+
app_canonical_url app_name, :api, handler: handler, verb: verb, predicate: predicate, sufix: sufix
|
97
|
+
end
|
91
98
|
end
|
92
99
|
|
100
|
+
def sapi(handler, verb, predicate, sufix, app_name = nil)
|
101
|
+
unless app_name
|
102
|
+
sign = sign_array [handler, verb, predicate], app.config.salt
|
103
|
+
canonical_url :sapi, sign: sign, handler: handler, verb: verb, predicate: predicate, sufix: sufix
|
104
|
+
else
|
105
|
+
sign = sign_array [handler, verb, predicate], app[:app_name].config.salt
|
106
|
+
app_canonical_url app_name, :sapi, sign: sign, handler: handler, verb: verb, predicate: predicate, sufix: sufix
|
107
|
+
end
|
108
|
+
end
|
93
109
|
|
94
110
|
end
|
95
111
|
|
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.5.
|
4
|
+
version: 0.5.3
|
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-
|
11
|
+
date: 2016-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|