circuitdata 0.6.4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +25 -122
- data/Rakefile +4 -6
- data/lib/circuitdata.rb +32 -120
- data/lib/circuitdata/bury/bury.rb +61 -0
- data/lib/circuitdata/dereferencer.rb +49 -17
- data/lib/circuitdata/exposed_area.rb +84 -0
- data/lib/circuitdata/json_schema.rb +14 -0
- data/lib/circuitdata/json_validator.rb +56 -0
- data/lib/circuitdata/json_validator/json_schema_error_parser.rb +57 -0
- data/lib/circuitdata/material_validator.rb +40 -0
- data/lib/circuitdata/product.rb +125 -0
- data/lib/circuitdata/product_id_validator.rb +81 -0
- data/lib/circuitdata/profile.rb +31 -69
- data/lib/circuitdata/schema.rb +145 -0
- data/lib/circuitdata/schema_files/schema_v1_dereferenced.json +107155 -0
- data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema.json +68 -5307
- data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_generics.json +23 -0
- data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_materials.json +99 -0
- data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_products.json +779 -0
- data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_profiles_and_capabilities.json +323 -0
- data/lib/circuitdata/summary.rb +96 -0
- data/lib/circuitdata/validator.rb +28 -0
- data/lib/circuitdata/version.rb +2 -1
- metadata +113 -20
- data/lib/circuitdata/bk_comparer.rb +0 -106
- data/lib/circuitdata/compatibility_checker.rb +0 -160
- data/lib/circuitdata/file_comparer.rb +0 -276
- data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_definitions.json +0 -1249
- data/lib/circuitdata/schema_files/v1/ottp_circuitdata_skeleton_schema.json +0 -94
- data/lib/circuitdata/schema_files/v1/ottp_schema_definitions.json +0 -102
- data/lib/circuitdata/tools.rb +0 -207
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: circuitdata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Lydersen
|
@@ -10,64 +10,148 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2019-01-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json-schema
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.8.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - '='
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 2.8.0
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: activesupport
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|
18
32
|
requirements:
|
19
33
|
- - "~>"
|
20
34
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
35
|
+
version: '5.1'
|
22
36
|
type: :runtime
|
23
37
|
prerelease: false
|
24
38
|
version_requirements: !ruby/object:Gem::Requirement
|
25
39
|
requirements:
|
26
40
|
- - "~>"
|
27
41
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
42
|
+
version: '5.1'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: terminal-table
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.8.0
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.8.0
|
29
57
|
- !ruby/object:Gem::Dependency
|
30
58
|
name: rake
|
31
59
|
requirement: !ruby/object:Gem::Requirement
|
32
60
|
requirements:
|
33
61
|
- - "~>"
|
34
62
|
- !ruby/object:Gem::Version
|
35
|
-
version: '12.
|
63
|
+
version: '12.3'
|
36
64
|
type: :development
|
37
65
|
prerelease: false
|
38
66
|
version_requirements: !ruby/object:Gem::Requirement
|
39
67
|
requirements:
|
40
68
|
- - "~>"
|
41
69
|
- !ruby/object:Gem::Version
|
42
|
-
version: '12.
|
70
|
+
version: '12.3'
|
43
71
|
- !ruby/object:Gem::Dependency
|
44
|
-
name:
|
72
|
+
name: rspec
|
45
73
|
requirement: !ruby/object:Gem::Requirement
|
46
74
|
requirements:
|
47
75
|
- - "~>"
|
48
76
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
77
|
+
version: '3.7'
|
50
78
|
type: :development
|
51
79
|
prerelease: false
|
52
80
|
version_requirements: !ruby/object:Gem::Requirement
|
53
81
|
requirements:
|
54
82
|
- - "~>"
|
55
83
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
84
|
+
version: '3.7'
|
57
85
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
86
|
+
name: byebug
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '10.0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '10.0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: guard
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 2.14.2
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.14.2
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: guard-rspec
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '4.7'
|
120
|
+
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - "~>"
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '4.7'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: hashdiff
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 0.3.7
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - "~>"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 0.3.7
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: rspec_junit_formatter
|
59
143
|
requirement: !ruby/object:Gem::Requirement
|
60
144
|
requirements:
|
61
145
|
- - "~>"
|
62
146
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
147
|
+
version: 0.4.1
|
64
148
|
type: :development
|
65
149
|
prerelease: false
|
66
150
|
version_requirements: !ruby/object:Gem::Requirement
|
67
151
|
requirements:
|
68
152
|
- - "~>"
|
69
153
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
154
|
+
version: 0.4.1
|
71
155
|
description: This gem provides you with functions to work with the CricuitData language.
|
72
156
|
Run files against the schema, check their compatibility agains each other compare
|
73
157
|
multiple files to find conflicts.
|
@@ -81,16 +165,25 @@ files:
|
|
81
165
|
- README.md
|
82
166
|
- Rakefile
|
83
167
|
- lib/circuitdata.rb
|
84
|
-
- lib/circuitdata/
|
85
|
-
- lib/circuitdata/compatibility_checker.rb
|
168
|
+
- lib/circuitdata/bury/bury.rb
|
86
169
|
- lib/circuitdata/dereferencer.rb
|
87
|
-
- lib/circuitdata/
|
170
|
+
- lib/circuitdata/exposed_area.rb
|
171
|
+
- lib/circuitdata/json_schema.rb
|
172
|
+
- lib/circuitdata/json_validator.rb
|
173
|
+
- lib/circuitdata/json_validator/json_schema_error_parser.rb
|
174
|
+
- lib/circuitdata/material_validator.rb
|
175
|
+
- lib/circuitdata/product.rb
|
176
|
+
- lib/circuitdata/product_id_validator.rb
|
88
177
|
- lib/circuitdata/profile.rb
|
178
|
+
- lib/circuitdata/schema.rb
|
179
|
+
- lib/circuitdata/schema_files/schema_v1_dereferenced.json
|
89
180
|
- lib/circuitdata/schema_files/v1/ottp_circuitdata_schema.json
|
90
|
-
- lib/circuitdata/schema_files/v1/
|
91
|
-
- lib/circuitdata/schema_files/v1/
|
92
|
-
- lib/circuitdata/schema_files/v1/
|
93
|
-
- lib/circuitdata/
|
181
|
+
- lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_generics.json
|
182
|
+
- lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_materials.json
|
183
|
+
- lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_products.json
|
184
|
+
- lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_profiles_and_capabilities.json
|
185
|
+
- lib/circuitdata/summary.rb
|
186
|
+
- lib/circuitdata/validator.rb
|
94
187
|
- lib/circuitdata/version.rb
|
95
188
|
homepage: http://circuitdata.org
|
96
189
|
licenses:
|
@@ -112,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
205
|
version: '0'
|
113
206
|
requirements: []
|
114
207
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.6
|
208
|
+
rubygems_version: 2.7.6
|
116
209
|
signing_key:
|
117
210
|
specification_version: 4
|
118
211
|
summary: Basic test and comparison of JSON files agains the CircuitData JSON schema
|
@@ -1,106 +0,0 @@
|
|
1
|
-
def self.compare_files(filehash, validate_origins=false)
|
2
|
-
# Prepare the return
|
3
|
-
ra = {
|
4
|
-
error: false,
|
5
|
-
errormessage: "",
|
6
|
-
summary: {},
|
7
|
-
conflicts: {},
|
8
|
-
product: nil,
|
9
|
-
columns: [],
|
10
|
-
mastercolumn: nil,
|
11
|
-
rows: []
|
12
|
-
}
|
13
|
-
|
14
|
-
#parsedfiles
|
15
|
-
unless filehash.is_a? Hash
|
16
|
-
ra[:error] = true
|
17
|
-
ra[:errormessage] = "You have to feed this function with a hash of names and hashes"
|
18
|
-
return ra
|
19
|
-
end
|
20
|
-
|
21
|
-
# extend the hash that is received
|
22
|
-
nh = {}
|
23
|
-
filehash.each do |fhk, fhv|
|
24
|
-
nh[fhk] = {
|
25
|
-
orig: fhv,
|
26
|
-
parsed: nil,
|
27
|
-
content: nil,
|
28
|
-
has: {}
|
29
|
-
}
|
30
|
-
# READ THE CONTENT
|
31
|
-
ra[:error], ra[:errormessage], nh[fhk][:content] = self.read_json(fhv)
|
32
|
-
ra[:summary] = {} if ra[:error]
|
33
|
-
ra[:conflicts] = {} if ra[:error]
|
34
|
-
return ra if ra[:error]
|
35
|
-
# VALIDATE THE FILES
|
36
|
-
if validate_origins
|
37
|
-
ra[:error], ra[:errormessage], validationserrors = self.validate(nh[fhk][:content])
|
38
|
-
ra[:summary] = {} if ra[:error]
|
39
|
-
ra[:conflicts] = {} if ra[:error]
|
40
|
-
return ra if ra[:error]
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
# SET THE PRODUCT NAME
|
45
|
-
nh[fhk][:has][:products], nh[fhk][:has][:stackup], nh[fhk][:has][:profile_default], nh[fhk][:has][:profile_restricted], nh[fhk][:has][:profile_enforced], nh[fhk][:has][:capabilities], nh[fhk][:has][:product] = self.content(nh[fhk][:content])
|
46
|
-
unless nh[fhk][:has][:product].nil?
|
47
|
-
#self.iterate(nh[fhk][:content])
|
48
|
-
|
49
|
-
#root_node = Tree::TreeNode.new("ROOT", "Root Content")
|
50
|
-
#root_node.print_tree
|
51
|
-
|
52
|
-
ra[:product] = nh[fhk][:has][:product] if ra[:product].nil?
|
53
|
-
if nh[fhk][:has][:product] != ra[:product]
|
54
|
-
ra[:error] = true
|
55
|
-
ra[:errormessage] = "Your files contains several different product names"
|
56
|
-
ra[:summary] = {}
|
57
|
-
ra[:conflicts] = {}
|
58
|
-
return ra
|
59
|
-
end
|
60
|
-
ra[:mastercolumn] = fhk if ra[:mastercolumn].nil?
|
61
|
-
end
|
62
|
-
|
63
|
-
# THIS IS WHERE I NEED THINGS TO HAPPEN
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
# RETURN IF THERE IS NO PRODUCT
|
68
|
-
if ra[:mastercolumn].nil?
|
69
|
-
ra[:error] = true
|
70
|
-
ra[:errormessage] = "none of the files contains a product"
|
71
|
-
ra[:summary] = {}
|
72
|
-
ra[:conflicts] = {}
|
73
|
-
return ra
|
74
|
-
end
|
75
|
-
|
76
|
-
{
|
77
|
-
current_level: 0,
|
78
|
-
current_key: nil,
|
79
|
-
|
80
|
-
}
|
81
|
-
# Populate the master column
|
82
|
-
#self.iterate(filehash[ra[:mastercolumn].to_sym])
|
83
|
-
#ra[:summary] = productjson[:open_trade_transfer_package][:products][ra[:product]][:printed_circuits_fabrication_data]
|
84
|
-
|
85
|
-
#test = {}
|
86
|
-
#self.save_pair(productjson[:open_trade_transfer_package][:products][ra[:product]][:printed_circuits_fabrication_data], test)
|
87
|
-
#puts test
|
88
|
-
# Populate the product rows
|
89
|
-
#productjson[:open_trade_transfer_package]["products"][ra[:product]]["printed_circuits_fabrication_data"].each do |key, value|
|
90
|
-
# if value.is_a? Hash
|
91
|
-
# value.each do |subkey, subvalue|
|
92
|
-
# ra[:rows][]
|
93
|
-
#end
|
94
|
-
|
95
|
-
# Do comparisons
|
96
|
-
#number = 1
|
97
|
-
#filehash.each do |key, value|
|
98
|
-
# unless key.to_s == productfile
|
99
|
-
# #puts self.compatibility_checker( productjson, value, false )
|
100
|
-
# number += 1
|
101
|
-
# end
|
102
|
-
# end
|
103
|
-
#puts JSON.pretty_generate(ra)
|
104
|
-
#puts JSON.pretty_generate(nh)
|
105
|
-
return ra
|
106
|
-
end
|
@@ -1,160 +0,0 @@
|
|
1
|
-
class Circuitdata::CompatibilityChecker
|
2
|
-
def initialize(product_file, check_file, validate_origins)
|
3
|
-
require 'json'
|
4
|
-
require 'json-schema'
|
5
|
-
|
6
|
-
@product_file = product_file
|
7
|
-
@check_file = check_file
|
8
|
-
@validate_origins = validate_origins
|
9
|
-
# Final hash
|
10
|
-
@fh = {error: false, message: nil, errors: {validation: {}, restricted: {}, enforced: {}, capabilities: {}}}
|
11
|
-
end
|
12
|
-
|
13
|
-
def start_check
|
14
|
-
# Initialize & validate
|
15
|
-
@fh[:error], @fh[:message], product_data = Circuitdata.read_json(@product_file)
|
16
|
-
return @fh if @fh[:error]
|
17
|
-
@fh[:error], @fh[:message], @fh[:errors][:validation] = Circuitdata.validate(product_data)
|
18
|
-
return @fh if @fh[:error]
|
19
|
-
if @check_file.present?
|
20
|
-
@fh[:error], @fh[:message], check_data = Circuitdata.read_json(@check_file)
|
21
|
-
return @fh if @fh[:error]
|
22
|
-
@fh[:error], @fh[:message], @fh[:errors][:validation] = Circuitdata.validate(check_data)
|
23
|
-
return @fh if @fh[:error]
|
24
|
-
f2_types = Circuitdata.get_data_summary(check_data)[1]
|
25
|
-
|
26
|
-
# read the schema
|
27
|
-
schema_path = File.join(File.dirname(__FILE__), 'schema_files/v1/ottp_circuitdata_skeleton_schema.json')
|
28
|
-
schema = JSON.parse(File.read(schema_path), symbolize_names: true)
|
29
|
-
deref_schema = Circuitdata::Dereferencer.dereference(schema, File.dirname(Circuitdata::SCHEMA_FULL_PATH))
|
30
|
-
restricted_schema = enforced_schema = capability_schema = deref_schema
|
31
|
-
# Compare the content
|
32
|
-
perform_comparison(product_data, check_data, restricted_schema, 'restricted') if f2_types.include? 'profile_restricted'
|
33
|
-
perform_comparison(product_data, check_data, enforced_schema, 'enforced') if f2_types.include? 'profile_enforced'
|
34
|
-
perform_comparison(product_data, check_data, capability_schema, 'capabilities') if f2_types.include? 'capabilities'
|
35
|
-
end
|
36
|
-
|
37
|
-
@fh
|
38
|
-
end
|
39
|
-
|
40
|
-
def perform_comparison(product_data, check_data, schema, type)
|
41
|
-
|
42
|
-
docu = Circuitdata::Tools.new()
|
43
|
-
ra = docu.create_structure
|
44
|
-
|
45
|
-
case type
|
46
|
-
when 'restricted'
|
47
|
-
check_hash = check_data.dig(:open_trade_transfer_package, :profiles, :restricted, :printed_circuits_fabrication_data)
|
48
|
-
when 'enforced'
|
49
|
-
check_hash = check_data.dig(:open_trade_transfer_package, :profiles, :enforced, :printed_circuits_fabrication_data)
|
50
|
-
when 'capabilities'
|
51
|
-
check_hash = check_data.dig(:open_trade_transfer_package, :capabilities, :printed_circuits_fabrication_data)
|
52
|
-
else
|
53
|
-
check_hash = {}
|
54
|
-
end
|
55
|
-
|
56
|
-
common_hash = schema.dig(:properties, :open_trade_transfer_package, :properties, :products, :patternProperties, :'^(?!generic$).*', :properties, :printed_circuits_fabrication_data, :properties)
|
57
|
-
check_hash.each do |k, v|
|
58
|
-
v.each do |kl1, vl1| # level 1
|
59
|
-
unless [:dielectric, :soldermask, :stiffener].include? k.to_sym
|
60
|
-
common_hash[k.to_sym]||= {:type => 'object', :properties => {}}
|
61
|
-
#common_hash[:stackup][:properties][:specified][:properties][k.to_sym] ||= {:type => 'object', :properties => {}}
|
62
|
-
end
|
63
|
-
enum = []
|
64
|
-
required = []
|
65
|
-
case type
|
66
|
-
when 'restricted'
|
67
|
-
case vl1[0].class.name
|
68
|
-
when 'String'
|
69
|
-
vl1.each {|enumvalue| enum << enumvalue.strip}
|
70
|
-
new_hash = {:not => {:anyOf => [{ :enum => enum }]}}
|
71
|
-
when 'Boolean', 'FalseClass', 'TrueClass'
|
72
|
-
vl1.each do |enumvalue|
|
73
|
-
required << kl1.to_s if enumvalue == false
|
74
|
-
enum << enumvalue
|
75
|
-
end
|
76
|
-
new_hash = {:not => {:anyOf => [{ :enum => enum }]}}
|
77
|
-
when 'Numeric', 'Float'
|
78
|
-
if ra.dig(:structured, :elements, k.to_sym, :elements, kl1.to_sym, :enum).nil?
|
79
|
-
new_hash = {:anyOf => [{ :minimum => vl1[0], :maximum => vl1[1] }]}
|
80
|
-
else
|
81
|
-
vl1.each {|enumvalue| enum << enumvalue}
|
82
|
-
new_hash = {:not => {:anyOf => [{ :enum => enum }]}}
|
83
|
-
end
|
84
|
-
end
|
85
|
-
when 'enforced'
|
86
|
-
enum << vl1
|
87
|
-
new_hash = eval("{:enum => #{enum}}")
|
88
|
-
when 'capabilities'
|
89
|
-
case vl1[0].class.name
|
90
|
-
when 'String'
|
91
|
-
vl1.each {|enumvalue| enum << enumvalue.strip}
|
92
|
-
new_hash = {:anyOf => [{ :enum => enum }]}
|
93
|
-
when 'Boolean', 'FalseClass', 'TrueClass'
|
94
|
-
vl1.each do |enumvalue|
|
95
|
-
required << kl1.to_s if enumvalue == true
|
96
|
-
enum << enumvalue
|
97
|
-
end
|
98
|
-
new_hash = {:anyOf => [{ :enum => enum }]}
|
99
|
-
when 'Numeric'
|
100
|
-
vl1.each {|enumvalue| enum << enumvalue.strip}
|
101
|
-
new_hash = {:anyOf => [{ :minimum => vl1[0], :maximum => vl1[1] }]}
|
102
|
-
when 'Integer', 'Float'
|
103
|
-
if vl1.length == 1
|
104
|
-
new_hash = {:anyOf => [{ :minimum => vl1[0], :maximum => vl1[0] }]}
|
105
|
-
elsif vl1.length == 2
|
106
|
-
new_hash = {:anyOf => [{ :minimum => vl1[0], :maximum => vl1[1] }]}
|
107
|
-
else
|
108
|
-
fail StandardError, "Unhandled array length=#{vl1.length} key=#{kl1}"
|
109
|
-
end
|
110
|
-
else
|
111
|
-
fail StandardError, "Unhandled type=#{vl1[1].class.name} key=#{kl1}"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
case k.to_sym
|
115
|
-
when :dielectric
|
116
|
-
schema[:properties][:open_trade_transfer_package][:properties][:custom][:properties][:materials][:properties][:printed_circuits_fabrication_data][:properties][:dielectrics][:items][:properties][kl1.to_sym] = new_hash
|
117
|
-
schema[:properties][:open_trade_transfer_package][:properties][:custom][:properties][:materials][:properties][:printed_circuits_fabrication_data][:properties][:dielectrics][:items][:required] = required
|
118
|
-
when :soldermask
|
119
|
-
schema[:properties][:open_trade_transfer_package][:properties][:custom][:properties][:materials][:properties][:printed_circuits_fabrication_data][:properties][:soldermasks][:items][:properties][kl1.to_sym] = new_hash
|
120
|
-
schema[:properties][:open_trade_transfer_package][:properties][:custom][:properties][:materials][:properties][:printed_circuits_fabrication_data][:properties][:soldermasks][:items][:required] = required
|
121
|
-
when :stiffener
|
122
|
-
schema[:properties][:open_trade_transfer_package][:properties][:custom][:properties][:materials][:properties][:printed_circuits_fabrication_data][:properties][:stiffeners][:items][:properties][kl1.to_sym] = new_hash
|
123
|
-
schema[:properties][:open_trade_transfer_package][:properties][:custom][:properties][:materials][:properties][:printed_circuits_fabrication_data][:properties][:stiffeners][:items][:required] = required
|
124
|
-
else
|
125
|
-
common_hash[k.to_sym][:properties][kl1.to_sym] = new_hash
|
126
|
-
common_hash[k.to_sym][:required] = required
|
127
|
-
end
|
128
|
-
#common_hash[:stackup][:properties][:specified][:properties][k.to_sym][:properties][kl1.to_sym] = new_hash
|
129
|
-
#common_hash[:stackup][:properties][:specified][:properties][k.to_sym][:properties][kl1.to_sym] = new_hash
|
130
|
-
end if v.is_a? Hash
|
131
|
-
|
132
|
-
common_hash[k.to_sym][:additionalProperties] = false if (v.is_a?(Hash) && type == 'capabilities')
|
133
|
-
end
|
134
|
-
# perform validations
|
135
|
-
begin
|
136
|
-
validation_errors = JSON::Validator.fully_validate(schema.to_json, product_data, :errors_as_objects => true)
|
137
|
-
|
138
|
-
if validation_errors.any?
|
139
|
-
@fh[:error] = true
|
140
|
-
@fh[:message] = 'The product to check did not meet the requirements'
|
141
|
-
|
142
|
-
validation_errors.each do |error|
|
143
|
-
error_array = []
|
144
|
-
begin
|
145
|
-
error_array << error[:message].match("^(The\\sproperty\\s\\'[\\s\\S]*\\'\\s)([\\s\\S]*)(\\sin\\sschema[\\s\\S]*)$").captures[1]
|
146
|
-
rescue
|
147
|
-
error_array << error[:message]
|
148
|
-
end
|
149
|
-
@fh[:errors][type.to_sym][error[:fragment]] = error_array
|
150
|
-
end
|
151
|
-
end
|
152
|
-
rescue JSON::Schema::ReadFailed
|
153
|
-
@fh[:error] = true
|
154
|
-
@fh[:message] = "Could not read the submitted `#{type}` schema" # enforced_schema
|
155
|
-
rescue JSON::Schema::SchemaError
|
156
|
-
@fh[:error] = true
|
157
|
-
@fh[:message] = "Something was wrong with the submitted `#{type}` schema" # enforced_schema
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|