smalruby-editor 0.2.2-x86-mingw32 → 0.2.3-x86-mingw32

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Guardfile +2 -6
  4. data/LEGAL +6 -0
  5. data/README.rdoc +2 -0
  6. data/app/assets/javascripts/application.js +1 -0
  7. data/app/assets/javascripts/blocks/hardware.js.coffee.erb +37 -0
  8. data/app/assets/javascripts/models/source_code.js +123 -0
  9. data/app/assets/javascripts/msg/en_us.js +2 -0
  10. data/app/assets/javascripts/msg/ja.js +2 -0
  11. data/app/assets/javascripts/smalruby.js.coffee.erb +1 -1
  12. data/app/assets/javascripts/views/character_modal_view.js.coffee +2 -0
  13. data/app/assets/javascripts/views/character_selector_view.js.coffee +2 -2
  14. data/app/assets/javascripts/views/load_modal_view.js.coffee.erb +2 -0
  15. data/app/assets/javascripts/views/reset_modal_view.js.coffee +2 -0
  16. data/app/assets/stylesheets/application.css +0 -0
  17. data/app/assets/stylesheets/editor.css.scss +0 -0
  18. data/app/assets/stylesheets/toolbox_raspberrypi.css.scss.erb +32 -0
  19. data/app/assets/stylesheets/toolbox_smalrubot_s1.css.scss.erb +1 -0
  20. data/app/controllers/editor_controller.rb +0 -0
  21. data/app/helpers/application_helper.rb +5 -0
  22. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_dc_motor_power_ratio.rb +26 -0
  23. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_dc_motor_set_power_ratio.rb +21 -0
  24. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_motor_set_speed.rb +21 -0
  25. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_motor_speed.rb +26 -0
  26. data/app/models/source_code.rb +0 -0
  27. data/app/views/editor/_toolbox_default.html.haml +7 -3
  28. data/app/views/editor/_toolbox_raspberrypi.html.haml +233 -0
  29. data/app/views/editor/_toolbox_smalrubot_s1.html.haml +75 -51
  30. data/app/views/editor/_toolbox_smalrubot_v3.html.haml +70 -55
  31. data/app/views/editor/index.html.haml +0 -6
  32. data/app/views/layouts/application.html.erb +1 -0
  33. data/db/schema.rb +23 -23
  34. data/lib/smalruby_editor.rb +5 -1
  35. data/lib/smalruby_editor/config.rb +2 -0
  36. data/lib/smalruby_editor/version.rb +1 -1
  37. data/smalruby-editor.gemspec +1 -1
  38. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_dc_motor_power_ratio.feature +116 -0
  39. data/spec/javascripts/models/source_code_spec.coffee +5 -0
  40. data/spec/models/concerns/ruby_to_block/block/hardware__smalrubot_s1_spec.rb +89 -1
  41. data/spec/models/concerns/ruby_to_block/block/hardware__smalrubot_v3_spec.rb +433 -0
  42. data/spec/models/concerns/ruby_to_block/block/hardware_spec.rb +0 -338
  43. data/vendor/assets/javascripts/strftime-min.js +8 -0
  44. metadata +27 -14
  45. data/app/assets/javascripts/models/source_code.js.coffee +0 -80
@@ -0,0 +1,26 @@
1
+ module RubyToBlock
2
+ module Block
3
+ class HardwareSmalrubotV3MotorSpeed < Value
4
+ include CharacterOperation
5
+ include HardwareOperation
6
+
7
+ blocknize '^\s*' + CHAR_RE +
8
+ 'smalrubot_v3\.' +
9
+ LOR_RE + '_motor_speed\s*$',
10
+ value: true
11
+
12
+ def self.process_match_data(md, context)
13
+ md2 = regexp.match(md[type])
14
+
15
+ character = get_character(context, md2[1])
16
+ return false if context.receiver && context.receiver != character
17
+
18
+ block = new(fields: { LOR: md2[2] })
19
+ context.add_value(block)
20
+ block.character = character
21
+
22
+ true
23
+ end
24
+ end
25
+ end
26
+ end
File without changes
@@ -28,12 +28,12 @@
28
28
  = toolbox_number_value('X')
29
29
  = toolbox_number_value('Y')
30
30
 
31
- -# マウスポインターへ行く
32
- %block{:type => "#{category}_go_to_mouse"}
33
-
34
31
  -# [▼]へ行く
35
32
  %block{:type => "#{category}_go_to_character"}
36
33
 
