smalruby-editor 0.2.1 → 0.2.2
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/LEGAL +4 -3
- data/app/assets/javascripts/blocks/character.js.coffee.erb +7 -3
- data/app/assets/javascripts/blocks/events.js.coffee.erb +7 -10
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +119 -31
- data/app/assets/javascripts/blocks/motion.js.coffee.erb +16 -20
- data/app/assets/javascripts/blocks/operators.js.coffee.erb +1 -1
- data/app/assets/javascripts/blocks/pen.js.coffee.erb +2 -1
- data/app/assets/javascripts/blocks/ruby.js.coffee.erb +3 -3
- data/app/assets/javascripts/blocks/sensing.js.coffee.erb +8 -8
- data/app/assets/javascripts/blocks/sound.js.coffee.erb +3 -1
- data/app/assets/javascripts/fix_blockly.js.erb +105 -0
- data/app/assets/javascripts/generators/ruby.js.coffee.erb +3 -0
- data/app/assets/javascripts/msg/en_us.js +67 -17
- data/app/assets/javascripts/msg/ja.js +151 -95
- data/app/assets/javascripts/{smalruby.js.coffee → smalruby.js.coffee.erb} +35 -16
- data/app/assets/javascripts/views/character_selector_view.js.coffee +2 -2
- data/app/assets/javascripts/views/{load_modal_view.js.coffee → load_modal_view.js.coffee.erb} +8 -2
- data/app/assets/javascripts/views/main_menu_view.js.coffee.erb +33 -48
- data/app/assets/javascripts/views/signin_modal_view.js.coffee.erb +43 -0
- data/app/assets/stylesheets/application.css +3 -1
- data/app/assets/stylesheets/toolbox.css.scss.erb +2 -56
- data/app/assets/stylesheets/toolbox_default.css.scss.erb +34 -0
- data/app/assets/stylesheets/toolbox_smalrubot_s1.css.scss.erb +31 -0
- data/app/assets/stylesheets/toolbox_smalrubot_v3.css.scss.erb +32 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/source_codes_controller.rb +6 -3
- data/app/helpers/application_helper.rb +12 -0
- data/app/helpers/editor_helper.rb +25 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action.rb +13 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action_with_sec.rb +14 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_ir_photoreflector_value.rb +29 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_led_turn_on_or_off.rb +22 -0
- data/app/views/editor/_block_tab.html.haml +7 -6
- data/app/views/editor/_reset_modal.html.haml +4 -4
- data/app/views/editor/_signin_modal.html.haml +8 -9
- data/app/views/editor/_toolbox_default.html.haml +504 -0
- data/app/views/editor/_toolbox_smalrubot_s1.html.haml +171 -0
- data/app/views/editor/_toolbox_smalrubot_v3.html.haml +177 -0
- data/app/views/editor/index.html.haml +12 -2
- data/app/views/layouts/application.html.erb +1 -0
- data/config/environments/production.rb +1 -0
- data/config/locales/en.yml +19 -16
- data/config/locales/ja.yml +28 -25
- data/demos/hardware_led.rb.xml +79 -79
- data/lib/smalruby_editor.rb +58 -0
- data/lib/smalruby_editor/config.rb +22 -0
- data/lib/smalruby_editor/version.rb +1 -1
- data/public/blockly/media/anon.jpeg +0 -0
- data/public/blockly/media/handclosed.cur +0 -0
- data/public/blockly/media/handdelete.cur +0 -0
- data/public/blockly/media/progress.gif +0 -0
- data/public/blockly/media/sprites.png +0 -0
- data/smalruby-editor.gemspec +2 -1
- data/spec/acceptance/base.feature +3 -3
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action.feature +107 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action_with_sec.feature +151 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_ir_photoreflector_value.feature +100 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_led_turn_on_or_off.feature +73 -0
- data/spec/acceptance/ruby_mode/translate.feature +6 -6
- data/spec/acceptance/standalone/save.feature +3 -3
- data/spec/acceptance/standalone/signin.feature +1 -2
- data/spec/lib/smalruby_editor_spec.rb +21 -11
- data/spec/models/concerns/ruby_to_block/block/hardware__smalrubot_s1_spec.rb +279 -0
- data/vendor/assets/javascripts/blockly/blockly_compressed.js +995 -668
- data/vendor/assets/javascripts/blockly/blocks_compressed.js +138 -114
- data/vendor/assets/javascripts/blockly/msg/js/en_us.js +6 -6
- data/vendor/assets/javascripts/blockly/msg/js/ja.js +42 -28
- metadata +66 -25
- data/app/assets/javascripts/fix_blockly.js +0 -128
- data/app/assets/javascripts/views/signin_modal_view.js.coffee +0 -33
- data/app/views/editor/_toolbox.html.haml +0 -496
- data/public/blockly/media/trashbody.png +0 -0
- data/public/blockly/media/trashlid.png +0 -0
- data/public/blockly/media/tree.png +0 -0
data/config/locales/ja.yml
CHANGED
@@ -3,6 +3,15 @@ ja:
|
|
3
3
|
smalruby_editor: "スモウルビー v%{version}"
|
4
4
|
"ok": "決めた!"
|
5
5
|
cancel: "やめる"
|
6
|
+
reset: &reset "リセット"
|
7
|
+
login: &login "ログイン"
|
8
|
+
name: "名前"
|
9
|
+
|
10
|
+
controllers:
|
11
|
+
source_codes:
|
12
|
+
not_ruby_program: "はRubyのプログラムではありません"
|
13
|
+
not_exist: "はありません"
|
14
|
+
exist: "すでに同じ名前のプログラムがあります"
|
6
15
|
|
7
16
|
editor:
|
8
17
|
index:
|
@@ -13,9 +22,9 @@ ja:
|
|
13
22
|
load: "ロード"
|
14
23
|
save: "セーブ"
|
15
24
|
check: "チェック"
|
16
|
-
reset:
|
25
|
+
reset: *reset
|
17
26
|
logout: "ログアウト"
|
18
|
-
login:
|
27
|
+
login: *login
|
19
28
|
|
20
29
|
block_tab:
|
21
30
|
character: "キャラクター"
|
@@ -24,30 +33,16 @@ ja:
|
|
24
33
|
stage: "ステージ"
|
25
34
|
|
26
35
|
toolbox:
|
27
|
-
motion: "
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
data_variables: "変数"
|
36
|
-
events: "イベント(〜のとき)"
|
37
|
-
control: "制御"
|
38
|
-
control_loop: "繰り返し"
|
39
|
-
control_wait: "待つ"
|
40
|
-
control_if: "もし~なら"
|
41
|
-
sensing: "調べる"
|
42
|
-
sensing_general: "いろいろ"
|
43
|
-
sensing_hardware: "ハードウェア"
|
36
|
+
motion: "■動き"
|
37
|
+
looks: "★見た目"
|
38
|
+
sound: "♪音"
|
39
|
+
pen: "●ペン"
|
40
|
+
data: "☼データ"
|
41
|
+
events: "♣イベント"
|
42
|
+
control: "◆制御"
|
43
|
+
sensing: "◎調べる"
|
44
44
|
operators: "演算"
|
45
|
-
|
46
|
-
operators_string: "文字列"
|
47
|
-
operators_condition: "条件"
|
48
|
-
etc: "その他"
|
49
|
-
etc_ruby: "Ruby"
|
50
|
-
etc_hardware: "ハードウェア"
|
45
|
+
etc: "♠その他"
|
51
46
|
hello: "こんにちは!"
|
52
47
|
world: "あいうえお"
|
53
48
|
text: "文章"
|
@@ -64,3 +59,11 @@ ja:
|
|
64
59
|
find_program: "プログラムをさがす"
|
65
60
|
computer: "このコンピュータ"
|
66
61
|
remix: "リミックス"
|
62
|
+
|
63
|
+
reset_modal:
|
64
|
+
title: "本当にリセットしますか?"
|
65
|
+
message: "作成中のプログラムが消えてしまうよ!"
|
66
|
+
|
67
|
+
signin_modal:
|
68
|
+
message: "あなたの名前をいれて、<br />ほかの人のプログラムとまざらないようにしよう♪"
|
69
|
+
username_placeholder: "名前、生徒番号、ニックネームなど"
|
data/demos/hardware_led.rb.xml
CHANGED
@@ -1,79 +1,79 @@
|
|
1
|
-
<xml xmlns="http://www.w3.org/1999/xhtml">
|
2
|
-
<character x="261" y="191" name="frog1" costumes="frog1.png" angle="0"></character>
|
3
|
-
<block type="ruby_comment" x="42" y="-39">
|
4
|
-
<field name="COMMENT">ライトをぴかっとさせるでよ</field>
|
5
|
-
</block>
|
6
|
-
<block type="hardware_init_hardware" x="40" y="6"></block>
|
7
|
-
<block type="character_new" x="45" y="50">
|
8
|
-
<field name="NAME">frog1</field>
|
9
|
-
<statement name="DO">
|
10
|
-
<block type="events_on_click">
|
11
|
-
<statement name="DO">
|
12
|
-
<block type="looks_say" inline="true">
|
13
|
-
<value name="TEXT">
|
14
|
-
<block type="text">
|
15
|
-
<field name="TEXT">ライトをぴかっとさせるでよ♪</field>
|
16
|
-
</block>
|
17
|
-
</value>
|
18
|
-
<next>
|
19
|
-
<block type="
|
20
|
-
<field name="PIN">D2</field>
|
21
|
-
<next>
|
22
|
-
<block type="control_sleep" inline="true">
|
23
|
-
<value name="SEC">
|
24
|
-
<block type="math_number">
|
25
|
-
<field name="NUM">1</field>
|
26
|
-
</block>
|
27
|
-
</value>
|
28
|
-
<next>
|
29
|
-
<block type="
|
30
|
-
<field name="PIN">D2</field>
|
31
|
-
<next>
|
32
|
-
<block type="control_sleep" inline="true">
|
33
|
-
<value name="SEC">
|
34
|
-
<block type="math_number">
|
35
|
-
<field name="NUM">1</field>
|
36
|
-
</block>
|
37
|
-
</value>
|
38
|
-
<next>
|
39
|
-
<block type="
|
40
|
-
<field name="PIN">D13</field>
|
41
|
-
<next>
|
42
|
-
<block type="control_sleep" inline="true">
|
43
|
-
<value name="SEC">
|
44
|
-
<block type="math_number">
|
45
|
-
<field name="NUM">1</field>
|
46
|
-
</block>
|
47
|
-
</value>
|
48
|
-
<next>
|
49
|
-
<block type="
|
50
|
-
<field name="PIN">D13</field>
|
51
|
-
<next>
|
52
|
-
<block type="looks_say" inline="true">
|
53
|
-
<value name="TEXT">
|
54
|
-
<block type="text">
|
55
|
-
<field name="TEXT"></field>
|
56
|
-
</block>
|
57
|
-
</value>
|
58
|
-
</block>
|
59
|
-
</next>
|
60
|
-
</block>
|
61
|
-
</next>
|
62
|
-
</block>
|
63
|
-
</next>
|
64
|
-
</block>
|
65
|
-
</next>
|
66
|
-
</block>
|
67
|
-
</next>
|
68
|
-
</block>
|
69
|
-
</next>
|
70
|
-
</block>
|
71
|
-
</next>
|
72
|
-
</block>
|
73
|
-
</next>
|
74
|
-
</block>
|
75
|
-
</statement>
|
76
|
-
</block>
|
77
|
-
</statement>
|
78
|
-
</block>
|
79
|
-
</xml>
|
1
|
+
<xml xmlns="http://www.w3.org/1999/xhtml">
|
2
|
+
<character x="261" y="191" name="frog1" costumes="frog1.png" angle="0"></character>
|
3
|
+
<block type="ruby_comment" x="42" y="-39">
|
4
|
+
<field name="COMMENT">ライトをぴかっとさせるでよ</field>
|
5
|
+
</block>
|
6
|
+
<block type="hardware_init_hardware" x="40" y="6"></block>
|
7
|
+
<block type="character_new" x="45" y="50">
|
8
|
+
<field name="NAME">frog1</field>
|
9
|
+
<statement name="DO">
|
10
|
+
<block type="events_on_click">
|
11
|
+
<statement name="DO">
|
12
|
+
<block type="looks_say" inline="true">
|
13
|
+
<value name="TEXT">
|
14
|
+
<block type="text">
|
15
|
+
<field name="TEXT">ライトをぴかっとさせるでよ♪</field>
|
16
|
+
</block>
|
17
|
+
</value>
|
18
|
+
<next>
|
19
|
+
<block type="hardware_led_turn_on">
|
20
|
+
<field name="PIN">D2</field>
|
21
|
+
<next>
|
22
|
+
<block type="control_sleep" inline="true">
|
23
|
+
<value name="SEC">
|
24
|
+
<block type="math_number">
|
25
|
+
<field name="NUM">1</field>
|
26
|
+
</block>
|
27
|
+
</value>
|
28
|
+
<next>
|
29
|
+
<block type="hardware_led_turn_off">
|
30
|
+
<field name="PIN">D2</field>
|
31
|
+
<next>
|
32
|
+
<block type="control_sleep" inline="true">
|
33
|
+
<value name="SEC">
|
34
|
+
<block type="math_number">
|
35
|
+
<field name="NUM">1</field>
|
36
|
+
</block>
|
37
|
+
</value>
|
38
|
+
<next>
|
39
|
+
<block type="hardware_led_turn_on">
|
40
|
+
<field name="PIN">D13</field>
|
41
|
+
<next>
|
42
|
+
<block type="control_sleep" inline="true">
|
43
|
+
<value name="SEC">
|
44
|
+
<block type="math_number">
|
45
|
+
<field name="NUM">1</field>
|
46
|
+
</block>
|
47
|
+
</value>
|
48
|
+
<next>
|
49
|
+
<block type="hardware_led_turn_off">
|
50
|
+
<field name="PIN">D13</field>
|
51
|
+
<next>
|
52
|
+
<block type="looks_say" inline="true">
|
53
|
+
<value name="TEXT">
|
54
|
+
<block type="text">
|
55
|
+
<field name="TEXT"></field>
|
56
|
+
</block>
|
57
|
+
</value>
|
58
|
+
</block>
|
59
|
+
</next>
|
60
|
+
</block>
|
61
|
+
</next>
|
62
|
+
</block>
|
63
|
+
</next>
|
64
|
+
</block>
|
65
|
+
</next>
|
66
|
+
</block>
|
67
|
+
</next>
|
68
|
+
</block>
|
69
|
+
</next>
|
70
|
+
</block>
|
71
|
+
</next>
|
72
|
+
</block>
|
73
|
+
</next>
|
74
|
+
</block>
|
75
|
+
</statement>
|
76
|
+
</block>
|
77
|
+
</statement>
|
78
|
+
</block>
|
79
|
+
</xml>
|
data/lib/smalruby_editor.rb
CHANGED
@@ -18,6 +18,37 @@ module SmalrubyEditor
|
|
18
18
|
sound: 300,
|
19
19
|
}
|
20
20
|
|
21
|
+
# http://c4se.hatenablog.com/entry/2013/08/04/190937 をほぼコピーした
|
22
|
+
def hsv_to_rgb(h, s, v)
|
23
|
+
s /= 100.0
|
24
|
+
v /= 100.0
|
25
|
+
c = v * s
|
26
|
+
x = c * (1 - ((h / 60.0) % 2 - 1).abs)
|
27
|
+
m = v - c
|
28
|
+
r, g, b = *(
|
29
|
+
case
|
30
|
+
when h < 60 then [c, x, 0]
|
31
|
+
when h < 120 then [x, c, 0]
|
32
|
+
when h < 180 then [0, c, x]
|
33
|
+
when h < 240 then [0, x, c]
|
34
|
+
when h < 300 then [x, 0, c]
|
35
|
+
else [c, 0, x]
|
36
|
+
end
|
37
|
+
)
|
38
|
+
[r, g, b].map { |channel|
|
39
|
+
sprintf('%02x', ((channel + m) * 255).ceil)
|
40
|
+
}.join
|
41
|
+
end
|
42
|
+
module_function :hsv_to_rgb
|
43
|
+
|
44
|
+
# return smalruby's home directory
|
45
|
+
# (default is '~/.smalruby-editor').
|
46
|
+
def home_directory
|
47
|
+
path = ENV['SMALRUBY_EDITOR_HOME'] || '~/.smalruby-editor'
|
48
|
+
Pathname(path).expand_path
|
49
|
+
end
|
50
|
+
module_function :home_directory
|
51
|
+
|
21
52
|
def create_home_directory(home_dir = nil)
|
22
53
|
if home_dir.blank?
|
23
54
|
path = ENV['SMALRUBY_EDITOR_HOME'] || '~/.smalruby-editor'
|
@@ -25,6 +56,7 @@ module SmalrubyEditor
|
|
25
56
|
end
|
26
57
|
create_under_home_directories(home_dir)
|
27
58
|
create_database_yml(home_dir)
|
59
|
+
create_config_yml(home_dir)
|
28
60
|
home_dir
|
29
61
|
end
|
30
62
|
module_function :create_home_directory
|
@@ -93,5 +125,31 @@ standalone:
|
|
93
125
|
f.write(DATABASE_YML_TEMPLATE.gsub(/%db_path%/, db_path.to_s))
|
94
126
|
end
|
95
127
|
end
|
128
|
+
|
129
|
+
CONFIG_YML_TEMPLATE = <<-EOS
|
130
|
+
#toolbox_name: default
|
131
|
+
#toolbox_css_name: default
|
132
|
+
features:
|
133
|
+
- add_character_from_beginning
|
134
|
+
#- disabled_new_character
|
135
|
+
#- auto_init_hardware
|
136
|
+
#- readonly_ruby_mode
|
137
|
+
#- must_signin
|
138
|
+
#- enabled_hardware_blocks_on_default
|
139
|
+
#- enabled_2wd_car_blocks_on_default
|
140
|
+
#- enabled_smalrubot_v3_blocks_on_default
|
141
|
+
#- enabled_smalrubot_s1_blocks_on_default
|
142
|
+
EOS
|
143
|
+
|
144
|
+
def create_config_yml(home_dir)
|
145
|
+
config_yml_path = home_dir.join('config', 'config.yml')
|
146
|
+
unless config_yml_path.exist?
|
147
|
+
File.open(config_yml_path, 'w') do |f|
|
148
|
+
f.write(CONFIG_YML_TEMPLATE)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
96
152
|
end
|
97
153
|
end
|
154
|
+
|
155
|
+
require 'smalruby_editor/config'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module SmalrubyEditor
|
4
|
+
class Config < Settingslogic
|
5
|
+
if Rails.env.test?
|
6
|
+
source({})
|
7
|
+
else
|
8
|
+
path = SmalrubyEditor.home_directory.join('config', 'config.yml')
|
9
|
+
if path.exist?
|
10
|
+
source(path)
|
11
|
+
else
|
12
|
+
source({})
|
13
|
+
end
|
14
|
+
end
|
15
|
+
suppress_errors(true)
|
16
|
+
|
17
|
+
def enabled?(feature)
|
18
|
+
features.try(:include?, feature)
|
19
|
+
end
|
20
|
+
module_function :enabled?
|
21
|
+
end
|
22
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/smalruby-editor.gemspec
CHANGED
@@ -68,7 +68,8 @@ Gem::Specification.new do |spec|
|
|
68
68
|
['mime-types', '~> 1.16'],
|
69
69
|
['haml-rails'],
|
70
70
|
['nokogiri'],
|
71
|
-
['
|
71
|
+
['settingslogic'],
|
72
|
+
['smalruby', '~> 0.1.3'],
|
72
73
|
]
|
73
74
|
runtime_dependencies << ['therubyracer'] unless is_windows
|
74
75
|
runtime_dependencies.each do |args|
|
@@ -26,7 +26,7 @@
|
|
26
26
|
ならば 次のXMLと同等のブロックが配置されていること:
|
27
27
|
"""
|
28
28
|
<xml>
|
29
|
-
<block type="ruby_statement" x="0" y="0">
|
29
|
+
<block type="ruby_statement" id="1" x="0" y="0">
|
30
30
|
<field name="STATEMENT">stage1 = Stage.new(color: "white")</field>
|
31
31
|
</block>
|
32
32
|
</xml>
|
@@ -65,7 +65,7 @@
|
|
65
65
|
ならば 次のXMLと同等のブロックが配置されていること:
|
66
66
|
"""
|
67
67
|
<xml>
|
68
|
-
<block type="ruby_statement" x="0" y="0">
|
68
|
+
<block type="ruby_statement" id="1" x="0" y="0">
|
69
69
|
<field name="STATEMENT">stage1 = Stage.new(color: "white")</field>
|
70
70
|
</block>
|
71
71
|
</xml>
|
@@ -153,7 +153,7 @@
|
|
153
153
|
ならば 次のXMLと同等のブロックが配置されていること:
|
154
154
|
"""
|
155
155
|
<xml>
|
156
|
-
<block type="ruby_statement" x="0" y="0">
|
156
|
+
<block type="ruby_statement" id="1" x="0" y="0">
|
157
157
|
<field name="STATEMENT">stage1 = Stage.new(color: "white")</field>
|
158
158
|
</block>
|
159
159
|
</xml>
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# language: en
|
3
|
+
@javascript
|
4
|
+
Feature: hardware_smalrubot_s1_action block
|
5
|
+
Background:
|
6
|
+
Given "ブロック" タブを表示する
|
7
|
+
And キャラクターcar1を追加する
|
8
|
+
|
9
|
+
Scenario: ブロックのみ配置する
|
10
|
+
When 次のブロックを配置する:
|
11
|
+
"""
|
12
|
+
%block{:type => "hardware_smalrubot_s1_action", :x => "0", :y => "0"}
|
13
|
+
%field{:name => "ACTION"}<
|
14
|
+
backward
|
15
|
+
"""
|
16
|
+
And ブロックからソースコードを生成する
|
17
|
+
|
18
|
+
Then テキストエディタのプログラムは "" であること
|
19
|
+
|
20
|
+
Scenario: キャラクターとブロックを配置する
|
21
|
+
When 次のブロックを配置する:
|
22
|
+
"""
|
23
|
+
%block{:type => "character_new", :x => "21", :y => "15"}
|
24
|
+
%field{:name => "NAME"}<
|
25
|
+
car1
|
26
|
+
%statement{:name => "DO"}
|
27
|
+
%block{:type => "hardware_smalrubot_s1_action", :x => "0", :y => "0"}
|
28
|
+
%field{:name => "ACTION"}<
|
29
|
+
forward
|
30
|
+
%next
|
31
|
+
%block{:type => "hardware_smalrubot_s1_action", :x => "0", :y => "0"}
|
32
|
+
%field{:name => "ACTION"}<
|
33
|
+
backward
|
34
|
+
%next
|
35
|
+
%block{:type => "hardware_smalrubot_s1_action", :x => "0", :y => "0"}
|
36
|
+
%field{:name => "ACTION"}<
|
37
|
+
turn_left
|
38
|
+
%next
|
39
|
+
%block{:type => "hardware_smalrubot_s1_action", :x => "0", :y => "0"}
|
40
|
+
%field{:name => "ACTION"}<
|
41
|
+
turn_right
|
42
|
+
%next
|
43
|
+
%block{:type => "hardware_smalrubot_s1_action", :x => "0", :y => "0"}
|
44
|
+
%field{:name => "ACTION"}<
|
45
|
+
stop
|
46
|
+
"""
|
47
|
+
And ブロックからソースコードを生成する
|
48
|
+
|
49
|
+
Then テキストエディタのプログラムは以下であること:
|
50
|
+
"""
|
51
|
+
require "smalruby"
|
52
|
+
|
53
|
+
car1 = Character.new(costume: "car1.png", x: 0, y: 0, angle: 0)
|
54
|
+
car1.smalrubot_s1.forward
|
55
|
+
car1.smalrubot_s1.backward
|
56
|
+
car1.smalrubot_s1.turn_left
|
57
|
+
car1.smalrubot_s1.turn_right
|
58
|
+
car1.smalrubot_s1.stop
|
59
|
+
|
60
|
+
"""
|
61
|
+
|
62
|
+
Scenario: キャラクターとイベントとブロックを配置する
|
63
|
+
When 次のブロックを配置する:
|
64
|
+
"""
|
65
|
+
%block{:type => "character_new", :x => "21", :y => "15"}
|
66
|
+
%field{:name => "NAME"}<
|
67
|
+
car1
|
68
|
+
%statement{:name => "DO"}
|
69
|
+
%block{:type => "events_on_start"}
|
70
|
+
%statement{:name => "DO"}
|
71
|
+
%block{:type => "hardware_smalrubot_s1_action", :x => "0", :y => "0"}
|
72
|
+
%field{:name => "ACTION"}<
|
73
|
+
forward
|
74
|
+
%next
|
75
|
+
%block{:type => "hardware_smalrubot_s1_action", :x => "0", :y => "0"}
|
76
|
+
%field{:name => "ACTION"}<
|
77
|
+
backward
|
78
|
+
%next
|
79
|
+
%block{:type => "hardware_smalrubot_s1_action", :x => "0", :y => "0"}
|
80
|
+
%field{:name => "ACTION"}<
|
81
|
+
turn_left
|
82
|
+
%next
|
83
|
+
%block{:type => "hardware_smalrubot_s1_action", :x => "0", :y => "0"}
|
84
|
+
%field{:name => "ACTION"}<
|
85
|
+
turn_right
|
86
|
+
%next
|
87
|
+
%block{:type => "hardware_smalrubot_s1_action", :x => "0", :y => "0"}
|
88
|
+
%field{:name => "ACTION"}<
|
89
|
+
stop
|
90
|
+
"""
|
91
|
+
And ブロックからソースコードを生成する
|
92
|
+
|
93
|
+
Then テキストエディタのプログラムは以下であること:
|
94
|
+
"""
|
95
|
+
require "smalruby"
|
96
|
+
|
97
|
+
car1 = Character.new(costume: "car1.png", x: 0, y: 0, angle: 0)
|
98
|
+
|
99
|
+
car1.on(:start) do
|
100
|
+
smalrubot_s1.forward
|
101
|
+
smalrubot_s1.backward
|
102
|
+
smalrubot_s1.turn_left
|
103
|
+
smalrubot_s1.turn_right
|
104
|
+
smalrubot_s1.stop
|
105
|
+
end
|
106
|
+
|
107
|
+
"""
|