-
Notifications
You must be signed in to change notification settings - Fork 22
Add sound volume blocks #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
takaokouji
merged 6 commits into
smalruby:master
from
junichi-ishikura:add_sound_volume
Feb 11, 2016
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2c34143
[#57117664] added set_volume block.
junichi-ishikura c2f681d
[#57117664] added spec and cucumber test.
junichi-ishikura 1bdd53e
[#57117660] added volume block.
junichi-ishikura ed59929
[#57117660] added spec and cucumber test.
junichi-ishikura c708278
fixed spec. refactor.
junichi-ishikura 51e8242
removed comments.
junichi-ishikura File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
app/models/concerns/ruby_to_block/block/sound_set_volume.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
spec/acceptance/block_mode/blocks/sound/set_volume.feature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
|
||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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) | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここに
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 追加しました 😄 |
||
| car1.volume = 100 | ||
| p(car1.volume) | ||
| EOS | ||
| describe compact_source_code(parts), character_new_data: true do | ||
| _parts = parts | ||
|
|
@@ -21,12 +25,28 @@ | |
| <statement name="DO"> | ||
| <block type="events_on_start"> | ||
| <statement name="DO"> | ||
| <block type="sound_play" inline="true"> | ||
| <value name="NAME"> | ||
| <block type="sound_preset_sounds"> | ||
| <field name="NAME">piano_do.wav</field> | ||
| <block type="sound_set_volume" inline="true"> | ||
| <value name="VOLUME"> | ||
| <block type="math_number"> | ||
| <field name="NUM">100</field> | ||
| </block> | ||
| </value> | ||
| <next> | ||
| <block type="sound_play" inline="true"> | ||
| <value name="NAME"> | ||
| <block type="sound_preset_sounds"> | ||
| <field name="NAME">piano_do.wav</field> | ||
| </block> | ||
| </value> | ||
| <next> | ||
| <block type="ruby_p" inline="true"> | ||
| <value name="ARG"> | ||
| <block type="sound_volume" /> | ||
| </value> | ||
| </block> | ||
| </next> | ||
| </block> | ||
| </next> | ||
| </block> | ||
| </statement> | ||
| <next> | ||
|
|
@@ -36,6 +56,24 @@ | |
| <field name="NAME">piano_do.wav</field> | ||
| </block> | ||
| </value> | ||
| <next> | ||
| <block type="sound_set_volume" inline="true"> | ||
| <value name="VOLUME"> | ||
| <block type="math_number"> | ||
| <field name="NUM">100</field> | ||
| </block> | ||
| </value> | ||
| <next> | ||
| <block type="ruby_p" inline="true"> | ||
| <value name="ARG"> | ||
| <block type="ruby_expression"> | ||
| <field name="EXP">car1.volume</field> | ||
| </block> | ||
| </value> | ||
| </block> | ||
| </next> | ||
| </block> | ||
| </next> | ||
| </block> | ||
| </next> | ||
| </block> | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここに
p(volume)を追加していただきたいです 🙇There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
追加しました 😄
🔚