jcrvalidator 0.8.2 → 0.8.3

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: 1e0ce8e0beaae3b56921ab98051cacb83723a621
4
- data.tar.gz: 37b9cf7bb6c35389f565ef1848fff7d84b768e08
3
+ metadata.gz: 7c50c1a2af0d88092277ad46e1df5d67515ba5aa
4
+ data.tar.gz: 3cb4e27aa441e830103d36afc1eb2766a4184e09
5
5
  SHA512:
6
- metadata.gz: '078d9e3c1d59b82fa9b0aef8da7724900d49acb941aac381e4b73b760d83a9684ccd70eaa7ebfa9a7086545c09c9a8a54a4cf1b210c6c6f5d44f7512389898bd'
7
- data.tar.gz: ed65f15f0b346a285fc2a4da36df771f43c4450b18ff2419fdc4e8baaebc5041151dfa96ec73de7120324d2c3256569f45a4449c632a04285a9172328ebc29da
6
+ metadata.gz: db6a495f22d675dcf2729947768ec4f7978226590f84fa6a35596601d62c7eecc1a24dad83ca7dbd4a8c460ac3b036bc480b26b07f339a3b87f1c39429c4e169
7
+ data.tar.gz: 82cd1669d3003be226dad39c3d5048b1a8d412cc0470b8ec1fb6acca1c784a811d7fc1d479845ac9aa1066fade53c5a0251ae32aec836daaa5f167a8b2ba8d50
@@ -56,7 +56,7 @@ module JCR
56
56
  class EvalConditions
57
57
  attr_accessor :mapping, :callbacks, :trace, :trace_stack, :failures
58
58
  def initialize mapping, callbacks, trace = false
59
- @failures = {}
59
+ @failures = []
60
60
  @mapping = mapping
61
61
  @trace = trace
62
62
  @trace_stack = []
@@ -68,21 +68,25 @@ module JCR
68
68
  end
69
69
 
70
70
  def report_failure failure
71
- coord = JCR::trace_coord( self )
72
- @failures[ coord ] = Array.new unless @failures[ coord ]
73
- @failures[ coord ] << failure
71
+ stack_level = trace_stack.length - 1
72
+ @failures[ stack_level ] = Array.new unless @failures[ stack_level ]
73
+ @failures[ stack_level ] << failure
74
74
  end
75
75
 
76
76
  def report_success
77
- coord = JCR::trace_coord( self )
78
- @failures.delete( coord )
77
+ stack_level = trace_stack.length - 1
78
+ @failures.slice!( stack_level..-1 )
79
79
  end
80
80
  end
81
81
 
82
82
  class Failure
83
83
  attr_accessor :data, :json, :json_elided, :evaluation, :rule, :pos, :offset, :type, :definition, :stack_level, :reason_elided
84
84
  def initialize data, jcr, type, evaluation, stack_level
85
- @json = data.to_json
85
+ if type == "member"
86
+ @json = "\"#{data[0]}\" : #{data[1].to_json} "
87
+ else
88
+ @json = data.to_json
89
+ end
86
90
  @json_elided = JCR::elide(@json)
87
91
  @data = JCR::rule_data( data )
88
92
  @rule = JCR::find_first_slice( jcr )
data/lib/jcr/jcr.rb CHANGED
@@ -31,6 +31,7 @@ module JCR
31
31
 
32
32
  class Context
33
33
  attr_accessor :mapping, :callbacks, :id, :tree, :roots, :catalog, :trace, :failed_roots, :failure_report
34
+ attr_accessor :failure_report_line_length
34
35
 
35
36
  def add_ruleset_alias( ruleset_alias, alias_uri )
36
37
  unless @catalog
@@ -71,6 +72,7 @@ module JCR
71
72
  @tree = ingested.tree
72
73
  @roots = ingested.roots
73
74
  end
75
+ @failure_report_line_length = 80
74
76
  end
75
77
 
76
78
  def override( ruleset )
@@ -151,14 +153,14 @@ module JCR
151
153
  else
152
154
  report << "- Failures for root rule at line #{failed_root.pos[0]}"
153
155
  end
154
- failed_root.failures.sort.map do |stack_level, failures|
156
+ failed_root.failures.each_with_index do |failures,stack_level|
155
157
  if failures.length > 1
156
- report << " - failure at rule #{stack_level} caused by one of the following #{failures.length} reasons"
158
+ report << " - failure at rule level #{stack_level} caused by one of the following #{failures.length} reasons"
157
159
  else
158
- report << " - failure at rule #{stack_level} caused by"
160
+ report << " - failure at rule level #{stack_level} caused by"
159
161
  end
160
162
  failures.each_with_index do |failure, index|
161
- lines = breakup_message( "<< #{failure.json_elided} >> failed rule #{failure.definition} at #{failure.pos} because #{failure.evaluation.reason}", 75 )
163
+ lines = breakup_message( "<< #{failure.json_elided} >> failed rule #{failure.definition}", ctx.failure_report_line_length - 5 )
162
164
  lines.each_with_index do |l,i|
163
165
  if i == 0
164
166
  report << " - #{l}"
data/lib/jcr/version.rb CHANGED
@@ -15,6 +15,6 @@
15
15
 
16
16
  module JCR
17
17
 
18
- VERSION = "0.8.2"
18
+ VERSION = "0.8.3"
19
19
 
20
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jcrvalidator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Newton
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-12-20 00:00:00.000000000 Z
12
+ date: 2018-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parslet
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.6.11
114
+ rubygems_version: 2.5.2
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: JCR Validator