34
+ -# マウスポインターへ行く
35
+ %block{:type => "#{category}_go_to_mouse"}
36
+
37
37
  -# ( )秒でx座標を( )、y座標を( )に変える
38
38
  -#%block{:type => "#{category}_glide_to_x_y"}
39
39
  -# = toolbox_number_value('SEC', 1)
@@ -160,6 +160,9 @@
160
160
  forward
161
161
  = toolbox_number_value('SEC', 0.5)
162
162
 
163
+ %block{type: "#{category}_#{subcategory}_dc_motor_set_power_ratio"}
164
+ = toolbox_number_value('SPEED', 100)
165
+
163
166
  - category = 'looks'
164
167
  %category{:name => tt('.looks')}
165
168
  -# [ ]と( )秒言う
@@ -400,6 +403,7 @@
400
403
  - category = 'hardware'
401
404
  - subcategory = 'smalrubot_s1'
402
405
  %block{type: "#{category}_#{subcategory}_ir_photoreflector_value"}
406
+ %block{type: "#{category}_#{subcategory}_dc_motor_power_ratio"}
403
407
 
404
408
  - category = 'operators'
405
409
  %category{:name => tt('.operators')}
@@ -0,0 +1,233 @@
1
+ %xml{:id => 'toolbox', :style => 'display: none'}
2
+ - category = 'motion'
3
+ %category{:name => tt('.motion')}
4
+ -# ( )歩動かす
5
+ %block{:type => "#{category}_move"}
6
+ = toolbox_number_value('STEP', 10)
7
+
8
+ -# 時計回りに( )度回す
9
+ %block{:type => "#{category}_rotate_right"}
10
+ = toolbox_number_value('ANGLE', 15)
11
+
12
+ -# 反時計回りに( )度回す
13
+ %block{:type => "#{category}_rotate_left"}
14
+ = toolbox_number_value('ANGLE', 15)
15
+
16
+ -# ( )度に向ける
17
+ %block{:type => "#{category}_set_angle"}
18
+ = toolbox_number_value('ANGLE', 90)
19
+
20
+ -# [▼]へ向ける
21
+ %block{:type => "#{category}_point_towards_character"}
22
+
23
+ -# マウスポインターへ向ける
24
+ %block{:type => "#{category}_point_towards_mouse"}
25
+
26
+ -# [▼]へ行く
27
+ %block{:type => "#{category}_go_to_character"}
28
+
29
+ -# マウスポインターへ行く
30
+ %block{:type => "#{category}_go_to_mouse"}
31
+
32
+ -# x座標を( )ずつ変える
33
+ %block{:type => "#{category}_change_x_by"}
34
+ = toolbox_number_value('X', 10)
35
+
36
+ -# x座標を( )にする
37
+ %block{:type => "#{category}_set_x"}
38
+ = toolbox_number_value('X', 0)
39
+
40
+ -# y座標を( )ずつ変える
41
+ %block{:type => "#{category}_change_y_by"}
42
+ = toolbox_number_value('Y', 10)
43
+
44
+ -# y座標を( )にする
45
+ %block{:type => "#{category}_set_y"}
46
+ = toolbox_number_value('Y', 0)
47
+
48
+ -# もし端に着いたら、跳ね返る
49
+ %block{:type => "#{category}_turn_if_reach_wall"}
50
+
51
+ -# 跳ね返る
52
+ %block{:type => "#{category}_turn"}
53
+
54
+ -# [▼水平(X)]方向に跳ね返る
55
+ %block{:type => "#{category}_turn_xy"}
56
+
57
+ -# 回転方法を[▼]にする
58
+ %block{:type => "#{category}_set_rotation_style"}
59
+
60
+ - category = 'looks'
61
+ %category{:name => tt('.looks')}
62
+ -# [ ]と言う
63
+ %block{:type => "#{category}_say"}
64
+ = toolbox_text_value('TEXT', tt('.hello'))
65
+
66
+ -# [ ]と考える
67
+ -#%block{:type => "#{category}_think"}
68
+ -# = toolbox_text_value('TEXT', 'ふーん')
69
+
70
+ -# 表示する
71
+ %block{:type => "#{category}_show"}
72
+
73
+ -# 隠す
74
+ %block{:type => "#{category}_hide"}
75
+
76
+ -# 消滅する
77
+ %block{:type => "#{category}_vanish"}
78
+
79
+ -# 大きさを( )%ずつ変える
80
+ -#%block{:type => "#{category}_change_scale_by"}
81
+ -# = toolbox_number_value('SCALE', 10)
82
+
83
+ -# 大きさを( )%にする
84
+ -#%block{:type => "#{category}_set_scale"}
85
+ -# = toolbox_number_value('SCALE', 100)
86
+
87
+ - category = 'sound'
88
+ %category{:name => tt('.sound')}
89
+ -# [▼プリセット音声]の音を鳴らす
90
+ %block{:type => "#{category}_play"}
91
+ %value{:name => 'NAME'}
92
+ %block{:type => "#{category}_preset_sounds"}
93
+
94
+ -# すべての音を止める
95
+ -#%block{:type => "#{category}_stop"}
96
+
97
+ %category{name: tt('.data'), custom: 'VARIABLE'}
98
+
99
+ - category = 'events'
100
+ %category{:name => tt('.events')}
101
+ -# まずは
102
+ %block{:type => "#{category}_on_start"}
103
+
104
+ -# キーボードの[▼キー]が[▼押された/押され続けている]とき
105
+ %block{:type => "#{category}_on_key_push_or_down"}
106
+ = toolbox_key_field
107
+ = toolbox_pod_field
108
+
109
+ -# キャラクターがクリックされたとき
110
+ %block{:type => "#{category}_on_click"}
111
+
112
+ -# [▼キャラクター]にぶつかったとき
113
+ %block{:type => "#{category}_on_hit"}
114
+
115
+ - category = 'control'
116
+ %category{:name => tt('.control')}
117
+ -# ( )秒待つ
118
+ %block{:type => "#{category}_sleep"}
119
+ = toolbox_number_value('SEC', 1)
120
+
121
+ -# ほんの少し待つ
122
+ %block{:type => "#{category}_await"}
123
+
124
+ -# ( )回繰り返す
125
+ %block{:type => "#{category}_times"}
126
+ = toolbox_number_value('COUNT', 10)
127
+
128
+ -# ずっと
129
+ %block{:type => "#{category}_loop"}
130
+
131
+ -# もし< >なら
132
+ %block{:type => "#{category}_if"}
133
+
134
+ -# < >まで待つ
135
+ %block{:type => "#{category}_await_until"}
136
+
137
+ -# 繰り返しから脱出する
138
+ %block{:type => "#{category}_break"}
139
+
140
+ - category = 'sensing'
141
+ %category{:name => tt('.sensing')}
142
+ -# 条件:[▼キャラクター]に触れた
143
+ %block{:type => "#{category}_hit"}
144
+
145
+ -# 条件:端に触れた
146
+ %block{:type => "#{category}_reach_wall"}
147
+
148
+ -# [ ]と聞いて待つ
149
+ -#%block{:type => "#{category}_ask"}
150
+ -# = toolbox_text_value('TEXT', 'あなたのお名前は?')
151
+
152
+ -# 変数:答え
153
+ -#%block{:type => "#{category}_answer"}
154
+
155
+ -# 条件:キーボードの[▼キー]が[▼押された]
156
+ %block{:type => "#{category}_input_key_push_or_down"}
157
+ = toolbox_key_field
158
+ = toolbox_pod_field
159
+
160
+ -# 条件:マウスの[▼左ボタン]が[▼押された]
161
+ %block{:type => "#{category}_input_mouse_push_or_down"}
162
+ = toolbox_pod_field
163
+
164
+ -# 変数:マウスのx座標
165
+ %block{:type => "#{category}_input_mouse_pos_x"}
166
+
167
+ -# 変数:マウスのy座標
168
+ %block{:type => "#{category}_input_mouse_pos_y"}
169
+
170
+ -# 変数:タイマー
171
+ -#%block{:type => "#{category}_timer_count"}
172
+
173
+ -# タイマーをリセット
174
+ -#%block{:type => "#{category}_timer_reset"}
175
+
176
+ -# 変数:[▼キャラクター]の[▼プロパティ]
177
+ %block{:type => "#{category}_character_property"}
178
+
179
+ - category = 'operators'
180
+ %category{:name => tt('.operators')}
181
+ -# 数値
182
+ %block{:type => 'math_number'}
183
+ %field{:name => 'NUM'}<
184
+ 0
185
+
186
+ -# テキスト
187
+ %block{:type => 'text'}
188
+ %field{:name => 'TEXT'}<
189
+ = tt('.text')
190
+
191
+ -# 変数:( ) + ( )
192
+ %block{:type => "#{category}_add"}
193
+
194
+ -# 変数:( ) - ( )
195
+ %block{:type => "#{category}_minus"}
196
+
197
+ -# 変数:( ) * ( )
198
+ %block{:type => "#{category}_multiply"}
199
+
200
+ -# 変数:( ) / ( )
201
+ %block{:type => "#{category}_divide"}
202
+
203
+ -# 変数:( )から( )までの乱数
204
+ %block{:type => "#{category}_rand"}
205
+ = toolbox_number_value('A', 1)
206
+ = toolbox_number_value('B', 10)
207
+
208
+ -# 条件:( ) < ( )
209
+ %block{:type => "#{category}_compare_lt"}
210
+
211
+ -# 条件:( ) = ( )
212
+ %block{:type => "#{category}_compare_eq"}
213
+
214
+ -# 条件:( ) > ( )
215
+ %block{:type => "#{category}_compare_gt"}
216
+
217
+ -# 条件:< > かつ < >
218
+ %block{:type => "#{category}_and"}
219
+
220
+ -# 条件:< > または < >
221
+ %block{:type => "#{category}_or"}
222
+
223
+ -# 条件:< > ではない
224
+ %block{:type => "#{category}_negate"}
225
+
226
+ -# 変数:( )を( )で割った余り
227
+ %block{:type => "#{category}_modulo"}
228
+ = toolbox_number_value('A', 5)
229
+ = toolbox_number_value('B', 2)
230
+
231
+ -# 変数:( )を四捨五入
232
+ %block{:type => "#{category}_round"}
233
+ = toolbox_number_value('A', 0.5)
@@ -11,6 +11,9 @@
11
11
  forward
