circuitdata 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +25 -122
  3. data/Rakefile +4 -6
  4. data/lib/circuitdata.rb +32 -120
  5. data/lib/circuitdata/bury/bury.rb +61 -0
  6. data/lib/circuitdata/dereferencer.rb +49 -17
  7. data/lib/circuitdata/exposed_area.rb +84 -0
  8. data/lib/circuitdata/json_schema.rb +14 -0
  9. data/lib/circuitdata/json_validator.rb +56 -0
  10. data/lib/circuitdata/json_validator/json_schema_error_parser.rb +57 -0
  11. data/lib/circuitdata/material_validator.rb +40 -0
  12. data/lib/circuitdata/product.rb +125 -0
  13. data/lib/circuitdata/product_id_validator.rb +81 -0
  14. data/lib/circuitdata/profile.rb +31 -69
  15. data/lib/circuitdata/schema.rb +145 -0
  16. data/lib/circuitdata/schema_files/schema_v1_dereferenced.json +107155 -0
  17. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema.json +68 -5307
  18. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_generics.json +23 -0
  19. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_materials.json +99 -0
  20. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_products.json +779 -0
  21. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_profiles_and_capabilities.json +323 -0
  22. data/lib/circuitdata/summary.rb +96 -0
  23. data/lib/circuitdata/validator.rb +28 -0
  24. data/lib/circuitdata/version.rb +2 -1
  25. metadata +113 -20
  26. data/lib/circuitdata/bk_comparer.rb +0 -106
  27. data/lib/circuitdata/compatibility_checker.rb +0 -160
  28. data/lib/circuitdata/file_comparer.rb +0 -276
  29. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_definitions.json +0 -1249
  30. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_skeleton_schema.json +0 -94
  31. data/lib/circuitdata/schema_files/v1/ottp_schema_definitions.json +0 -102
  32. data/lib/circuitdata/tools.rb +0 -207
@@ -1,94 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "type": "object",
4
- "additionalProperties": false,
5
- "required": ["open_trade_transfer_package"],
6
- "properties": {
7
- "open_trade_transfer_package": {
8
- "type": "object",
9
- "properties": {
10
- "version": {
11
- "type": "string",
12
- "pattern": "^1.0$"
13
- },
14
- "information": {
15
- "$ref": "ottp_schema_definitions.json#/definitions/information"
16
- },
17
- "products": {
18
- "type": "object",
19
- "properties": {
20
- "generic": {
21
- "type": "object",
22
- "properties": {},
23
- "id": "generic",
24
- "description": "this should validate any element under generic to be valid"
25
- }
26
- },
27
- "patternProperties": {
28
- "^(?!generic$).*": {
29
- "type": "object",
30
- "required": ["printed_circuits_fabrication_data"],
31
- "properties": {
32
- "printed_circuits_fabrication_data": {
33
- "type": "object",
34
- "required": ["version"],
35
- "properties": {
36
- "stackup": {
37
- "type": "object",
38
- "properties": {
39
- "specified": {
40
- "type": "object",
41
- "properties": {}
42
- }
43
- }
44
- }
45
- }
46
- }
47
- }
48
- }
49
- }
50
- },
51
- "custom": {
52
- "properties": {
53
- "colors": {
54
- "type": "array",
55
- "items": {
56
- "type": "object",
57
- "properties": {}
58
- }
59
- } ,
60
- "materials": {
61
- "properties": {
62
- "printed_circuits_fabrication_data": {
63
- "properties": {
64
- "dielectrics": {
65
- "type": "array",
66
- "items": {
67
- "type": "object",
68
- "properties": {}
69
- }
70
- },
71
- "soldermasks": {
72
- "type": "array",
73
- "items": {
74
- "type": "object",
75
- "properties": {}
76
- }
77
- },
78
- "stiffeners": {
79
- "type": "array",
80
- "items": {
81
- "type": "object",
82
- "properties": {}
83
- }
84
- }
85
- }
86
- }
87
- }
88
- }
89
- }
90
- }
91
- }
92
- }
93
- }
94
- }
@@ -1,102 +0,0 @@
1
- {
2
- "definitions": {
3
- "information": {
4
- "type": "object",
5
- "additionalProperties": false,
6
- "properties": {
7
- "company": {
8
- "type": "string",
9
- "description": "The company who owns the information in the file"
10
- },
11
- "person": {
12
- "type": "string",
13
- "description": "The person responsible for the information in the file"
14
- },
15
- "editor_software": {
16
- "type": "string",
17
- "description": "The software that has generated the file"
18
- },
19
- "created": {
20
- "type": "string",
21
- "format": "date-time",
22
- "description": "The timestamp of the creation of the file, in RFC 3339 date-time format"
23
- },
24
- "updated": {
25
- "type": "string",
26
- "format": "date-time",
27
- "description": "The timestamp of the last update of the file, in RFC 3339 date-time format"
28
- },
29
- "project": {
30
- "type": "string",
31
- "description": "The name of the project included in the file"
32
- },
33
- "version": {
34
- "type": "number",
35
- "description": "The name of the project included in the file"
36
- },
37
- "description": {
38
- "type": "string"
39
- }
40
- }
41
- },
42
- "product": {
43
- "type": "object",
44
- "properties": {
45
- }
46
- },
47
- "profile": {
48
- "type": "object",
49
- "additionalProperties": false,
50
- "properties": {
51
- "defaults": {
52
- "type": "object",
53
- "properties": {
54
- }
55
- },
56
- "enforced": {
57
- "type": "object",
58
- "properties": {
59
- }
60
- },
61
- "restricted": {
62
- "type": "object",
63
- "properties": {
64
- }
65
- }
66
- }
67
- },
68
- "capability": {
69
- "type": "object",
70
- "properties": {
71
- "summary": {
72
- "type": "object",
73
- "properties": {
74
- }
75
- },
76
- "materials": {
77
- "type": "object",
78
- "properties": {
79
- }
80
- }
81
- }
82
- },
83
- "custom": {
84
- "type": "object",
85
- "properties": {
86
- "colors": {
87
- "type": "object",
88
- "properties": {
89
- },
90
- "aliases": "",
91
- "name": "any_name",
92
- "description": "Colors can be defined by hex, rgb, cmyk or name. Name of the color present here can be references in the other elements"
93
- },
94
- "materials": {
95
- "type": "object",
96
- "properties": {
97
- }
98
- }
99
- }
100
- }
101
- }
102
- }
@@ -1,207 +0,0 @@
1
- class Circuitdata::Tools
2
- def initialize()
3
- require 'json'
4
- @schema_path = File.join(File.dirname(__FILE__), 'schema_files/v1/ottp_circuitdata_schema.json')
5
- @definitions_path = File.join(File.dirname(__FILE__), 'schema_files/v1/ottp_circuitdata_schema_definitions.json')
6
- @ra = {}
7
- end
8
-
9
- def update_ra(type, key, value)
10
- if key == :materials
11
- update_ra(type, :dielectric, value[:properties][:printed_circuits_fabrication_data][:properties][:dielectrics])
12
- update_ra(type, :soldermask, value[:properties][:printed_circuits_fabrication_data][:properties][:soldermasks])
13
- update_ra(type, :stiffener, value[:properties][:printed_circuits_fabrication_data][:properties][:stiffeners])
14
- return
15
- end
16
- parsed_elements = Circuitdata.read_json(@definitions_path)[2]
17
- unless @ra[:structured][:elements].has_key? key
18
- @ra[:structured][:elements][key] = {
19
- :type => value[:type],
20
- :elements => {},
21
- :name => nil,
22
- :description => nil,
23
- :aliases => nil
24
- }
25
- @ra[:structured][:elements][key][:name] = value[:descriptive_name] if value.has_key? :descriptive_name
26
- @ra[:structured][:elements][key][:description] = value[:description] if value.has_key? :description
27
- if value.has_key? :aliases
28
- @ra[:structured][:elements][key][:aliases] = value[:aliases] unless value[:aliases] == ""
29
- end
30
- end
31
- if value[:type] == "array"
32
- subelement = value[:items]
33
- else
34
- subelement = value
35
- end
36
- if subelement.has_key? :properties
37
- subelement[:properties].each do |skey, svalue|
38
- unless @ra[:structured][:elements][key][:elements].has_key? skey
39
- @ra[:structured][:elements][key][:elements][skey] = {
40
- :in_product_generic => false,
41
- :in_product_stackup => false,
42
- :in_profile_default => false,
43
- :in_profile_enforced => false,
44
- :in_profile_restricted => false,
45
- :in_custom => false,
46
- :in_capabilities => false,
47
- :type => nil,
48
- :arrayitems => nil,
49
- :enum => nil,
50
- :enum_description => nil,
51
- :description => nil,
52
- :uom => nil,
53
- :minimum => nil,
54
- :maximum => nil
55
- }
56
- if svalue.has_key? :$ref
57
- elements = svalue[:$ref].split('/')
58
- if elements.length == 4
59
- element = parsed_elements[elements[1].to_sym][elements[2].to_sym][elements[3].to_sym]
60
- elsif elements.length == 5
61
- element = parsed_elements[elements[1].to_sym][elements[2].to_sym][elements[3].to_sym][elements[4].to_sym]
62
- else
63
- element = parsed_elements[elements[1].to_sym][elements[2].to_sym][elements[3].to_sym][elements[4].to_sym][elements[5].to_sym]
64
- end
65
- else
66
- element = nil
67
- [:rigid_conductive_layer, :flexible_conductive_layer].include? key.to_sym ? newkey = :conductive_layer : newkey = key.to_sym
68
- if parsed_elements[:definitions][:elements].has_key? newkey
69
- element = parsed_elements[:definitions][:elements][newkey][skey.to_sym] if parsed_elements[:definitions][:elements][newkey].has_key? skey.to_sym
70
- end
71
- end
72
- unless element.nil?
73
- if element.has_key? :type
74
- @ra[:structured][:elements][key][:elements][skey][:type] = element[:type]
75
- if element[:type] == "array"
76
- if element.has_key? :items and element[:items].has_key? :type
77
- @ra[:structured][:elements][key][:elements][skey][:arrayitems] == element[:items][:type]
78
- end
79
- end
80
- end
81
- if element.has_key? :enum
82
- @ra[:structured][:elements][key][:elements][skey][:enum] = element[:enum]
83
- @ra[:structured][:elements][key][:elements][skey][:enum_description] = element[:enum_description] if element.has_key? :enum_description
84
- end
85
- @ra[:structured][:elements][key][:elements][skey][:description] = element[:description] if element.has_key? :description
86
- @ra[:structured][:elements][key][:elements][skey][:uom] = element[:uom] if element.has_key? :uom
87
- @ra[:structured][:elements][key][:elements][skey][:minimum] = element[:minimum] if element.has_key? :minimum
88
- @ra[:structured][:elements][key][:elements][skey][:maximum] = element[:maximum] if element.has_key? :maximum
89
- end
90
- else
91
- if [:in_profile_restricted, :in_capabilities].include? type
92
- if @ra[:structured][:elements][key][:elements][skey][:type].nil?
93
- @ra[:structured][:elements][key][:elements][skey][:type] = svalue[:type] unless ['array', 'object'].include? svalue[:type]
94
- end
95
- case @ra[:structured][:elements][key][:elements][skey][:type]
96
- when *["number", "integer", "boolean", "string"]
97
- @ra[:structured][:elements][key][:elements][skey][:type] = "number" if @ra[:structured][:elements][key][:elements][skey][:type] == "integer"
98
- unless ( svalue.has_key? :type and svalue[:type] == "array" ) and ( svalue.has_key? :items and svalue[:items].has_key? :type and svalue[:items][:type] == @ra[:structured][:elements][key][:elements][skey][:type])
99
- (@ra[:errors][type][key] ||= {})[skey] = "Type is #{@ra[:structured][:elements][key][:elements][skey][:type]}, wrong check"
100
- end
101
- if type == :in_profile_restricted and not @ra[:structured][:elements][key][:elements][skey][:enum].nil? and svalue.has_key? :minItems
102
- puts
103
- (@ra[:errors][type][key] ||= {})[skey] = "Error in profile restricted where enum is not considered"
104
- end
105
- when "array"
106
- unless svalue.has_key? :type and svalue[:type] == "array"
107
- (@ra[:errors][type][key] ||= {})[skey] = "Type is #{@ra[:structured][:elements][key][:elements][skey][:type]}, wrong check"
108
- end
109
- else
110
- (@ra[:errors][type][key] ||= {})[skey] = "Unknown type #{@ra[:structured][:elements][key][:elements][skey][:type]} in #{key}, #{skey} when doing #{type}"
111
- end
112
- end
113
- end
114
- @ra[:structured][:elements][key][:elements][skey][type] = true
115
- end
116
- end
117
- end
118
-
119
- def create_structure
120
- @ra[:structured] = {:elements => {}, :custom => {}}
121
- @ra[:errors] = {:in_profile_restricted => {}, :in_capabilities => {}}
122
- parsed_schema = Circuitdata.read_json(@schema_path)[2]
123
- # Go through all products
124
- parsed_schema[:properties][:open_trade_transfer_package][:properties][:products][:patternProperties]["^(?!generic$).*".to_sym][:properties][:printed_circuits_fabrication_data][:properties].each do |key, value|
125
- self.update_ra(:in_product_generic, key, value)
126
- end
127
- # Go through all profiles
128
- ["defaults", "restricted", "enforced"].each do |sym|
129
- parsed_schema[:properties][:open_trade_transfer_package][:properties][:profiles][:properties][sym.to_sym][:properties][:printed_circuits_fabrication_data][:properties].each do |key, value|
130
- case sym
131
- when "defaults"
132
- t = :in_profile_default
133
- when "restricted"
134
- t = :in_profile_restricted
135
- when "enforced"
136
- t = :in_profile_enforced
137
- end
138
- self.update_ra(t, key, value)
139
- end
140
- end
141
- # Go through all capabilities
142
- parsed_schema[:properties][:open_trade_transfer_package][:properties][:capabilities][:properties][:printed_circuits_fabrication_data][:properties].each do |key, value|
143
- self.update_ra(:in_capabilities, key, value)
144
- end
145
- # Go through all custom
146
- parsed_schema[:properties][:open_trade_transfer_package][:properties][:custom][:properties].each do |key, value|
147
- self.update_ra(:in_custom, key, value)
148
- end
149
-
150
- @ra[:structured][:elements].sort.to_h
151
- @ra[:structured][:elements].delete(:version)
152
- @ra[:structured][:elements][:stackup].delete(:specified)
153
- return @ra
154
- end
155
-
156
- def create_documentation(ra)
157
- ra[:documentation] = "## Elements and tags\n"
158
- ra[:structured][:elements].each do |element_key, element_value|
159
- ra[:documentation] += "### #{element_key} [link](##{element_key.to_s.downcase.tr(" ", "-")})\n"
160
- element_value[:elements].each do |e_key, e_value|
161
- ra[:documentation] += "* #{e_key}\n"
162
- end
163
- ra[:documentation] += "\n"
164
- end
165
- ra[:structured][:elements].each do |element_key, element_value|
166
- ra[:documentation] += "### #{element_key}\n"
167
- ra[:documentation] += "Name: #{element_value[:descriptive_name]}\n\n" unless element_value[:descriptive_name].nil?
168
- ra[:documentation] += "Aliases: #{element_value[:aliases]}\n\n" unless element_value[:aliases].nil?
169
- ra[:documentation] += "#{element_value[:description]}\n" unless element_value[:description].nil?
170
- ra[:documentation] += "\n"
171
- if element_value[:type] == "array"
172
- ra[:documentation] += "**You must specify this as en array when used in a generic product description or a stackup, but as a object when used in any of the other parts. Read more [here](#elements-that-are-both-arrays-and-objects)**\n\n"
173
- end
174
- element_value[:elements].each do |e_key, e_value|
175
- ra[:documentation] += "#### #{e_key}\n"
176
- ra[:documentation] += "Aliases: #{e_value[:aliases]}\n\n" unless e_value[:aliases].nil?
177
- ra[:documentation] += "#{e_value[:description]}\n\n" unless e_value[:description].nil?
178
- ra[:documentation] += "Unit of Measure: #{e_value[:uom][0]}\n\n" unless e_value[:uom].nil?
179
- if e_value.has_key? :enum and not e_value[:enum].nil?
180
- ra[:documentation] += "Use one of these values:\n"
181
- e_value[:enum].each do |ev|
182
- ra[:documentation] += "* #{ev}"
183
- if e_value.has_key? :enum_description and not e_value[:enum_description].nil? and e_value[:enum_description].has_key? ev.to_sym and not e_value[:enum_description][ev.to_sym].nil?
184
- ra[:documentation] += " (#{e_value[:enum_description][ev.to_sym]})\n"
185
- else
186
- ra[:documentation] += "\n"
187
- end
188
- end
189
- ra[:documentation] += "\n"
190
- end
191
- ra[:documentation] += "| | Generic product | Stackup | Profile defaults | Profile enforced | Profile restricted | Capabilities | Custom |\n"
192
- ra[:documentation] += "|-:|:---------------:|:-------:|:----------------:|:----------------:|:------------------:|:------------:|:------:|\n| **Use in:** | "
193
- [:in_product_generic, :in_product_stackup, :in_profile_default, :in_profile_enforced, :in_profile_restricted, :in_capabilities, :in_custom].each do |part|
194
- e_value[part] ? ra[:documentation] += "Allowed | " : ra[:documentation] += "Disallowed | "
195
- end
196
- ra[:documentation] += "\n|**Format:** | #{e_value[:type]} | #{e_value[:type]} | #{e_value[:type]} | #{e_value[:type]} | Array of #{e_value[:type]}s | Array of #{e_value[:type]}s | Array of #{e_value[:type]}s |\n"
197
- if e_value[:enum].nil? and e_value[:type] == "number"
198
- ra[:documentation] += "|**Min value:** | #{e_value[:minimum]} | #{e_value[:minimum]} | #{e_value[:minimum]} | #{e_value[:minimum]} | Each item: #{e_value[:minimum]} | Each item: #{e_value[:minimum]} | Each item: #{e_value[:minimum]} |\n" unless e_value[:minimum].nil?
199
- ra[:documentation] += "|**Max value:** | #{e_value[:maximum]} | #{e_value[:maximum]} | #{e_value[:maximum]} | #{e_value[:maximum]} | Each item : #{e_value[:maximum]} | Each item: #{e_value[:maximum]} | Each item: #{e_value[:maximum]} |\n" unless e_value[:maximum].nil?
200
- end
201
- ra[:documentation] += "\n"
202
- end
203
- end
204
- return ra[:documentation]
205
- end
206
-
207
- end