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.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/Guardfile +8 -1
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +11 -152
- data/app/assets/javascripts/msg/en_us.js +5 -5
- data/app/assets/javascripts/msg/ja.js +5 -5
- data/app/assets/javascripts/views/signin_modal_view.js.coffee.erb +0 -0
- data/app/controllers/sessions_controller.rb +0 -0
- data/app/helpers/sessions_helper.rb +4 -0
- data/app/models/concerns/ruby_to_block/block/hardware_operation.rb +11 -0
- data/app/models/concerns/ruby_to_block/block/{hardware_smalrubot_s1_led_turn_on_or_off.rb → hardware_smalrubot_action.rb} +8 -5
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_action_with_sec.rb +25 -0
- data/app/models/concerns/ruby_to_block/block/{hardware_smalrubot_v3_motor_speed.rb → hardware_smalrubot_dc_motor_power_ratio.rb} +8 -5
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_dc_motor_set_power_ratio.rb +23 -0
- 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
- data/app/models/concerns/ruby_to_block/block/{hardware_smalrubot_s1_ir_photoreflector_value.rb → hardware_smalrubot_sensor_value.rb} +8 -6
- data/app/views/editor/_toolbox_default.html.haml +4 -7
- data/app/views/editor/index.html.haml +7 -18
- data/bin/spring +0 -0
- data/config/application.rb +1 -0
- data/lib/smalruby_editor/version.rb +1 -1
- data/smalruby-editor.gemspec +1 -1
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_led_turn_on_or_off.feature +8 -8
- data/spec/acceptance/block_mode/blocks/hardware/{smalrubot_v3_motor_speed.feature → smalrubot_v3_dc_motor_power_ratio.feature} +12 -12
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_led_turn_on_or_off.feature +8 -8
- data/spec/acceptance/block_mode/blocks/hardware/{smalrubot_s1_ir_photoreflector_value.feature → smalrubot_v3_sensor_value.feature} +7 -7
- data/spec/models/concerns/ruby_to_block/block/{hardware__smalrubot_s1_spec.rb → hardware__smalrubot_spec.rb} +88 -84
- data/spec/spec_helper.rb +0 -0
- data/spec/steps/base_steps.rb +0 -0
- data/spec/steps/text_editor_steps.rb +0 -0
- metadata +23 -36
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action.rb +0 -13
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action_with_sec.rb +0 -14
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_dc_motor_power_ratio.rb +0 -26
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_dc_motor_set_power_ratio.rb +0 -21
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_action.rb +0 -22
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_action_with_sec.rb +0 -24
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_light_sensor_value.rb +0 -28
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_motor_set_speed.rb +0 -21
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_touch_sensor_pressed_or_released.rb +0 -29
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_light_sensor_value.feature +0 -92
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_touch_sensor_pressed_or_released.feature +0 -108
- data/spec/models/concerns/ruby_to_block/block/hardware__smalrubot_v3_spec.rb +0 -433
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d519d07db19419635f0be2aa269950b37b83f1d3
|
4
|
+
data.tar.gz: a06bc9dcc87dbb3f5b25075281a18305f706ca15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7620ae47249b1052a4076bc18287f19f738f5baa6e9e3820356f1f2b956486c01d43e27f3c26ed74002b972108da171786e00b598b6952eb7f15738e2213cc58
|
7
|
+
data.tar.gz: e19c3affd303d060f88741f875a970c2f88b97004e281cc93876b93b1d72decd8ad6c9cfae6c66b53547d20e81d51d411901cdcbece5fa657c2ebb366b47519a
|
data/.rubocop.yml
CHANGED
@@ -37,3 +37,11 @@ ClassLength:
|
|
37
37
|
# LoadErrorなど、rescueブロックを空にすることはよくあるため。
|
38
38
|
HandleExceptions:
|
39
39
|
Enabled: false
|
40
|
+
|
41
|
+
# when use if/unless modifier, can't check coverage
|
42
|
+
IfUnlessModifier:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
# this is not important for me.
|
46
|
+
StringLiterals:
|
47
|
+
Enabled: false
|
data/Guardfile
CHANGED
@@ -17,12 +17,19 @@ group :red_green_refactor, halt_on_fail: true do
|
|
17
17
|
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
18
18
|
end
|
19
19
|
|
20
|
-
guard :rspec, cmd: 'bundle exec bin/rspec' do
|
20
|
+
guard :rspec, cmd: 'bundle exec bin/spring rspec' do
|
21
21
|
watch(%r{^spec/.+_spec\.rb$})
|
22
22
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
23
23
|
watch('spec/spec_helper.rb') { "spec" }
|
24
24
|
|
25
25
|
# Rails example
|
26
|
+
watch(%r{^app/models/concerns/ruby_to_block/block/hardware_(.*)\.rb$}) { |m|
|
27
|
+
if /smalrubot/.match(m[1])
|
28
|
+
"spec/models/concerns/ruby_to_block/block/hardware__smalrubot_spec.rb"
|
29
|
+
else
|
30
|
+
"spec/models/concerns/ruby_to_block/block/hardware_spec.rb"
|
31
|
+
end
|
32
|
+
}
|
26
33
|
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
27
34
|
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
28
35
|
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
@@ -453,158 +453,15 @@ Blockly.Ruby['<%= n %>'] = (block) ->
|
|
453
453
|
pin = @getFieldValue('PIN')
|
454
454
|
Blockly.Ruby.characterMethodCallInput_("sensor(#{Blockly.Ruby.quote_(pin)}).value")
|
455
455
|
|
456
|
-
# SmalrubotV3 sub category
|
457
|
-
<% subcategory = 'smalrubot_v3' %>
|
458
|
-
|
459
|
-
# turn on/off Smalrubot v3 red/green LED
|
460
|
-
<% n = "#{category}_#{subcategory}_led_turn_on_or_off" %>
|
461
|
-
Blockly.Blocks['<%= n %>'] =
|
462
|
-
init: ()->
|
463
|
-
colourDropdown = [
|
464
|
-
[<%= bm('colour.red') %>, 'red'],
|
465
|
-
[<%= bm('colour.green') %>, 'green'],
|
466
|
-
]
|
467
|
-
oooDropdown = [
|
468
|
-
[<%= bm('common.turn_on') %>, 'turn_on'],
|
469
|
-
[<%= bm('common.turn_off') %>, 'turn_off'],
|
470
|
-
]
|
471
|
-
|
472
|
-
@setHelpUrl('')
|
473
|
-
@setColour(<%= colors[:looks] %>)
|
474
|
-
@interpolateMsg(<%= bm(".#{subcategory}_led_turn_on_or_off") %>,
|
475
|
-
['COLOUR', new Blockly.FieldDropdown(colourDropdown)],
|
476
|
-
['OOO', new Blockly.FieldDropdown(oooDropdown)],
|
477
|
-
Blockly.ALIGN_RIGHT)
|
478
|
-
@setInputsInline(true)
|
479
|
-
@setPreviousStatement(true)
|
480
|
-
@setNextStatement(true)
|
481
|
-
@setTooltip('')
|
482
|
-
|
483
|
-
Blockly.Ruby['<%= n %>'] = (block) ->
|
484
|
-
colour = @getFieldValue('COLOUR')
|
485
|
-
ooo = @getFieldValue('OOO')
|
486
|
-
Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{colour}_led.#{ooo}")
|
487
|
-
|
488
|
-
# Smalrubot v3 left/right motor speed
|
489
|
-
<% n = "#{category}_#{subcategory}_motor_speed" %>
|
490
|
-
Blockly.Blocks['<%= n %>'] =
|
491
|
-
init: ()->
|
492
|
-
@setHelpUrl('')
|
493
|
-
@setColour(<%= colors[:sensing] %>)
|
494
|
-
@interpolateMsg(<%= bm(".#{subcategory}_motor_speed") %>,
|
495
|
-
['LOR', new Blockly.FieldDropdown(lorDropdown)],
|
496
|
-
Blockly.ALIGN_RIGHT)
|
497
|
-
@setOutput(true, 'Number')
|
498
|
-
@setTooltip('')
|
499
|
-
|
500
|
-
Blockly.Ruby['<%= n %>'] = (block) ->
|
501
|
-
lor = @getFieldValue('LOR')
|
502
|
-
Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.#{lor}_motor.speed")
|
503
|
-
|
504
|
-
# set Smalrubot v3 left/right motor speed
|
505
|
-
<% n = "#{category}_#{subcategory}_motor_set_speed" %>
|
506
|
-
Blockly.Blocks['<%= n %>'] =
|
507
|
-
init: ()->
|
508
|
-
@setHelpUrl('')
|
509
|
-
@setColour(<%= colors[:motion] %>)
|
510
|
-
@interpolateMsg(<%= bm(".#{subcategory}_motor_set_speed") %>,
|
511
|
-
['LOR', new Blockly.FieldDropdown(lorDropdown)],
|
512
|
-
['SPEED', ['Number'], Blockly.ALIGN_RIGHT],
|
513
|
-
Blockly.ALIGN_RIGHT)
|
514
|
-
@setInputsInline(true)
|
515
|
-
@setPreviousStatement(true)
|
516
|
-
@setNextStatement(true)
|
517
|
-
@setTooltip('')
|
518
|
-
|
519
|
-
Blockly.Ruby['<%= n %>'] = (block) ->
|
520
|
-
lor = @getFieldValue('LOR')
|
521
|
-
speed = Blockly.Ruby.valueToCode(@, 'SPEED', Blockly.Ruby.ORDER_NONE) || '100'
|
522
|
-
Blockly.Ruby.characterSetVariable_("<%= subcategory %>.#{lor}_motor.speed",
|
523
|
-
speed)
|
524
|
-
|
525
|
-
# forward/backward/turn left/turn right/stop Smalrubot v3
|
526
|
-
<% n = "#{category}_#{subcategory}_action" %>
|
527
|
-
Blockly.Blocks['<%= n %>'] =
|
528
|
-
init: ()->
|
529
|
-
@setHelpUrl('')
|
530
|
-
@setColour(<%= colors[:motion] %>)
|
531
|
-
@interpolateMsg(<%= bm(".#{subcategory}_action") %>,
|
532
|
-
['ACTION', new Blockly.FieldDropdown(actionDropdown)],
|
533
|
-
Blockly.ALIGN_RIGHT)
|
534
|
-
@setInputsInline(true)
|
535
|
-
@setPreviousStatement(true)
|
536
|
-
@setNextStatement(true)
|
537
|
-
@setTooltip('')
|
538
|
-
|
539
|
-
Blockly.Ruby['<%= n %>'] = (block) ->
|
540
|
-
action = @getFieldValue('ACTION')
|
541
|
-
Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{action}")
|
542
|
-
|
543
|
-
# forward/backward/turn left/turn right/stop Smalrubot v3 for ( ) secs
|
544
|
-
<% n = "#{category}_#{subcategory}_action_with_sec" %>
|
545
|
-
Blockly.Blocks['<%= n %>'] =
|
546
|
-
init: ()->
|
547
|
-
@setHelpUrl('')
|
548
|
-
@setColour(<%= colors[:motion] %>)
|
549
|
-
@interpolateMsg(<%= bm(".#{subcategory}_action_with_sec") %>,
|
550
|
-
['ACTION', new Blockly.FieldDropdown(actionDropdown)],
|
551
|
-
['SEC', ['Number'], Blockly.ALIGN_RIGHT],
|
552
|
-
Blockly.ALIGN_RIGHT)
|
553
|
-
@setInputsInline(true)
|
554
|
-
@setPreviousStatement(true)
|
555
|
-
@setNextStatement(true)
|
556
|
-
@setTooltip('')
|
557
|
-
|
558
|
-
Blockly.Ruby['<%= n %>'] = (block) ->
|
559
|
-
action = @getFieldValue('ACTION')
|
560
|
-
sec = Blockly.Ruby.valueToCode(@, 'SEC', Blockly.Ruby.ORDER_FUNCTION_CALL) || 'nil'
|
561
|
-
Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{action}(sec: #{sec})")
|
562
|
-
|
563
|
-
# Smalrubot v3 touch sensor pressed/released
|
564
|
-
<% n = "#{category}_#{subcategory}_touch_sensor_pressed_or_released" %>
|
565
|
-
Blockly.Blocks['<%= n %>'] =
|
566
|
-
init: ()->
|
567
|
-
porDropdown = window.SmalrubyEditor.Sensing.PressedOrReleasedDropdown
|
568
|
-
|
569
|
-
@setHelpUrl('')
|
570
|
-
@setColour(<%= colors[:sensing] %>)
|
571
|
-
@interpolateMsg(<%= bm(".#{subcategory}_touch_sensor_pressed_or_released") %>,
|
572
|
-
['LOR', new Blockly.FieldDropdown(lorDropdown)],
|
573
|
-
['POR', new Blockly.FieldDropdown(porDropdown)],
|
574
|
-
Blockly.ALIGN_RIGHT)
|
575
|
-
@setOutput(true, 'Boolean')
|
576
|
-
@setTooltip('')
|
577
|
-
|
578
|
-
Blockly.Ruby['<%= n %>'] = (block) ->
|
579
|
-
lor = @getFieldValue('LOR')
|
580
|
-
por = @getFieldValue('POR')
|
581
|
-
Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.#{lor}_touch_sensor.#{por}?")
|
582
|
-
|
583
|
-
# Smalrubot v3 light sensor value
|
584
|
-
<% n = "#{category}_#{subcategory}_light_sensor_value" %>
|
585
|
-
Blockly.Blocks['<%= n %>'] =
|
586
|
-
init: ()->
|
587
|
-
@setHelpUrl('')
|
588
|
-
@setColour(<%= colors[:sensing] %>)
|
589
|
-
@appendDummyInput().appendField(<%= bm(".#{subcategory}_light_sensor_value") %>)
|
590
|
-
@setOutput(true, 'Number')
|
591
|
-
@setTooltip('')
|
592
|
-
|
593
|
-
Blockly.Ruby['<%= n %>'] = (block) ->
|
594
|
-
Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.light_sensor.value")
|
595
|
-
|
596
456
|
|
457
|
+
# SmalrubotV3 sub category
|
597
458
|
# SmalrubotS1 sub category
|
598
|
-
<%
|
459
|
+
<% %w(smalrubot_v3 smalrubot_s1).each do |subcategory| %>
|
599
460
|
|
600
461
|
# turn on/off Smalrubot s1 blue/white LED
|
601
462
|
<% n = "#{category}_#{subcategory}_led_turn_on_or_off" %>
|
602
463
|
Blockly.Blocks['<%= n %>'] =
|
603
464
|
init: ()->
|
604
|
-
colourDropdown = [
|
605
|
-
[<%= bm('colour.blue') %>, 'blue'],
|
606
|
-
[<%= bm('colour.white') %>, 'white'],
|
607
|
-
]
|
608
465
|
oooDropdown = [
|
609
466
|
[<%= bm('common.turn_on') %>, 'turn_on'],
|
610
467
|
[<%= bm('common.turn_off') %>, 'turn_off'],
|
@@ -613,7 +470,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
613
470
|
@setHelpUrl('')
|
614
471
|
@setColour(<%= colors[:looks] %>)
|
615
472
|
@interpolateMsg(<%= bm(".#{subcategory}_led_turn_on_or_off") %>,
|
616
|
-
['
|
473
|
+
['LOR', new Blockly.FieldDropdown(lorDropdown)],
|
617
474
|
['OOO', new Blockly.FieldDropdown(oooDropdown)],
|
618
475
|
Blockly.ALIGN_RIGHT)
|
619
476
|
@setInputsInline(true)
|
@@ -622,9 +479,9 @@ Blockly.Blocks['<%= n %>'] =
|
|
622
479
|
@setTooltip('')
|
623
480
|
|
624
481
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
625
|
-
|
482
|
+
lor = @getFieldValue('LOR')
|
626
483
|
ooo = @getFieldValue('OOO')
|
627
|
-
Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{ooo}_#{
|
484
|
+
Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{ooo}_#{lor}_led")
|
628
485
|
|
629
486
|
# forward/backward/turn left/turn right/stop Smalrubot s1
|
630
487
|
<% n = "#{category}_#{subcategory}_action" %>
|
@@ -664,13 +521,13 @@ Blockly.Ruby['<%= n %>'] = (block) ->
|
|
664
521
|
sec = Blockly.Ruby.valueToCode(@, 'SEC', Blockly.Ruby.ORDER_FUNCTION_CALL) || 'nil'
|
665
522
|
Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{action}(sec: #{sec})")
|
666
523
|
|
667
|
-
# Smalrubot s1 left/right
|
668
|
-
<% n = "#{category}_#{subcategory}
|
524
|
+
# Smalrubot s1 left/right sensor value
|
525
|
+
<% n = "#{category}_#{subcategory}_sensor_value" %>
|
669
526
|
Blockly.Blocks['<%= n %>'] =
|
670
527
|
init: ()->
|
671
528
|
@setHelpUrl('')
|
672
529
|
@setColour(<%= colors[:sensing] %>)
|
673
|
-
@interpolateMsg(<%= bm(".#{subcategory}
|
530
|
+
@interpolateMsg(<%= bm(".#{subcategory}_sensor_value") %>,
|
674
531
|
['LOR', new Blockly.FieldDropdown(lorDropdown)],
|
675
532
|
Blockly.ALIGN_RIGHT)
|
676
533
|
@setOutput(true, 'Boolean')
|
@@ -678,7 +535,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
678
535
|
|
679
536
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
680
537
|
lor = @getFieldValue('LOR')
|
681
|
-
Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.#{lor}
|
538
|
+
Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.#{lor}_sensor_value")
|
682
539
|
|
683
540
|
# Smalrubot s1 left/right dc motor power ratio
|
684
541
|
<% n = "#{category}_#{subcategory}_dc_motor_power_ratio" %>
|
@@ -716,3 +573,5 @@ Blockly.Ruby['<%= n %>'] = (block) ->
|
|
716
573
|
speed = Blockly.Ruby.valueToCode(@, 'SPEED', Blockly.Ruby.ORDER_NONE) || '100'
|
717
574
|
Blockly.Ruby.characterSetVariable_("<%= subcategory %>.#{lor}_dc_motor_power_ratio",
|
718
575
|
speed)
|
576
|
+
|
577
|
+
<% end %>
|
@@ -252,17 +252,17 @@ Blockly.Msg.BLOCKS_HARDWARE_MOTOR_DRIVER_SET_SPEED = "set (motor driver %1's) mo
|
|
252
252
|
Blockly.Msg.BLOCKS_HARDWARE_MOTOR_DRIVER_SPEED = "(motor driver %1's) motor speed (%)";
|
253
253
|
Blockly.Msg.BLOCKS_HARDWARE_BUTTON_PRESSED_OR_RELEASED = 'button %1 %2 ?';
|
254
254
|
Blockly.Msg.BLOCKS_HARDWARE_SENSOR_VALUE = 'sensor %1 value';
|
255
|
+
|
255
256
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_LED_TURN_ON_OR_OFF = '%2 Smalrubot v3 %1 LED';
|
256
|
-
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_MOTOR_SPEED = 'Smalrubot v3 %1 motor speed';
|
257
|
-
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_MOTOR_SET_SPEED = 'set Smalrubot v3 %1 motor speed to %2 %';
|
258
257
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_ACTION = '%1 Smalrubot v3';
|
259
258
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_ACTION_WITH_SEC = '%1 Smalrubot v3 for %2 secs';
|
260
|
-
Blockly.Msg.
|
261
|
-
Blockly.Msg.
|
259
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_SENSOR_VALUE = 'Smalrubot v3 %1 sensor';
|
260
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_DC_MOTOR_POWER_RATIO = 'Smalrubot v3 %1 dc motor power ratio';
|
261
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_DC_MOTOR_SET_POWER_RATIO = 'set Smalrubot v3 %1 dc motor power ratio to %2 %';
|
262
262
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_LED_TURN_ON_OR_OFF = '%2 Smalrubot s1 %1 LED';
|
263
263
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_ACTION = '%1 Smalrubot s1';
|
264
264
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_ACTION_WITH_SEC = '%1 Smalrubot s1 for %2 secs';
|
265
|
-
Blockly.Msg.
|
265
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_SENSOR_VALUE = 'Smalrubot s1 %1 sensor';
|
266
266
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_DC_MOTOR_POWER_RATIO = 'Smalrubot s1 %1 dc motor power ratio';
|
267
267
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_DC_MOTOR_SET_POWER_RATIO = 'set Smalrubot s1 %1 dc motor power ratio to %2 %';
|
268
268
|
|
@@ -86,6 +86,7 @@ Blockly.Msg.VIEWS_SIGNIN_MODAL_VIEW_ERROR = 'ログインに失敗しました';
|
|
86
86
|
|
87
87
|
// blocks/motion.js.coffee.erb
|
88
88
|
Blockly.Msg.BLOCKS_MOTION_MOVE = '■%1歩動かす';
|
89
|
+
Blockly.Msg.BLOCKS_MOTION_MOVE2 = '■%1歩動かす2';
|
89
90
|
Blockly.Msg.BLOCKS_MOTION_TURN_RIGHT_DEGREES = '■時計回りに%1度回す';
|
90
91
|
Blockly.Msg.BLOCKS_MOTION_TURN_LEFT_DEGREES = '■反時計回りに%1度回す';
|
91
92
|
Blockly.Msg.BLOCKS_MOTION_POINT_IN_DIRECTION = '■%1 度に向ける';
|
@@ -253,16 +254,15 @@ Blockly.Msg.BLOCKS_HARDWARE_MOTOR_DRIVER_SPEED = '◎(モータードライバ %
|
|
253
254
|
Blockly.Msg.BLOCKS_HARDWARE_BUTTON_PRESSED_OR_RELEASED = '◎ボタン %1 が %2 ?';
|
254
255
|
Blockly.Msg.BLOCKS_HARDWARE_SENSOR_VALUE = '◎センサー %1';
|
255
256
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_LED_TURN_ON_OR_OFF = '★スモウルボットV3の %1 LEDを %2';
|
256
|
-
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_MOTOR_SPEED = '◎スモウルボットV3の %1 モーターの速度(%)';
|
257
|
-
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_MOTOR_SET_SPEED = '■スモウルボットV3の %1 モーターの速度を %2 (%) にする';
|
258
257
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_ACTION = '■スモウルボットV3を %1';
|
259
258
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_ACTION_WITH_SEC = '■スモウルボットV3を %2 秒 %1';
|
260
|
-
Blockly.Msg.
|
261
|
-
Blockly.Msg.
|
259
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_SENSOR_VALUE = '◎スモウルボットV3の %1 のセンサー';
|
260
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_DC_MOTOR_POWER_RATIO = '◎スモウルボットV3の %1 DCモーターの速度(%)';
|
261
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_DC_MOTOR_SET_POWER_RATIO = '■スモウルボットV3の %1 DCモーターの速度を %2 (%) にする';
|
262
262
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_LED_TURN_ON_OR_OFF = '★スモウルボットS1の %1 LEDを %2';
|
263
263
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_ACTION = '■スモウルボットS1を %1';
|
264
264
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_ACTION_WITH_SEC = '■スモウルボットS1を %2 秒 %1';
|
265
|
-
Blockly.Msg.
|
265
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_SENSOR_VALUE = '◎スモウルボットS1の %1 のセンサー';
|
266
266
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_DC_MOTOR_POWER_RATIO = '◎スモウルボットS1の %1 DCモーターの速度(%)';
|
267
267
|
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_DC_MOTOR_SET_POWER_RATIO = '■スモウルボットS1の %1 DCモーターの速度を %2 (%) にする';
|
268
268
|
|
File without changes
|
File without changes
|
@@ -5,13 +5,24 @@ module RubyToBlock
|
|
5
5
|
module HardwareOperation
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
|
+
SMALRUBOT_RE = '(smalrubot_[^.]+)'
|
8
9
|
DIO_PIN_RE = '\s*"(D(?:[2-9]|10|11|12|13))"\s*'
|
9
10
|
PWM_PIN_RE = '\s*"(D(?:3|5|6|9|10|11))"\s*'
|
10
11
|
AIO_PIN_RE = '\s*"(A[0-5])"\s*'
|
11
12
|
TWO_WHEEL_DRIVE_CAR_PIN_RE = '\s*"(D[56])"\s*'
|
12
13
|
LOR_RE = '(left|right)'
|
14
|
+
ON_OFF_RE = '(turn_on|turn_off)'
|
13
15
|
POR_RE = '(pressed|released)'
|
14
16
|
ACTION_RE = '(forward|backward|turn_left|turn_right|stop)'
|
17
|
+
|
18
|
+
included do
|
19
|
+
attr_accessor :smalrubot_name
|
20
|
+
end
|
21
|
+
|
22
|
+
def type
|
23
|
+
@type ||=
|
24
|
+
(smalrubot_name ? super.gsub('smalrubot', smalrubot_name) : super)
|
25
|
+
end
|
15
26
|
end
|
16
27
|
end
|
17
28
|
end
|
@@ -1,19 +1,22 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
module RubyToBlock
|
3
3
|
module Block
|
4
|
-
class
|
4
|
+
class HardwareSmalrubotAction < CharacterMethodCall
|
5
5
|
include HardwareOperation
|
6
6
|
|
7
7
|
# rubocop:disable LineLength
|
8
|
-
blocknize '^\s*'
|
9
|
-
|
10
|
-
|
8
|
+
blocknize ['^\s*',
|
9
|
+
CHAR_RE,
|
10
|
+
SMALRUBOT_RE, '\.',
|
11
|
+
ACTION_RE,
|
12
|
+
'\s*$'].join(''),
|
11
13
|
statement: true, inline: true
|
12
14
|
# rubocop:enable LineLength
|
13
15
|
|
14
16
|
def self.process_match_data(md, context)
|
15
17
|
md2 = regexp.match(md[type])
|
16
|
-
block = new(fields: {
|
18
|
+
block = new(fields: { ACTION: md2[3] })
|
19
|
+
block.smalrubot_name = md2[2]
|
17
20
|
add_character_method_call_block(context, md2[1], block)
|
18
21
|
true
|
19
22
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class HardwareSmalrubotActionWithSec < CharacterMethodCall
|
5
|
+
include HardwareOperation
|
6
|
+
|
7
|
+
# rubocop:disable LineLength
|
8
|
+
blocknize ['^\s*',
|
9
|
+
CHAR_RE,
|
10
|
+
SMALRUBOT_RE, '\.',
|
11
|
+
ACTION_RE, '\(\s*sec:\s*(\d+(?:\.\d+)?)\)',
|
12
|
+
'\s*$'].join(''),
|
13
|
+
statement: true, inline: true
|
14
|
+
# rubocop:enable LineLength
|
15
|
+
|
16
|
+
def self.process_match_data(md, context)
|
17
|
+
md2 = regexp.match(md[type])
|
18
|
+
block = new(fields: { ACTION: md2[3] })
|
19
|
+
block.smalrubot_name = md2[2]
|
20
|
+
add_character_method_call_block(context, md2[1], block, SEC: md2[4])
|
21
|
+
true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
module RubyToBlock
|
2
2
|
module Block
|
3
|
-
class
|
3
|
+
class HardwareSmalrubotDcMotorPowerRatio < Value
|
4
4
|
include CharacterOperation
|
5
5
|
include HardwareOperation
|
6
6
|
|
7
|
-
blocknize '^\s*'
|
8
|
-
|
9
|
-
|
7
|
+
blocknize ['^\s*',
|
8
|
+
CHAR_RE,
|
9
|
+
SMALRUBOT_RE, '\.',
|
10
|
+
LOR_RE, '_dc_motor_power_ratio',
|
11
|
+
'\s*$'].join(''),
|
10
12
|
value: true
|
11
13
|
|
12
14
|
def self.process_match_data(md, context)
|
@@ -15,7 +17,8 @@ module RubyToBlock
|
|
15
17
|
character = get_character(context, md2[1])
|
16
18
|
return false if context.receiver && context.receiver != character
|
17
19
|
|
18
|
-
block = new(fields: { LOR: md2[
|
20
|
+
block = new(fields: { LOR: md2[3] })
|
21
|
+
block.smalrubot_name = md2[2]
|
19
22
|
context.add_value(block)
|
20
23
|
block.character = character
|
21
24
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class HardwareSmalrubotDcMotorSetPowerRatio < CharacterMethodCall
|
5
|
+
include HardwareOperation
|
6
|
+
|
7
|
+
blocknize ['^\s*',
|
8
|
+
CHAR_RE,
|
9
|
+
SMALRUBOT_RE, '\.',
|
10
|
+
LOR_RE, '_dc_motor_power_ratio\s*=\s*(\S+)',
|
11
|
+
'\s*$'].join(''),
|
12
|
+
statement: true, inline: true
|
13
|
+
|
14
|
+
def self.process_match_data(md, context)
|
15
|
+
md2 = regexp.match(md[type])
|
16
|
+
block = new(fields: { LOR: md2[3] })
|
17
|
+
block.smalrubot_name = md2[2]
|
18
|
+
add_character_method_call_block(context, md2[1], block, SPEED: md2[4])
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|