12
12
  = toolbox_number_value('SEC', 0.5)
13
13
 
14
+ %block{type: "#{category}_#{subcategory}_dc_motor_set_power_ratio"}
15
+ = toolbox_number_value('SPEED', 100)
16
+
14
17
  - category = 'looks'
15
18
  %category{:name => tt('.looks')}
16
19
  %block{:type => "#{category}_say"}
@@ -36,42 +39,42 @@
36
39
  = toolbox_key_field
37
40
  = toolbox_pod_field
38
41
 
42
+ -# キャラクターがクリックされたとき
43
+ %block{:type => "#{category}_on_click"}
44
+
39
45
  - category = 'control'
40
46
  %category{:name => tt('.control')}
41
- -# ずっと
42
- %block{:type => "#{category}_loop"}
47
+ -# ( )秒待つ
48
+ %block{:type => "#{category}_sleep"}
49
+ = toolbox_number_value('SEC', 1)
50
+
51
+ -# ほんの少し待つ
52
+ %block{:type => "#{category}_await"}
43
53
 
44
54
  -# ( )回繰り返す
45
55
  %block{:type => "#{category}_times"}
46
56
  = toolbox_number_value('COUNT', 10)
47
57
 
48
- -# < >まで繰り返す
49
- %block{:type => "#{category}_until"}
50
-
51
- -# 繰り返しから脱出する
52
- %block{:type => "#{category}_break"}
53
-
54
- -# 次の繰り返しにジャンプする
55
- %block{:type => "#{category}_next"}
58
+ -# ずっと
59
+ %block{:type => "#{category}_loop"}
56
60
 
