diff --git a/Gemfile.lock b/Gemfile.lock index 6f91c4b..3705ad5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -81,7 +81,6 @@ GEM database_rewinder (0.0.2) diff-lcs (1.2.5) docile (1.1.5) - dxruby (1.4.0) dxruby_sdl (0.0.13) rsdl rubysdl (~> 2.1.3) @@ -98,7 +97,6 @@ GEM eventmachine (1.0.4) execjs (2.0.2) ffi (1.9.8) - ffi (1.9.8-x86-mingw32) flatstrap-sass (2.3.1.0) font-awesome-rails (~> 3.0.2.0) sass (~> 3.2) @@ -107,8 +105,6 @@ GEM formatador (0.2.5) gherkin (2.12.2) multi_json (~> 1.3) - gherkin (2.12.2-x86-mingw32) - multi_json (~> 1.3) guard (2.12.5) formatador (>= 0.2.4) listen (~> 2.7) @@ -172,8 +168,6 @@ GEM netrc (0.10.2) nokogiri (1.6.1) mini_portile (~> 0.5.0) - nokogiri (1.6.1-x86-mingw32) - mini_portile (~> 0.5.0) notiffany (0.0.6) nenv (~> 0.1) shellany (~> 0.0) @@ -279,11 +273,6 @@ GEM dxruby_sdl (~> 0.0.13) mime-types (~> 1.6) smalrubot (~> 0.0.6) - smalruby (0.1.10-x86-mingw32) - activesupport - dxruby (= 1.4.0) - mime-types (~> 1.6) - smalrubot (~> 0.0.6) spring (1.2.0) spring-commands-rspec (1.0.4) spring (>= 0.9.1) @@ -299,7 +288,6 @@ GEM activesupport (>= 3.0) sprockets (~> 2.8) sqlite3 (1.3.8) - sqlite3 (1.3.8-x86-mingw32) teaspoon (0.7.9) railties (>= 3.2.5, < 5) term-ansicolor (1.3.0) @@ -328,8 +316,6 @@ GEM raindrops (~> 0.7) websocket (1.0.7) websocket-driver (0.3.2) - win32-process (0.7.4) - ffi (>= 1.0.0) xpath (2.0.0) nokogiri (~> 1.3) @@ -379,3 +365,9 @@ DEPENDENCIES turnip uglifier (>= 1.3.0) unicorn + +RUBY VERSION + ruby 2.1.5p273 + +BUNDLED WITH + 1.12.0.pre.2 diff --git a/app/assets/javascripts/blocks/control.js.coffee.erb b/app/assets/javascripts/blocks/control.js.coffee.erb index 321c6a2..b92a6af 100644 --- a/app/assets/javascripts/blocks/control.js.coffee.erb +++ b/app/assets/javascripts/blocks/control.js.coffee.erb @@ -123,7 +123,7 @@ Blockly.Blocks['<%= n %>'] = @setTooltip('') Blockly.Ruby['<%= n %>'] = (block) -> - count = Blockly.Ruby.valueToCode(@, 'COUNT', Blockly.Ruby.ORDER_NONE) || 0 + count = Blockly.Ruby.valueToCode(@, 'COUNT', Blockly.Ruby.ORDER_STRING_CONVERSION) || 0 branch = Blockly.Ruby.statementToCode(block, 'DO') || '\n' "#{count}.times do\n" + branch + 'end\n' diff --git a/app/assets/javascripts/blocks/events.js.coffee.erb b/app/assets/javascripts/blocks/events.js.coffee.erb index c0d6697..4a525cb 100644 --- a/app/assets/javascripts/blocks/events.js.coffee.erb +++ b/app/assets/javascripts/blocks/events.js.coffee.erb @@ -79,3 +79,59 @@ Blockly.Blocks['<%= n %>'] = Blockly.Ruby['<%= n %>'] = (block) -> char = @getCharacterFieldValue() Blockly.Ruby.characterEvent_(block, 'DO', 'hit', char) + +# [▼メッセージ] +<% n = "#{category}_messages" %> +Blockly.Blocks['<%= n %>'] = + init: ()-> + messages = [ + [<%= bm('.messages1') %>, 'messages1'], + [<%= bm('.messages2') %>, 'messages2'], + ] + @setHelpUrl('') + @setColour(<%= color %>) + @interpolateMsg(<%= bm('.messages') %>, + ['NAME', new Blockly.FieldDropdown(messages)], + Blockly.ALIGN_RIGHT) + @setOutput(true, 'String') + @setTooltip('') + +Blockly.Ruby['<%= n %>'] = (block) -> + code = Blockly.Ruby.quote_(@getFieldValue('NAME')) + [code, Blockly.Ruby.ORDER_ATOMIC] + +# [▼メッセージ]を受け取ったとき +<% n = '#{category}_when_i_receive' %> +Blockly.Blocks['<%= n %>'] = + init: ()-> + @setHelpUrl('') + @setColour(<%= color %>) + @interpolateMsg(<%= bm('.when_i_receive') %>, + ['TEXT', null, Blockly.ALIGN_RIGHT], + Blockly.ALIGN_RIGHT) + @appendStatementInput('DO') + @setPreviousStatement(true) + @setNextStatement(true) + @setTooltip('') + +Blockly.Ruby['<%= n %>'] = (block) -> + arg = Blockly.Ruby.valueToCode(@, 'TEXT', Blockly.Ruby.ORDER_NONE) || '' + Blockly.Ruby.characterEvent_(block, 'DO', 'receive', arg) + +# [▼メッセージ]を送る +<% n = '#{category}_broadcast' %> +Blockly.Blocks['<%= n %>'] = + init: ()-> + @setHelpUrl('') + @setColour(<%= color %>) + @interpolateMsg(<%= bm('.broadcast') %>, + ['TEXT', null, Blockly.ALIGN_RIGHT], + Blockly.ALIGN_RIGHT) + @setInputsInline(true) + @setPreviousStatement(true) + @setNextStatement(true) + @setTooltip('') + +Blockly.Ruby['<%= n %>'] = (block) -> + arg = Blockly.Ruby.valueToCode(@, 'TEXT', Blockly.Ruby.ORDER_NONE) || '' + Blockly.Ruby.characterMethodCall_('broadcast', arg) \ No newline at end of file diff --git a/app/assets/javascripts/blocks/sound.js.coffee.erb b/app/assets/javascripts/blocks/sound.js.coffee.erb index ee7c4c9..89db3eb 100644 --- a/app/assets/javascripts/blocks/sound.js.coffee.erb +++ b/app/assets/javascripts/blocks/sound.js.coffee.erb @@ -66,13 +66,29 @@ Blockly.Blocks['<%= n %>'] = Blockly.Ruby['<%= n %>'] = (block) -> 'stop\n' -# 変数:ボリューム +<% n = "#{category}_set_volume" %> +Blockly.Blocks['<%= n %>'] = + init: ()-> + @setHelpUrl('') + @setColour(<%= color %>) + @interpolateMsg(<%= bm('.set_volume') %>, + ['VOLUME', ['Number'], Blockly.ALIGN_RIGHT] + Blockly.ALIGN_RIGHT) + @setInputsInline(true) + @setPreviousStatement(true) + @setNextStatement(true) + @setTooltip('') + +Blockly.Ruby['<%= n %>'] = (block) -> + volume = Blockly.Ruby.valueToCode(@, 'VOLUME', Blockly.Ruby.ORDER_NONE) || '100' + Blockly.Ruby.characterSetVariable_('volume', volume) + <% n = "#{category}_volume" %> Blockly.Blocks['<%= n %>'] = init: ()-> @setHelpUrl('') @setColour(<%= color %>) - @appendDummyInput().appendField('ボリューム') + @appendDummyInput().appendField(<%= bm(".volume") %>) @setOutput(true, 'Number') @setTooltip('') diff --git a/app/assets/javascripts/msg/en_us.js b/app/assets/javascripts/msg/en_us.js index 12c660c..0c8e149 100644 --- a/app/assets/javascripts/msg/en_us.js +++ b/app/assets/javascripts/msg/en_us.js @@ -118,6 +118,12 @@ Blockly.Msg.BLOCKS_EVENTS_ON_START = 'when Run clicked'; Blockly.Msg.BLOCKS_EVENTS_ON_KEY_PUSH_OR_DOWN = 'when %1 key %2'; Blockly.Msg.BLOCKS_EVENTS_ON_CLICK = 'when this sprite clicked'; Blockly.Msg.BLOCKS_EVENTS_ON_HIT = 'when %1 hit'; +Blockly.Msg.BLOCKS_EVENTS_MESSAGES = '%1'; +Blockly.Msg.BLOCKS_EVENTS_MESSAGES1 = 'message1'; +Blockly.Msg.BLOCKS_EVENTS_MESSAGES2 = 'message2'; +Blockly.Msg.BLOCKS_EVENTS_WHEN_I_RECEIVE = 'when I receive %1'; +Blockly.Msg.BLOCKS_EVENTS_BROADCAST = 'broadcast %1'; +// Blockly.Msg.BLOCKS_EVENTS_BROADCAST_AND_WAIT = 'broadcast %1 and wait'; // blocks/sensing.js.coffee.erb @@ -205,6 +211,8 @@ Blockly.Msg.BLOCKS_SOUND_PRESET_SOUNDS_PIANO_RA = 'A of piano'; Blockly.Msg.BLOCKS_SOUND_PRESET_SOUNDS_PIANO_SI = 'B of piano'; Blockly.Msg.BLOCKS_SOUND_PRESET_SOUNDS_PIANO_DO_2 = 'High C of piano'; Blockly.Msg.BLOCKS_SOUND_PLAY = 'play sound %1'; +Blockly.Msg.BLOCKS_SOUND_SET_VOLUME = 'set volume to %1 %'; +Blockly.Msg.BLOCKS_SOUND_VOLUME = 'volume'; // blocks/looks.js.coffee.erb diff --git a/app/assets/javascripts/msg/ja.js b/app/assets/javascripts/msg/ja.js index 46f928b..1fa48c5 100644 --- a/app/assets/javascripts/msg/ja.js +++ b/app/assets/javascripts/msg/ja.js @@ -119,9 +119,15 @@ Blockly.Msg.BLOCKS_MOTION_SELF_ANGLE = '■向き'; // blocks/events.js.coffee.erb Blockly.Msg.BLOCKS_EVENTS_ON_START = '♣実行ボタンがクリックされたとき'; -Blockly.Msg.BLOCKS_EVENTS_ON_KEY_PUSH_OR_DOWN = '♣キーボードの %1 が %2 のとき'; +Blockly.Msg.BLOCKS_EVENTS_ON_KEY_PUSH_OR_DOWN = '♣キーボードの %1 が %2 とき'; Blockly.Msg.BLOCKS_EVENTS_ON_CLICK = '♣キャラクターがクリックされたとき'; Blockly.Msg.BLOCKS_EVENTS_ON_HIT = '♣%1 にぶつかったとき'; +Blockly.Msg.BLOCKS_EVENTS_MESSAGES = '%1'; +Blockly.Msg.BLOCKS_EVENTS_MESSAGES1 = 'メッセージ1'; +Blockly.Msg.BLOCKS_EVENTS_MESSAGES2 = 'メッセージ2' +Blockly.Msg.BLOCKS_EVENTS_WHEN_I_RECEIVE = '♣%1 を受け取ったとき'; +Blockly.Msg.BLOCKS_EVENTS_BROADCAST = '♣%1 を送る'; +// Blockly.Msg.BLOCKS_EVENTS_BROADCAST_AND_WAIT = '♣%1 を送って、待つ'; // blocks/sensing.js.coffee.erb @@ -209,6 +215,8 @@ Blockly.Msg.BLOCKS_SOUND_PRESET_SOUNDS_PIANO_RA = 'ピアノのラ'; Blockly.Msg.BLOCKS_SOUND_PRESET_SOUNDS_PIANO_SI = 'ピアノのシ'; Blockly.Msg.BLOCKS_SOUND_PRESET_SOUNDS_PIANO_DO_2 = 'ピアノの高いド'; Blockly.Msg.BLOCKS_SOUND_PLAY = '♪%1 の音を鳴らす'; +Blockly.Msg.BLOCKS_SOUND_SET_VOLUME = '♪音量を %1 %にする'; +Blockly.Msg.BLOCKS_SOUND_VOLUME = '♪音量'; // blocks/looks.js.coffee.erb diff --git a/app/models/concerns/ruby_to_block/block/control_times.rb b/app/models/concerns/ruby_to_block/block/control_times.rb new file mode 100644 index 0000000..4f6caa6 --- /dev/null +++ b/app/models/concerns/ruby_to_block/block/control_times.rb @@ -0,0 +1,20 @@ +module RubyToBlock + module Block + class ControlTimes < Base + blocknize '^\s*(.+)\.times\s+do\s*$', statement: true, indent: true + + def self.process_match_data(md, context) + return false unless context.receiver + md2 = regexp.match(md[type]) + + do_block = Block.new('null') + block = new(statements: { DO: do_block }) + process_value_string(context, block, md2[1], :COUNT) + context.statement_stack.push([type, block]) + context.current_block.sibling = block + context.current_block = do_block + true + end + end + end +end diff --git a/app/models/concerns/ruby_to_block/block/events_broadcast.rb b/app/models/concerns/ruby_to_block/block/events_broadcast.rb new file mode 100644 index 0000000..0202945 --- /dev/null +++ b/app/models/concerns/ruby_to_block/block/events_broadcast.rb @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +module RubyToBlock + module Block + class EventBroadcast < CharacterEvent + blocknize ['^\s*', + CHAR_RE, + 'broadcast\(\s*("[^"]*")\)', + '\s*$'].join(''), + statement: true, inline: true + + def self.process_match_data(md, context) + md2 = regexp.match(md[type]) + add_character_method_call_block(context, md2[1], new, MESSAGE: md2[2]) + true + end + end + end +end diff --git a/app/models/concerns/ruby_to_block/block/events_when_i_receive.rb b/app/models/concerns/ruby_to_block/block/events_when_i_receive.rb new file mode 100644 index 0000000..fb60003 --- /dev/null +++ b/app/models/concerns/ruby_to_block/block/events_when_i_receive.rb @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +module RubyToBlock + module Block + class EventBroadcast < CharacterEvent + blocknize ['^\s*', + CHAR_RE, + 'on\(:receive,\s*("[^"),]*")\)\s+do', + '\s*$'].join(''), + statement: true, indent: true + + def self.process_match_data(md, context) + md2 = regexp.match(md[type]) + add_character_event_blocks(context, md2[1], new, MESSAGE: md2[2]) + true + end + end + end +end diff --git a/app/models/concerns/ruby_to_block/block/sound_set_volume.rb b/app/models/concerns/ruby_to_block/block/sound_set_volume.rb new file mode 100644 index 0000000..739ab25 --- /dev/null +++ b/app/models/concerns/ruby_to_block/block/sound_set_volume.rb @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +module RubyToBlock + module Block + class SoundSetVolume < CharacterMethodCall + blocknize ['^\s*', + CHAR_RE, + 'volume\s*=\s*(\S+)', + '\s*$'].join(''), + statement: true, inline: true + + def self.process_match_data(md, context) + md2 = regexp.match(md[type]) + add_character_method_call_block(context, md2[1], new, VOLUME: md2[2]) + true + end + end + end +end diff --git a/app/models/concerns/ruby_to_block/block/sound_volume.rb b/app/models/concerns/ruby_to_block/block/sound_volume.rb new file mode 100644 index 0000000..dfbee1f --- /dev/null +++ b/app/models/concerns/ruby_to_block/block/sound_volume.rb @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +module RubyToBlock + module Block + class SoundVolume < Value + include CharacterOperation + + blocknize ['^\s*', + CHAR_RE, + 'volume', + '\s*$'].join(''), + value: true + + def self.process_match_data(md, context) + md2 = regexp.match(md[type]) + + character = get_character(context, md2[1]) + return false if context.receiver != character + + block = new + context.add_value(block) + block.character = character + + true + end + end + end +end diff --git a/app/views/editor/_toolbox_default.html.haml b/app/views/editor/_toolbox_default.html.haml index 5077bb0..7350a41 100644 --- a/app/views/editor/_toolbox_default.html.haml +++ b/app/views/editor/_toolbox_default.html.haml @@ -264,6 +264,7 @@ - category = 'sound' %category{:name => tt('.sound')} + -# [▼プリセット音声]の音を鳴らす %block{:type => "#{category}_play"} %value{:name => 'NAME'} @@ -272,8 +273,10 @@ -# すべての音を止める -#%block{:type => "#{category}_stop"} - -# 変数:ボリューム - -#%block{:type => "#{category}_volume"} + %block{:type => "#{category}_set_volume"} + = toolbox_number_value('VOLUME', 100) + + %block{:type => "#{category}_volume"} - category = 'pen' %category{:name => tt('.pen')} @@ -304,6 +307,18 @@ -# [▼キャラクター]にぶつかったとき %block{:type => "#{category}_on_hit"} + -# [▼メッセージ]を受け取ったとき + %block{:type => '#{category}_when_i_receive'} + = toolbox_text_value('TEXT', tt('.text')) + + -# [▼メッセージ]を送る + %block{:type => '#{category}_broadcast'} + = toolbox_text_value('TEXT', tt('.text')) + + -# [▼メッセージ]を送って、待つ + -#%block{:type => '#{category}_broadcast_and_wait'} + -# = toolbox_text_value('TEXT', tt('.message')) + - category = 'control' %category{:name => tt('.control')} -# ( )秒待つ diff --git a/config/locales/en.yml b/config/locales/en.yml index 6539a80..ddc2836 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -68,6 +68,7 @@ en: hello: "Hello!" world: "world" text: "text" + message: "message" character_modal: name: "Name" diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 513506e..f8751a1 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -69,6 +69,7 @@ ja: hello: "こんにちは!" world: "あいうえお" text: "文章" + message: "メッセージ" character_modal: name: "名前" diff --git a/db/schema.rb b/db/schema.rb index 70762c4..63fb893 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -22,9 +22,9 @@ t.datetime "updated_at" end - add_index "costumes", ["name"], name: "index_costumes_on_name" - add_index "costumes", ["position"], name: "index_costumes_on_position" - add_index "costumes", ["user_id"], name: "index_costumes_on_user_id" + add_index "costumes", ["name"], name: "index_costumes_on_name", using: :btree + add_index "costumes", ["position"], name: "index_costumes_on_position", using: :btree + add_index "costumes", ["user_id"], name: "index_costumes_on_user_id", using: :btree create_table "source_codes", force: true do |t| t.text "data" @@ -43,15 +43,15 @@ t.datetime "created_at" end - add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true - add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context" + add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree + add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree create_table "tags", force: true do |t| t.string "name" t.integer "taggings_count", default: 0 end - add_index "tags", ["name"], name: "index_tags_on_name", unique: true + add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree create_table "users", force: true do |t| t.string "name" @@ -60,6 +60,6 @@ t.datetime "updated_at" end - add_index "users", ["name"], name: "index_users_on_name", unique: true + add_index "users", ["name"], name: "index_users_on_name", unique: true, using: :btree end diff --git a/spec/acceptance/block_mode/blocks/control/times.feature b/spec/acceptance/block_mode/blocks/control/times.feature index 2924fe8..a01f54f 100644 --- a/spec/acceptance/block_mode/blocks/control/times.feature +++ b/spec/acceptance/block_mode/blocks/control/times.feature @@ -70,3 +70,46 @@ end """ + + シナリオ: ブロックの中身に計算式を配置する。 + 前提 "ブロック" タブを表示する + + もし 次のブロックを配置する: + """ + %block{:type => "variables_set", :x => "0", :y => "0"} + %field{:name => "VAR"}< + 変数1 + %value{:name => "VALUE"} + %block{:type => "math_number"} + %field{:name => "NUM"}< + 5 + %next + %block{:type => "control_times", :x => "0", :y => "0"} + %value{:name => "COUNT"} + %block{:type => "operators_minus"} + %value{:name => "A"} + %block{:type => "variables_get"} + %field{:name => "VAR"}< + 変数1 + %value{:name => "B"} + %block{:type => "math_number"} + %field{:name => "NUM"}< + 1 + %statement{:name => "DO"} + %block{:type => "ruby_statement", :x => "0", :y => "0"} + %field{:name => "STATEMENT"}< + p self + """ + かつ ブロックからソースコードを生成する + + ならば テキストエディタのプログラムは以下であること: + """ + require "smalruby" + + 変数1 = 5 + + (変数1 - 1).times do + p self + end + + """ diff --git a/spec/acceptance/block_mode/blocks/sound/set_volume.feature b/spec/acceptance/block_mode/blocks/sound/set_volume.feature new file mode 100644 index 0000000..a77d42e --- /dev/null +++ b/spec/acceptance/block_mode/blocks/sound/set_volume.feature @@ -0,0 +1,81 @@ +# encoding: utf-8 +# language: ja +@javascript +機能: sound_set_volume - 「音量を( )%にする」ブロック + シナリオ: ブロックのみ配置する + 前提 "ブロック" タブを表示する + + もし 次のブロックを配置する: + """ + %block{:type => "sound_set_volume", :x => "0", :y => "0"} + %value{:name => "VOLUME"} + %block{:type => "math_number"} + %field{:name => "NUM"}< + 100 + """ + かつ ブロックからソースコードを生成する + + ならば テキストエディタのプログラムは "" であること + + シナリオ: キャラクターとブロックを配置する + 前提 "ブロック" タブを表示する + かつ 次のキャラクターを追加する: + | name | costumes | x | y | angle | + | car1 | car1.png | 0 | 0 | 0 | + + もし 次のブロックを配置する: + """ + %block{:type => "character_new", :x => "21", :y => "15"} + %field{:name => "NAME"}< + car1 + %statement{:name => "DO"} + %block{:type => "sound_set_volume", :x => "0", :y => "0"} + %value{:name => "VOLUME"} + %block{:type => "math_number"} + %field{:name => "NUM"}< + 100 + """ + かつ ブロックからソースコードを生成する + + ならば テキストエディタのプログラムは以下であること: + """ + require "smalruby" + + car1 = Character.new(costume: "costume1:car1.png", x: 0, y: 0, angle: 0) + car1.volume = 100 + + """ + + シナリオ: キャラクターとイベントとブロックを配置する + 前提 "ブロック" タブを表示する + かつ 次のキャラクターを追加する: + | name | costumes | x | y | angle | + | car1 | car1.png | 0 | 0 | 0 | + + もし 次のブロックを配置する: + """ + %block{:type => "character_new", :x => "21", :y => "15"} + %field{:name => "NAME"}< + car1 + %statement{:name => "DO"} + %block{:type => "events_on_start"} + %statement{:name => "DO"} + %block{:type => "sound_set_volume", :x => "0", :y => "0"} + %value{:name => "VOLUME"} + %block{:type => "math_number"} + %field{:name => "NUM"}< + 100 + """ + かつ ブロックからソースコードを生成する + + ならば テキストエディタのプログラムは以下であること: + """ + require "smalruby" + + car1 = Character.new(costume: "costume1:car1.png", x: 0, y: 0, angle: 0) + + car1.on(:start) do + self.volume = 100 + end + + """ diff --git a/spec/acceptance/block_mode/blocks/sound/volume.feature b/spec/acceptance/block_mode/blocks/sound/volume.feature new file mode 100644 index 0000000..e1b88f5 --- /dev/null +++ b/spec/acceptance/block_mode/blocks/sound/volume.feature @@ -0,0 +1,31 @@ +# encoding: utf-8 +# language: ja +@javascript +機能: sound_volume - 「音量」ブロック + 背景: + 前提 "ブロック" タブを表示する + + シナリオ: ブロックを配置する + もし 次のブロックを配置する: + """ + %block{:type => "sound_volume", :x => "0", :y => "0", :inline => "true"} + """ + かつ ブロックからソースコードを生成する + + ならば テキストエディタのプログラムは以下を含むこと: + """ + volume + """ + + もし 次のブロックを配置する: + """ + %block{:type => "ruby_p", :x => "0", :y => "0", :inline => "true"} + %value{:name => "ARG"} + %block{:type => "sound_volume"} + """ + かつ ブロックからソースコードを生成する + + ならば テキストエディタのプログラムは以下を含むこと: + """ + p(volume) + """ diff --git a/spec/models/concerns/ruby_to_block/block/sound_spec.rb b/spec/models/concerns/ruby_to_block/block/sound_spec.rb index f1ec7a1..9afe346 100644 --- a/spec/models/concerns/ruby_to_block/block/sound_spec.rb +++ b/spec/models/concerns/ruby_to_block/block/sound_spec.rb @@ -7,9 +7,13 @@ describe RubyToBlock::Block, '音ジャンル', to_blocks: true do parts = <<-EOS car1.on(:start) do + self.volume = 100 play(name: "piano_do.wav") + p(volume) end car1.play(name: "piano_do.wav") +car1.volume = 100 +p(car1.volume) EOS describe compact_source_code(parts), character_new_data: true do _parts = parts @@ -21,12 +25,28 @@ - - - - piano_do.wav + + + + 100 + + + + + piano_do.wav + + + + + + + + + + + @@ -36,6 +56,24 @@ piano_do.wav + + + + + 100 + + + + + + + car1.volume + + + + + +