joseph 0.1.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +97 -2
- data/.gitlab-ci.yml +21 -0
- data/.ruby-version +1 -0
- data/Gemfile +2 -2
- data/{MIT-LICENSE → LICENSE.txt} +3 -1
- data/README.md +33 -7
- data/Rakefile +4 -21
- data/examples/fiducials.rb +31 -0
- data/examples/panelize.rb +36 -0
- data/joseph.gemspec +25 -18
- data/lib/core_extensions/float/conversions.rb +13 -0
- data/lib/core_extensions/integer/conversions.rb +9 -0
- data/lib/joseph.rb +25 -29
- data/lib/joseph/aperture.rb +12 -0
- data/lib/joseph/bridge.rb +45 -0
- data/lib/joseph/cirseg.rb +11 -0
- data/lib/joseph/file_info.rb +17 -0
- data/lib/joseph/gdk_color.rb +35 -0
- data/lib/joseph/image.rb +143 -0
- data/lib/joseph/image_info.rb +25 -0
- data/lib/joseph/knockout.rb +13 -0
- data/lib/joseph/layer.rb +11 -0
- data/lib/joseph/net.rb +38 -0
- data/lib/joseph/project.rb +87 -0
- data/lib/joseph/render_info.rb +11 -0
- data/lib/joseph/render_size.rb +50 -0
- data/lib/joseph/step_and_repeat.rb +9 -0
- data/lib/joseph/user_transformation.rb +18 -0
- data/lib/joseph/version.rb +1 -1
- data/spec/assets/3_hat.boardoutline.ger +1628 -0
- data/spec/assets/3_hat.bottomlayer.ger +2038 -0
- data/spec/assets/3_hat.toplayer.ger +3103 -0
- data/spec/assets/test.EXTREP +20 -0
- data/spec/assets/test_wrong.GBL +20 -0
- data/spec/assets/vesc-capbank.topsilkscreen.ger +520 -0
- data/spec/bridge_spec.rb +10 -0
- data/spec/image_spec.rb +75 -0
- data/spec/project_spec.rb +48 -0
- data/spec/render_size_spec.rb +25 -0
- data/spec/results/bottomlayer_mirrored.png +0 -0
- data/spec/results/toplayer_as_png.png +0 -0
- data/spec/spec_helper.rb +16 -0
- metadata +172 -79
- data/Gemfile.lock +0 -26
- data/example.rb +0 -32
- data/spec/joseph_spec.rb +0 -32
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ec2a3944a1b9ca6248a276959433ea03c7c05844
|
4
|
+
data.tar.gz: 3f2cff40d93104f9d4fc62bd5a0e245a371b2633
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b9ad7c83e1670e8daab89cc10f88b1fcdf57ff907e80aca37da26984229a41799ecfa9255849347ad9900d2ef29a3dbb538ef8d1eae22c0ea5509c99b5178275
|
7
|
+
data.tar.gz: bfabbbc2458a14ebc65f60cfa757bb5531f6de6be51b52281b845c9402ef582f509e64099ed4c5c9368d4d103610b086463fafec3618d12ceb2df141a6cfc596
|
data/.gitignore
CHANGED
@@ -1,3 +1,98 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
# Created by https://www.gitignore.io/api/ruby,node,osx,linux
|
3
|
+
|
4
|
+
### Ruby ###
|
2
5
|
*.gem
|
3
|
-
|
6
|
+
*.rbc
|
7
|
+
/.config
|
8
|
+
/coverage/
|
9
|
+
/InstalledFiles
|
10
|
+
/pkg/
|
11
|
+
/spec/reports/
|
12
|
+
/spec/examples.txt
|
13
|
+
/test/tmp/
|
14
|
+
/test/version_tmp/
|
15
|
+
/tmp/
|
16
|
+
Gemfile.lock
|
17
|
+
.rbenv-vars
|
18
|
+
|
19
|
+
# Used by dotenv library to load environment variables.
|
20
|
+
# .env
|
21
|
+
|
22
|
+
## Specific to RubyMotion:
|
23
|
+
.dat*
|
24
|
+
.repl_history
|
25
|
+
build/
|
26
|
+
*.bridgesupport
|
27
|
+
build-iPhoneOS/
|
28
|
+
build-iPhoneSimulator/
|
29
|
+
|
30
|
+
## Specific to RubyMotion (use of CocoaPods):
|
31
|
+
#
|
32
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
33
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
34
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
35
|
+
#
|
36
|
+
# vendor/Pods/
|
37
|
+
|
38
|
+
## Documentation cache and generated files:
|
39
|
+
/.yardoc/
|
40
|
+
/_yardoc/
|
41
|
+
# /doc/
|
42
|
+
/rdoc/
|
43
|
+
|
44
|
+
## Environment normalization:
|
45
|
+
/.bundle/
|
46
|
+
/vendor/bundle
|
47
|
+
/lib/bundler/man/
|
48
|
+
|
49
|
+
# for a library or gem, you might want to ignore these files since the code is
|
50
|
+
# intended to run in multiple environments; otherwise, check them in:
|
51
|
+
# Gemfile.lock
|
52
|
+
# .ruby-version
|
53
|
+
# .ruby-gemset
|
54
|
+
|
55
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
56
|
+
.rvmrc
|
57
|
+
|
58
|
+
### OSX ###
|
59
|
+
*.DS_Store
|
60
|
+
.AppleDouble
|
61
|
+
.LSOverride
|
62
|
+
|
63
|
+
# Icon must end with two \r
|
64
|
+
Icon
|
65
|
+
|
66
|
+
|
67
|
+
# Thumbnails
|
68
|
+
._*
|
69
|
+
|
70
|
+
# Files that might appear in the root of a volume
|
71
|
+
.DocumentRevisions-V100
|
72
|
+
.fseventsd
|
73
|
+
.Spotlight-V100
|
74
|
+
.TemporaryItems
|
75
|
+
.Trashes
|
76
|
+
.VolumeIcon.icns
|
77
|
+
.com.apple.timemachine.donotpresent
|
78
|
+
|
79
|
+
# Directories potentially created on remote AFP share
|
80
|
+
.AppleDB
|
81
|
+
.AppleDesktop
|
82
|
+
Network Trash Folder
|
83
|
+
Temporary Items
|
84
|
+
.apdisk
|
85
|
+
|
86
|
+
|
87
|
+
### Linux ###
|
88
|
+
*~
|
89
|
+
|
90
|
+
# temporary files which can be created if a process still has a handle open of a deleted file
|
91
|
+
.fuse_hidden*
|
92
|
+
|
93
|
+
# KDE directory preferences
|
94
|
+
.directory
|
95
|
+
|
96
|
+
# Linux trash folder which might appear on any partition or disk
|
97
|
+
.Trash-*
|
98
|
+
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
before_script:
|
2
|
+
- ruby -v
|
3
|
+
- which ruby
|
4
|
+
- gem install bundler --no-ri --no-rdoc
|
5
|
+
- bundle install --jobs $(nproc) "${FLAGS[@]}"
|
6
|
+
|
7
|
+
stages:
|
8
|
+
- test
|
9
|
+
- deploy
|
10
|
+
|
11
|
+
|
12
|
+
rspec_job:
|
13
|
+
stage: test
|
14
|
+
script:
|
15
|
+
- bundle exec rspec
|
16
|
+
|
17
|
+
deploy_job:
|
18
|
+
stage: deploy
|
19
|
+
script:
|
20
|
+
- bundle exec rake build
|
21
|
+
- bundle exec gem inabox -g https://gems.aisler.net
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.3
|
data/Gemfile
CHANGED
data/{MIT-LICENSE → LICENSE.txt}
RENAMED
data/README.md
CHANGED
@@ -1,12 +1,38 @@
|
|
1
|
-
Joseph
|
2
|
-
======
|
1
|
+
# Joseph
|
3
2
|
|
4
|
-
|
3
|
+
Make working with gerber files great again! See [talk @ FOSDEM 2017](https://docs.google.com/presentation/d/1P0TlYbtU38EL7d7HRAupMRoa70ejif5nWAY0IsgneYI/edit?usp=sharing) for more information.
|
5
4
|
|
6
|
-
Named after [Joseph Finder](http://www.nytimes.com/1987/02/22/magazine/about-men-a-male-secretary.html?pagewanted=all).
|
7
5
|
|
8
|
-
License
|
9
|
-
=======
|
10
6
|
|
11
|
-
|
7
|
+
## Installation
|
12
8
|
|
9
|
+
Make sure gerbv is installed on your system.
|
10
|
+
|
11
|
+
### MacOS
|
12
|
+
```bash
|
13
|
+
brew install gerbv
|
14
|
+
```
|
15
|
+
|
16
|
+
### Debian / Ubuntu via apt-get
|
17
|
+
```bash
|
18
|
+
sudo apt-get install gerbv
|
19
|
+
```
|
20
|
+
|
21
|
+
Windows is not supported yet because of Ruby FF's missing support for this platform.
|
22
|
+
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
See examples directory. More specific examples coming soon.
|
26
|
+
|
27
|
+
## License
|
28
|
+
|
29
|
+
Joseph is Copyright © 2017 by AISLER B.V. It is free software, and may be
|
30
|
+
redistributed under the terms specified in the MIT-LICENSE file.
|
31
|
+
|
32
|
+
## About AISLER
|
33
|
+
|
34
|
+
![AISLER](https://cdn-2.aisler.net/assets/logo_invert_orange-7ca49b7abecdf2f857639df2c0de142889a9dc23d33af4b9f875db54c0bc417e.png)
|
35
|
+
|
36
|
+
Joseph is developed and funded by AISLER B.V.
|
37
|
+
|
38
|
+
Looking for industry quality and affordable PCBs, visit us at [AISLER GO](https://go.aisler.net)
|
data/Rakefile
CHANGED
@@ -1,24 +1,7 @@
|
|
1
|
-
require
|
2
|
-
Bundler.setup
|
3
|
-
|
1
|
+
require "bundler/gem_tasks"
|
4
2
|
require "rspec/core/rake_task"
|
5
3
|
|
6
|
-
|
7
|
-
|
8
|
-
desc "Run all examples"
|
9
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
10
|
-
t.rspec_opts = %w[--color]
|
11
|
-
t.verbose = false
|
12
|
-
end
|
13
|
-
|
14
|
-
desc("Open IRB console")
|
15
|
-
task :console do
|
16
|
-
require 'irb'
|
17
|
-
require 'irb/completion'
|
18
|
-
require 'joseph'
|
19
|
-
ARGV.clear
|
20
|
-
IRB.start
|
21
|
-
end
|
22
|
-
|
23
|
-
task :default => [:spec]
|
4
|
+
RSpec::Core::RakeTask.new
|
24
5
|
|
6
|
+
task :default => :spec
|
7
|
+
task :test => :spec
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'joseph'
|
3
|
+
|
4
|
+
# Create new project and load files
|
5
|
+
project = Joseph::Project.create
|
6
|
+
Dir.glob('./gerbers/*.ger').each { |file| project.add_file file, /\.([a-z]+)\.ger/.match(file)[1].to_sym }
|
7
|
+
|
8
|
+
# Use boardoutline layer as bounding box
|
9
|
+
bb = Joseph::RenderSize.from_image(project.file(:boardoutline).image)
|
10
|
+
|
11
|
+
fiducials = []
|
12
|
+
spacing = 0.05
|
13
|
+
diameter_copper = 0.03
|
14
|
+
diameter_soldermask = 0.05
|
15
|
+
# Copper layer
|
16
|
+
fiducials << { x: bb[:left] - spacing, y: bb[:bottom] + spacing, d: diameter_copper, layer: :toplayer }
|
17
|
+
fiducials << { x: bb[:right] + spacing, y: bb[:top] - spacing, d: diameter_copper, layer: :toplayer }
|
18
|
+
fiducials << { x: bb[:left] - spacing, y: bb[:top] - spacing, d: diameter_copper, layer: :toplayer }
|
19
|
+
# Soldermask layer
|
20
|
+
fiducials << { x: bb[:left] - spacing, y: bb[:bottom] + spacing, d: diameter_soldermask, layer: :topsoldermask }
|
21
|
+
fiducials << { x: bb[:right] + spacing, y: bb[:top] - spacing, d: diameter_soldermask, layer: :topsoldermask }
|
22
|
+
fiducials << { x: bb[:left] - spacing, y: bb[:top] - spacing, d: diameter_soldermask, layer: :topsoldermask }
|
23
|
+
|
24
|
+
fiducials.each do |fid|
|
25
|
+
Joseph::Bridge.gerbv_image_create_line_object(project.file(fid[:layer]).image, fid[:x], fid[:y], fid[:x], fid[:y], fid[:d], :circle)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Save output files
|
29
|
+
project.index.each do |k, ix|
|
30
|
+
FileUtils.cp(project.file(ix).image.to_output.file, "with_fiducial.#{k}.ger")
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'zip'
|
2
|
+
require 'joseph'
|
3
|
+
|
4
|
+
rows = 10
|
5
|
+
columns = 10
|
6
|
+
|
7
|
+
# Create new project and load files
|
8
|
+
project = Joseph::Project.create
|
9
|
+
Dir.glob('./*.ger').each { |file| project.add_file file, /\.([a-z]+)\.ger/.match(file)[1].to_sym }
|
10
|
+
|
11
|
+
# Use boardoutline layer as bounding box
|
12
|
+
bb = Joseph::RenderSize.from_image(project.file(:boardoutline).image)
|
13
|
+
|
14
|
+
# Create panel containing all images
|
15
|
+
panel = {}
|
16
|
+
project.index.each { |k, ix| panel[k] = Joseph::Image.create }
|
17
|
+
|
18
|
+
# Panelize!
|
19
|
+
rows.times do |row|
|
20
|
+
columns.times do |col|
|
21
|
+
transform = Joseph::UserTransformation.new
|
22
|
+
transform[:translate_x] = bb.width * col
|
23
|
+
transform[:translate_y] = bb.height * row
|
24
|
+
|
25
|
+
panel.each do |k, image|
|
26
|
+
image.add project.file(k).image, transform
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Build ZIP as output format
|
32
|
+
io = Zip::File.open('./panel.zip', Zip::File::CREATE)
|
33
|
+
panel.each do |k, image|
|
34
|
+
io.get_output_stream("panel.#{k}.ger") { |f| f.puts(image.to_output.data) }
|
35
|
+
end
|
36
|
+
io.close
|
data/joseph.gemspec
CHANGED
@@ -1,22 +1,29 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'joseph/version'
|
4
5
|
|
5
|
-
Gem::Specification.new do |
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "joseph"
|
8
|
+
spec.version = Joseph::VERSION
|
9
|
+
spec.authors = ["Patrick Franken", "AISLER B.V."]
|
10
|
+
spec.email = ["p.franken@aisler.net"]
|
11
|
+
spec.summary = "Make working with gerber files great again"
|
12
|
+
spec.description = "Read, modify and writer Gerber RS274X files with ruby using libgerbv bindings and some sugar."
|
13
|
+
spec.homepage = "http://aisler.net"
|
14
|
+
spec.license = "MIT"
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
spec.add_runtime_dependency 'ffi', '~> 1.9'
|
22
|
+
spec.add_runtime_dependency 'ramdo', '~> 0.2'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "geminabox"
|
28
|
+
spec.add_development_dependency "chunky_png"
|
22
29
|
end
|
data/lib/joseph.rb
CHANGED
@@ -1,32 +1,28 @@
|
|
1
|
-
require '
|
1
|
+
require 'pp'
|
2
|
+
require 'ffi'
|
3
|
+
require 'ramdo'
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
super
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def config
|
13
|
-
@config ||= OpenStruct.new
|
14
|
-
end
|
5
|
+
# Apply monkey patches
|
6
|
+
require 'core_extensions/float/conversions'
|
7
|
+
require 'core_extensions/integer/conversions'
|
8
|
+
Float.include CoreExtensions::Float::Conversions
|
9
|
+
Integer.include CoreExtensions::Integer::Conversions
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
require 'joseph/gdk_color'
|
12
|
+
require 'joseph/cirseg'
|
13
|
+
require 'joseph/render_size'
|
14
|
+
require 'joseph/render_info'
|
15
|
+
require 'joseph/net'
|
16
|
+
require 'joseph/user_transformation'
|
17
|
+
require 'joseph/aperture'
|
18
|
+
require 'joseph/knockout'
|
19
|
+
require 'joseph/step_and_repeat'
|
20
|
+
require 'joseph/layer'
|
21
|
+
require 'joseph/image_info'
|
22
|
+
require 'joseph/image'
|
23
|
+
require 'joseph/file_info'
|
24
|
+
require 'joseph/project'
|
25
|
+
require 'joseph/bridge'
|
19
26
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
# Lifted from http://github.com/stephencelis/app/blob/master/lib/app.rb#L69-76
|
25
|
-
def method_missing(method, *args, &block)
|
26
|
-
super if (key = method.to_s).end_with?("=")
|
27
|
-
boolean = key.chomp!("?")
|
28
|
-
value = self[key]
|
29
|
-
value = value.call(*args, &block) if value.respond_to?(:call)
|
30
|
-
boolean ? !!value : value
|
31
|
-
end
|
32
|
-
end
|
27
|
+
module Joseph
|
28
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Joseph
|
2
|
+
class Aperture < FFI::Struct
|
3
|
+
layout :type, :int,
|
4
|
+
:amacro, :pointer,
|
5
|
+
:simplified_amacro, :pointer,
|
6
|
+
:parameter_0, :double,
|
7
|
+
:parameter_1, :double,
|
8
|
+
:parameters, :double, FFI::Type::FLOAT.size * 102, # APERTURE_PARAMETERS_MAX
|
9
|
+
:nuf_parameters, :int,
|
10
|
+
:unit, :int
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Joseph
|
2
|
+
module Bridge
|
3
|
+
extend FFI::Library
|
4
|
+
ffi_lib 'libgerbv'
|
5
|
+
|
6
|
+
# http://gerbv.geda-project.org/doxygen/gerbv_8h.html#ac99303749c4afdc6a24eafbfa37e1237
|
7
|
+
enum :aptype, [:none, 1,
|
8
|
+
:circle,
|
9
|
+
:rectangle,
|
10
|
+
:oval,
|
11
|
+
:polygon,
|
12
|
+
:macro ]
|
13
|
+
|
14
|
+
# http://gerbv.geda-project.org/doxygen/index.html
|
15
|
+
attach_function :gerbv_create_project, [], Project.ptr
|
16
|
+
attach_function :gerbv_create_image, [:pointer, :pointer], Image.ptr
|
17
|
+
|
18
|
+
attach_function :gerbv_open_layer_from_filename, [:pointer, :string], :void
|
19
|
+
attach_function :gerbv_open_layer_from_filename_with_color, [:pointer, :string, :int, :int, :int, :int], :void
|
20
|
+
|
21
|
+
attach_function :gerbv_export_png_file_from_project, [:pointer, :pointer, :string], :void
|
22
|
+
attach_function :gerbv_export_png_file_from_project_autoscaled, [:pointer, :int, :int, :string], :void
|
23
|
+
attach_function :gerbv_export_svg_file_from_project_autoscaled, [:pointer, :string], :void
|
24
|
+
|
25
|
+
attach_function :gerbv_export_rs274x_file_from_image, [:string, :pointer, :pointer], :bool
|
26
|
+
attach_function :gerbv_export_drill_file_from_image, [:string, :pointer, :pointer], :bool
|
27
|
+
|
28
|
+
attach_function :gerbv_render_get_boundingbox, [:pointer, :pointer], :void
|
29
|
+
attach_function :gerbv_render_zoom_to_fit_display, [:pointer, :pointer], :void
|
30
|
+
|
31
|
+
attach_function :gerbv_image_copy_image, [:pointer, :pointer, :pointer], :void
|
32
|
+
attach_function :gerbv_image_duplicate_image, [:pointer, :pointer], Image.ptr
|
33
|
+
attach_function :gerbv_image_create_line_object, [:pointer, :double, :double, :double, :double, :double, :aptype], :void
|
34
|
+
attach_function :gerbv_image_create_arc_object, [:pointer, :double, :double, :double, :double, :double, :double, :aptype], :void
|
35
|
+
attach_function :gerbv_image_create_rectangle_object, [:pointer, :double, :double, :double, :double], :void
|
36
|
+
attach_function :gerbv_image_delete_net, [:pointer], :void
|
37
|
+
|
38
|
+
attach_function :gerbv_image_return_new_layer, [:pointer], Layer.ptr
|
39
|
+
attach_function :gerber_create_new_net, [:pointer, :pointer, :pointer], Net.ptr
|
40
|
+
|
41
|
+
attach_function :gerbv_destroy_project, [:pointer], :void
|
42
|
+
attach_function :gerbv_destroy_image, [:pointer], :void
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|