tzispa_rig 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: facbd14f4e528f79d4860a11db426c6b31e748b1
4
- data.tar.gz: ce92598b9f554bc0f6d6d3aba9e8500aabd15fe6
3
+ metadata.gz: 47caf9d29bcf57c26262b3cbde5513060b677f23
4
+ data.tar.gz: cc3036e2437a2eadcdda3a6c0c2ef3fc5c97279b
5
5
  SHA512:
6
- metadata.gz: 6b8b5e8cac668248500ef5010fab8a271c7a09e869ef9c39479706456115ed82ffbbce2ab5aed3cbbc62b5e68f21514e382a2cfa39f3d803e56afa6990b07c97
7
- data.tar.gz: 9293bc6aeba603f6ef05c35dafe9a0b96ca512f13442fc2f8e98160ed686459e23273d67f93df955fb62a3d8511d0b3ee0ec552ebc48af0faf8e688b3f66110a
6
+ metadata.gz: 2a773cca4ef477089298ec6b70856303429869bfcae2412a058cbd257fdc37a25e87521c5ba1b052706d9477653bfd419ece1d2f6fecfcd244b34a34034f23d1
7
+ data.tar.gz: f80a648340d0a6a06c76d700956e6de301f8fa3d80e73e911dcfb0b6d46adcafb4f76d265b4f427f449565b5d9fd3f440a4adae3ecb0a098e172b49944f711e9
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@ Tzispa Rig
2
2
 
3
3
  Rig templates implementation
4
4
 
5
+ ## 0.3.3
6
+ - Raise a custom exception when a binder tag does not exists in the template
7
+ - Raise custom exception when there are duplicated loops in binder
8
+
5
9
  ## 0.3.2
6
10
  - Fix error bad format parameter when engine template cache is disabled
7
11
 
@@ -7,10 +7,14 @@ module Tzispa
7
7
  module Rig
8
8
 
9
9
 
10
+ class UnknownTag < NameError; end
11
+ class DuplicatedLoop < StandardError; end
12
+
13
+
10
14
  class Binder
11
15
  extend Forwardable
12
16
 
13
- attr_reader :context, :dataStruct, :parser
17
+ attr_reader :context, :dataStruct, :tags, :parser
14
18
  def_delegators :@parser, :attribute_tags
15
19
  def_delegators :@context, :app, :request, :response
16
20
 
@@ -21,6 +25,8 @@ module Tzispa
21
25
  @dataStruct = attribute_tags.count > 0 ? Struct.new(*attribute_tags) : Struct.new(nil)
22
26
  end
23
27
 
28
+ alias :tags :attribute_tags
29
+
24
30
  # Gets a LoopBinder context for the given loop_id in a rig template
25
31
  #
26
32
  # .... <var:myvar/> ...
@@ -42,8 +48,8 @@ module Tzispa
42
48
  #
43
49
  def loop_binder(loop_id)
44
50
  loop_parser = @parser.loop_parser loop_id
45
- raise ArgumentError.new("#{self.class}:: there isn't any loop tagged '#{loop_id}'") unless loop_parser && loop_parser.count > 0
46
- raise ArgumentError.new("#{self.class}:: there are #{loop_parser.count} loops tagged '#{loop_id}' at the same level: only one allowed") unless loop_parser.count == 1
51
+ raise UnknownTag.new("#{self.class.name} there isn't any loop tagged '#{loop_id}'") unless loop_parser && loop_parser.count > 0
52
+ raise DuplicatedLoop.new("#{self.class.name} there are #{loop_parser.count} loops tagged '#{loop_id}' at the same level: only one allowed") unless loop_parser.count == 1
47
53
  LoopBinder.new loop_parser[0], @context
48
54
  end
49
55
 
@@ -65,6 +71,7 @@ module Tzispa
65
71
  def data(**params)
66
72
  (@data ||= @dataStruct.new).tap { |d|
67
73
  params.each{ |k,v|
74
+ raise UnknownTag.new "#{k} is not a tag in #{self.class.name}" unless tags.include? k
68
75
  d[k] = v
69
76
  }
70
77
  }
@@ -74,8 +81,8 @@ module Tzispa
74
81
  if template.bindable?
75
82
  binder_class = template.binder_class
76
83
  binder_class.new(template, context).tap { |binder|
77
- raise "#{binder_class} isn't a TemplateBinder" unless binder&.is_a? Tzispa::Rig::TemplateBinder
78
- } if binder_class
84
+ raise ArgumentError.new "#{binder_class.name} isn't a TemplateBinder" unless binder&.is_a? Tzispa::Rig::TemplateBinder
85
+ } if binder_class
79
86
  else
80
87
  self.new(template, context)
81
88
  end
@@ -101,6 +108,7 @@ module Tzispa
101
108
  def loop_item(params=nil)
102
109
  (LoopItem.new self).tap { |item|
103
110
  params.each{ |k,v|
111
+ raise UnknownTag.new "#{k} is not a tag in #{self.class.name}" unless tags.include? k
104
112
  item.data[k] = v
105
113
  } if params
106
114
  }
@@ -3,7 +3,7 @@
3
3
  module Tzispa
4
4
  module Rig
5
5
 
6
- VERSION = '0.3.2'
6
+ VERSION = '0.3.3'
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.2
4
+ version: 0.3.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-05-11 00:00:00.000000000 Z
11
+ date: 2016-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzispa_helpers