mirror of
https://github.com/rsheldiii/KeyV2.git
synced 2025-09-13 15:49:50 +00:00
remove models directory and switch to generating them via script
This commit is contained in:
parent
c8b4011fac
commit
dc9b2a5aa6
8 changed files with 98 additions and 39 deletions
30
openscad.rb
Normal file
30
openscad.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
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|
|
||||
if line =~ /(include|use)\s*<(.*)>/
|
||||
# File.readlines("./#{$2}")
|
||||
expand("./#{$2}")
|
||||
# in lieu of actually implementing `use`, we can just cull this final line from key.scad
|
||||
elsif line =~ /example\_key\(\);/
|
||||
""
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue