KeyV2/openscad.rb
Bob 45940e8059 Fix up custimzer.scad
also add git post-commit hook to generate it, so I don't have to do this again
2020-04-24 19:51:43 -04:00

29 lines
580 B
Ruby

module OpenSCAD
def self.expand(filename)
lines = File.readlines(filename)
old_dir = Dir.getwd
Dir.chdir File.dirname(filename)
lines = lines.flat_map do |line|
# please note we do not implement `use` at all
if line =~ /(include|use)\s*<(.*)>/
# File.readlines("./#{$2}")
expand("./#{$2}")
else
line
end
end
Dir.chdir old_dir
lines
end
def self.expand_openSCAD_file(source, destination)
lines = OpenSCAD::expand(source)
f = File.open(destination, 'w')
f.write lines.join
end
end