tzispa_rig 0.3.4 → 0.4.0

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: 34c29a6d0cb71518ba08bf0c7c3274ac6a1cad35
4
- data.tar.gz: 23a5a9a18a5d22e871a51b5085d730b47f4676ff
3
+ metadata.gz: 09e80ff368915af834b5d85df68834d5d373a6bd
4
+ data.tar.gz: 4919330b471c6970c2e7939fee29b9f56e4ea689
5
5
  SHA512:
6
- metadata.gz: 2780edabd2cbf6d049860a10eb04363c094a9b851a5ec95fd3b394cb34389b483cb4613418f7430bc791f942c9b3d55143d73853cd985402207be25e5deceb59
7
- data.tar.gz: 8bbffe98a3a17c8a33d646980bc95f1ce3e7828f8779d323230c95b51d1897b335b3b5c2b67c5fc18b525085f94770ea0778b8c6def762b34028df2e88d71914
6
+ metadata.gz: 4641da9ff01bdb47eb4fd750d4185f444299d5204eac978eb1c707e98cd1c578ebab185598fbf40ea74a2af80d0b335731f0df391c4cf9dc85fcc047eff08bab
7
+ data.tar.gz: 8dd5f5669ea8f3ebeefdd969b53ff903b351758d8da38a346d11fcd603a97f6a09b324690a542fb3cf0d1d4c1bb9e44d21ae0748b248d6ebfbbab9898d146b4e
data/CHANGELOG.md CHANGED
@@ -2,20 +2,23 @@ Tzispa Rig
2
2
 
3
3
  Rig templates implementation
4
4
 
5
- ## 0.3.4
5
+ ## v0.4.0
6
+ - add suport for signed/unsigned api calls
7
+
8
+ ## v0.3.4
6
9
  - fix template cache returning empty template sometimes
7
10
 
8
- ## 0.3.3
11
+ ## v0.3.3
9
12
  - Raise a custom exception when a binder tag does not exists in the template
10
13
  - Raise custom exception when there are duplicated loops in binder
11
14
 
12
- ## 0.3.2
15
+ ## v0.3.2
13
16
  - Fix error bad format parameter when engine template cache is disabled
14
17
 
15
- ## 0.3.1
18
+ ## v0.3.1
16
19
  - Fix error in engine template cache that was losing template params when a template was recovered from cache
17
20
 
18
- ## 0.3.0
21
+ ## v0.3.0
19
22
  - Separate engine class into independant ruby file
20
23
  - Move rig url builder tags into independant parser category
21
24
  - Now static blocks can parse url builder tags: url, purl & api
data/README.md CHANGED
@@ -66,8 +66,7 @@ private
66
66
  attr_reader :idb
67
67
 
68
68
  def load_brand
