circuitdata 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cee57a28b38b2f4e09b6e27af0140b0d6bfe02287ec8e6452519c7f4106e9d84
4
- data.tar.gz: 02ed3d0c396aab1df49448c3ee9f78977ff16c7483384240b94729178068710b
3
+ metadata.gz: c49e6b15e75ca8c402c0807a9d241ba30cd9dd207c125fe3f1f6ae87da303960
4
+ data.tar.gz: cd912f52fb9c29398623954865938385f44a20fe0e1135d439d1a99e667c85f3
5
5
  SHA512:
6
- metadata.gz: acd38a087dcfe90a368ab15d491f272cc00af1b9addc9749723e80cd626e766b5ed01aa92e87df54b38565b25c0ebf73666fd4085f3c8af1f93b7d7a23ddc57a
7
- data.tar.gz: 87eb841eb3ab9d350f8e1bc7f7278b450771f278cc9c0713527c16bab3e9097c2c916cfe1e60106e12717b9d26fc00bb9c5f929f9a9a0a4fb09c281c09f84468
6
+ metadata.gz: 547b8febd516827f0c4c91b4d5849d7f36d0b5683a5ea2bed706c33a882568ad05859a88c049fc788e0a99d90dd37df215f75bdd6c9b9e0bc577a133102804f9
7
+ data.tar.gz: a052c9c068b168c7316c4763a17bde9d2298c15484a4502f870e292ca4bb51e342d04a12cbdcd668886cd1d4b8b2e89f4dcc01aabb43aad186fb5d757213d20c
@@ -5,30 +5,20 @@ module Circuitdata
5
5
  @product = product
6
6
  end
7
7
 
8
- def exposed_copper_area
8
+ def final_finish_total_area
9
9
  return nil if board_area.nil?
10
- exposed_layer_copper_area+barrel_area
10
+ layer_final_finish_area+barrel_area
11
11
  end
12
12
 
13
13
  def barrel_area
14
14
  return 0 if board_thickness.nil?
15
- plated_through_holes.map{ |hole| sum_holes_area(hole)}.sum
15
+ plated_holes.map{ |hole| sum_holes_area(hole)}.sum
16
16
  end
17
17
 
18
18
  private
19
19
 
20
- def exposed_layer_copper_area
21
- coverage = []
22
- unless top_final_finish.nil?
23
- if top_final_finish[:coverage].is_a? Numeric
24
- coverage << top_final_finish[:coverage]
25
- end
26
- end
27
- unless bottom_final_finish.nil?
28
- if bottom_final_finish[:coverage].is_a? Numeric
29
- coverage << bottom_final_finish[:coverage]
30
- end
31
- end
20
+ def layer_final_finish_area
21
+ coverage = final_finish_layers.map{ |layer| layer[:coverage]}.compact
32
22
  coverage.map{ |percent| percent/100.0*board_area}.sum
33
23
  end
34
24
 
@@ -50,35 +40,32 @@ module Circuitdata
50
40
  @product.question_answer([:metrics, :board, :area])
51
41
  end
52
42
 
53
- def plated_through_holes
54
- @product.processes
55
- .select{|process| process[:function] == "holes"}
56
- .select{|process| process[:function_attributes][:plated] == true}
57
- .select{|process| process[:function_attributes][:hole_type] == "through"}
58
- .select{|process| process[:function_attributes][:number_of_holes].present?}
59
- .select{|process| process[:function_attributes][:finished_size].present?}
43
+ def plated_holes
44
+ holes.select{ |process| requires_final_finish?(process) }
45
+ .select{ |process| has_necessary_data?(process) }
60
46
  end
61
47
 
62
- def layers
63
- @product.layers
48
+ def requires_final_finish?(process)
49
+ process[:function_attributes][:plated] == true &&
50
+ process[:function_attributes][:covered] == false
51
+ end
52
+
53
+ def has_necessary_data?(process)
54
+ process[:function_attributes][:number_of_holes].present? &&
55
+ process[:function_attributes][:finished_size].present?
64
56
  end
65
57
 
66
- def top_final_finish
67
- return nil if conductive_final_finish_layers.first.nil?
68
- return nil if conductive_final_finish_layers.first[:function] != "final_finish"
69
- conductive_final_finish_layers.first
58
+ def holes
59
+ @product.processes
60
+ .select{|process| process[:function] == "holes"}
70
61
  end
71
62
 
72
- def bottom_final_finish
73
- return nil if conductive_final_finish_layers.last.nil?
74
- return nil if conductive_final_finish_layers.last[:function] != "final_finish"
75
- conductive_final_finish_layers.last
63
+ def layers
64
+ @product.layers
76
65
  end
77
66
 
78
- # We are using the knowledge that at least one conductive layer must
79
- # be present to separate the top and bottom solder masks from each other.
80
- def conductive_final_finish_layers
81
- layers.select{ |layer| ["conductive", "final_finish"].include?(layer[:function]) }
67
+ def final_finish_layers
68
+ layers.select{ |layer| layer[:function] == "final_finish" }
82
69
  end
83
70
  end
84
71
  end
@@ -90,10 +90,10 @@ module Circuitdata
90
90
  product_data.fetch(:metrics, {})
91
91
  end
92
92
 
93
- def exposed_copper
94
- exposed_area.exposed_copper_area
93
+ def final_finish_total_area
94
+ exposed_area.final_finish_total_area
95
95
  end
96
-
96
+
97
97
  def product_data_path
98
98
  [:open_trade_transfer_package, :products, id.to_sym, :circuitdata]
99
99
  end
@@ -1,4 +1,4 @@
1
1
  module Circuitdata
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  SCHEMA_VERSION = 1.0
4
4
  end
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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Lydersen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-01-30 00:00:00.000000000 Z
13
+ date: 2019-02-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json-schema