circuitdata 0.3.2 → 0.3.4

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: 6737f68c923e293cb0a8f34cc823bbd8a8720c86
4
- data.tar.gz: b61c1e55d6bc2f5f36ee2888e8a58088d8ce1274
3
+ metadata.gz: de1c4f538c68286e354093ef876042e3cc143d2f
4
+ data.tar.gz: f70c19817d410e8315a355e20ac957a3bc2f55e3
5
5
  SHA512:
6
- metadata.gz: 90dbfb96febaa796148c4cc482ffebc0e86f3d9f7605bce7091f751886c50ceafe01a21d50d3fa36f4c68a24ec65c9252f5d42d5ab8571369bdada961a041128
7
- data.tar.gz: efbc9ae9681288f4b8ada2791062cda1c9ff29ee2f0505145a97c9ac3c24431bf0f879fee47ebe0ac0ede169e251a01e57735283bf07c058c63df756ce5087d4
6
+ metadata.gz: 4de909b65a9d98b88b200b812edb5b61a921766f2f3b7198bcf332c82fcf953d4bd8734d029542a778525c31595ced1c7f6bb5dc248fc6e27726a7f1b468bade
7
+ data.tar.gz: aa828cbea7219133c8e20c72d9a54f2afdeaa44f21b61a3c27c15477c02485a5ec9c3a6482a1e08219a58ddf059ec25553ffaa57eea213a116dc82c280cdb08b
data/lib/circuitdata.rb CHANGED
@@ -2,7 +2,7 @@ module Circuitdata
2
2
 
3
3
 
4
4
  def self.content(checksjson)
5
- product = false
5
+ number_of_products = 0
6
6
  stackup = false
7
7
  profile_defaults = false
8
8
  profile_enforced = false
@@ -11,7 +11,7 @@ module Circuitdata
11
11
  if checksjson.has_key? "open_trade_transfer_package"
12
12
  if checksjson["open_trade_transfer_package"].has_key? "products"
13
13
  if checksjson["open_trade_transfer_package"]["products"].length > 0
14
- product = true
14
+ number_of_products = checksjson["open_trade_transfer_package"]["products"].length
15
15
  checksjson["open_trade_transfer_package"]["products"].each do |key, value|
16
16
  if checksjson["open_trade_transfer_package"]["products"][key].has_key? "stackup"
17
17
  if checksjson["open_trade_transfer_package"]["products"][key]["stackup"].has_key? "specification_level"
@@ -50,7 +50,7 @@ module Circuitdata
50
50
  end
51
51
  end
52
52
  end
53
- return product, stackup, profile_defaults, profile_restricted, profile_enforced, capabilities
53
+ return number_of_products, stackup, profile_defaults, profile_restricted, profile_enforced, capabilities
54
54
  end
55
55
 
56
56
  def self.read_json(content)
@@ -63,7 +63,7 @@ module Circuitdata
63
63
  returncontent = nil
64
64
  if content.is_a? Hash
65
65
  begin
66
- returncontent = JSON.parse(content)
66
+ returncontent = content.to_json
67
67
  rescue
68
68
  error = true
69
69
  message = "Could not convert the Hash into JSON"
@@ -114,7 +114,30 @@ module Circuitdata
114
114
  end
115
115
  end
116
116
  return error, message, validationserrors
117
+ end
117
118
 
119
+ def self.compare_files(list)
120
+ # Will presume that the files are validated
121
+ # Prepare the return
122
+ ra = {
123
+ error: false,
124
+ errormessage: "",
125
+ summary: {},
126
+ conflicts: {},
127
+ files: []
128
+ }
129
+ if not list.is_a? Array
130
+ ra[:error] = true
131
+ ra[:errormessage] = "You have to feed this function with a list of files or hashes"
132
+ return ra
133
+ end
134
+ list.each do |totest|
135
+ error, message, returncontent = self.read_json(totest)
136
+ #puts returncontent
137
+ ra[:summary] = ra[:summary].merge(returncontent)
138
+ ra[:files] << totest
139
+ end
140
+ return ra
118
141
  end
119
142
 
120
143
  def self.compatibility_checker( productfile, checksfile=nil, validate_origins=true )
@@ -135,7 +158,7 @@ module Circuitdata
135
158
  capabilitieserrors: {},
136
159
  contains: {
137
160
  file1: {
138
- product: false,
161
+ products: 0,
139
162
  stackup: false,
140
163
  profile_defaults: false,
141
164
  profile_enforced: false,
@@ -143,7 +166,7 @@ module Circuitdata
143
166
  capabilities: false
144
167
  },
145
168
  file2: {
146
- product: false,
169
+ products: 0,
147
170
  stackup: false,
148
171
  profile_defaults: false,
149
172
  profile_enforced: false,
@@ -173,9 +196,9 @@ module Circuitdata
173
196
  end
174
197
 
175
198
  # Check against the content
176
- returnarray[:contains][:file1][:product], returnarray[:contains][:file1][:stackup], returnarray[:contains][:file1][:profile_defaults], returnarray[:contains][:file1][:profile_restricted], returnarray[:contains][:file1][:profile_enforced], returnarray[:contains][:file1][:capabilities] = self.content(json_productfile)
199
+ returnarray[:contains][:file1][:products], returnarray[:contains][:file1][:stackup], returnarray[:contains][:file1][:profile_defaults], returnarray[:contains][:file1][:profile_restricted], returnarray[:contains][:file1][:profile_enforced], returnarray[:contains][:file1][:capabilities] = self.content(json_productfile)
177
200
  if not checksfile.nil?
178
- returnarray[:contains][:file2][:product], returnarray[:contains][:file2][:stackup], returnarray[:contains][:file2][:profile_defaults], returnarray[:contains][:file2][:profile_restricted], returnarray[:contains][:file2][:profile_enforced], returnarray[:contains][:file2][:capabilities] = self.content(json_checksfile)
201
+ returnarray[:contains][:file2][:products], returnarray[:contains][:file2][:stackup], returnarray[:contains][:file2][:profile_defaults], returnarray[:contains][:file2][:profile_restricted], returnarray[:contains][:file2][:profile_enforced], returnarray[:contains][:file2][:capabilities] = self.content(json_checksfile)
179
202
  end
180
203
 
181
204
  if not checksfile.nil?
@@ -1,3 +1,3 @@
1
1
  module Circuitdata
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circuitdata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Lydersen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-05 00:00:00.000000000 Z
11
+ date: 2017-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema