kicad 0.9.3 → 0.9.5

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: 9d8cfc291b0619e083673bc0239c3423c6fc9decd02348d91e99ce884dd24d39
4
+ data.tar.gz: df0a12ac2396bbb27f4c843e76f6c7004e8ffd8e3577c4e824be32d8717b7d91
5
5
  SHA512:
6
- metadata.gz: 44681ff57b45bebeea66e8a0dc92932e8219354dd2545e2dd4a9b4feb614aa7d2d528aff3946875c4373ff701e95015961e7865d0cc12a527404b84d29ae4b74
7
- data.tar.gz: f2af698d30cd4b24a700a03a937f7a7a6c9913250c63aa99b3d75828191bb7d589d6fa06acd4a342f66c7d8a585d48ed8487aa0d1059e69a70262b2ce0da54cc
6
+ metadata.gz: a1907a0652b06784809b3f5c1692c2cd46f187bf0178e1389597e1f56a1142ac66d0772b1964e2b5fa4eda7ffe4ec80c38b34522188b5644d83c310550ed0fb8
7
+ data.tar.gz: 7b268bcc9684f36967f36b205a93706128589261cddf51abea86de5dd55b71a431fd2a25b2de6d5da2d6f2b561901669f3f46f8ab925ae72fdc2af05b674ed26
data/README.md CHANGED
@@ -1,18 +1,25 @@
1
1
  # KiCad
2
2
 
3
- Parse, load, modify and rewrite Kicad (s-epression) files into a convenient tree structure for scripting
3
+ Parse, load, modify and rewrite Kicad (s-expression) files into a convenient tree structure for scripting
4
4
 
5
5
  ## Installation
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')&.hidden = 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
@@ -190,18 +190,14 @@ module KiCad
190
190
  child_types :at, :effects
191
191
 
192
192
  # Set or clear (hide) on the property_node
193
- def hide=(h = true)
193
+ def hidden=(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
 
@@ -368,12 +364,12 @@ module KiCad
368
364
  end
369
365
 
370
366
  class PinNumbers < Node
371
- value_types :hide => [:no, :yes]
367
+ # This is a child node, not as documented (a value in https://dev-docs.kicad.org/en/file-formats/sexpr-intro/)
368
+ child_types :hide
372
369
  end
373
370
 
374
371
  class PinNames < Node
375
- child_types :offset
376
- value_types :hide => [:no, :yes]
372
+ child_types :offset, :hide
377
373
  end
378
374
 
379
375
  class InBom < Node
data/lib/kicad/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module KiCad
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.5"
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.5
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-11 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler