kicad 0.9.3 → 0.9.4

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: 2a91d99c4c831dbc121717ef0609e05c8fe07c20d1b2044bfddda163c75c6620
4
- data.tar.gz: 9110254e21b4e2913160100ec75f2887ea327107a0fefb257a23e77a9dfba362
3
+ metadata.gz: '097aa1cbc02ed277cface17ac18f0ee277328b17be825a7ca45d4e63bd0d7e50'
4
+ data.tar.gz: 9bd0c4a1ee66de76c8f4036d88e2e1e77f472f13ec3d0fc00ad81e52d625d8cd
5
5
  SHA512:
6
- metadata.gz: 44681ff57b45bebeea66e8a0dc92932e8219354dd2545e2dd4a9b4feb614aa7d2d528aff3946875c4373ff701e95015961e7865d0cc12a527404b84d29ae4b74
7
- data.tar.gz: f2af698d30cd4b24a700a03a937f7a7a6c9913250c63aa99b3d75828191bb7d589d6fa06acd4a342f66c7d8a585d48ed8487aa0d1059e69a70262b2ce0da54cc
6
+ metadata.gz: 175c29e9a0d6fdd616b325c88cd5aa7e02e45735e13379356153814a8c02384486d0d998f79d4c580cf7621e07044552579547897ce32eb60bec310c5ed4622a
7
+ data.tar.gz: e42383f3dd059c3749e34ad48dd8201661930543d86ae15d50d8f4e1957be6293e7c0515b5b758d8e8233eb3132b4b1591a8548be251b8fc984de47d01854fed
data/README.md CHANGED
@@ -6,13 +6,20 @@ Parse, load, modify and rewrite Kicad (s-epression) files into a convenient tree
6
6
 
7
7
  gem install kicad
8
8
 
9
- ## Usage
9
+ ## Usage Example
10
+
11
+ For all parts with no PartNumber property, copy it from the Value field and make sure it's hidden:
10
12
 
11
13
  $ irb -r kicad
12
- irb(main):001> k = KiCad.load("my_file.kicad_sym").value
13
- irb(main):001> k.children.filter{|c| KiCad::AST::Symbol === c }.map{|c| c.values[1]}
14
- ["BC107", "CD4046"]
15
- irb(main):001> puts k.emit
14
+ irb(main):001> k = KiCad.load('mylib.kicad_sym').value
15
+ =>
16
+ #<KiCad::AST::KicadSymbolLib:0x00000001473f5488
17
+ ...
18
+ irb(main):002> k.all_symbol.each{|s| s['PartNumber'] = s.property('Value') unless s.property('PartNumber') }; nil
19
+ => nil
20
+ irb(main):003> k.all_symbol.each{|s| s.property_node('PartNumber')&.hide = true }
21
+ => nil
22
+ irb(main):001> File.open("rewrite.kicad_sym", "w") { |f| f.puts k.emit }
16
23
  ...
17
24
 
18
25
  ## Development
@@ -26,6 +33,10 @@ To install this gem onto your local machine from local source code, run `rake in
26
33
  KiCad uses a version of the Cadence SPECCTRA Design Language, defined in https://cdn.hackaday.io/files/1666717130852064/specctra.pdf
27
34
 
28
35
  KiCad's documentation of this is at https://dev-docs.kicad.org/en/file-formats/sexpr-intro/
36
+ The documentation is incomplete. This library contains some items as found in KiCad 9 symbol libraries,
37
+ and doesn't contain everything documented above, especially of those have not been found.
38
+ Best efforts - if you find a problem, you discovered why this is open source.
39
+ lib/kicad/asts.rb is your starting point for adding metedata.
29
40
 
30
41
  A related Rust library that was not consulted while building this is https://github.com/adom-inc/kicad_lib/tree/main/kicad_sexpr
31
42
 
data/lib/kicad/ast.rb CHANGED
@@ -192,16 +192,12 @@ module KiCad
192
192
  # Set or clear (hide) on the property_node
193
193
  def hide=(h = true)
194
194
  v = (h ? :yes : :no)
195
- if !effects
196
- # puts "No effects yet"
195
+ if !effects # No effects yet
197
196
  prop = KiCad.parse(%Q{(effects(hide #{v}))})&.value
198
197
  @children.append(prop) if prop
199
- elsif (existing = effects.hide)
200
- # puts "Effects and hide already"
198
+ elsif (existing = effects.hide) # Effects and hide already
201
199
  existing.hide = v
202
- else
203
- # Create new (hide) node:
204
- # puts "Effects but no hide"
200
+ else # Create new (hide) node
205
201
  prop = KiCad.parse(%Q{(hide #{v})})&.value
206
202
  @children.append(prop) if prop
207
203
  end
@@ -347,19 +343,19 @@ module KiCad
347
343
  end
348
344
 
349
345
  def []=(k, v)
350
- puts "Setting property #{k} to #{v.inspect}"
351
- if (p = property_node)
352
- p.send(:"#{self.class.to_symbol k}=", v)
346
+ # puts "Setting property #{k} to #{v.inspect}"
347
+ if (prop = property_node(k))
348
+ prop.value = v
353
349
  else # Create new Property using the parser:
354
350
  prop = KiCad.parse(%Q{
355
351
  (property "#{k}" #{String === v ? v.inspect : v.to_s}
356
352
  (at 0 0 0)
357
- (effects(font(size 1.27 1.27)))
358
- (hide yes)
353
+ (effects(font(size 1.27 1.27)) (hide yes))
359
354
  )
360
355
  })&.value
361
356
  @children.append(prop) if prop
362
357
  end
358
+ prop
363
359
  end
364
360
  end
365
361
 
data/lib/kicad/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module KiCad
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kicad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clifford Heath
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-09 00:00:00.000000000 Z
10
+ date: 2025-05-10 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler