oozby 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72a9ef479750895c4718a2fc8d0f68ca54f9741e
4
- data.tar.gz: 61345c4bbfd49980801843157756baef7ce98cba
3
+ metadata.gz: bbeac0d8921f607998af1bcdc80dcd33fc8a1458
4
+ data.tar.gz: 9aa07a90a933bb5e71371132efeb3e319d19b7cd
5
5
  SHA512:
6
- metadata.gz: 61786bf4d356df899a4b091501d6e8477d4ac8ea8d449888b0efde86a018558d793d24c1049e94e63947b47cf0bb453ba804c9198db18d74874c131b519f1019
7
- data.tar.gz: 3f9f1a23a1e03c1287eecca227ac4fe9b1c1a0c0ff367ffadcc929087961029027cc41994ea22401e1796f16cdd6862f4603088029a25f9e3e11bd9fe3f5e2c3
6
+ metadata.gz: e93d14c4822a3d96ccc2ec468186308e6ce7d15413cc0a6a7bbf5d7cfce07596b444f4bf6fda1004876d6d1c536b8e99a39c85d48ff12105e19bd334fca3788a
7
+ data.tar.gz: 1164475b829db6152960f3aee796ea3d0f360208f2820837d01f0ca9910bfd431d4d1c233e661ed845ab77369448fada5d4513cc6a6685f9a6a5a13ccbe8aa49
data/lib/oozby/base.rb CHANGED
@@ -17,7 +17,7 @@ class Oozby
17
17
  rescue
18
18
  warn "Recent Calls: " + env.instance_variable_get(:@method_history).last(10).reverse.inspect
19
19
  backtrace = $!.backtrace
20
- backtrace = backtrace.select { |item| !item.include? __dir__ }
20
+ backtrace = backtrace.select { |item| !item.include? __dir__ } unless backtrace.first.include? __dir__
21
21
  raise $!, $!.message, backtrace
22
22
  end
23
23
  @code_tree = env._abstract_tree
@@ -60,13 +60,13 @@ class Oozby::MethodPreprocessor
60
60
  expanded_names(info)
61
61
  layout_defaults(info)
62
62
 
63
- if info[:named_args][:r]
63
+ if info.named_args[:r]
64
64
  # render rounded rectangle
65
65
  info.replace rounded_cube(**args_parse(info, :size, :center, :r))
66
66
  end
67
67
  end
68
68
 
69
- def expanded_names(info)
69
+ def expanded_names(info, height_label: :h)
70
70
  # let users use 'radius' as longhand for 'r'
71
71
  info.named_args[:r] = info.named_args.delete(:radius) if info.named_args[:radius]
72
72
  info.named_args[:r1] = info.named_args.delete(:radius1) if info.named_args[:radius1]
@@ -76,28 +76,35 @@ class Oozby::MethodPreprocessor
76
76
 
77
77
  info.named_args[:"$fn"] = info.named_args.delete(:facets) if info.named_args[:facets]
78
78
 
79
- # allow range for radius
80
- if info.named_args[:r].is_a? Range
81
- range = info.named_args.delete(:r)
82
- info.named_args[:r1] = range.first
83
- info.named_args[:r2] = range.last
84
- end
85
-
86
79
  # let users specify diameter instead of radius - convert it
87
80
  { diameter: :r, dia: :r, d: :r,
88
81
  diameter1: :r1, diameter_1: :r1, dia1: :r1, dia_1: :r1, d1: :r1,
89
82
  diameter2: :r2, diameter_2: :r2, dia2: :r2, dia_2: :r2, d2: :r2
90
83
  }.each do |d, r|
91
84
  if info.named_args.key? d
92
- info.named_args[r] = info.named_args.delete(d) / 2.0
85
+ data = info.named_args.delete(d)
86
+ if data.is_a? Range
87
+ data = Range.new(data.first / 2.0, data.last / 2.0, data.exclude_end?)
88
+ else
89
+ data = data / 2.0
90
+ end
91
+ info.named_args[r] = data
93
92
  end
94
93
  end
95
94
 
95
+ # allow range for radius
96
+ if info.named_args[:r].is_a? Range
97
+ range = info.named_args.delete(:r)
98
+ info.named_args[:r1] = range.first
99
+ info.named_args[:r2] = range.last
100
+ end
101
+
96
102
  # long version 'height' becomes 'h'
97
- info.named_args[:h] = info.named_args.delete(:height) if info.named_args[:height]
103
+ height_specification = info.named_args.delete(:height) || info.named_args.delete(:h)
104
+ info.named_args[height_label] = height_specification if height_specification
98
105
  end
99
106
 
100
- def _linear_extrude(info); layout_defaults(info); expanded_names(info); end
107
+ def _linear_extrude(info); layout_defaults(info); expanded_names(info, height_label: :height); end
101
108
  def _rotate_extrude(info); layout_defaults(info); expanded_names(info); end
102
109
 
103
110
  def _circle(info); expanded_names(info); end
@@ -148,11 +155,11 @@ class Oozby::MethodPreprocessor
148
155
  translate(offset) do
149
156
  # extrude the main body parts using rounded_rect as the basis
150
157
  linear_extrude(height: size[2] - diameter, center: true) {
151
- inject_abstract_tree(preprocessor.rounded_rect(size: [size[0], size[1]], center: center, r: r)) }
158
+ inject_abstract_tree(preprocessor.rounded_rect(size: [size[0], size[1]], center: true, r: r)) }
152
159
  rotate([90,0,0]) { linear_extrude(height: size[1] - diameter, center: true) {
153
- inject_abstract_tree(preprocessor.rounded_rect(size: [size[0], size[2]], center: center, r: r)) }}
160
+ inject_abstract_tree(preprocessor.rounded_rect(size: [size[0], size[2]], center: true, r: r)) }}
154
161
  rotate([0,90,0]) { linear_extrude(height: size[0] - diameter, center: true) {
155
- inject_abstract_tree(preprocessor.rounded_rect(size: [size[2], size[1]], center: center, r: r)) }}
162
+ inject_abstract_tree(preprocessor.rounded_rect(size: [size[2], size[1]], center: true, r: r)) }}
156
163
 
157
164
  # fill in the corners with spheres
158
165
  xr, yr, zr = size.map { |x| (x / 2) - r }
@@ -189,7 +196,7 @@ class Oozby::MethodPreprocessor
189
196
  def args_parse(info, *arg_names)
190
197
  args = info[:named_args].dup
191
198
  info[:args].length.times do |index|
192
- warn "Overwriting argument #{arg_names[index]}"
199
+ warn "Overwriting argument #{arg_names[index]}" if args.key? arg_names[index]
193
200
  args[arg_names[index]] = info[:args][index]
194
201
  end
195
202
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oozby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bluebie
@@ -46,7 +46,8 @@ files:
46
46
  - license.txt
47
47
  - bin/oozby
48
48
  homepage: http://github.com/Bluebie/digiusb.rb
49
- licenses: []
49
+ licenses:
50
+ - LGPL-3
50
51
  metadata: {}
51
52
  post_install_message:
52
53
  rdoc_options: