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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09e80ff368915af834b5d85df68834d5d373a6bd
4
- data.tar.gz: 4919330b471c6970c2e7939fee29b9f56e4ea689
3
+ metadata.gz: 85460707b768aacfda498419acc54745d5c16023
4
+ data.tar.gz: fed21c4359870abf3c347166777b6cf6fe63693d
5
5
  SHA512:
6
- metadata.gz: 4641da9ff01bdb47eb4fd750d4185f444299d5204eac978eb1c707e98cd1c578ebab185598fbf40ea74a2af80d0b335731f0df391c4cf9dc85fcc047eff08bab
7
- data.tar.gz: 8dd5f5669ea8f3ebeefdd969b53ff903b351758d8da38a346d11fcd603a97f6a09b324690a542fb3cf0d1d4c1bb9e44d21ae0748b248d6ebfbbab9898d146b4e
6
+ metadata.gz: b7f6c00dbab72e985feb68dc402f1b37d8af52f2893380d224a758125ab5e955ff9c11e0d17259c883af1a811042a4d09da2dce90e7c59a700648fa7704b2b50
7
+ data.tar.gz: 9851c3d85331cb4436faeeae19dd603fe8e2dfe05dfc940d84af88abac60142ba28eb8974bf48798533b36aafa2fd553df68740e9dbd345d3c7845d594172ca6
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@ Tzispa Rig
2
2
 
3
3
  Rig templates implementation
4
4
 
5
+ ## v0.4.1
6
+ - add inter-app calls for url and api tags
7
+
5
8
  ## v0.4.0
6
9
  - add suport for signed/unsigned api calls
7
10
 
@@ -2,18 +2,15 @@
2
2
 
3
3
  module Tzispa
4
4
  module Rig
5
- class Parameters
6
-
7
5
 
8
- attr_reader :inner
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, iouter=',', iinner='=')
10
+ def initialize(params=nil, outer=',', inner='=')
14
11
  @data = Hash.new
15
- @outer = iouter
16
- @inner = iinner
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[2], match[4]
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[2], match[3], match[4], match[5]
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
- def initialize(parser, type, path_id, params)
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
- binder.context.path @path_id, Parameters.new(b_params).data
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
- binder.context.canonical_url @path_id, Parameters.new(b_params).data
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
@@ -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):(\w+(?:\.\w+)?)(\[(\w+=[^,\]]+(,\w+=[^,\]]+)*?)\])?\/>/,
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
@@ -43,6 +43,7 @@ module Tzispa
43
43
  while line = f.gets
44
44
  @content << line
45
45
  end
46
+ f.close
46
47
  }
47
48
  @loaded = true
48
49
  rescue Errno::ENOENT
@@ -3,7 +3,7 @@
3
3
  module Tzispa
4
4
  module Rig
5
5
 
6
- VERSION = '0.4.0'
6
+ VERSION = '0.4.1'
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.4.0
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-06-27 00:00:00.000000000 Z
11
+ date: 2016-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzispa_helpers