smalruby-editor 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of smalruby-editor might be problematic. Click here for more details.

Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -0
  3. data/Guardfile +8 -1
  4. data/app/assets/javascripts/blocks/hardware.js.coffee.erb +11 -152
  5. data/app/assets/javascripts/msg/en_us.js +5 -5
  6. data/app/assets/javascripts/msg/ja.js +5 -5
  7. data/app/assets/javascripts/views/signin_modal_view.js.coffee.erb +0 -0
  8. data/app/controllers/sessions_controller.rb +0 -0
  9. data/app/helpers/sessions_helper.rb +4 -0
  10. data/app/models/concerns/ruby_to_block/block/hardware_operation.rb +11 -0
  11. data/app/models/concerns/ruby_to_block/block/{hardware_smalrubot_s1_led_turn_on_or_off.rb → hardware_smalrubot_action.rb} +8 -5
  12. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_action_with_sec.rb +25 -0
  13. data/app/models/concerns/ruby_to_block/block/{hardware_smalrubot_v3_motor_speed.rb → hardware_smalrubot_dc_motor_power_ratio.rb} +8 -5
  14. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_dc_motor_set_power_ratio.rb +23 -0
  15. data/app/models/concerns/ruby_to_block/block/{hardware_smalrubot_v3_led_turn_on_or_off.rb → hardware_smalrubot_led_turn_on_or_off.rb} +8 -5
  16. data/app/models/concerns/ruby_to_block/block/{hardware_smalrubot_s1_ir_photoreflector_value.rb → hardware_smalrubot_sensor_value.rb} +8 -6
  17. data/app/views/editor/_toolbox_default.html.haml +4 -7
  18. data/app/views/editor/index.html.haml +7 -18
  19. data/bin/spring +0 -0
  20. data/config/application.rb +1 -0
  21. data/lib/smalruby_editor/version.rb +1 -1
  22. data/smalruby-editor.gemspec +1 -1
  23. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_led_turn_on_or_off.feature +8 -8
  24. data/spec/acceptance/block_mode/blocks/hardware/{smalrubot_v3_motor_speed.feature → smalrubot_v3_dc_motor_power_ratio.feature} +12 -12
  25. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_led_turn_on_or_off.feature +8 -8
  26. data/spec/acceptance/block_mode/blocks/hardware/{smalrubot_s1_ir_photoreflector_value.feature → smalrubot_v3_sensor_value.feature} +7 -7
  27. data/spec/models/concerns/ruby_to_block/block/{hardware__smalrubot_s1_spec.rb → hardware__smalrubot_spec.rb} +88 -84
  28. data/spec/spec_helper.rb +0 -0
  29. data/spec/steps/base_steps.rb +0 -0
  30. data/spec/steps/text_editor_steps.rb +0 -0
  31. metadata +23 -36
  32. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action.rb +0 -13
  33. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action_with_sec.rb +0 -14
  34. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_dc_motor_power_ratio.rb +0 -26
  35. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_dc_motor_set_power_ratio.rb +0 -21
  36. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_action.rb +0 -22
  37. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_action_with_sec.rb +0 -24
  38. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_light_sensor_value.rb +0 -28
  39. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_motor_set_speed.rb +0 -21
  40. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_touch_sensor_pressed_or_released.rb +0 -29
  41. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_light_sensor_value.feature +0 -92
  42. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_touch_sensor_pressed_or_released.feature +0 -108
  43. data/spec/models/concerns/ruby_to_block/block/hardware__smalrubot_v3_spec.rb +0 -433
