kut 0.1.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.
Files changed (40) hide show
  1. data/LICENSE.rdoc +6 -0
  2. data/README.rdoc +20 -0
  3. data/Rakefile.rb +63 -0
  4. data/bin/kut +27 -0
  5. data/doc-src/PINS.rdoc +18 -0
  6. data/examples/example_helper.rb +1 -0
  7. data/examples/net_list/print_cmp_list.rb +101 -0
  8. data/examples/pins/A3P1000_PQFP208.pins +216 -0
  9. data/examples/pins/AT32UC3A0512.pins +151 -0
  10. data/examples/pins/EMP7464S_TQFP100.pins +101 -0
  11. data/examples/pins/ata40conn.pins +44 -0
  12. data/examples/pins/full_sata.pins +25 -0
  13. data/examples/pins/jm20330.pins +85 -0
  14. data/lib/kut.rb +2 -0
  15. data/lib/kut/application.rb +56 -0
  16. data/lib/kut/commands/gost/bom2el_list.rb +171 -0
  17. data/lib/kut/commands/help-cmd.rb +32 -0
  18. data/lib/kut/commands/lib-gen-cmd.rb +88 -0
  19. data/lib/kut/commands/net_list2bom.rb +81 -0
  20. data/lib/kut/eeschema/wire.rb +3 -0
  21. data/lib/kut/kut_module.rb +18 -0
  22. data/lib/kut/library/components.rb +167 -0
  23. data/lib/kut/library/generator.rb +25 -0
  24. data/lib/kut/library/generator/default.rb +123 -0
  25. data/lib/kut/library/generator/gost-con.rb +116 -0
  26. data/lib/kut/library/generator/simple.rb +123 -0
  27. data/lib/kut/library/pins_reader.rb +47 -0
  28. data/lib/kut/library/regexp.rb +18 -0
  29. data/lib/kut/misc/matrix.rb +2 -0
  30. data/lib/kut/misc/point.rb +25 -0
  31. data/lib/kut/misc/rectangle.rb +20 -0
  32. data/lib/kut/net_list/concept.rb +20 -0
  33. data/lib/kut/net_list/kicad.rb +40 -0
  34. data/lib/kut/net_list/pcad.rb +69 -0
  35. data/lib/kut/tests/Rakefile.rb +0 -0
  36. data/lib/kut/tests/rectangle.rb +23 -0
  37. data/test/library_cmp_pin_test.rb +16 -0
  38. data/test/library_pins_reader_test.rb +40 -0
  39. data/test/point_test.rb +17 -0
  40. metadata +100 -0
@@ -0,0 +1,2 @@
1
+ class Matrix
2
+ end
@@ -0,0 +1,25 @@
1
+ class Point
2
+
3
+ attr_accessor :x, :y
4
+
5
+ def initialize(x = 0, y = 0)
6
+ @x = x
7
+ @y = y
8
+ end
9
+
10
+ def Point.[](x = 0, y = 0)
11
+ return Point.new(x, y)
12
+ end
13
+
14
+ def +(pt)
15
+ return Point[@x + pt.x, @y + pt.y]
16
+ end
17
+
18
+ def -(pt)
19
+ return Point[@x - pt.x, @y - pt.y]
20
+ end
21
+
22
+ def ==(pt)
23
+ (pt.x == @x) && (pt.y == @y) ? true : false
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ class Rectangle
2
+ attr_accessor :x, :y, :w, :h
3
+
4
+ def initialize(x = 0, y = 0, w = 0, h = 0)
5
+ @x = x
6
+ @y = y
7
+ @w = w
8
+ @h = h
9
+ end
10
+
11
+ def &(rt)
12
+ end
13
+
14
+ =begin
15
+ return true if rect contains point pt
16
+ =end
17
+ def contains?(pt)
18
+ pt.x.between?(@x, @x + w) && pt.y.between?(@y, @y + h)
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Kut
2
+ module NetList
3
+ class NetListCocept
4
+ def initialize (f_in)
5
+ #read f_in by each_line
6
+ end
7
+
8
+ def by_components
9
+ # return array of cmp_object
10
+ # where cmp_object
11
+ # def reference - C15
12
+ # def value - 0.1uF
13
+ # def footprint - 0805
14
+ # def nets - array of {:net => 'GND', :pin => '1' }
15
+ #
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,40 @@
1
+ require 'ostruct'
2
+
3
+ module Kut
4
+ module NetList
5
+ class KiCadNetList
6
+ def initialize(f_in = nil)
7
+ @components = []
8
+ load(f_in) if f_in
9
+ end
10
+
11
+ def load(f_in)
12
+ cur_component = nil
13
+ f_in.each_line { |line|
14
+ #puts line
15
+ #( /4A5F296D con-yamaichi-cf-2-CF050P2 X4 CF050P2 {Lib=CF050P2}
16
+ if mh = /^\s+\(\s+\/([\dABCDEF]{8})\s+(\S*)\s+(\S*)\s+(\S*)\s+/.match(line)
17
+ cur_component = OpenStruct.new
18
+ cur_component.reference = mh[3]
19
+ cur_component.footprint = mh[2]
20
+ cur_component.value = mh[4]
21
+ cur_component.nets = []
22
+ end
23
+
24
+ if /^\s+\)/ =~ line
25
+ @components << cur_component if cur_component
26
+ cur_component = nil
27
+ end
28
+
29
+ if cur_component && (mh = /^\s+\(\s+(\S+)\s+(\S+)\s+\)/.match(line))
30
+ cur_component.nets << { :net => mh[2], :pin => mh[1]} if cur_component
31
+ end
32
+ }
33
+ end
34
+
35
+ def by_components
36
+ return @components
37
+ end
38
+ end
39
+ end # end module NetList
40
+ end # end module Kut
@@ -0,0 +1,69 @@
1
+ require 'ostruct'
2
+
3
+ module Kut
4
+ module NetList
5
+ class PCadNetList
6
+ def initialize(f_in = nil)
7
+ @components = []
8
+ load(f_in) if f_in
9
+ end
10
+
11
+ def load(f_in)
12
+ components = {}
13
+ cur_cmp = nil
14
+ cur_net = nil
15
+ f_in.each_line { |line|
16
+
17
+ if mh = /^\s*\(compInst\s*\"([^\"]*)\"/.match(line)
18
+ ref = mh[1]
19
+ cur_cmp = components[ref]
20
+ unless cur_cmp then
21
+ cur_cmp = OpenStruct.new
22
+ cur_cmp.reference = ref
23
+ cur_cmp.nets = []
24
+ components[ref] = cur_cmp
25
+ end
26
+ end
27
+
28
+ if (mh = /^\s*\(compValue\s*\"([^\"]*)\"/.match(line)) && cur_cmp
29
+ cur_cmp.value = mh[1]
30
+ end
31
+
32
+ if (mh = /^\s*\(originalName\s*\"([^\"]*)\"/.match(line)) && cur_cmp
33
+ cur_cmp.footprint = mh[1]
34
+ end
35
+
36
+ #(originalName "IDC2.54-V16C")
37
+
38
+ if mh = /^\s*\(net\s\"([^\"]*)\"/.match(line)
39
+ cur_net = mh[1]
40
+ end
41
+
42
+ if (mh = /^\s*\(node\s+\"([^\"]*)\"\s+\"([^\"]*)\"\s*\)/.match(line)) && cur_net
43
+ ref = mh[1]
44
+ cmp = components[ref]
45
+ unless cmp then
46
+ cmp = OpenStruct.new
47
+ cmp.reference = ref
48
+ cmp.nets = []
49
+ components[ref] = cmp
50
+ end
51
+
52
+ cmp.nets << {:net => cur_net, :pin => mh[1]}
53
+ end
54
+
55
+ if /^\s*\)/ =~ line
56
+ cur_cmp = nil
57
+ cur_net = nil
58
+ end
59
+ }
60
+
61
+ @components = components.values
62
+ end
63
+
64
+ def by_components
65
+ return @components
66
+ end
67
+ end
68
+ end # end module NetList
69
+ end # end module Kut
File without changes
@@ -0,0 +1,23 @@
1
+ require 'test/unit'
2
+ require 'misc/rectangle'
3
+
4
+ class Point_Test < Test::Unit::TestCase
5
+ # def setup
6
+ # end
7
+
8
+ # def teardown
9
+ # end
10
+
11
+ def test_compare
12
+ assert(true, Point[1,2] == Point[1, 2])
13
+ assert(true, Point[1,2] != Point[2, 2])
14
+ end
15
+
16
+ def test_sum
17
+ assert(true, Point[-1,2] == (Point[0, 3] + Point[-1, -1]))
18
+ end
19
+
20
+ def test_sub
21
+ assert(true, Point[1,4] == (Point[0, 3] - Point[-1, -1]))
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ require 'test/unit'
2
+ require 'kut/library/components'
3
+ require 'kut/library/regexp'
4
+
5
+ class LibraryCmpPin_Test < Test::Unit::TestCase
6
+
7
+ def test_default_initialize
8
+ assert(Kut::Library::Pin.new.to_s() =~ Kut::Library::RegExp::PIN_EXP)
9
+ end
10
+
11
+ def test_initialize
12
+ assert(Kut::Library::Pin.new(:name => 'PL2303', :orientation => 'U').to_s() =~ Kut::Library::RegExp::PIN_EXP)
13
+ assert($1 == 'PL2303')
14
+ assert($6 == 'U')
15
+ end
16
+ end
@@ -0,0 +1,40 @@
1
+ require 'test/unit'
2
+ require 'kut/library/pins_reader'
3
+
4
+ class LibraryPinsReader_Test < Test::Unit::TestCase
5
+
6
+ PINS_FILE = <<EOFS
7
+ #NAMES NAME1, NAME2 , NONAME
8
+ #REF DA
9
+ 1 VCC
10
+ 2 GND
11
+
12
+ #TOP
13
+ 3 3PIN
14
+ #NO-PIN
15
+ 4 4PIN
16
+
17
+ #LEFT
18
+ 5 5PIN
19
+
20
+ #RIGHT
21
+ 6 6PIN
22
+
23
+ #BOTTOM
24
+ S23 S23PIN
25
+ S1 S1PIN
26
+
27
+ EOFS
28
+
29
+ def test_parse
30
+ res = Kut::Library::PinsParser.parse(PINS_FILE)
31
+ assert(res.reference == 'DA')
32
+ assert(res.names == ['NAME1', 'NAME2', 'NONAME'], 'Names mismatch.')
33
+ assert(res.other_pins == [['VCC', '1'], ['GND', '2']])
34
+ assert(res.top_pins == [['3PIN', '3'], nil, ['4PIN', '4']])
35
+ assert(res.left_pins == [['5PIN', '5']])
36
+ assert(res.right_pins == [['6PIN', '6']])
37
+ assert(res.bottom_pins == [['S23PIN', 'S23'], ['S1PIN', 'S1']])
38
+ end
39
+
40
+ end
@@ -0,0 +1,17 @@
1
+ require 'test/unit'
2
+ require 'kut/misc/point'
3
+
4
+ class Point_Test < Test::Unit::TestCase
5
+ def test_compare
6
+ assert(true, Point[1,2] == Point[1, 2])
7
+ assert(true, Point[1,2] != Point[2, 2])
8
+ end
9
+
10
+ def test_sum
11
+ assert(true, Point[-1,2] == (Point[0, 3] + Point[-1, -1]))
12
+ end
13
+
14
+ def test_sub
15
+ assert(true, Point[1,4] == (Point[0, 3] - Point[-1, -1]))
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kut
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexey Pavlyukov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-24 00:00:00 +04:00
13
+ default_executable: kut
14
+ dependencies: []
15
+
16
+ description:
17
+ email: lexaficus@list.ru
18
+ executables:
19
+ - kut
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - examples/net_list
26
+ - examples/net_list/print_cmp_list.rb
27
+ - examples/pins
28
+ - examples/pins/jm20330.pins
29
+ - examples/pins/AT32UC3A0512.pins
30
+ - examples/pins/EMP7464S_TQFP100.pins
31
+ - examples/pins/ata40conn.pins
32
+ - examples/pins/A3P1000_PQFP208.pins
33
+ - examples/pins/full_sata.pins
34
+ - examples/example_helper.rb
35
+ - lib/kut.rb
36
+ - lib/kut
37
+ - lib/kut/application.rb
38
+ - lib/kut/eeschema
39
+ - lib/kut/eeschema/wire.rb
40
+ - lib/kut/net_list
41
+ - lib/kut/net_list/concept.rb
42
+ - lib/kut/net_list/kicad.rb
43
+ - lib/kut/net_list/pcad.rb
44
+ - lib/kut/misc
45
+ - lib/kut/misc/matrix.rb
46
+ - lib/kut/misc/point.rb
47
+ - lib/kut/misc/rectangle.rb
48
+ - lib/kut/kut_module.rb
49
+ - lib/kut/tests
50
+ - lib/kut/tests/Rakefile.rb
51
+ - lib/kut/tests/rectangle.rb
52
+ - lib/kut/commands
53
+ - lib/kut/commands/gost
54
+ - lib/kut/commands/gost/bom2el_list.rb
55
+ - lib/kut/commands/help-cmd.rb
56
+ - lib/kut/commands/lib-gen-cmd.rb
57
+ - lib/kut/commands/net_list2bom.rb
58
+ - lib/kut/library
59
+ - lib/kut/library/pins_reader.rb
60
+ - lib/kut/library/components.rb
61
+ - lib/kut/library/regexp.rb
62
+ - lib/kut/library/generator
63
+ - lib/kut/library/generator/simple.rb
64
+ - lib/kut/library/generator/default.rb
65
+ - lib/kut/library/generator/gost-con.rb
66
+ - lib/kut/library/generator.rb
67
+ - Rakefile.rb
68
+ - doc-src/PINS.rdoc
69
+ - ./README.rdoc
70
+ - ./LICENSE.rdoc
71
+ has_rdoc: false
72
+ homepage:
73
+ post_install_message:
74
+ rdoc_options:
75
+ - --charset=utf-8
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ version:
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ requirements: []
91
+
92
+ rubyforge_project:
93
+ rubygems_version: 1.3.1
94
+ signing_key:
95
+ specification_version: 2
96
+ summary: KiCAD utils & tools for generation, manipulation KiCAD files.
97
+ test_files:
98
+ - test/library_cmp_pin_test.rb
99
+ - test/library_pins_reader_test.rb
100
+ - test/point_test.rb