circuitdata 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,8 +47,48 @@
47
47
  }
48
48
  }
49
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
+ }
50
90
  }
51
91
  }
52
92
  }
53
93
  }
54
- }
94
+ }
@@ -7,6 +7,12 @@ class Circuitdata::Tools
7
7
  end
8
8
 
9
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
10
16
  parsed_elements = Circuitdata.read_json(@definitions_path)[2]
11
17
  unless @ra[:structured][:elements].has_key? key
12
18
  @ra[:structured][:elements][key] = {
@@ -36,10 +42,12 @@ class Circuitdata::Tools
36
42
  :in_profile_default => false,
37
43
  :in_profile_enforced => false,
38
44
  :in_profile_restricted => false,
45
+ :in_custom => false,
39
46
  :in_capabilities => false,
40
47
  :type => nil,
41
48
  :arrayitems => nil,
42
49
  :enum => nil,
50
+ :enum_description => nil,
43
51
  :description => nil,
44
52
  :uom => nil,
45
53
  :minimum => nil,
@@ -47,10 +55,12 @@ class Circuitdata::Tools
47
55
  }
48
56
  if svalue.has_key? :$ref
49
57
  elements = svalue[:$ref].split('/')
50
- if elements.length < 5
58
+ if elements.length == 4
51
59
  element = parsed_elements[elements[1].to_sym][elements[2].to_sym][elements[3].to_sym]
52
- else
60
+ elsif elements.length == 5
53
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]
54
64
  end
55
65
  else
56
66
  element = nil
@@ -68,7 +78,10 @@ class Circuitdata::Tools
68
78
  end
69
79
  end
70
80
  end
71
- @ra[:structured][:elements][key][:elements][skey][:enum] = element[:enum] if element.has_key? :enum
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
72
85
  @ra[:structured][:elements][key][:elements][skey][:description] = element[:description] if element.has_key? :description
73
86
  @ra[:structured][:elements][key][:elements][skey][:uom] = element[:uom] if element.has_key? :uom
74
87
  @ra[:structured][:elements][key][:elements][skey][:minimum] = element[:minimum] if element.has_key? :minimum
@@ -76,18 +89,25 @@ class Circuitdata::Tools
76
89
  end
77
90
  else
78
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
79
95
  case @ra[:structured][:elements][key][:elements][skey][:type]
80
96
  when *["number", "integer", "boolean", "string"]
81
97
  @ra[:structured][:elements][key][:elements][skey][:type] = "number" if @ra[:structured][:elements][key][:elements][skey][:type] == "integer"
82
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])
83
99
  (@ra[:errors][type][key] ||= {})[skey] = "Type is #{@ra[:structured][:elements][key][:elements][skey][:type]}, wrong check"
84
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
85
105
  when "array"
86
106
  unless svalue.has_key? :type and svalue[:type] == "array"
87
107
  (@ra[:errors][type][key] ||= {})[skey] = "Type is #{@ra[:structured][:elements][key][:elements][skey][:type]}, wrong check"
88
108
  end
89
109
  else
90
- puts "unknown type #{@ra[:structured][:elements][key][:elements][skey][:type]} in #{key}, #{skey} when doing #{type}"
110
+ (@ra[:errors][type][key] ||= {})[skey] = "Unknown type #{@ra[:structured][:elements][key][:elements][skey][:type]} in #{key}, #{skey} when doing #{type}"
91
111
  end
92
112
  end
93
113
  end
@@ -100,9 +120,11 @@ class Circuitdata::Tools
100
120
  @ra[:structured] = {:elements => {}, :custom => {}}
101
121
  @ra[:errors] = {:in_profile_restricted => {}, :in_capabilities => {}}
102
122
  parsed_schema = Circuitdata.read_json(@schema_path)[2]
123
+ # Go through all products
103
124
  parsed_schema[:properties][:open_trade_transfer_package][:properties][:products][:patternProperties]["^(?!generic$).*".to_sym][:properties][:printed_circuits_fabrication_data][:properties].each do |key, value|
104
125
  self.update_ra(:in_product_generic, key, value)
105
126
  end
127
+ # Go through all profiles
106
128
  ["defaults", "restricted", "enforced"].each do |sym|
107
129
  parsed_schema[:properties][:open_trade_transfer_package][:properties][:profiles][:properties][sym.to_sym][:properties][:printed_circuits_fabrication_data][:properties].each do |key, value|
108
130
  case sym
@@ -116,17 +138,23 @@ class Circuitdata::Tools
116
138
  self.update_ra(t, key, value)
117
139
  end
118
140
  end
141
+ # Go through all capabilities
119
142
  parsed_schema[:properties][:open_trade_transfer_package][:properties][:capabilities][:properties][:printed_circuits_fabrication_data][:properties].each do |key, value|
120
143
  self.update_ra(:in_capabilities, key, value)
121
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
+
122
150
  @ra[:structured][:elements].sort.to_h
123
151
  @ra[:structured][:elements].delete(:version)
124
-
152
+ @ra[:structured][:elements][:stackup].delete(:specified)
125
153
  return @ra
126
154
  end
127
155
 
128
156
  def create_documentation(ra)
129
- ra[:documentation] = "## Elements and tags\n====================\n\n"
157
+ ra[:documentation] = "## Elements and tags\n"
130
158
  ra[:structured][:elements].each do |element_key, element_value|
131
159
  ra[:documentation] += "### #{element_key} [link](##{element_key.to_s.downcase.tr(" ", "-")})\n"
132
160
  element_value[:elements].each do |e_key, e_value|
@@ -141,7 +169,7 @@ class Circuitdata::Tools
141
169
  ra[:documentation] += "#{element_value[:description]}\n" unless element_value[:description].nil?
142
170
  ra[:documentation] += "\n"
143
171
  if element_value[:type] == "array"
144
- ra[:documentation] += "**You must specify this as en array when used in a generic product description or a stackup, but as a single object when used in any of the other parts.**\n\n"
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"
145
173
  end
146
174
  element_value[:elements].each do |e_key, e_value|
147
175
  ra[:documentation] += "#### #{e_key}\n"
@@ -151,19 +179,24 @@ class Circuitdata::Tools
151
179
  if e_value.has_key? :enum and not e_value[:enum].nil?
152
180
  ra[:documentation] += "Use one of these values:\n"
153
181
  e_value[:enum].each do |ev|
154
- ra[:documentation] += "* #{ev}\n"
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
155
188
  end
156
189
  ra[:documentation] += "\n"
157
190
  end
158
- ra[:documentation] += "| | Generic product | Stackup | Profile defaults | Profile enforced | Profile restricted | Capabilities |\n"
159
- ra[:documentation] += "|-:|:---------------:|:-------:|:----------------:|:----------------:|:------------------:|:------------:|\n| **Use in:** | "
160
- [e_value[:in_product_generic], e_value[:in_product_stackup], e_value[:in_profile_default], e_value[:in_profile_enforced], e_value[:in_profile_restricted], e_value[:in_capabilities]].each do |part|
161
- part.nil? ? ra[:documentation] += "Disallowed | " : ra[:documentation] += "Allowed | "
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 | "
162
195
  end
163
- 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 |\n"
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"
164
197
  if e_value[:enum].nil? and e_value[:type] == "number"
165
- 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]} |\n" unless e_value[:minimum].nil?
166
- 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]} |\n" unless e_value[:maximum].nil?
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?
167
200
  end
168
201
  ra[:documentation] += "\n"
169
202
  end
@@ -1,3 +1,3 @@
1
1
  module Circuitdata
2
- VERSION = '0.6.3'
2
+ VERSION = '0.6.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circuitdata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Lydersen
8
+ - Maximilian Brosnahan
9
+ - Benjamin Mwendwa
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2017-10-16 00:00:00.000000000 Z
13
+ date: 2017-10-23 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: json-schema
@@ -66,8 +68,9 @@ dependencies:
66
68
  - - "~>"
67
69
  - !ruby/object:Gem::Version
68
70
  version: '4.2'
69
- description: This gem allows you to do basic test and comparison of JSON files agains
70
- the CircuitData JSON schema
71
+ description: This gem provides you with functions to work with the CricuitData language.
72
+ Run files against the schema, check their compatibility agains each other compare
73
+ multiple files to find conflicts.
71
74
  email:
72
75
  - andreas.lydersen@ntty.com
73
76
  executables: []
@@ -112,6 +115,6 @@ rubyforge_project:
112
115
  rubygems_version: 2.6.13
113
116
  signing_key:
114
117
  specification_version: 4
115
- summary: This gem allows you to do basic test and comparison of JSON files agains
116
- the CircuitData JSON schema
118
+ summary: Basic test and comparison of JSON files agains the CircuitData JSON schema
119
+ and each other
117
120
  test_files: []