@@ -1,108 +0,0 @@
1
- # encoding: utf-8
2
- # language: en
3
- @javascript
4
- Feature: hardware_smalrubot_v3_touch_sensor_pressed_or_released block
5
- Scenario: ブロックのみ配置する
6
- Given "ブロック" タブを表示する
7
-
8
- When 次のブロックを配置する:
9
- """
10
- %block{:type => "hardware_smalrubot_v3_touch_sensor_pressed_or_released", :x => "0", :y => "0"}
11
- %field{:name => "LOR"}<
12
- right
13
- %field{:name => "POR"}<
14
- pressed
15
- """
16
- And ブロックからソースコードを生成する
17
-
18
- Then テキストエディタのプログラムは "" であること
19
-
20
- Scenario: 文とブロックを配置する
21
- Given "ブロック" タブを表示する
22
-
23
- When 次のブロックを配置する:
24
- """
25
- %block{:type => "ruby_p", :x => "0", :y => "0", :inline => "true" }
26
- %value{:name => "ARG"}
27
- %block{:type => "hardware_smalrubot_v3_touch_sensor_pressed_or_released", :x => "0", :y => "0"}
28
- %field{:name => "LOR"}<
29
- right
30
- %field{:name => "POR"}<
31
- pressed
32
- """
33
- And ブロックからソースコードを生成する
34
-
35
- Then テキストエディタのプログラムは以下であること:
36
- """
37
- require "smalruby"
38
-
39
- p("")
40
-
41
- """
42
-
43
- Scenario: キャラクターとブロックを配置する
44
- Given "ブロック" タブを表示する
45
- And 次のキャラクターを追加する:
46
- | name | costumes | x | y | angle |
47
- | car1 | car1.png | 0 | 0 | 0 |
48
-
49
- When 次のブロックを配置する:
50
- """
51
- %block{:type => "character_new", :x => "21", :y => "15"}
52
- %field{:name => "NAME"}<
53
- car1
54
- %statement{:name => "DO"}
55
- %block{:type => "ruby_p", :x => "0", :y => "0", :inline => "true" }
56
- %value{:name => "ARG"}
57
- %block{:type => "hardware_smalrubot_v3_touch_sensor_pressed_or_released", :x => "0", :y => "0"}
58
- %field{:name => "LOR"}<
59
- right
60
- %field{:name => "POR"}<
61
- pressed
62
- """
63
- And ブロックからソースコードを生成する
64
-
65
- Then テキストエディタのプログラムは以下であること:
66
- """
67
- require "smalruby"
68
-
69
- car1 = Character.new(costume: "car1.png", x: 0, y: 0, angle: 0)
70
- p(car1.smalrubot_v3.right_touch_sensor.pressed?)
71
-
72
- """
73
-
74
- Scenario: キャラクターとイベントとブロックを配置する
75
- Given "ブロック" タブを表示する
76
- And 次のキャラクターを追加する:
77
- | name | costumes | x | y | angle |
78
- | car1 | car1.png | 0 | 0 | 0 |
79
-
80
- When 次のブロックを配置する:
81
- """
82
- %block{:type => "character_new", :x => "21", :y => "15"}
83
- %field{:name => "NAME"}<
84
- car1
85
- %statement{:name => "DO"}
86
- %block{:type => "events_on_start"}
87
- %statement{:name => "DO"}
88
- %block{:type => "ruby_p", :x => "0", :y => "0", :inline => "true" }
89
- %value{:name => "ARG"}
90
- %block{:type => "hardware_smalrubot_v3_touch_sensor_pressed_or_released", :x => "0", :y => "0"}
91
- %field{:name => "LOR"}<
92
- left
93
- %field{:name => "POR"}<
94
- released
95
- """
96
- And ブロックからソースコードを生成する
97
-
98
- Then テキストエディタのプログラムは以下であること:
99
- """
100
- require "smalruby"
101
-
102
- car1 = Character.new(costume: "car1.png", x: 0, y: 0, angle: 0)
103
-
104
- car1.on(:start) do
105
- p(smalrubot_v3.left_touch_sensor.released?)
106
- end
107
-
108
- """
@@ -1,433 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'spec_helper'
3
- require_relative 'shared/block_examples'
4
-
5
- # rubocop:disable EmptyLines, LineLength
6
-
7
- describe RubyToBlock::Block, 'Smalrubot v3 blocks', to_blocks: true do
8
- parts = <<-EOS
9
- require "smalruby"
10
-
11
- init_hardware
12
- car1 = Character.new(costume: "car1.png", x: 0, y: 0, angle: 0)
13
-
14
- car1.on(:start) do
15
- smalrubot_v3.forward
16
- smalrubot_v3.backward
17
- smalrubot_v3.turn_left
18
- smalrubot_v3.turn_right
19
- smalrubot_v3.stop
20
-
21
- smalrubot_v3.forward(sec: 0.5)
22
- smalrubot_v3.backward(sec: 0.4)
23
- smalrubot_v3.turn_left(sec: 0.3)
24
- smalrubot_v3.turn_right(sec: 0.2)
25
- smalrubot_v3.stop(sec: 0.1)
26
-
27
- p(smalrubot_v3.left_touch_sensor.pressed?)
28
- p(smalrubot_v3.left_touch_sensor.released?)
29
- p(smalrubot_v3.right_touch_sensor.pressed?)
30
- p(smalrubot_v3.right_touch_sensor.released?)
31
-
32
- p(smalrubot_v3.light_sensor.value)
33
-
34
- smalrubot_v3.red_led.turn_on
35
- smalrubot_v3.green_led.turn_off
36
-
37
- p(smalrubot_v3.left_motor_speed)
38
- p(smalrubot_v3.right_motor_speed)
39
-
40
- smalrubot_v3.left_motor_speed = 10
41
- smalrubot_v3.right_motor_speed = 90
42
- end
43
- car1.smalrubot_v3.forward
44
- car1.smalrubot_v3.backward
45
- car1.smalrubot_v3.turn_left
46
- car1.smalrubot_v3.turn_right
47
- car1.smalrubot_v3.stop
48
-
49
- car1.smalrubot_v3.forward(sec: 0.5)
50
- car1.smalrubot_v3.backward(sec: 0.4)
51
- car1.smalrubot_v3.turn_left(sec: 0.3)
52
- car1.smalrubot_v3.turn_right(sec: 0.2)
53
- car1.smalrubot_v3.stop(sec: 0.1)
54
-
55
- p(car1.smalrubot_v3.left_touch_sensor.pressed?)
56
- p(car1.smalrubot_v3.left_touch_sensor.released?)
57
- p(car1.smalrubot_v3.right_touch_sensor.pressed?)
58
- p(car1.smalrubot_v3.right_touch_sensor.released?)
59
-
60
- p(car1.smalrubot_v3.light_sensor.value)
61
-
62
- car1.smalrubot_v3.red_led.turn_on
63
- car1.smalrubot_v3.green_led.turn_off
64
-
65
- p(car1.smalrubot_v3.left_motor_speed)
66
- p(car1.smalrubot_v3.right_motor_speed)
67
-
68
- car1.smalrubot_v3.left_motor_speed = 10
69
- car1.smalrubot_v3.right_motor_speed = 90
70
- EOS
71
- describe compact_source_code(parts) do
72
- _parts = parts
73
- let(:data) { _parts }
74
-
75
- it '結果が正しいこと' do
76
- should eq_block_xml(<<-XML)
77
- <character name="car1" x="0" y="0" angle="0" costumes="car1.png" />
78
- <block type="hardware_init_hardware" />
79
- <block type="character_new">
80
- <field name="NAME">car1</field>
81
- <statement name="DO">
82
- <block type="events_on_start">
83
- <statement name="DO">
84
- <block type="hardware_smalrubot_v3_action" inline="true">
85
- <field name="ACTION">forward</field>
86
- <next>
87
- <block type="hardware_smalrubot_v3_action" inline="true">
88
- <field name="ACTION">backward</field>
89
- <next>
90
- <block type="hardware_smalrubot_v3_action" inline="true">
91
- <field name="ACTION">turn_left</field>
92
- <next>
93
- <block type="hardware_smalrubot_v3_action" inline="true">
94
- <field name="ACTION">turn_right</field>
95
- <next>
96
- <block type="hardware_smalrubot_v3_action" inline="true">
97
- <field name="ACTION">stop</field>
98
- <next>
99
- <block type="hardware_smalrubot_v3_action_with_sec" inline="true">
100
- <field name="ACTION">forward</field>
101
- <value name="SEC">
102
- <block type="math_number">
103
- <field name="NUM">0.5</field>
104
- </block>
105
- </value>
106
- <next>
107
- <block type="hardware_smalrubot_v3_action_with_sec" inline="true">
108
- <field name="ACTION">backward</field>
109
- <value name="SEC">
110
- <block type="math_number">
111
- <field name="NUM">0.4</field>
112
- </block>
113
- </value>
114
- <next>
115
- <block type="hardware_smalrubot_v3_action_with_sec" inline="true">
116
- <field name="ACTION">turn_left</field>
117
- <value name="SEC">
118
- <block type="math_number">
119
- <field name="NUM">0.3</field>
120
- </block>
121
- </value>
122
- <next>
123
- <block type="hardware_smalrubot_v3_action_with_sec" inline="true">
124
- <field name="ACTION">turn_right</field>
125
- <value name="SEC">
126
- <block type="math_number">
127
- <field name="NUM">0.2</field>
128
- </block>
129
- </value>
130
- <next>
131
- <block type="hardware_smalrubot_v3_action_with_sec" inline="true">
132
- <field name="ACTION">stop</field>
133
- <value name="SEC">
134
- <block type="math_number">
135
- <field name="NUM">0.1</field>
136
- </block>
137
- </value>
138
- <next>
139
- <block type="ruby_p" inline="true">
140
- <value name="ARG">
141
- <block type="hardware_smalrubot_v3_touch_sensor_pressed_or_released">
142
- <field name="LOR">left</field>
143
- <field name="POR">pressed</field>
144
- </block>
145
- </value>
146
- <next>
147
- <block type="ruby_p" inline="true">
148
- <value name="ARG">
149
- <block type="hardware_smalrubot_v3_touch_sensor_pressed_or_released">
150
- <field name="LOR">left</field>
151
- <field name="POR">released</field>
152
- </block>
153
- </value>
154
- <next>
155
- <block type="ruby_p" inline="true">
156
- <value name="ARG">
157
- <block type="hardware_smalrubot_v3_touch_sensor_pressed_or_released">
158
- <field name="LOR">right</field>
159
- <field name="POR">pressed</field>
160
- </block>
161
- </value>
162
- <next>
163
- <block type="ruby_p" inline="true">
164
- <value name="ARG">
165
- <block type="hardware_smalrubot_v3_touch_sensor_pressed_or_released">
166
- <field name="LOR">right</field>
167
- <field name="POR">released</field>
168
- </block>
169
- </value>
170
- <next>
171
- <block type="ruby_p" inline="true">
172
- <value name="ARG">
173
- <block type="hardware_smalrubot_v3_light_sensor_value" />
174
- </value>
175
- <next>
176
- <block type="hardware_smalrubot_v3_led_turn_on_or_off" inline="true">
177
- <field name="COLOUR">red</field>
178
- <field name="OOO">turn_on</field>
179
- <next>
180
- <block type="hardware_smalrubot_v3_led_turn_on_or_off" inline="true">
181
- <field name="COLOUR">green</field>
182
- <field name="OOO">turn_off</field>
183
- <next>
184
- <block type="ruby_p" inline="true">
185
- <value name="ARG">
186
- <block type="hardware_smalrubot_v3_motor_speed">
187
- <field name="LOR">left</field>
188
- </block>
189
- </value>
190
- <next>
191
- <block type="ruby_p" inline="true">
192
- <value name="ARG">
193
- <block type="hardware_smalrubot_v3_motor_speed">
194
- <field name="LOR">right</field>
195
- </block>
196
- </value>
197
- <next>
198
- <block type="hardware_smalrubot_v3_motor_set_speed" inline="true">
199
- <field name="LOR">left</field>
200
- <value name="SPEED">
201
- <block type="math_number">
202
- <field name="NUM">10</field>
203
- </block>
204
- </value>
205
- <next>
206
- <block type="hardware_smalrubot_v3_motor_set_speed" inline="true">
207
- <field name="LOR">right</field>
208
- <value name="SPEED">
209
- <block type="math_number">
210
- <field name="NUM">90</field>
211
- </block>
212
- </value>
213
- </block>
214
- </next>
215
- </block>
216
- </next>
217
- </block>
218
- </next>
219
- </block>
220
- </next>
221
- </block>
222
- </next>
223
- </block>
224
- </next>
225
- </block>
226
- </next>
227
- </block>
228
- </next>
229
- </block>
230
- </next>
231
- </block>
232
- </next>
233
- </block>
234
- </next>
235
- </block>
236
- </next>
237
- </block>
238
- </next>
239
- </block>
240
- </next>
241
- </block>
242
- </next>
243
- </block>
244
- </next>
245
- </block>
246
- </next>
247
- </block>
248
- </next>
249
- </block>
250
- </next>
251
- </block>
252
- </next>
253
- </block>
254
- </statement>
255
- <next>
256
- <block type="hardware_smalrubot_v3_action" inline="true">
257
- <field name="ACTION">forward</field>
258
- <next>
259
- <block type="hardware_smalrubot_v3_action" inline="true">
260
- <field name="ACTION">backward</field>
261
- <next>
262
- <block type="hardware_smalrubot_v3_action" inline="true">
263
- <field name="ACTION">turn_left</field>
264
- <next>
265
- <block type="hardware_smalrubot_v3_action" inline="true">
266
- <field name="ACTION">turn_right</field>
267
- <next>
268
- <block type="hardware_smalrubot_v3_action" inline="true">
269
- <field name="ACTION">stop</field>
270
- <next>
271
- <block type="hardware_smalrubot_v3_action_with_sec" inline="true">
272
- <field name="ACTION">forward</field>
273
- <value name="SEC">
274
- <block type="math_number">
275
- <field name="NUM">0.5</field>
276
- </block>
277
- </value>
278
- <next>
279
- <block type="hardware_smalrubot_v3_action_with_sec" inline="true">
280
- <field name="ACTION">backward</field>
281
- <value name="SEC">
282
- <block type="math_number">
283
- <field name="NUM">0.4</field>
284
- </block>
285
- </value>
286
- <next>
287
- <block type="hardware_smalrubot_v3_action_with_sec" inline="true">
288
- <field name="ACTION">turn_left</field>
289
- <value name="SEC">
290
- <block type="math_number">
291
- <field name="NUM">0.3</field>
292
- </block>
293
- </value>
294
- <next>
295
- <block type="hardware_smalrubot_v3_action_with_sec" inline="true">
296
- <field name="ACTION">turn_right</field>
297
- <value name="SEC">
298
- <block type="math_number">
299
- <field name="NUM">0.2</field>
300
- </block>
301
- </value>
302
- <next>
303
- <block type="hardware_smalrubot_v3_action_with_sec" inline="true">
304
- <field name="ACTION">stop</field>
305
- <value name="SEC">
306
- <block type="math_number">
307
- <field name="NUM">0.1</field>
308
- </block>
309
- </value>
310
- <next>
311
- <block type="ruby_p" inline="true">
312
- <value name="ARG">
313
- <block type="hardware_smalrubot_v3_touch_sensor_pressed_or_released">
314
- <field name="LOR">left</field>
315
- <field name="POR">pressed</field>
316
- </block>
317
- </value>
318
- <next>
319
- <block type="ruby_p" inline="true">
320
- <value name="ARG">
321
- <block type="hardware_smalrubot_v3_touch_sensor_pressed_or_released">
322
- <field name="LOR">left</field>
323
- <field name="POR">released</field>
324
- </block>
325
- </value>
326
- <next>
327
- <block type="ruby_p" inline="true">
328
- <value name="ARG">
329
- <block type="hardware_smalrubot_v3_touch_sensor_pressed_or_released">
330
- <field name="LOR">right</field>
331
- <field name="POR">pressed</field>
332
- </block>
333
- </value>
334
- <next>
335
- <block type="ruby_p" inline="true">
336
- <value name="ARG">
337
- <block type="hardware_smalrubot_v3_touch_sensor_pressed_or_released">
338
- <field name="LOR">right</field>
339
- <field name="POR">released</field>
340
- </block>
341
- </value>
342
- <next>
343
- <block type="ruby_p" inline="true">
344
- <value name="ARG">
345
- <block type="hardware_smalrubot_v3_light_sensor_value" />
346
- </value>
347
- <next>
348
- <block type="hardware_smalrubot_v3_led_turn_on_or_off" inline="true">
349
- <field name="COLOUR">red</field>
350
- <field name="OOO">turn_on</field>
351
- <next>
352
- <block type="hardware_smalrubot_v3_led_turn_on_or_off" inline="true">
353
- <field name="COLOUR">green</field>
354
- <field name="OOO">turn_off</field>
355
- <next>
356
- <block type="ruby_p" inline="true">
357
- <value name="ARG">
358
- <block type="hardware_smalrubot_v3_motor_speed">
359
- <field name="LOR">left</field>
360
- </block>
361
- </value>
362
- <next>
363
- <block type="ruby_p" inline="true">
364
- <value name="ARG">
365
- <block type="hardware_smalrubot_v3_motor_speed">
366
- <field name="LOR">right</field>
367
- </block>
368
- </value>
369
- <next>
370
- <block type="hardware_smalrubot_v3_motor_set_speed" inline="true">
371
- <field name="LOR">left</field>
372
- <value name="SPEED">
373
- <block type="math_number">
374
- <field name="NUM">10</field>
375
- </block>
376
- </value>
377
- <next>
378
- <block type="hardware_smalrubot_v3_motor_set_speed" inline="true">
379
- <field name="LOR">right</field>
380
- <value name="SPEED">
381
- <block type="math_number">
382
- <field name="NUM">90</field>
383
- </block>
384
- </value>
385
- </block>
386
- </next>
387
- </block>
388
- </next>
389
- </block>
390
- </next>
391
- </block>
392
- </next>
393
- </block>
394
- </next>
395
- </block>
396
- </next>
397
- </block>
398
- </next>
399
- </block>
400
- </next>
401
- </block>
402
- </next>
403
- </block>
404
- </next>
405
- </block>
406
- </next>
407
- </block>
408
- </next>
409
- </block>
410
- </next>
411
- </block>
412
- </next>
413
- </block>
414
- </next>
415
- </block>
416
- </next>
417
- </block>
418
- </next>
419
- </block>
420
- </next>
421
- </block>
422
- </next>
423
- </block>
424
- </next>
425
- </block>
426
- </next>
427
- </block>
428
- </statement>
429
- </block>
430
- XML
431
- end
432
- end
433
- end