rapiro_wrapper 0.1.0

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.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +138 -0
  9. data/Rakefile +5 -0
  10. data/bin/rapiro_wrapper +147 -0
  11. data/lib/rapiro_wrapper.rb +23 -0
  12. data/lib/rapiro_wrapper/body.rb +43 -0
  13. data/lib/rapiro_wrapper/command.rb +19 -0
  14. data/lib/rapiro_wrapper/commander.rb +28 -0
  15. data/lib/rapiro_wrapper/led.rb +4 -0
  16. data/lib/rapiro_wrapper/led/eyes.rb +23 -0
  17. data/lib/rapiro_wrapper/servo_motor.rb +27 -0
  18. data/lib/rapiro_wrapper/servo_motor/head.rb +21 -0
  19. data/lib/rapiro_wrapper/servo_motor/left_foot_pitch.rb +21 -0
  20. data/lib/rapiro_wrapper/servo_motor/left_foot_yaw.rb +21 -0
  21. data/lib/rapiro_wrapper/servo_motor/left_hand_grip.rb +21 -0
  22. data/lib/rapiro_wrapper/servo_motor/left_sholder_pitch.rb +18 -0
  23. data/lib/rapiro_wrapper/servo_motor/left_sholder_roll.rb +18 -0
  24. data/lib/rapiro_wrapper/servo_motor/right_foot_pitch.rb +21 -0
  25. data/lib/rapiro_wrapper/servo_motor/right_foot_yaw.rb +21 -0
  26. data/lib/rapiro_wrapper/servo_motor/right_hand_grip.rb +21 -0
  27. data/lib/rapiro_wrapper/servo_motor/right_sholder_pitch.rb +18 -0
  28. data/lib/rapiro_wrapper/servo_motor/right_sholder_roll.rb +14 -0
  29. data/lib/rapiro_wrapper/servo_motor/waist.rb +21 -0
  30. data/lib/rapiro_wrapper/version.rb +4 -0
  31. data/rapiro_wrapper.gemspec +27 -0
  32. data/spec/integration/base_spec.rb +577 -0
  33. data/spec/rapiro_wrapper/body_spec.rb +77 -0
  34. data/spec/rapiro_wrapper/command_spec.rb +54 -0
  35. data/spec/rapiro_wrapper/commander_spec.rb +111 -0
  36. data/spec/rapiro_wrapper/led/eyes_spec.rb +38 -0
  37. data/spec/rapiro_wrapper/servo_moter/head_spec.rb +248 -0
  38. data/spec/rapiro_wrapper/servo_moter/left_foot_pitch_spec.rb +261 -0
  39. data/spec/rapiro_wrapper/servo_moter/left_foot_yaw_spec.rb +256 -0
  40. data/spec/rapiro_wrapper/servo_moter/left_hand_grip_spec.rb +256 -0
  41. data/spec/rapiro_wrapper/servo_moter/left_sholder_pitch_spec.rb +134 -0
  42. data/spec/rapiro_wrapper/servo_moter/left_sholder_roll_spec.rb +150 -0
  43. data/spec/rapiro_wrapper/servo_moter/right_foot_pitch_spec.rb +261 -0
  44. data/spec/rapiro_wrapper/servo_moter/right_foot_yaw_spec.rb +256 -0
  45. data/spec/rapiro_wrapper/servo_moter/right_hand_grip_spec.rb +256 -0
  46. data/spec/rapiro_wrapper/servo_moter/right_sholder_pitch_spec.rb +134 -0
  47. data/spec/rapiro_wrapper/servo_moter/right_sholder_roll_spec.rb +150 -0
  48. data/spec/rapiro_wrapper/servo_moter/waist_spec.rb +248 -0
  49. data/spec/rapiro_wrapper/servo_moter_spec.rb +64 -0
  50. data/spec/rapiro_wrapper/version_spec.rb +11 -0
  51. data/spec/spec_helper.rb +4 -0
  52. metadata +199 -0
@@ -0,0 +1,248 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RapiroWrapper::Waist do
4
+ context 'constants' do
5
+ context 'NO' do
6
+ subject { described_class.const_get(:NO) }
7
+ it { is_expected.to eq 1 }
8
+ end
9
+ context 'DEFAULT' do
10
+ subject { described_class.const_get(:DEFAULT) }
11
+ it { is_expected.to eq 90 }
12
+ end
13
+ context 'MIN' do
14
+ subject { described_class.const_get(:MIN) }
15
+ it { is_expected.to eq 0 }
16
+ end
17
+ context 'MAX' do
18
+ subject { described_class.const_get(:MAX) }
19
+ it { is_expected.to eq 180 }
20
+ end
21
+ end
22
+
23
+ context '.code' do
24
+ context 'without arguments' do
25
+ subject { described_class.code }
26
+ it { is_expected.to eq 'S01A090' }
27
+ end
28
+
29
+ context 'with both right and left' do
30
+ subject { described_class.code(option) }
31
+ let(:option) { { right: 0, left: 0 } }
32
+ it { expect { subject }.to raise_error ArgumentError }
33
+ end
34
+
35
+ context 'with right' do
36
+ subject { described_class.code(option) }
37
+
38
+ context '-180' do
39
+ let(:option) { { right: -180 } }
40
+ it { expect { subject }.to raise_error ArgumentError }
41
+ end
42
+
43
+ context '-91' do
44
+ let(:option) { { right: -91 } }
45
+ it { expect { subject }.to raise_error ArgumentError }
46
+ end
47
+
48
+ context '-90' do
49
+ let(:option) { { right: -90 } }
50
+ it { is_expected.to eq 'S01A180' }
51
+ end
52
+
53
+ context '0' do
54
+ let(:option) { { right: 0 } }
55
+ it { is_expected.to eq 'S01A090' }
56
+ end
57
+
58
+ context '90' do
59
+ let(:option) { { right: 90 } }
60
+ it { is_expected.to eq 'S01A000' }
61
+ end
62
+
63
+ context '91' do
64
+ let(:option) { { right: 91 } }
65
+ it { expect { subject }.to raise_error ArgumentError }
66
+ end
67
+
68
+ context '180' do
69
+ let(:option) { { right: 180 } }
70
+ it { expect { subject }.to raise_error ArgumentError }
71
+ end
72
+ end
73
+
74
+ context 'with left' do
75
+ subject { described_class.code(option) }
76
+
77
+ context '-180' do
78
+ let(:option) { { left: -180 } }
79
+ it { expect { subject }.to raise_error ArgumentError }
80
+ end
81
+
82
+ context '-91' do
83
+ let(:option) { { left: -91 } }
84
+ it { expect { subject }.to raise_error ArgumentError }
85
+ end
86
+
87
+ context '-90' do
88
+ let(:option) { { left: -90 } }
89
+ it { is_expected.to eq 'S01A000' }
90
+ end
91
+
92
+ context '0' do
93
+ let(:option) { { left: 0 } }
94
+ it { is_expected.to eq 'S01A090' }
95
+ end
96
+
97
+ context '90' do
98
+ let(:option) { { left: 90 } }
99
+ it { is_expected.to eq 'S01A180' }
100
+ end
101
+
102
+ context '91' do
103
+ let(:option) { { left: 91 } }
104
+ it { expect { subject }.to raise_error ArgumentError }
105
+ end
106
+
107
+ context '180' do
108
+ let(:option) { { left: 180 } }
109
+ it { expect { subject }.to raise_error ArgumentError }
110
+ end
111
+ end
112
+ end
113
+
114
+ context 'constructor' do
115
+ context 'without arguments' do
116
+ subject { described_class.new }
117
+ it { expect { subject }.to_not raise_error }
118
+ context '@value' do
119
+ subject { described_class.new.instance_variable_get(:@value) }
120
+ it { is_expected.to eq 90 }
121
+ end
122
+ context '#to_code' do
123
+ subject { described_class.new.to_code }
124
+ it { is_expected.to eq 'S01A090' }
125
+ end
126
+ end
127
+
128
+ context 'with both right and left' do
129
+ subject { described_class.new(option).instance_variable_get(:@value) }
130
+ let(:option) { { right: 0, left: 0 } }
131
+ it { expect { subject }.to raise_error ArgumentError }
132
+ end
133
+
134
+ context 'with right' do
135
+ subject { described_class.new(option).instance_variable_get(:@value) }
136
+
137
+ context '-180' do
138
+ let(:option) { { right: -180 } }
139
+ it { expect { subject }.to raise_error ArgumentError }
140
+ end
141
+
142
+ context '-91' do
143
+ let(:option) { { right: -91 } }
144
+ it { expect { subject }.to raise_error ArgumentError }
145
+ end
146
+
147
+ context '-90' do
148
+ let(:option) { { right: -90 } }
149
+ context '@value' do
150
+ it { is_expected.to eq 180 }
151
+ end
152
+ context '#to_code' do
153
+ subject { described_class.new(option).to_code }
154
+ it { is_expected.to eq 'S01A180' }
155
+ end
156
+ end
157
+
158
+ context '0' do
159
+ let(:option) { { right: 0 } }
160
+ context '@value' do
161
+ it { is_expected.to eq 90 }
162
+ end
163
+ context '#to_code' do
164
+ subject { described_class.new(option).to_code }
165
+ it { is_expected.to eq 'S01A090' }
166
+ end
167
+ end
168
+
169
+ context '90' do
170
+ let(:option) { { right: 90 } }
171
+ context '@value' do
172
+ it { is_expected.to eq 0 }
173
+ end
174
+ context '#to_code' do
175
+ subject { described_class.new(option).to_code }
176
+ it { is_expected.to eq 'S01A000' }
177
+ end
178
+ end
179
+
180
+ context '91' do
181
+ let(:option) { { right: 91 } }
182
+ it { expect { subject }.to raise_error ArgumentError }
183
+ end
184
+
185
+ context '180' do
186
+ let(:option) { { right: 180 } }
187
+ it { expect { subject }.to raise_error ArgumentError }
188
+ end
189
+ end
190
+
191
+ context 'with left' do
192
+ subject { described_class.new(option).instance_variable_get(:@value) }
193
+
194
+ context '-180' do
195
+ let(:option) { { left: -180 } }
196
+ it { expect { subject }.to raise_error ArgumentError }
197
+ end
198
+
199
+ context '-91' do
200
+ let(:option) { { left: -91 } }
201
+ it { expect { subject }.to raise_error ArgumentError }
202
+ end
203
+
204
+ context '-90' do
205
+ let(:option) { { left: -90 } }
206
+ context '@value' do
207
+ it { is_expected.to eq 0 }
208
+ end
209
+ context '#to_code' do
210
+ subject { described_class.new(option).to_code }
211
+ it { is_expected.to eq 'S01A000' }
212
+ end
213
+ end
214
+
215
+ context '0' do
216
+ let(:option) { { left: 0 } }
217
+ context '@value' do
218
+ it { is_expected.to eq 90 }
219
+ end
220
+ context '#to_code' do
221
+ subject { described_class.new(option).to_code }
222
+ it { is_expected.to eq 'S01A090' }
223
+ end
224
+ end
225
+
226
+ context '90' do
227
+ let(:option) { { left: 90 } }
228
+ context '@value' do
229
+ it { is_expected.to eq 180 }
230
+ end
231
+ context '#to_code' do
232
+ subject { described_class.new(option).to_code }
233
+ it { is_expected.to eq 'S01A180' }
234
+ end
235
+ end
236
+
237
+ context '91' do
238
+ let(:option) { { left: 91 } }
239
+ it { expect { subject }.to raise_error ArgumentError }
240
+ end
241
+
242
+ context '180' do
243
+ let(:option) { { left: 180 } }
244
+ it { expect { subject }.to raise_error ArgumentError }
245
+ end
246
+ end
247
+ end
248
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RapiroWrapper::ServoMotor do
4
+ before(:all) do
5
+ DummyClass1 = Class.new(described_class) do
6
+ NO = 0
7
+ def initialize(_options = {})
8
+ @value = 12
9
+ end
10
+ end
11
+ end
12
+
13
+ context 'constructor' do
14
+ subject { described_class.new }
15
+ it { expect { subject }.to raise_error NotImplementedError }
16
+ end
17
+
18
+ context 'extended class' do
19
+ subject { Class.new(described_class) }
20
+ it { is_expected.to respond_to :code }
21
+ it { is_expected.to respond_to :find_servos }
22
+ end
23
+ context 'extended instance' do
24
+ subject { Class.new(described_class).new }
25
+ it { expect { subject }.to raise_error NotImplementedError }
26
+ context 'that wrapped constructor' do
27
+ subject { Class.new(described_class) { def initialize; end }.new }
28
+ it { expect { subject }.to_not raise_error }
29
+ it { is_expected.to respond_to :to_code }
30
+ end
31
+ end
32
+
33
+ context '#to_code' do
34
+ subject { DummyClass1.new.to_code }
35
+ it { is_expected.to be_instance_of String }
36
+ it { is_expected.to match(/^S\d{2}A\d{3}$/) }
37
+ context 'for examples' do
38
+ context 'set NO = 0 and @value = 12' do
39
+ subject { DummyClass1.new.to_code }
40
+ it { is_expected.to eq 'S00A012' }
41
+ end
42
+ end
43
+ end
44
+
45
+ context '.code' do
46
+ subject { DummyClass1.code }
47
+ it { is_expected.to be_instance_of String }
48
+ it { is_expected.to match(/^S\d{2}A\d{3}$/) }
49
+ context 'for examples' do
50
+ context 'set NO = 0 and @value = 12' do
51
+ subject { DummyClass1.code }
52
+ it { is_expected.to eq 'S00A012' }
53
+ end
54
+ end
55
+ end
56
+
57
+ context '.find_servos' do
58
+ subject { described_class.find_servos }
59
+ it { is_expected.to be_instance_of Array }
60
+ it 'should include subclasses' do
61
+ is_expected.to include DummyClass1
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RapiroWrapper do
4
+ subject { described_class }
5
+ context 'constants' do
6
+ context 'VERSION' do
7
+ subject { described_class.const_get(:VERSION) }
8
+ it { is_expected.to eq '0.1.0' }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'rapiro_wrapper'
metadata ADDED
@@ -0,0 +1,199 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rapiro_wrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Takahiro HAMAGUCHI
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: serialport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.29.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.29.0
97
+ description: A gem providing access to Rapiro with SerialPort.
98
+ email:
99
+ - tk.hamaguchi@gmail.com
100
+ executables:
101
+ - rapiro_wrapper
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".ruby-gemset"
108
+ - ".ruby-version"
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/rapiro_wrapper
114
+ - lib/rapiro_wrapper.rb
115
+ - lib/rapiro_wrapper/body.rb
116
+ - lib/rapiro_wrapper/command.rb
117
+ - lib/rapiro_wrapper/commander.rb
118
+ - lib/rapiro_wrapper/led.rb
119
+ - lib/rapiro_wrapper/led/eyes.rb
120
+ - lib/rapiro_wrapper/servo_motor.rb
121
+ - lib/rapiro_wrapper/servo_motor/head.rb
122
+ - lib/rapiro_wrapper/servo_motor/left_foot_pitch.rb
123
+ - lib/rapiro_wrapper/servo_motor/left_foot_yaw.rb
124
+ - lib/rapiro_wrapper/servo_motor/left_hand_grip.rb
125
+ - lib/rapiro_wrapper/servo_motor/left_sholder_pitch.rb
126
+ - lib/rapiro_wrapper/servo_motor/left_sholder_roll.rb
127
+ - lib/rapiro_wrapper/servo_motor/right_foot_pitch.rb
128
+ - lib/rapiro_wrapper/servo_motor/right_foot_yaw.rb
129
+ - lib/rapiro_wrapper/servo_motor/right_hand_grip.rb
130
+ - lib/rapiro_wrapper/servo_motor/right_sholder_pitch.rb
131
+ - lib/rapiro_wrapper/servo_motor/right_sholder_roll.rb
132
+ - lib/rapiro_wrapper/servo_motor/waist.rb
133
+ - lib/rapiro_wrapper/version.rb
134
+ - rapiro_wrapper.gemspec
135
+ - spec/integration/base_spec.rb
136
+ - spec/rapiro_wrapper/body_spec.rb
137
+ - spec/rapiro_wrapper/command_spec.rb
138
+ - spec/rapiro_wrapper/commander_spec.rb
139
+ - spec/rapiro_wrapper/led/eyes_spec.rb
140
+ - spec/rapiro_wrapper/servo_moter/head_spec.rb
141
+ - spec/rapiro_wrapper/servo_moter/left_foot_pitch_spec.rb
142
+ - spec/rapiro_wrapper/servo_moter/left_foot_yaw_spec.rb
143
+ - spec/rapiro_wrapper/servo_moter/left_hand_grip_spec.rb
144
+ - spec/rapiro_wrapper/servo_moter/left_sholder_pitch_spec.rb
145
+ - spec/rapiro_wrapper/servo_moter/left_sholder_roll_spec.rb
146
+ - spec/rapiro_wrapper/servo_moter/right_foot_pitch_spec.rb
147
+ - spec/rapiro_wrapper/servo_moter/right_foot_yaw_spec.rb
148
+ - spec/rapiro_wrapper/servo_moter/right_hand_grip_spec.rb
149
+ - spec/rapiro_wrapper/servo_moter/right_sholder_pitch_spec.rb
150
+ - spec/rapiro_wrapper/servo_moter/right_sholder_roll_spec.rb
151
+ - spec/rapiro_wrapper/servo_moter/waist_spec.rb
152
+ - spec/rapiro_wrapper/servo_moter_spec.rb
153
+ - spec/rapiro_wrapper/version_spec.rb
154
+ - spec/spec_helper.rb
155
+ homepage: https://github.com/tk-hamaguchi/rapiro_wrapper.git
156
+ licenses:
157
+ - MIT
158
+ metadata: {}
159
+ post_install_message:
160
+ rdoc_options: []
161
+ require_paths:
162
+ - lib
163
+ required_ruby_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ requirements: []
174
+ rubyforge_project:
175
+ rubygems_version: 2.4.5
176
+ signing_key:
177
+ specification_version: 4
178
+ summary: A gem providing access to Rapiro with SerialPort
179
+ test_files:
180
+ - spec/integration/base_spec.rb
181
+ - spec/rapiro_wrapper/body_spec.rb
182
+ - spec/rapiro_wrapper/command_spec.rb
183
+ - spec/rapiro_wrapper/commander_spec.rb
184
+ - spec/rapiro_wrapper/led/eyes_spec.rb
185
+ - spec/rapiro_wrapper/servo_moter/head_spec.rb
186
+ - spec/rapiro_wrapper/servo_moter/left_foot_pitch_spec.rb
187
+ - spec/rapiro_wrapper/servo_moter/left_foot_yaw_spec.rb
188
+ - spec/rapiro_wrapper/servo_moter/left_hand_grip_spec.rb
189
+ - spec/rapiro_wrapper/servo_moter/left_sholder_pitch_spec.rb
190
+ - spec/rapiro_wrapper/servo_moter/left_sholder_roll_spec.rb
191
+ - spec/rapiro_wrapper/servo_moter/right_foot_pitch_spec.rb
192
+ - spec/rapiro_wrapper/servo_moter/right_foot_yaw_spec.rb
193
+ - spec/rapiro_wrapper/servo_moter/right_hand_grip_spec.rb
194
+ - spec/rapiro_wrapper/servo_moter/right_sholder_pitch_spec.rb
195
+ - spec/rapiro_wrapper/servo_moter/right_sholder_roll_spec.rb
196
+ - spec/rapiro_wrapper/servo_moter/waist_spec.rb
197
+ - spec/rapiro_wrapper/servo_moter_spec.rb
198
+ - spec/rapiro_wrapper/version_spec.rb
199
+ - spec/spec_helper.rb