engineering 0.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +2 -1
- data/README.markdown +3 -3
- data/engineering.gemspec +6 -5
- data/lib/engineering.rb +55 -32
- data/lib/sketchup.rb +18 -7
- data/test/engineering.rb +68 -0
- data/test/fixtures/sketchup/empty.su +3 -0
- data/test/fixtures/sketchup/hexagon_sketch.su +4 -0
- data/test/fixtures/sketchup/line_sketch.su +4 -0
- data/test/fixtures/sketchup/rectangle_sketch.su +4 -0
- data/test/fixtures/sketchup/simple_extrusion.su +4 -0
- data/test/fixtures/sketchup/simple_extrusion_units.su +4 -0
- data/test/fixtures/sketchup/sketch_group.su +4 -0
- data/test/geometry/edge.rb +8 -0
- data/test/model/builder.rb +1 -1
- data/test/sketchup/builder.rb +32 -9
- data/test/units/literal.rb +2 -2
- metadata +51 -34
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: edf0dffae8854098af2df322958e8540d05676a2
|
4
|
+
data.tar.gz: f1a408fab212a5268b6a10f81117dd9c5be3c6c1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8427c54453c06709181a6ac2f8c7480af92bab90c4a59dd8482bdc6f5d20770acf13204b82cc1facb74259cd39ef16255796ce37e081725f78b640f8fd6ae042
|
7
|
+
data.tar.gz: 406eb9aa3eb061de7b520f6e6c1ddbced71fa279aec59c7c2e18312f9a6a9c2457cb3e94cbbafb6d3cd65dfd965fbb53efa779f2f647b1e8bcce675fc05447d5
|
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -14,13 +14,13 @@ the module and adds whatever is missing, if that's more your style.
|
|
14
14
|
License
|
15
15
|
-------
|
16
16
|
|
17
|
-
Copyright 2012-
|
17
|
+
Copyright 2012-2014 Brandon Fosdick <bfoz@bfoz.net> and released under the BSD license.
|
18
18
|
|
19
19
|
Dependencies
|
20
20
|
------------
|
21
21
|
|
22
22
|
- DXF [GitHub](http://github.com/bfoz/ruby-dxf) [RubyGems](https://rubygems.org/gems/dxf)
|
23
|
-
- Units [GitHub](https://github.com/bfoz/units)
|
23
|
+
- Units [GitHub](https://github.com/bfoz/units-ruby)
|
24
24
|
- Geometry [GitHub](https://github.com/bfoz/geometry) [RubyGems](https://rubygems.org/gems/geometry)
|
25
25
|
- Sketch [GitHub](https://github.com/bfoz/sketch)
|
26
26
|
- Model [GitHub](https://github.com/bfoz/model)
|
@@ -30,7 +30,7 @@ Installation
|
|
30
30
|
|
31
31
|
Engineering has a number of dependencies. Some of which are hosted on rubygems.org
|
32
32
|
and can therefore be handled by the gem utility, but others must be installed
|
33
|
-
manually. The easiest option is to use [Bundler](http://
|
33
|
+
manually. The easiest option is to use [Bundler](http://bundler.io/), but
|
34
34
|
*gem* can be used if you're willing to install the *units* gem manually.
|
35
35
|
|
36
36
|
### Using Bundler
|
data/engineering.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "engineering"
|
6
|
-
s.version = 0.
|
6
|
+
s.version = '0.2'
|
7
7
|
s.authors = ["Brandon Fosdick"]
|
8
8
|
s.email = ["bfoz@bfoz.net"]
|
9
9
|
s.homepage = "http://github.com/bfoz/engineering"
|
@@ -17,8 +17,9 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
-
s.add_dependency 'dxf'
|
21
|
-
s.add_dependency '
|
22
|
-
s.add_dependency '
|
23
|
-
s.add_dependency '
|
20
|
+
s.add_dependency 'dxf', '~> 0.2'
|
21
|
+
s.add_dependency 'geometry', '~> 6.1'
|
22
|
+
s.add_dependency 'model', '~> 0.1'
|
23
|
+
s.add_dependency 'sketch', '~> 0.2'
|
24
|
+
s.add_dependency 'units', '~> 2.2'
|
24
25
|
end
|
data/lib/engineering.rb
CHANGED
@@ -17,47 +17,70 @@ module Engineering
|
|
17
17
|
private
|
18
18
|
|
19
19
|
# Create a new {Extrusion} subclass and initialize it with the given block
|
20
|
-
# @param [Symbol]
|
21
|
-
|
22
|
-
|
20
|
+
# @param name [Symbol] The name of the resulting subclass
|
21
|
+
def extrusion(symbol, &block)
|
22
|
+
builder = Model::Extrusion::Builder.new
|
23
|
+
builder.evaluate(&block) if block_given?
|
24
|
+
initial_arguments = {sketch: builder.extrusion.sketch, length: builder.extrusion.length}.select {|k,v| v }
|
25
|
+
|
23
26
|
klass = Class.new(Model::Extrusion)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
]
|
31
|
-
|
27
|
+
|
28
|
+
if initial_arguments.has_key?(:length)
|
29
|
+
klass.instance_variable_set :@length, initial_arguments[:length]
|
30
|
+
klass.class.send(:define_method, :length) { @length }
|
31
|
+
end
|
32
|
+
|
33
|
+
klass.instance_variable_set :@sketch, initial_arguments[:sketch]
|
34
|
+
klass.class.send(:define_method, :sketch) { @sketch }
|
35
|
+
|
36
|
+
klass.send :define_method, :initialize do |options={}, &block|
|
37
|
+
raise ArgumentError, "Can't initialize with a length when #{self} already has a length attribute" if initial_arguments.has_key?(:length) and options.has_key?(:length)
|
38
|
+
super initial_arguments.merge(options), &block
|
39
|
+
end
|
40
|
+
|
41
|
+
Object.const_set(symbol, klass)
|
32
42
|
end
|
33
43
|
|
34
44
|
# Create a new {Model} subclass and initialize it with the given block
|
35
|
-
# @param [Symbol]
|
36
|
-
|
37
|
-
def model(symbol=nil, &block)
|
45
|
+
# @param name [Symbol] The name of the new {Model} subclass
|
46
|
+
def model(name, &block)
|
38
47
|
klass = Class.new(Model)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
48
|
+
builder = Model::Builder.new
|
49
|
+
builder.evaluate(&block) if block_given?
|
50
|
+
initial_elements = builder.elements
|
51
|
+
|
52
|
+
# The defaults are hidden in an instance variable so that the passed block can't accidentally corrupt them
|
53
|
+
attribute_defaults = builder.instance_variable_get(:@attribute_defaults) || {}
|
54
|
+
|
55
|
+
# Bind any attribute getters and setters to the new subclass
|
56
|
+
attribute_getters = builder.instance_variable_get(:@attribute_getters) || {}
|
57
|
+
attribute_getters.each {|k, m| klass.send :define_method, k, m }
|
58
|
+
|
59
|
+
attribute_setters = builder.instance_variable_get(:@attribute_setters) || {}
|
60
|
+
attribute_setters.each {|k, m| klass.send :define_method, k, m }
|
61
|
+
|
62
|
+
klass.send :define_method, :initialize do |*args, &block|
|
63
|
+
super *(attribute_defaults.map {|k,v| { k => (v.respond_to?(:call) ? v.call : v) } }), *args, &block
|
64
|
+
initial_elements.each {|a| push a }
|
65
|
+
end
|
66
|
+
|
67
|
+
Object.const_set(name, klass)
|
47
68
|
end
|
48
69
|
|
49
70
|
# Create a new {Sketch} subclass and initialize it with the given block
|
50
|
-
# @param [Symbol]
|
51
|
-
def sketch(symbol
|
71
|
+
# @param name [Symbol] The name of the {Sketch} subclass
|
72
|
+
def sketch(symbol, &block)
|
73
|
+
builder = Sketch::Builder.new
|
74
|
+
builder.evaluate(&block) if block_given?
|
75
|
+
initial_elements = builder.elements
|
76
|
+
|
52
77
|
klass = Class.new(Sketch)
|
53
|
-
klass.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
]
|
60
|
-
symbol ? Object.const_set(symbol, klass) : klass
|
78
|
+
klass.send :define_method, :initialize do |*args, &block|
|
79
|
+
super *args, &block
|
80
|
+
initial_elements.each {|a| push a }
|
81
|
+
end
|
82
|
+
|
83
|
+
Object.const_set(symbol, klass)
|
61
84
|
end
|
62
85
|
|
63
86
|
class Geometry::Polygon
|
data/lib/sketchup.rb
CHANGED
@@ -31,7 +31,7 @@ module SketchUp
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def to_a
|
34
|
-
a = to_array(@container) # Generates the definitions as a side effect
|
34
|
+
a = to_array(@container) || [] # Generates the definitions as a side effect
|
35
35
|
HEADER_LINES + @definition_names.values.flatten + a
|
36
36
|
end
|
37
37
|
|
@@ -101,12 +101,21 @@ module SketchUp
|
|
101
101
|
else
|
102
102
|
container.elements.map {|element| to_array(element, parent) }.flatten
|
103
103
|
end
|
104
|
-
when Sketch
|
105
|
-
container.geometry.map {|element| to_sketchup(element, parent, transformation) }
|
104
|
+
when Sketch::Group
|
105
|
+
container.geometry.map {|element| to_sketchup(element, parent, container.transformation) }.flatten
|
106
|
+
when Sketch # !!! Must be after all subclasses of Sketch
|
107
|
+
container.geometry.map do |element|
|
108
|
+
case element
|
109
|
+
when Sketch::Group then to_array(element, parent)
|
110
|
+
else
|
111
|
+
to_sketchup(element, parent, transformation)
|
112
|
+
end
|
113
|
+
end.flatten
|
106
114
|
end
|
107
115
|
end
|
108
116
|
|
109
117
|
# Convert the given entity to a string that SketchUp can read
|
118
|
+
# @return [String]
|
110
119
|
def to_sketchup(entity, parent='model.entities', transformation=nil)
|
111
120
|
case entity
|
112
121
|
when Array
|
@@ -114,7 +123,7 @@ module SketchUp
|
|
114
123
|
when Geometry::Arc
|
115
124
|
"#{parent}.add_arc(#{to_sketchup(entity.center)}, [1,0,0], [0,0,1], #{to_sketchup(entity.radius)}, #{to_sketchup(entity.start_angle)}, #{to_sketchup(entity.end_angle)})"
|
116
125
|
when Geometry::Circle
|
117
|
-
"lambda{ points = #{parent}.add_circle(#{to_sketchup(entity.center)}, [0,0,1], #{to_sketchup(entity.radius)}); points[0].find_faces; points[0].faces[0]}.call"
|
126
|
+
"lambda{ points = #{parent}.add_circle(#{to_sketchup(entity.center, parent, transformation)}, [0,0,1], #{to_sketchup(entity.radius)}); points[0].find_faces; points[0].faces[0]}.call"
|
118
127
|
when Geometry::Edge
|
119
128
|
"#{parent}.add_edges(#{to_sketchup(entity.first)}, #{to_sketchup(entity.last)})"
|
120
129
|
when Geometry::Line
|
@@ -126,6 +135,8 @@ module SketchUp
|
|
126
135
|
vertices = entity.vertices.map {|v| to_sketchup(v, parent, transformation) }.join ', '
|
127
136
|
method = entity.is_a?(Geometry::Polygon) ? 'add_face' : 'add_curve'
|
128
137
|
"#{parent}.#{method}(#{vertices})"
|
138
|
+
when Geometry::PointZero
|
139
|
+
to_sketchup(Point[0,0], parent, transformation)
|
129
140
|
when Geometry::Point
|
130
141
|
if transformation and not transformation.identity?
|
131
142
|
'Geom::Point3d.new(' + to_sketchup(entity.to_a) + ').transform!(' + to_sketchup(transformation) + ')'
|
@@ -138,8 +149,8 @@ module SketchUp
|
|
138
149
|
"#{parent}.add_face(#{to_sketchup(entity.points, parent, transformation)})"
|
139
150
|
when Geometry::Transformation
|
140
151
|
pt = '[' + (entity.translation ? to_sketchup(entity.translation.to_a) : '0,0,0') + ']'
|
141
|
-
x_axis = '[' + (entity.rotation.x ? to_sketchup(entity.rotation.x.to_a) : '1,0,0') + ']'
|
142
|
-
y_axis = '[' + (entity.rotation.y ? to_sketchup(entity.rotation.y.to_a) : '0,1,0') + ']'
|
152
|
+
x_axis = '[' + ((entity.rotation && entity.rotation.x) ? to_sketchup(entity.rotation.x.to_a) : '1,0,0') + ']'
|
153
|
+
y_axis = '[' + ((entity.rotation && entity.rotation.y) ? to_sketchup(entity.rotation.y.to_a) : '0,1,0') + ']'
|
143
154
|
"Geom::Transformation.new(#{[pt,x_axis,y_axis].join(',')})"
|
144
155
|
when Geometry::Triangle
|
145
156
|
"#{parent}.add_face(#{to_sketchup(entity.points, parent, transformation)})"
|
@@ -150,7 +161,7 @@ module SketchUp
|
|
150
161
|
when Units
|
151
162
|
s = entity.to_s
|
152
163
|
SKETCHUP_UNITS[s] or raise "SketchUp won't recognize '#{s}'"
|
153
|
-
when Units::
|
164
|
+
when Units::Numeric
|
154
165
|
[entity.value, entity.units].compact.map {|a| to_sketchup(a)}.join '.'
|
155
166
|
else
|
156
167
|
entity.to_s
|
data/test/engineering.rb
CHANGED
@@ -75,6 +75,45 @@ describe Engineering do
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
describe 'when creating a Model subclass with attributes' do
|
79
|
+
before do
|
80
|
+
model :TestModel4 do
|
81
|
+
attribute :attribute0
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'must define the attributes' do
|
86
|
+
TestModel4.new.must_be :respond_to?, :attribute0
|
87
|
+
TestModel4.new.must_be :respond_to?, :attribute0=
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'must have working accessors' do
|
91
|
+
test_model = TestModel4.new
|
92
|
+
test_model.attribute0 = 42
|
93
|
+
test_model.attribute0.must_equal 42
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'must be able to initialize the attribute during construction' do
|
97
|
+
TestModel4.new(attribute0: 37).attribute0.must_equal 37
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe 'when creating a Model subclass with attributes that have default values' do
|
102
|
+
subject do
|
103
|
+
model :TestModel5 do
|
104
|
+
attribute :attribute0, 42
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'must have the default value' do
|
109
|
+
subject.new.attribute0.must_equal 42
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'must allow the default value to be overriden' do
|
113
|
+
subject.new(attribute0: 24).attribute0.must_equal 24
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
78
117
|
describe "when creating an Extrusion subclass" do
|
79
118
|
after do
|
80
119
|
Object.send(:remove_const, :TestExtrusion)
|
@@ -94,6 +133,10 @@ describe Engineering do
|
|
94
133
|
(TestExtrusion < Model::Extrusion).must_equal true
|
95
134
|
end
|
96
135
|
|
136
|
+
it 'must have a class attribute for the Sketch' do
|
137
|
+
TestExtrusion.sketch.must_be_kind_of Sketch
|
138
|
+
end
|
139
|
+
|
97
140
|
describe "when initializing a new instance" do
|
98
141
|
subject { TestExtrusion.new(length: 5) }
|
99
142
|
|
@@ -107,6 +150,31 @@ describe Engineering do
|
|
107
150
|
end
|
108
151
|
end
|
109
152
|
|
153
|
+
describe 'when creating an Extrusion subclass with a length' do
|
154
|
+
after { Object.send :remove_const, :TestExtrusion }
|
155
|
+
|
156
|
+
before do
|
157
|
+
extrusion :TestExtrusion do
|
158
|
+
length 10
|
159
|
+
square 5
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'must have a class attribute for the length' do
|
164
|
+
TestExtrusion.length.must_equal 10
|
165
|
+
end
|
166
|
+
|
167
|
+
describe 'when initializing a new instance' do
|
168
|
+
it 'must reject a length argument' do
|
169
|
+
-> { TestExtrusion.new(length:5) }.must_raise ArgumentError
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'must have the proper length' do
|
173
|
+
TestExtrusion.new.length.must_equal 10
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
110
178
|
describe "when creating a Model that uses global constants" do
|
111
179
|
before do
|
112
180
|
LENGTH = 5
|
@@ -0,0 +1,4 @@
|
|
1
|
+
model = Sketchup.active_model
|
2
|
+
model.entities.clear!
|
3
|
+
model.definitions.purge_unused
|
4
|
+
model.entities.add_face([5.0, 0.0], [2.5000000000000004, 4.330127018922193], [-2.499999999999999, 4.3301270189221945], [-5.0, 6.123233995736766e-16], [-2.500000000000002, -4.330127018922192], [2.4999999999999964, -4.330127018922195])
|
@@ -0,0 +1,4 @@
|
|
1
|
+
model = Sketchup.active_model
|
2
|
+
model.entities.clear!
|
3
|
+
model.definitions.purge_unused
|
4
|
+
lambda{ points = model.entities.add_circle(Geom::Point3d.new(0, 0).transform!(Geom::Transformation.new([1, 2],[1,0,0],[0,1,0])), [0,0,1], 0.5); points[0].find_faces; points[0].faces[0]}.call
|
data/test/geometry/edge.rb
CHANGED
@@ -20,4 +20,12 @@ describe Geometry::Edge do
|
|
20
20
|
edge.last.must_equal Point[4.meters, 5.meters]
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
it "must preserve units in the vector method" do
|
25
|
+
Edge.new([0.meters, 0.meters], [1.meter, 0.meters]).vector.must_equal Point[1.meter, 0.meters]
|
26
|
+
end
|
27
|
+
|
28
|
+
it "must not preserve units in the direction method" do
|
29
|
+
Edge.new([0.meters, 0.meters], [1.meter, 0.meters]).direction.must_equal Point[1, 0]
|
30
|
+
end
|
23
31
|
end
|
data/test/model/builder.rb
CHANGED
data/test/sketchup/builder.rb
CHANGED
@@ -2,6 +2,8 @@ require 'minitest/autorun'
|
|
2
2
|
require 'sketchup'
|
3
3
|
|
4
4
|
describe SketchUp::Builder do
|
5
|
+
Size = Geometry::Size
|
6
|
+
|
5
7
|
subject { SketchUp::Builder.new }
|
6
8
|
|
7
9
|
before do
|
@@ -27,7 +29,7 @@ describe SketchUp::Builder do
|
|
27
29
|
describe "when given an empty Model object" do
|
28
30
|
before do
|
29
31
|
model = Model.new
|
30
|
-
model.
|
32
|
+
model.push Model::Extrusion.new(length:5, sketch:Sketch.new)
|
31
33
|
@builder.container = model
|
32
34
|
end
|
33
35
|
|
@@ -38,10 +40,10 @@ describe SketchUp::Builder do
|
|
38
40
|
|
39
41
|
describe "when given a Model of a translated Extrusion" do
|
40
42
|
sketch = Sketch.new
|
41
|
-
sketch.add_rectangle 10, 20
|
43
|
+
sketch.add_rectangle size:[10, 20]
|
42
44
|
before do
|
43
45
|
subject.container = Model.new do
|
44
|
-
|
46
|
+
push Model::Extrusion.new(length:5, sketch:sketch, transformation:Geometry::Transformation.new(origin:[1,2,3]))
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
@@ -52,9 +54,9 @@ describe SketchUp::Builder do
|
|
52
54
|
|
53
55
|
it "should generate the correct text from a Model of a simple extrusion" do
|
54
56
|
sketch = Sketch.new
|
55
|
-
sketch.add_rectangle 10, 20
|
57
|
+
sketch.add_rectangle size:[10, 20]
|
56
58
|
model = Model.new do
|
57
|
-
|
59
|
+
push Model::Extrusion.new(length:5, sketch:sketch)
|
58
60
|
end
|
59
61
|
@builder.container = model
|
60
62
|
@builder.to_s.must_equal File.read('test/fixtures/sketchup/simple_extrusion.su')
|
@@ -62,9 +64,9 @@ describe SketchUp::Builder do
|
|
62
64
|
|
63
65
|
it "should generate the correct text from a Model of a simple extrusion with units" do
|
64
66
|
sketch = Sketch.new
|
65
|
-
sketch.add_rectangle 1.meter, 10
|
67
|
+
sketch.add_rectangle size:[1.meter, 10]
|
66
68
|
model = Model.new
|
67
|
-
model.
|
69
|
+
model.push Model::Extrusion.new(length:5.meters, sketch:sketch)
|
68
70
|
@builder.container = model
|
69
71
|
@builder.to_s.must_equal File.read('test/fixtures/sketchup/simple_extrusion_units.su')
|
70
72
|
end
|
@@ -81,9 +83,16 @@ describe SketchUp::Builder do
|
|
81
83
|
@builder.to_s.must_equal File.read('test/fixtures/sketchup/line_sketch.su')
|
82
84
|
end
|
83
85
|
|
86
|
+
describe "when given a Sketch" do
|
87
|
+
it "must RegularPolygon" do
|
88
|
+
subject.container = Sketch.new.tap {|s| s.push RegularPolygon.new(sides:6, center:[0,0], radius:5) }
|
89
|
+
subject.to_s.must_equal File.read('test/fixtures/sketchup/hexagon_sketch.su')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
84
93
|
it "should generate correct text from a Sketch object with a single Rectangle" do
|
85
94
|
sketch = Sketch.new
|
86
|
-
sketch.add_rectangle [0,0],
|
95
|
+
sketch.add_rectangle origin:[0,0], size:[1,1]
|
87
96
|
@builder.container = sketch
|
88
97
|
@builder.to_s.must_equal rectangle_sketch_fixture
|
89
98
|
end
|
@@ -109,9 +118,23 @@ describe SketchUp::Builder do
|
|
109
118
|
builder.to_s.must_match %r{model = Sketchup.active_model\nmodel.entities.clear!\nmodel.definitions.purge_unused\nlambda {|m|\n\t\n}.call(model.definitions.add('Model(\d+)'))\nmodel.entities.add_instance(model.definitions\['Model(\d+)'\], Geom::Transformation.new(\[3, 2, 1\],\[1,0,0\],\[0,1,0\]))}
|
110
119
|
end
|
111
120
|
|
121
|
+
describe "when unparsing a Sketch" do
|
122
|
+
describe "when the Sketch has a Group" do
|
123
|
+
before do
|
124
|
+
builder = Sketch::Builder.new
|
125
|
+
builder.group origin:[1,2] { circle diameter:1 }
|
126
|
+
subject.container = builder.sketch
|
127
|
+
end
|
128
|
+
|
129
|
+
it "must generate the correct text" do
|
130
|
+
subject.to_s.must_equal File.read('test/fixtures/sketchup/sketch_group.su')
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
112
135
|
it "Path" do
|
113
136
|
sketch = Sketch.new
|
114
|
-
sketch.add_path [0,0], Geometry::Arc.new([0,0],5,0,90*Math::PI/180), [0,0]
|
137
|
+
sketch.add_path [0,0], Geometry::Arc.new(center:[0,0], radius:5, start:0, end:90*Math::PI/180), [0,0]
|
115
138
|
builder = SketchUp::Builder.new( Model::Builder.new.evaluate { extrude length:5, sketch:sketch })
|
116
139
|
end
|
117
140
|
end
|
data/test/units/literal.rb
CHANGED
@@ -8,10 +8,10 @@ require 'units'
|
|
8
8
|
# there's no good way to test their integration at a lower level.
|
9
9
|
|
10
10
|
def Literal(*args)
|
11
|
-
Units::
|
11
|
+
Units::Numeric.new(*args)
|
12
12
|
end
|
13
13
|
|
14
|
-
describe Units::
|
14
|
+
describe Units::Numeric do
|
15
15
|
let(:one_meter) { Literal(1, :meter) }
|
16
16
|
let(:three_meters) { Literal(3, :meters) }
|
17
17
|
let(:four_meters) { Literal(4, :meters) }
|
metadata
CHANGED
@@ -1,80 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engineering
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
5
|
-
prerelease:
|
4
|
+
version: '0.2'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Brandon Fosdick
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: dxf
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
19
|
+
version: '0.2'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
26
|
+
version: '0.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: geometry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '6.1'
|
30
41
|
- !ruby/object:Gem::Dependency
|
31
42
|
name: model
|
32
43
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
44
|
requirements:
|
35
|
-
- -
|
45
|
+
- - ~>
|
36
46
|
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
47
|
+
version: '0.1'
|
38
48
|
type: :runtime
|
39
49
|
prerelease: false
|
40
50
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
51
|
requirements:
|
43
|
-
- -
|
52
|
+
- - ~>
|
44
53
|
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
54
|
+
version: '0.1'
|
46
55
|
- !ruby/object:Gem::Dependency
|
47
56
|
name: sketch
|
48
57
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
58
|
requirements:
|
51
|
-
- -
|
59
|
+
- - ~>
|
52
60
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
61
|
+
version: '0.2'
|
54
62
|
type: :runtime
|
55
63
|
prerelease: false
|
56
64
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
65
|
requirements:
|
59
|
-
- -
|
66
|
+
- - ~>
|
60
67
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
68
|
+
version: '0.2'
|
62
69
|
- !ruby/object:Gem::Dependency
|
63
70
|
name: units
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
72
|
requirements:
|
67
|
-
- -
|
73
|
+
- - ~>
|
68
74
|
- !ruby/object:Gem::Version
|
69
|
-
version: '2'
|
75
|
+
version: '2.2'
|
70
76
|
type: :runtime
|
71
77
|
prerelease: false
|
72
78
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
79
|
requirements:
|
75
|
-
- -
|
80
|
+
- - ~>
|
76
81
|
- !ruby/object:Gem::Version
|
77
|
-
version: '2'
|
82
|
+
version: '2.2'
|
78
83
|
description: Tools for Mad Engineers and those who want to be
|
79
84
|
email:
|
80
85
|
- bfoz@bfoz.net
|
@@ -90,6 +95,13 @@ files:
|
|
90
95
|
- lib/engineering.rb
|
91
96
|
- lib/sketchup.rb
|
92
97
|
- test/engineering.rb
|
98
|
+
- test/fixtures/sketchup/empty.su
|
99
|
+
- test/fixtures/sketchup/hexagon_sketch.su
|
100
|
+
- test/fixtures/sketchup/line_sketch.su
|
101
|
+
- test/fixtures/sketchup/rectangle_sketch.su
|
102
|
+
- test/fixtures/sketchup/simple_extrusion.su
|
103
|
+
- test/fixtures/sketchup/simple_extrusion_units.su
|
104
|
+
- test/fixtures/sketchup/sketch_group.su
|
93
105
|
- test/fixtures/translated_extrusion.su
|
94
106
|
- test/geometry.rb
|
95
107
|
- test/geometry/edge.rb
|
@@ -102,30 +114,36 @@ files:
|
|
102
114
|
- test/units/literal.rb
|
103
115
|
homepage: http://github.com/bfoz/engineering
|
104
116
|
licenses: []
|
117
|
+
metadata: {}
|
105
118
|
post_install_message:
|
106
119
|
rdoc_options: []
|
107
120
|
require_paths:
|
108
121
|
- lib
|
109
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
123
|
requirements:
|
112
|
-
- -
|
124
|
+
- - '>='
|
113
125
|
- !ruby/object:Gem::Version
|
114
126
|
version: '0'
|
115
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
-
none: false
|
117
128
|
requirements:
|
118
|
-
- -
|
129
|
+
- - '>='
|
119
130
|
- !ruby/object:Gem::Version
|
120
131
|
version: '0'
|
121
132
|
requirements: []
|
122
133
|
rubyforge_project: engineering
|
123
|
-
rubygems_version: 1.
|
134
|
+
rubygems_version: 2.1.11
|
124
135
|
signing_key:
|
125
|
-
specification_version:
|
136
|
+
specification_version: 4
|
126
137
|
summary: Mad Engineering, Ruby style
|
127
138
|
test_files:
|
128
139
|
- test/engineering.rb
|
140
|
+
- test/fixtures/sketchup/empty.su
|
141
|
+
- test/fixtures/sketchup/hexagon_sketch.su
|
142
|
+
- test/fixtures/sketchup/line_sketch.su
|
143
|
+
- test/fixtures/sketchup/rectangle_sketch.su
|
144
|
+
- test/fixtures/sketchup/simple_extrusion.su
|
145
|
+
- test/fixtures/sketchup/simple_extrusion_units.su
|
146
|
+
- test/fixtures/sketchup/sketch_group.su
|
129
147
|
- test/fixtures/translated_extrusion.su
|
130
148
|
- test/geometry.rb
|
131
149
|
- test/geometry/edge.rb
|
@@ -136,4 +154,3 @@ test_files:
|
|
136
154
|
- test/sketchup.rb
|
137
155
|
- test/sketchup/builder.rb
|
138
156
|
- test/units/literal.rb
|
139
|
-
has_rdoc:
|