69
- context.repository.use :ecomm_shop
70
- brand = context.repository[:brand][idb]
69
+ brand = context.repository[:brand, :ecomm_shop][idb]
71
70
  data(
72
71
  idb: brand.id,
73
72
  name: brand.name,
@@ -109,8 +108,7 @@ In the binder you must define customer_exist
109
108
 
110
109
  def bind!
111
110
  idc = context.router_params[:id0]
112
- context.repository.use :ecomm_shop
113
- customer = context.repository[:customer][idb]
111
+ customer = context.repository[:customer, :ecomm_shop][idb]
114
112
  data.customer_exist = !customer.nil?
115
113
  end
116
114
 
@@ -131,7 +129,7 @@ To repeat a part in the template use loop tag
131
129
  <td><var:name/></td>
132
130
  <td class='text-right'>
133
131
  <a href='<purl:site[layout=brand_edit,title=edit-brand,id0={%id%}]/>'><i class='fa fa-edit'></i></a>
134
- <a href='javascript:delete_brand("<api:brand:delete:{%id%}/>")'><i class='fa fa-trash'></i></a>
132
+ <a href='javascript:delete_brand("<sapi:brand:delete:{%id%}/>")'><i class='fa fa-trash'></i></a>
135
133
  </td>
136
134
  <tr>
137
135
  </loop:lbrands>
@@ -148,8 +146,7 @@ private
148
146
 
149
147
  def load_brands
150
148
  Proc.new {
151
- context.repository.use :ecomm_shop
152
- context.repository[:brand].list.map { |b|
149
+ context.repository[:brand, :ecomm_shop].list.map { |b|
153
150
  loop_item(
154
151
  id: b.id,
155
152
  skey: b.skey,
@@ -184,14 +181,14 @@ The route_id's area defined in the start.ru file
184
181
  Api urls: used to provide urls to the application Api
185
182
 
186
183
  ```
187
- <api:handler:verb/>
188
- <api:handler:verb:predicate/>
184
+ <sapi:handler:verb/>
185
+ <sapi:handler:verb:predicate/>
189
186
  ```
190
187
 
191
188
  ```html
192
- <api:customer:add:address/>
189
+ <sapi:customer:add:address/>
193
190
 
194
- <api:brand:{%verb%}/>
191
+ <sapi:brand:{%verb%}/>
195
192
  ```
196
193
 
197
194
  ## Building templates
@@ -236,7 +233,6 @@ You can also use template subdomains using dot notation in the name
236
233
  In the folder binder you can access template parameters
237
234
  ```ruby
238
235
  def bind!
239
- context.repository.use :quality_dok
240
236
  @doctype = params[:doc]
241
237
  end
242
238
  ```
@@ -24,7 +24,7 @@ module Tzispa
24
24
  :re_loop => /<loop:(\w+)>(.*?)<\/loop:\1>/m.freeze,
25
25
  :re_ife => /<ife:(\w+)>(.*?)(<else:\1\/>(.*?))?<\/ife:\1>/m.freeze,
26
26
  :re_purl => /<purl:(\w+)(\[(\w+=[^,\]]+(,\w+=[^,\]]+)*?)\])?\/>/.freeze,
27
- :re_api => /<api:(\w+(?:\.\w+)?):(\w+)(?::([^:]+))?(?::([^\/]+))?\/>/.freeze
27
+ :re_api => /<sapi:(\w+(?:\.\w+)?):(\w+)(?::([^:]+))?(?::([^\/]+))?\/>/.freeze
28
28
  }
29
29
 
30
30
  def initialize(engine, binder=nil, text=nil)
@@ -29,11 +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, type, match[1], match[3]
33
- when :purl
34
- ParsedPurl.new parser, type, match[1], match[3]
32
+ ParsedUrl.new parser, match[1].to_sym, match[2], match[4]
35
33
  when :api
36
- ParsedApi.new parser, type, match[1], match[2], match[3], match[4]
34
+ ParsedApi.new parser, match[1].to_sym, match[2], match[3], match[4], match[5]
37
35
  when :loop
38
36
  ParsedLoop.new parser, type, match[3], match[4]
39
37
  when :ife
@@ -103,24 +101,6 @@ module Tzispa
103
101
  end
104
102
 
105
103
 
106
- class ParsedPurl < ParsedEntity
107
-
108
- def initialize(parser, type, path_id, params)
109
- super(parser, type)
110
- @path_id = path_id.to_sym
111
- @params = params
112
- end
113
-
114
- def render(binder)
115
- b_params = @params.dup.gsub(RE_ANCHOR) { |match|
116
- parser.the_parsed.select { |p| p.anchor == match}.first.render(binder)
117
- } if @params
118
- binder.context.path @path_id, Parameters.new(b_params).data
119
- end
120
-
121
- end
122
-
123
-
124
104
  class ParsedUrl < ParsedEntity
125
105
 
126
106
  def initialize(parser, type, path_id, params)
@@ -133,13 +113,17 @@ module Tzispa
133
113
  b_params = @params.dup.gsub(RE_ANCHOR) { |match|
134
114
  parser.the_parsed.select { |p| p.anchor == match}.first.render(binder)
135
115
  } if @params
136
- binder.context.canonical_url @path_id, Parameters.new(b_params).data
116
+ case type
117
+ when :purl
118
+ binder.context.path @path_id, Parameters.new(b_params).data
119
+ when :url
120
+ binder.context.canonical_url @path_id, Parameters.new(b_params).data
121
+ end
137
122
  end
138
123
 
139
124
  end
140
125
 
141
126
 
142
-
143
127
  class ParsedApi < ParsedEntity
144
128
 
145
129
  attr_reader :handler, :verb, :predicate
@@ -157,7 +141,7 @@ module Tzispa
157
141
  b_verb = bind_value @verb.dup, binder
158
142
  b_predicate = bind_value( @predicate.dup, binder ) if @predicate
159
143
  b_sufix = bind_value( @sufix.dup, binder ) if @sufix
160
- binder.context.api b_handler, b_verb, b_predicate, b_sufix
144
+ binder.context.send(type.to_sym, b_handler, b_verb, b_predicate, b_sufix)
161
145
  end
162
146
 
163
147
  private
@@ -11,10 +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
- :purl => /<purl:(\w+(?:\.\w+)?)(\[(\w+=[^,\]]+(,\w+=[^,\]]+)*?)\])?\/>/,
16
- :url => /<url:(\w+(?:\.\w+)?)(\[(\w+=[^,\]]+(,\w+=[^,\]]+)*?)\])?\/>/,
17
- :api => /<api:([^:\.]+(?:\.[^:]+)?):([^:\/]+)(?::([^:\/]+))?(?::([^\/]+))?\/>/
14
+ RIG_URL_BUILDER = {
15
+ :url => /<(url|purl):(\w+(?:\.\w+)?)(\[(\w+=[^,\]]+(,\w+=[^,\]]+)*?)\])?\/>/,
16
+ :api => /<(api|sapi):([^:\.]+(?:\.[^:]+)?):([^:\/]+)(?::([^:\/]+))?(?::([^\/]+))?\/>/
18
17
  }.freeze
19
18
 
20
19
  RIG_STATEMENTS = /(<(loop):(\w+)>(.*?)<\/loop:\3>)|(<(ife):(\w+)>(.*?)(<else:\7\/>(.*?))?<\/ife:\7>)/m
@@ -3,7 +3,7 @@
3
3
  module Tzispa
4
4
  module Rig
5
5
 
6
- VERSION = '0.3.4'
6
+ VERSION = '0.4.0'
7
7
  GEM_NAME = 'tzispa_rig'
8
8
 
9
9
  end
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.3.4
4
+ version: 0.4.0
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-06-02 00:00:00.000000000 Z
11
+ date: 2016-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzispa_helpers