scad4r 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -9
- data/VERSION +1 -1
- data/lib/scad4r/runner.rb +21 -2
- data/scad4r.gemspec +29 -29
- data/spec/lib/scad4r/runner_spec.rb +2 -2
- data/spec/support/openscad_execution_matcher.rb +19 -2
- metadata +40 -40
data/Gemfile
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
gem "
|
3
|
+
gem "childprocess", "~> 0.3"
|
4
4
|
|
5
5
|
group :development do
|
6
|
-
gem "growl"
|
7
|
-
gem "guard"
|
8
|
-
gem "guard-rspec"
|
6
|
+
gem "growl", "~> 1.0"
|
7
|
+
gem "guard", "~> 1.6"
|
8
|
+
gem "guard-rspec", "~> 2.3"
|
9
9
|
|
10
10
|
gem "jeweler", "~> 1.8.3"
|
11
11
|
|
12
|
-
gem "rdoc"
|
13
|
-
gem "rspec"
|
14
|
-
gem "rb-fsevent"
|
12
|
+
gem "rdoc", "~> 3.12"
|
13
|
+
gem "rspec", "~> 2.12"
|
14
|
+
gem "rb-fsevent", "~> 0.9"
|
15
15
|
|
16
|
-
gem "simplecov"
|
17
|
-
gem "simplecov-csv"
|
16
|
+
gem "simplecov", "~> 0.7"
|
17
|
+
gem "simplecov-csv", "~> 0.1"
|
18
18
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/scad4r/runner.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'childprocess'
|
2
|
+
|
1
3
|
module Scad4r
|
2
4
|
class Runner
|
3
5
|
class PassThrough
|
@@ -21,17 +23,34 @@ module Scad4r
|
|
21
23
|
# provide a reasonable default
|
22
24
|
net_options = {output: output_file(path, net_options)}.merge(net_options)
|
23
25
|
|
24
|
-
io =
|
26
|
+
io = shell_out(openscad_invocation(path, net_options))
|
25
27
|
|
26
28
|
result_hash = parser.parse io.read
|
27
29
|
|
28
30
|
result_hash.merge({output: net_options.fetch(:output)})
|
29
31
|
end
|
30
32
|
|
33
|
+
protected
|
34
|
+
|
35
|
+
def shell_out(*cmd)
|
36
|
+
r, w = pipes
|
37
|
+
process = ChildProcess.build(*cmd)
|
38
|
+
process.io.stdout = process.io.stderr = w
|
39
|
+
process.start
|
40
|
+
w.close
|
41
|
+
process.wait # to do, stream progress
|
42
|
+
|
43
|
+
r
|
44
|
+
end
|
45
|
+
|
31
46
|
private
|
32
47
|
|
48
|
+
def pipes
|
49
|
+
IO.pipe
|
50
|
+
end
|
51
|
+
|
33
52
|
def openscad_invocation(path, options)
|
34
|
-
[*openscad_command(options),*runtime_arguments(path, options)
|
53
|
+
[*openscad_command(options),*runtime_arguments(path, options)]
|
35
54
|
end
|
36
55
|
|
37
56
|
def openscad_command(options)
|
data/scad4r.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "scad4r"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Caleb Buxton"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-02-18"
|
13
13
|
s.description = "Provides Ruby affordances for scripting OpenSCAD"
|
14
14
|
s.email = "me@cpb.ca"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -52,39 +52,39 @@ Gem::Specification.new do |s|
|
|
52
52
|
s.specification_version = 3
|
53
53
|
|
54
54
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
-
s.add_runtime_dependency(%q<
|
56
|
-
s.add_development_dependency(%q<growl>, ["
|
57
|
-
s.add_development_dependency(%q<guard>, ["
|
58
|
-
s.add_development_dependency(%q<guard-rspec>, ["
|
55
|
+
s.add_runtime_dependency(%q<childprocess>, ["~> 0.3"])
|
56
|
+
s.add_development_dependency(%q<growl>, ["~> 1.0"])
|
57
|
+
s.add_development_dependency(%q<guard>, ["~> 1.6"])
|
58
|
+
s.add_development_dependency(%q<guard-rspec>, ["~> 2.3"])
|
59
59
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
60
|
-
s.add_development_dependency(%q<rdoc>, ["
|
61
|
-
s.add_development_dependency(%q<rspec>, ["
|
62
|
-
s.add_development_dependency(%q<rb-fsevent>, ["
|
63
|
-
s.add_development_dependency(%q<simplecov>, ["
|
64
|
-
s.add_development_dependency(%q<simplecov-csv>, ["
|
60
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
61
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.12"])
|
62
|
+
s.add_development_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
63
|
+
s.add_development_dependency(%q<simplecov>, ["~> 0.7"])
|
64
|
+
s.add_development_dependency(%q<simplecov-csv>, ["~> 0.1"])
|
65
65
|
else
|
66
|
-
s.add_dependency(%q<
|
67
|
-
s.add_dependency(%q<growl>, ["
|
68
|
-
s.add_dependency(%q<guard>, ["
|
69
|
-
s.add_dependency(%q<guard-rspec>, ["
|
66
|
+
s.add_dependency(%q<childprocess>, ["~> 0.3"])
|
67
|
+
s.add_dependency(%q<growl>, ["~> 1.0"])
|
68
|
+
s.add_dependency(%q<guard>, ["~> 1.6"])
|
69
|
+
s.add_dependency(%q<guard-rspec>, ["~> 2.3"])
|
70
70
|
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
71
|
-
s.add_dependency(%q<rdoc>, ["
|
72
|
-
s.add_dependency(%q<rspec>, ["
|
73
|
-
s.add_dependency(%q<rb-fsevent>, ["
|
74
|
-
s.add_dependency(%q<simplecov>, ["
|
75
|
-
s.add_dependency(%q<simplecov-csv>, ["
|
71
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
72
|
+
s.add_dependency(%q<rspec>, ["~> 2.12"])
|
73
|
+
s.add_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
74
|
+
s.add_dependency(%q<simplecov>, ["~> 0.7"])
|
75
|
+
s.add_dependency(%q<simplecov-csv>, ["~> 0.1"])
|
76
76
|
end
|
77
77
|
else
|
78
|
-
s.add_dependency(%q<
|
79
|
-
s.add_dependency(%q<growl>, ["
|
80
|
-
s.add_dependency(%q<guard>, ["
|
81
|
-
s.add_dependency(%q<guard-rspec>, ["
|
78
|
+
s.add_dependency(%q<childprocess>, ["~> 0.3"])
|
79
|
+
s.add_dependency(%q<growl>, ["~> 1.0"])
|
80
|
+
s.add_dependency(%q<guard>, ["~> 1.6"])
|
81
|
+
s.add_dependency(%q<guard-rspec>, ["~> 2.3"])
|
82
82
|
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
83
|
-
s.add_dependency(%q<rdoc>, ["
|
84
|
-
s.add_dependency(%q<rspec>, ["
|
85
|
-
s.add_dependency(%q<rb-fsevent>, ["
|
86
|
-
s.add_dependency(%q<simplecov>, ["
|
87
|
-
s.add_dependency(%q<simplecov-csv>, ["
|
83
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
84
|
+
s.add_dependency(%q<rspec>, ["~> 2.12"])
|
85
|
+
s.add_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
86
|
+
s.add_dependency(%q<simplecov>, ["~> 0.7"])
|
87
|
+
s.add_dependency(%q<simplecov-csv>, ["~> 0.1"])
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -26,13 +26,13 @@ module Scad4r
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns a hash describing the result" do
|
29
|
-
|
29
|
+
subject.stub(:shell_out).and_return(StringIO.new)
|
30
30
|
subject.run(passed_file).should be_a(Hash)
|
31
31
|
end
|
32
32
|
|
33
33
|
describe "result hash" do
|
34
34
|
before do
|
35
|
-
|
35
|
+
subject.stub(:shell_out).and_return(StringIO.new)
|
36
36
|
end
|
37
37
|
|
38
38
|
let(:parser) {
|
@@ -1,11 +1,28 @@
|
|
1
1
|
module OpenscadExecutionMatcher
|
2
2
|
extend RSpec::Matchers::DSL
|
3
3
|
|
4
|
+
def childprocess_double
|
5
|
+
double("ChildProcess", start: true, wait: true,
|
6
|
+
io: double("IO", "stdout=" => true, "stderr=" => true))
|
7
|
+
end
|
8
|
+
|
9
|
+
def write_pipe_double
|
10
|
+
double("write pipe", close: true)
|
11
|
+
end
|
12
|
+
|
13
|
+
def read_pipe_double(result)
|
14
|
+
StringIO.new(result || "")
|
15
|
+
end
|
16
|
+
|
4
17
|
matcher :run_openscad do |expected_openscad_command="openscad" |
|
5
18
|
@expected_openscad_invocation = Array(expected_openscad_command)
|
6
19
|
|
7
20
|
match do |openscad_runner|
|
8
|
-
|
21
|
+
|
22
|
+
openscad_runner.stub(:pipes).and_return([
|
23
|
+
read_pipe_double(@mock_result),write_pipe_double])
|
24
|
+
|
25
|
+
ChildProcess.should_receive(:build) do |arguments|
|
9
26
|
options = arguments.pop if arguments.last.is_a?(Hash)
|
10
27
|
|
11
28
|
arguments.shift(@expected_openscad_invocation.length).should eql(@expected_openscad_invocation)
|
@@ -16,7 +33,7 @@ module OpenscadExecutionMatcher
|
|
16
33
|
|
17
34
|
arguments.last.should eql(@expected_input_file)
|
18
35
|
|
19
|
-
|
36
|
+
childprocess_double
|
20
37
|
end
|
21
38
|
end
|
22
39
|
|
metadata
CHANGED
@@ -2,79 +2,79 @@
|
|
2
2
|
name: scad4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Caleb Buxton
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
type: :runtime
|
16
16
|
version_requirements: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
name:
|
21
|
+
version: '0.3'
|
22
|
+
name: childprocess
|
23
23
|
prerelease: false
|
24
24
|
requirement: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
29
|
+
version: '0.3'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
type: :development
|
32
32
|
version_requirements: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
37
|
+
version: '1.0'
|
38
38
|
name: growl
|
39
39
|
prerelease: false
|
40
40
|
requirement: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
45
|
+
version: '1.0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
type: :development
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '1.6'
|
54
54
|
name: guard
|
55
55
|
prerelease: false
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '1.6'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
type: :development
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '2.3'
|
70
70
|
name: guard-rspec
|
71
71
|
prerelease: false
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: '
|
77
|
+
version: '2.3'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
type: :development
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -96,81 +96,81 @@ dependencies:
|
|
96
96
|
version_requirements: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - ~>
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '
|
101
|
+
version: '3.12'
|
102
102
|
name: rdoc
|
103
103
|
prerelease: false
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
109
|
+
version: '3.12'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
type: :development
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '2.12'
|
118
118
|
name: rspec
|
119
119
|
prerelease: false
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: '
|
125
|
+
version: '2.12'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
type: :development
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
131
|
-
- -
|
131
|
+
- - ~>
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: '0'
|
133
|
+
version: '0.9'
|
134
134
|
name: rb-fsevent
|
135
135
|
prerelease: false
|
136
136
|
requirement: !ruby/object:Gem::Requirement
|
137
137
|
none: false
|
138
138
|
requirements:
|
139
|
-
- -
|
139
|
+
- - ~>
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version: '0'
|
141
|
+
version: '0.9'
|
142
142
|
- !ruby/object:Gem::Dependency
|
143
143
|
type: :development
|
144
144
|
version_requirements: !ruby/object:Gem::Requirement
|
145
145
|
none: false
|
146
146
|
requirements:
|
147
|
-
- -
|
147
|
+
- - ~>
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
149
|
+
version: '0.7'
|
150
150
|
name: simplecov
|
151
151
|
prerelease: false
|
152
152
|
requirement: !ruby/object:Gem::Requirement
|
153
153
|
none: false
|
154
154
|
requirements:
|
155
|
-
- -
|
155
|
+
- - ~>
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
157
|
+
version: '0.7'
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
159
|
type: :development
|
160
160
|
version_requirements: !ruby/object:Gem::Requirement
|
161
161
|
none: false
|
162
162
|
requirements:
|
163
|
-
- -
|
163
|
+
- - ~>
|
164
164
|
- !ruby/object:Gem::Version
|
165
|
-
version: '0'
|
165
|
+
version: '0.1'
|
166
166
|
name: simplecov-csv
|
167
167
|
prerelease: false
|
168
168
|
requirement: !ruby/object:Gem::Requirement
|
169
169
|
none: false
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - ~>
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
173
|
+
version: '0.1'
|
174
174
|
description: Provides Ruby affordances for scripting OpenSCAD
|
175
175
|
email: me@cpb.ca
|
176
176
|
executables: []
|
@@ -217,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
217
|
- !ruby/object:Gem::Version
|
218
218
|
segments:
|
219
219
|
- 0
|
220
|
-
hash:
|
220
|
+
hash: -3905703001506090554
|
221
221
|
version: '0'
|
222
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
223
|
none: false
|