tzispa_rig 0.4.0 → 0.4.1
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/rig/parameters.rb +11 -8
- data/lib/tzispa/rig/parsernext.rb +16 -8
- data/lib/tzispa/rig/syntax.rb +3 -3
- data/lib/tzispa/rig/template.rb +1 -0
- data/lib/tzispa/rig/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: 85460707b768aacfda498419acc54745d5c16023
|
4
|
+
data.tar.gz: fed21c4359870abf3c347166777b6cf6fe63693d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7f6c00dbab72e985feb68dc402f1b37d8af52f2893380d224a758125ab5e955ff9c11e0d17259c883af1a811042a4d09da2dce90e7c59a700648fa7704b2b50
|
7
|
+
data.tar.gz: 9851c3d85331cb4436faeeae19dd603fe8e2dfe05dfc940d84af88abac60142ba28eb8974bf48798533b36aafa2fd553df68740e9dbd345d3c7845d594172ca6
|
data/CHANGELOG.md
CHANGED
@@ -2,18 +2,15 @@
|
|
2
2
|
|
3
3
|
module Tzispa
|
4
4
|
module Rig
|
5
|
-
class Parameters
|
6
|
-
|
7
5
|
|
8
|
-
|
9
|
-
attr_reader :outer
|
10
|
-
attr_reader :data
|
6
|
+
class Parameters
|
11
7
|
|
8
|
+
attr_reader :inner, :outer
|
12
9
|
|
13
|
-
def initialize(params=nil,
|
10
|
+
def initialize(params=nil, outer=',', inner='=')
|
14
11
|
@data = Hash.new
|
15
|
-
@outer =
|
16
|
-
@inner =
|
12
|
+
@outer = outer
|
13
|
+
@inner = inner
|
17
14
|
setData(params) if params
|
18
15
|
end
|
19
16
|
|
@@ -37,6 +34,12 @@ module Tzispa
|
|
37
34
|
@data.map { |k,v| "#{k}#{inner}#{v}" }.join(outer)
|
38
35
|
end
|
39
36
|
|
37
|
+
def to_h
|
38
|
+
@data
|
39
|
+
end
|
40
|
+
|
41
|
+
alias_method :data, :to_h
|
42
|
+
|
40
43
|
def merge(params)
|
41
44
|
setData(params)
|
42
45
|
end
|
@@ -29,9 +29,9 @@ module Tzispa
|
|
29
29
|
when :var
|
30
30
|
ParsedVar.new parser, type, match[1], match[2]
|
31
31
|
when :url
|
32
|
-
ParsedUrl.new parser, match[1].to_sym, match[
|
32
|
+
ParsedUrl.new parser, match[1].to_sym, match[3], match[5], match[2]&.slice(1..-1)&.to_sym
|
33
33
|
when :api
|
34
|
-
ParsedApi.new parser, match[1].to_sym, match[
|
34
|
+
ParsedApi.new parser, match[1].to_sym, match[3], match[4], match[5], match[6], match[2]&.slice(1..-1)&.to_sym
|
35
35
|
when :loop
|
36
36
|
ParsedLoop.new parser, type, match[3], match[4]
|
37
37
|
when :ife
|
@@ -103,10 +103,13 @@ module Tzispa
|
|
103
103
|
|
104
104
|
class ParsedUrl < ParsedEntity
|
105
105
|
|
106
|
-
|
106
|
+
attr_reader :path_id, :params, :app_name
|
107
|
+
|
108
|
+
def initialize(parser, type, path_id, params, app_name = nil)
|
107
109
|
super(parser, type)
|
108
110
|
@path_id = path_id.to_sym
|
109
111
|
@params = params
|
112
|
+
@app_name = app_name
|
110
113
|
end
|
111
114
|
|
112
115
|
def render(binder)
|
@@ -115,9 +118,13 @@ module Tzispa
|
|
115
118
|
} if @params
|
116
119
|
case type
|
117
120
|
when :purl
|
118
|
-
|
121
|
+
app_name ?
|
122
|
+
binder.context.app_path(app_name, @path_id, Parameters.new(b_params).tp_h) :
|
123
|
+
binder.context.path(@path_id, Parameters.new(b_params).to_h)
|
119
124
|
when :url
|
120
|
-
|
125
|
+
app_name ?
|
126
|
+
binder.context.app_canonical_url(app_name, @path_id, Parameters.new(b_params).to_h) :
|
127
|
+
binder.context.canonical_url(@path_id, Parameters.new(b_params).to_h)
|
121
128
|
end
|
122
129
|
end
|
123
130
|
|
@@ -126,14 +133,15 @@ module Tzispa
|
|
126
133
|
|
127
134
|
class ParsedApi < ParsedEntity
|
128
135
|
|
129
|
-
attr_reader :handler, :verb, :predicate
|
136
|
+
attr_reader :handler, :verb, :predicate, :app_name
|
130
137
|
|
131
|
-
def initialize(parser, type, handler, verb, predicate, sufix)
|
138
|
+
def initialize(parser, type, handler, verb, predicate, sufix, app_name = nil)
|
132
139
|
super(parser, type)
|
133
140
|
@handler = handler
|
134
141
|
@verb = verb
|
135
142
|
@predicate = predicate
|
136
143
|
@sufix = sufix
|
144
|
+
@app_name = app_name
|
137
145
|
end
|
138
146
|
|
139
147
|
def render(binder)
|
@@ -141,7 +149,7 @@ module Tzispa
|
|
141
149
|
b_verb = bind_value @verb.dup, binder
|
142
150
|
b_predicate = bind_value( @predicate.dup, binder ) if @predicate
|
143
151
|
b_sufix = bind_value( @sufix.dup, binder ) if @sufix
|
144
|
-
binder.context.send(type.to_sym, b_handler, b_verb, b_predicate, b_sufix)
|
152
|
+
binder.context.send(type.to_sym, b_handler, b_verb, b_predicate, b_sufix, app_name)
|
145
153
|
end
|
146
154
|
|
147
155
|
private
|
data/lib/tzispa/rig/syntax.rb
CHANGED
@@ -11,9 +11,9 @@ module Tzispa
|
|
11
11
|
:var => /<var(\[%[A-Z]?[0-9]*[a-z]\])?:(\w+)\/>/
|
12
12
|
}.freeze
|
13
13
|
|
14
|
-
RIG_URL_BUILDER = {
|
15
|
-
:url => /<(url|purl)
|
16
|
-
:api => /<(api|sapi)
|
14
|
+
RIG_URL_BUILDER = {
|
15
|
+
:url => /<(url|purl)(@\w+)?:(\w+(?:\.\w+)?)(\[(\w+=[^,\]]+(,\w+=[^,\]]+)*?)\])?\/>/,
|
16
|
+
:api => /<(api|sapi)(@\w+)?:([^:\.]+(?:\.[^:]+)?):([^:\/]+)(?::([^:\/]+))?(?::([^\/]+))?\/>/
|
17
17
|
}.freeze
|
18
18
|
|
19
19
|
RIG_STATEMENTS = /(<(loop):(\w+)>(.*?)<\/loop:\3>)|(<(ife):(\w+)>(.*?)(<else:\7\/>(.*?))?<\/ife:\7>)/m
|
data/lib/tzispa/rig/template.rb
CHANGED
data/lib/tzispa/rig/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzispa_rig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
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-
|
11
|
+
date: 2016-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzispa_helpers
|