57
- -# 現在の繰り返しをやり直す
58
- %block{:type => "#{category}_redo"}
61
+ -# もし< >なら
62
+ %block{:type => "#{category}_if"}
59
63
 
60
- -# ( )秒待つ
61
- %block{:type => "#{category}_sleep"}
62
- = toolbox_number_value('SEC', 1)
64
+ -# もし< >なら~でなければ
65
+ %block{:type => "#{category}_if_else"}
63
66
 
64
67
  -# < >まで待つ
65
68
  %block{:type => "#{category}_await_until"}
66
69
 
67
- -# ほんの少し待つ
68
- %block{:type => "#{category}_await"}
70
+ -# < >まで繰り返す
71
+ %block{:type => "#{category}_until"}
69
72
 
70
- -# もし< >なら
71
- %block{:type => "#{category}_if"}
73
+ -# 繰り返しから脱出する
74
+ %block{:type => "#{category}_break"}
72
75
 
73
- -# もし< >なら~でなければ
74
- %block{:type => "#{category}_if_else"}
76
+ -# 次の繰り返しにジャンプする
77
+ %block{:type => "#{category}_next"}
75
78
 
76
79
  - category = 'sensing'
77
80
  %category{:name => tt('.sensing')}
@@ -100,23 +103,51 @@
100
103
  - category = 'hardware'
101
104
  - subcategory = 'smalrubot_s1'
102
105
  %block{type: "#{category}_#{subcategory}_ir_photoreflector_value"}
106
+ %block{type: "#{category}_#{subcategory}_dc_motor_power_ratio"}
103
107
 
