oozby 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/oozby +72 -16
- data/lib/oozby/method_preprocessor.rb +16 -9
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 901a0884ebe9594a1996929a598c3c43953f0311
|
4
|
+
data.tar.gz: c067f37b25ff24e0393e83a5f356e9c371924471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5967a2df6372a8466412595b7487809011d0de91a19b26d0a8cc105affe338158d7688fc40aa444db5585b62d5672676318a0e56b91856f131d91d3c78f1fd86
|
7
|
+
data.tar.gz: 899043bf5aa0605ad16406fc05f931d618da86aa15f853a3f5b9a69bdaca04edd925b34f25ca45b22b096c832881981e8374baf785cadf1e1f1c7e3262510795
|
data/bin/oozby
CHANGED
@@ -1,23 +1,79 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$:.unshift File.dirname(__FILE__) + "/../lib"
|
3
|
-
require '
|
4
|
-
#require '
|
3
|
+
require 'thor'
|
4
|
+
#require 'fssm'
|
5
|
+
require 'listen'
|
6
|
+
require 'pp'
|
5
7
|
require 'oozby'
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
ooz.parse_file file
|
10
|
-
#pp ooz.abstract_tree
|
11
|
-
File.open(file + '.scad', 'w') do |handle|
|
12
|
-
handle.write ooz.render
|
13
|
-
end
|
9
|
+
class OozbyUtility < Thor
|
10
|
+
desc "compile some#{File::SEPARATOR}folder", "The Oozby Utility searches a directory and compiles all the .oozby files it finds, creating identically named files with .scad stuck on the end, translated in to OpenSCAD nonsense. Open those files in OpenSCAD app and enable Automatic Reload and Compile in the Design menu, then get to work."
|
14
11
|
|
15
|
-
|
12
|
+
option :verbose, type: :boolean, desc: "Output lots of gunk, to figure out bizarre bugs in Oozby"
|
13
|
+
option :all, type: :boolean, desc: "Don't skip any files - recompile them all!"
|
14
|
+
option :watch, type: :boolean, default: true, desc: "Watch directory for changes and automatically recompile"
|
15
|
+
def compile path
|
16
|
+
if File.file? path
|
17
|
+
ooz = Oozby.new
|
18
|
+
begin
|
19
|
+
ooz.parse_file path
|
20
|
+
|
21
|
+
if options[:verbose]
|
22
|
+
puts "Oozby Abstract Syntax Tree:"
|
23
|
+
pp ooz.abstract_tree
|
24
|
+
end
|
25
|
+
|
26
|
+
File.open(path + '.scad', 'w') do |handle|
|
27
|
+
handle.write ooz.render
|
28
|
+
end
|
29
|
+
|
30
|
+
puts "compiled #{File.basename(path)}"
|
31
|
+
rescue StandardError, ScriptError => err
|
32
|
+
local_pwd = Dir.pwd
|
33
|
+
puts "#{err.class.name}: #{err.message.sub(local_pwd + File::SEPARATOR, '')}"
|
34
|
+
err.backtrace.each { |line| puts line.sub(local_pwd + File::SEPARATOR, '') }
|
35
|
+
end
|
36
|
+
|
37
|
+
elsif File.directory? path
|
38
|
+
directory = File.absolute_path(path) # calculate real absolute path - follow any links
|
39
|
+
globber = File.join(directory, '**', '*.oozby')
|
40
|
+
files = Dir.glob(globber)
|
41
|
+
files.each do |filename|
|
42
|
+
compile filename if !File.exists?("#{filename}.scad") || File.mtime(filename) >= File.mtime("#{filename}.scad") || options[:all]
|
43
|
+
end
|
44
|
+
|
45
|
+
if options[:watch]
|
46
|
+
recompile_handler = lambda do |*args|
|
47
|
+
compile File.join(*args)
|
48
|
+
end
|
49
|
+
|
50
|
+
Listen.to! directory, filter: /\.oozby$/ do |modified, added, removed|
|
51
|
+
modified.each { |path| recompile_handler[path] }
|
52
|
+
added.each { |path| recompile_handler[path] }
|
53
|
+
removed.each do |path|
|
54
|
+
puts "#{File.basename(path)} deleted."
|
55
|
+
if File.exists? "#{path}.scad"
|
56
|
+
File.delete("{path}.scad")
|
57
|
+
puts "Deleted generated .scad file for obsolete #{File.basename(path)}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# FSSM.monitor(directory, File.join('**', '*.oozby')) do
|
63
|
+
# create &recompile_handler
|
64
|
+
# update &recompile_handler
|
65
|
+
# delete do |dir, name|
|
66
|
+
# puts "#{name} deleted."
|
67
|
+
# if File.exists? File.join(dir, name + ".scad")
|
68
|
+
# File.delete(File.join(dir, name + ".scad"))
|
69
|
+
# puts "Deleted generated .scad file for obsolete #{name}"
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
# end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
16
76
|
end
|
17
77
|
|
18
|
-
|
19
|
-
|
20
|
-
FSSM.monitor(File.dirname(filename), File.basename(filename)) do
|
21
|
-
update { recompile filename }
|
22
|
-
create { recompile filename }
|
23
|
-
end
|
78
|
+
OozbyUtility.start(ARGV)
|
79
|
+
|
@@ -13,15 +13,22 @@ class Oozby::MethodPreprocessor
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# allow translate to take x, y, z named args instead of array, with defaults to 0
|
16
|
-
def xyz_to_array(info, default: 0, arg: false)
|
16
|
+
def xyz_to_array(info, default: 0, arg: false, depth: true)
|
17
17
|
if [:x, :y, :z].any? { |name| info[:named_args].include? name }
|
18
18
|
|
19
19
|
# create coordinate 'vector' (array)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
if depth
|
21
|
+
coords = [
|
22
|
+
info[:named_args][:x] || default,
|
23
|
+
info[:named_args][:y] || default,
|
24
|
+
info[:named_args][:z] || default
|
25
|
+
]
|
26
|
+
else
|
27
|
+
coords = [
|
28
|
+
info[:named_args][:x] || default,
|
29
|
+
info[:named_args][:y] || default
|
30
|
+
]
|
31
|
+
end
|
25
32
|
|
26
33
|
# if argument name is specified, use that, otherwise make it the first argument in the call
|
27
34
|
if arg
|
@@ -60,7 +67,7 @@ class Oozby::MethodPreprocessor
|
|
60
67
|
expanded_names(info)
|
61
68
|
layout_defaults(info)
|
62
69
|
|
63
|
-
if info.named_args[:r]
|
70
|
+
if info.named_args[:r] && info.named_args[:r] > 0.0
|
64
71
|
# render rounded rectangle
|
65
72
|
info.replace rounded_cube(**args_parse(info, :size, :center, :r))
|
66
73
|
end
|
@@ -112,10 +119,10 @@ class Oozby::MethodPreprocessor
|
|
112
119
|
def _cylinder(info); expanded_names(info); layout_defaults(info); end
|
113
120
|
def _square(info)
|
114
121
|
expanded_names(info)
|
115
|
-
xyz_to_array(info, default: 1, arg: :size)
|
122
|
+
xyz_to_array(info, default: 1, arg: :size, depth: false)
|
116
123
|
layout_defaults(info)
|
117
124
|
|
118
|
-
if info[:named_args][:r]
|
125
|
+
if info[:named_args][:r] and info.named_args[:r] > 0.0
|
119
126
|
# render rounded rectangle
|
120
127
|
info.replace rounded_rect(**args_parse(info, :size, :center, :r))
|
121
128
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oozby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bluebie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: listen
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.3.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.3.0
|
27
27
|
description: OpenSCAD - a cad language for creating solid 3d objects, useful for CNC
|
28
28
|
and 3D Printing, is incredibly annoying. It doesn't even support variables! Oozby
|
29
29
|
is a markup builder like Markaby or XML Builder, so you can write OpenSCAD programs
|