104
108
  - category = 'operators'
105
109
  %category{:name => tt('.operators')}
110
+ -# 数値
111
+ %block{:type => 'math_number'}
112
+ %field{:name => 'NUM'}<
113
+ 0
114
+
115
+ -# テキスト
116
+ %block{:type => 'text'}
117
+ %field{:name => 'TEXT'}<
118
+ = tt('.text')
119
+
120
+ -# 変数:( ) + ( )
121
+ %block{:type => "#{category}_add"}
122
+
123
+ -# 変数:( ) - ( )
124
+ %block{:type => "#{category}_minus"}
125
+
126
+ -# 変数:( ) * ( )
127
+ %block{:type => "#{category}_multiply"}
128
+
129
+ -# 変数:( ) / ( )
130
+ %block{:type => "#{category}_divide"}
131
+
132
+ -# 変数:( )から( )までの乱数
133
+ %block{:type => "#{category}_rand"}
134
+ = toolbox_number_value('A', 1)
135
+ = toolbox_number_value('B', 10)
136
+
106
137
  -# 条件:( ) < ( )
107
- %block{:type => "#{category}_compare_gt"}
138
+ %block{:type => "#{category}_compare_lt"}
108
139
 
109
140
  -# 条件:( ) <= ( )
110
- %block{:type => "#{category}_compare_gte"}
141
+ %block{:type => "#{category}_compare_lte"}
111
142
 
112
143
  -# 条件:( ) = ( )
113
144
  %block{:type => "#{category}_compare_eq"}
114
145
 
115
146
  -# 条件:( ) >= ( )
116
- %block{:type => "#{category}_compare_lte"}
147
+ %block{:type => "#{category}_compare_gte"}
117
148
 
118
149
  -# 条件:( ) > ( )
119
- %block{:type => "#{category}_compare_lt"}
150
+ %block{:type => "#{category}_compare_gt"}
120
151
 
121
152
  -# 条件:< > かつ < >
122
153
  %block{:type => "#{category}_and"}
@@ -127,35 +158,21 @@
127
158
  -# 条件:< > ではない
128
159
  %block{:type => "#{category}_negate"}
129
160
 
130
- -# 条件:真
131
- %block{:type => "#{category}_true"}
132
-
133
- -# 条件:偽
134
- %block{:type => "#{category}_false"}
135
-
136
- -# 変数:( ) + ( )
137
- %block{:type => "#{category}_add"}
161
+ -# 変数:( )の( )番目
162
+ %block{:type => "#{category}_index_of"}
163
+ = toolbox_text_value('A', tt('.world'))
164
+ = toolbox_number_value('INDEX', 1)
138
165
 
139
- -# 変数:( ) - ( )
140
- %block{:type => "#{category}_minus"}
141
-
142
- -# 変数:( ) * ( )
143
- %block{:type => "#{category}_multiply"}
144
-
145
- -# 変数:( ) / ( )
146
- %block{:type => "#{category}_divide"}
147
-
148
- -# 変数:( )から( )までの乱数
149
- %block{:type => "#{category}_rand"}
150
- = toolbox_number_value('A', 1)
151
- = toolbox_number_value('B', 10)
166
+ -# 変数:( )の長さ
167
+ %block{:type => "#{category}_length"}
168
+ = toolbox_text_value('A', tt('.world'))
152
169
 
153
170
  -# 変数:( )を( )で割った余り
154
171
  %block{:type => "#{category}_modulo"}
155
172
  = toolbox_number_value('A', 5)
156
173
  = toolbox_number_value('B', 2)
157
174
 
158
- -# 変数:( )を丸める
175
+ -# 変数:( )を四捨五入
159
176
  %block{:type => "#{category}_round"}
160
177
  = toolbox_number_value('A', 0.5)
161
178
 
@@ -165,7 +182,14 @@
165
182
  %field{:name => 'METHOD'}<
166
183
  Math.sqrt(%num%)
167
184
 
168
- -# 数値
169
- %block{:type => 'math_number'}
170
- %field{:name => 'NUM'}<
171
- 0
185
+ -# 条件:真
186
+ %block{:type => "#{category}_true"}
187
+
188
+ -# 条件:偽
189
+ %block{:type => "#{category}_false"}
190
+
191
+ - if !SmalrubyEditor::Config.enabled?('auto_init_hardware')
192
+ %category{:name => tt('.etc')}
193
+ - category = 'hardware'
194
+ -# ハードウェアを準備する
195
+ %block{:type => "#{category}_init_hardware"}