smalruby-editor 0.0.12-x86-mingw32 → 0.1.0-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 (179) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/.travis.yml +2 -0
  4. data/LEGAL +32 -0
  5. data/Rakefile +1 -1
  6. data/app/assets/demos/default.xml +126 -0
  7. data/app/assets/demos/rgb_led_anode.xml +83 -0
  8. data/app/assets/images/favicon.ico +0 -0
  9. data/app/assets/javascripts/application.js +18 -1
  10. data/app/assets/javascripts/block_mode.js.coffee.erb +10 -0
  11. data/app/assets/javascripts/blocks/blockly.js.coffee.erb +34 -0
  12. data/app/assets/javascripts/blocks/character.js.coffee.erb +76 -0
  13. data/app/assets/javascripts/blocks/control.js.coffee.erb +180 -0
  14. data/app/assets/javascripts/blocks/data.js.coffee.erb +6 -0
  15. data/app/assets/javascripts/blocks/etc.js.coffee.erb +6 -0
  16. data/app/assets/javascripts/blocks/events.js.coffee.erb +82 -0
  17. data/app/assets/javascripts/blocks/hardware.js.coffee.erb +313 -0
  18. data/app/assets/javascripts/blocks/looks.js.coffee.erb +163 -0
  19. data/app/assets/javascripts/blocks/motion.js.coffee.erb +297 -0
  20. data/app/assets/javascripts/blocks/operators.js.coffee.erb +279 -0
  21. data/app/assets/javascripts/blocks/pen.js.coffee.erb +6 -0
  22. data/app/assets/javascripts/blocks/ruby.js.coffee.erb +74 -0
  23. data/app/assets/javascripts/blocks/sensing.js.coffee.erb +241 -0
  24. data/app/assets/javascripts/blocks/sound.js.coffee.erb +75 -0
  25. data/{public/favicon.ico → app/assets/javascripts/collections/.keep} +0 -0
  26. data/app/assets/javascripts/collections/character_set.js.coffee +12 -0
  27. data/app/assets/javascripts/generators/ruby.js.coffee.erb +188 -0
  28. data/app/assets/javascripts/models/.keep +0 -0
  29. data/app/assets/javascripts/models/character.js.coffee +66 -0
  30. data/app/assets/javascripts/models/scene.js.coffee +5 -0
  31. data/app/assets/javascripts/models/source_code.js.coffee +64 -0
  32. data/app/assets/javascripts/routers/.keep +0 -0
  33. data/app/assets/javascripts/ruby_mode.js.coffee.erb +12 -0
  34. data/app/assets/javascripts/smalruby.js.coffee +97 -0
  35. data/app/assets/javascripts/views/.keep +0 -0
  36. data/app/assets/javascripts/views/character_modal_view.js.coffee +148 -0
  37. data/app/assets/javascripts/views/character_selector_view.js.coffee +109 -0
  38. data/app/assets/javascripts/views/main_menu_view.js.coffee +264 -0
  39. data/app/assets/stylesheets/editor.css.scss +318 -2
  40. data/app/assets/stylesheets/toolbox.css.scss.erb +62 -0
  41. data/app/assets/templates/.keep +0 -0
  42. data/app/controllers/application_controller.rb +19 -0
  43. data/app/controllers/editor_controller.rb +4 -0
  44. data/app/controllers/source_codes_controller.rb +8 -2
  45. data/app/helpers/application_helper.rb +1 -0
  46. data/app/helpers/editor_helper.rb +46 -0
  47. data/app/models/source_code.rb +49 -6
  48. data/app/views/editor/_block_tab.html.haml +53 -0
  49. data/app/views/editor/_character_modal.html.haml +53 -0
  50. data/app/views/editor/_toolbox.html.haml +384 -0
  51. data/app/views/editor/demo.html.erb +16 -0
  52. data/app/views/editor/index.html.haml +60 -0
  53. data/app/views/layouts/application.html.erb +7 -0
  54. data/config/application.rb +1 -0
  55. data/config/initializers/teaspoon.rb +79 -0
  56. data/config/routes.rb +4 -0
  57. data/lib/smalruby_editor/version.rb +1 -1
  58. data/lib/tasks/gem.rake +7 -4
  59. data/lib/tasks/release.rake +43 -0
  60. data/public/apple-touch-icon.png +0 -0
  61. data/public/blockly/media/1x1.gif +0 -0
  62. data/public/blockly/media/click.mp3 +0 -0
  63. data/public/blockly/media/click.ogg +0 -0
  64. data/public/blockly/media/click.wav +0 -0
  65. data/public/blockly/media/delete.mp3 +0 -0
  66. data/public/blockly/media/delete.ogg +0 -0
  67. data/public/blockly/media/delete.wav +0 -0
  68. data/public/blockly/media/handclosed.cur +0 -0
  69. data/public/blockly/media/handopen.cur +0 -0
  70. data/public/blockly/media/quote0.png +0 -0
  71. data/public/blockly/media/quote1.png +0 -0
  72. data/public/blockly/media/trashbody.png +0 -0
  73. data/public/blockly/media/trashlid.png +0 -0
  74. data/public/blockly/media/tree.png +0 -0
  75. data/public/browserconfig.xml +1 -0
  76. data/public/large.png +0 -0
  77. data/public/smalruby/assets/ball1.png +0 -0
  78. data/public/smalruby/assets/ball2.png +0 -0
  79. data/public/smalruby/assets/ball3.png +0 -0
  80. data/public/smalruby/assets/ball4.png +0 -0
  81. data/public/smalruby/assets/ball5.png +0 -0
  82. data/public/smalruby/assets/ball6.png +0 -0
  83. data/public/smalruby/assets/car1.png +0 -0
  84. data/public/smalruby/assets/car2.png +0 -0
  85. data/public/smalruby/assets/car3.png +0 -0
  86. data/public/smalruby/assets/car4.png +0 -0
  87. data/public/smalruby/assets/cat1.png +0 -0
  88. data/public/smalruby/assets/cat2.png +0 -0
  89. data/public/smalruby/assets/cat3.png +0 -0
  90. data/public/smalruby/assets/frog1.png +0 -0
  91. data/public/smalruby/assets/piano_do.wav +0 -0
  92. data/public/smalruby/assets/piano_do_2.wav +0 -0
  93. data/public/smalruby/assets/piano_fa.wav +0 -0
  94. data/public/smalruby/assets/piano_mi.wav +0 -0
  95. data/public/smalruby/assets/piano_ra.wav +0 -0
  96. data/public/smalruby/assets/piano_re.wav +0 -0
  97. data/public/smalruby/assets/piano_si.wav +0 -0
  98. data/public/smalruby/assets/piano_so.wav +0 -0
  99. data/public/square.png +0 -0
  100. data/public/tiny.png +0 -0
  101. data/public/wide.png +0 -0
  102. data/smalruby-editor.gemspec +4 -0
  103. data/spec/acceptance/block_mode/blocks/character/new.feature +136 -0
  104. data/spec/acceptance/block_mode/blocks/control/await.feature +20 -0
  105. data/spec/acceptance/block_mode/blocks/control/await_until.feature +39 -0
  106. data/spec/acceptance/block_mode/blocks/control/break.feature +20 -0
  107. data/spec/acceptance/block_mode/blocks/control/if.feature +68 -0
  108. data/spec/acceptance/block_mode/blocks/control/if_else.feature +78 -0
  109. data/spec/acceptance/block_mode/blocks/control/loop.feature +45 -0
  110. data/spec/acceptance/block_mode/blocks/control/next.feature +20 -0
  111. data/spec/acceptance/block_mode/blocks/control/redo.feature +20 -0
  112. data/spec/acceptance/block_mode/blocks/control/sleep.feature +41 -0
  113. data/spec/acceptance/block_mode/blocks/control/times.feature +72 -0
  114. data/spec/acceptance/block_mode/blocks/control/until.feature +68 -0
  115. data/spec/acceptance/block_mode/blocks/events/on_click.feature +75 -0
  116. data/spec/acceptance/block_mode/blocks/events/on_hit.feature +83 -0
  117. data/spec/acceptance/block_mode/blocks/events/on_key_push_or_down.feature +171 -0
  118. data/spec/acceptance/block_mode/blocks/events/on_start.feature +75 -0
  119. data/spec/acceptance/block_mode/blocks/hardware/init_hardware.feature +44 -0
  120. data/spec/acceptance/block_mode/blocks/hardware/led_off.feature +75 -0
  121. data/spec/acceptance/block_mode/blocks/hardware/led_on.feature +75 -0
  122. data/spec/acceptance/block_mode/blocks/hardware/on_sensor_change.feature +81 -0
  123. data/spec/acceptance/block_mode/blocks/hardware/rgb_led_off.feature +81 -0
  124. data/spec/acceptance/block_mode/blocks/hardware/rgb_led_on.feature +87 -0
  125. data/spec/acceptance/block_mode/blocks/hardware/sensor_value.feature +100 -0
  126. data/spec/acceptance/block_mode/blocks/looks/hide.feature +69 -0
  127. data/spec/acceptance/block_mode/blocks/looks/say.feature +106 -0
  128. data/spec/acceptance/block_mode/blocks/looks/show.feature +69 -0
  129. data/spec/acceptance/block_mode/blocks/looks/vanish.feature +69 -0
  130. data/spec/acceptance/block_mode/blocks/motion/change_x_by.feature +81 -0
  131. data/spec/acceptance/block_mode/blocks/motion/change_y_by.feature +81 -0
  132. data/spec/acceptance/block_mode/blocks/motion/move.feature +81 -0
  133. data/spec/acceptance/block_mode/blocks/motion/reach_wall.feature +98 -0
  134. data/spec/acceptance/block_mode/blocks/motion/rotate_left.feature +81 -0
  135. data/spec/acceptance/block_mode/blocks/motion/rotate_right.feature +81 -0
  136. data/spec/acceptance/block_mode/blocks/motion/self_angle.feature +92 -0
  137. data/spec/acceptance/block_mode/blocks/motion/self_x.feature +92 -0
  138. data/spec/acceptance/block_mode/blocks/motion/self_y.feature +92 -0
  139. data/spec/acceptance/block_mode/blocks/motion/set_angle.feature +81 -0
  140. data/spec/acceptance/block_mode/blocks/motion/set_x.feature +81 -0
  141. data/spec/acceptance/block_mode/blocks/motion/set_x_y.feature +95 -0
  142. data/spec/acceptance/block_mode/blocks/motion/set_y.feature +81 -0
  143. data/spec/acceptance/block_mode/blocks/motion/turn.feature +69 -0
  144. data/spec/acceptance/block_mode/blocks/motion/turn_if_reach_wall.feature +69 -0
  145. data/spec/acceptance/block_mode/blocks/sensing/character_property.feature +114 -0
  146. data/spec/acceptance/block_mode/blocks/sensing/hit.feature +110 -0
  147. data/spec/acceptance/block_mode/blocks/sensing/input_key_push_or_down.feature +91 -0
  148. data/spec/acceptance/block_mode/blocks/sensing/input_mouse_pos_x.feature +39 -0
  149. data/spec/acceptance/block_mode/blocks/sensing/input_mouse_pos_y.feature +39 -0
  150. data/spec/acceptance/block_mode/blocks/sensing/input_mouse_push_or_down.feature +91 -0
  151. data/spec/acceptance/block_mode/blocks/sensing/time_now.feature +43 -0
  152. data/spec/acceptance/block_mode/blocks/sound/play.feature +81 -0
  153. data/spec/acceptance/block_mode/demo.feature +49 -0
  154. data/spec/acceptance/{text_editor → ruby_mode}/base.feature +11 -2
  155. data/spec/acceptance/{standalone → ruby_mode}/check.feature +8 -9
  156. data/spec/acceptance/ruby_mode/download.feature +33 -0
  157. data/spec/acceptance/{text_editor → ruby_mode}/load.feature +13 -13
  158. data/spec/acceptance/standalone/run.feature +17 -0
  159. data/spec/acceptance/standalone/save.feature +6 -6
  160. data/spec/helpers/editor_helper_spec.rb +110 -10
  161. data/spec/javascripts/collections/character_set_spec.coffee +41 -0
  162. data/spec/javascripts/models/character_spec.coffee +146 -0
  163. data/spec/javascripts/models/scene_spec.coffee +15 -0
  164. data/spec/javascripts/spec_helper.js +29 -0
  165. data/spec/spec_helper.rb +3 -8
  166. data/spec/steps/block_mode_steps.rb +37 -0
  167. data/spec/steps/global_variable.rb +30 -6
  168. data/spec/steps/text_editor_steps.rb +20 -2
  169. data/spec/teaspoon_env.rb +46 -0
  170. data/vendor/assets/javascripts/blockly/blockly_compressed.js +992 -0
  171. data/vendor/assets/javascripts/blockly/blocks_compressed.js +129 -0
  172. data/vendor/assets/javascripts/blockly/msg/js/ja.js +377 -0
  173. data/vendor/assets/javascripts/jquery.blockUI.js +619 -0
  174. metadata +290 -23
  175. data/app/assets/javascripts/editor.js.coffee.erb +0 -137
  176. data/app/views/editor/index.html.erb +0 -22
  177. data/spec/acceptance/text_editor/check.feature +0 -29
  178. data/spec/acceptance/text_editor/save.feature +0 -34
  179. data/spec/support/assets.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b55362fec68e6279cfa5cdafbb0a9fccfc9ee7f3
4
- data.tar.gz: 1319543f4e30a65c9f2a79dffccaef0b5dd9cc0a
3
+ metadata.gz: 5efc7115de1a0e5e5d2623e0fb311acf49807068
4
+ data.tar.gz: 7267907754f7b526e77d754ba06eb242d38b49a4
5
5
  SHA512:
6
- metadata.gz: 5cbe52f392e59752ff36df1f7ed251c47c150f2f6b9a4e558a834b9926049c5c47640493a823d1f5c039b463819d66bfd39481964357a55a79e5acb90a3635ce
7
- data.tar.gz: 84c244208e926c700c1506f0157d3020e2047acb3f98f27f3f1dfb47d60488ea0d0aab007c963d34ac3951cd982137f521e0fb1f8e11fe3d3711480b2da9f986
6
+ metadata.gz: d25b0cfc3dabc55403d9f7a9b3a67bd7670362b892bc58a40c1a568904acea2987a68ae434e3c24805eaf1d2b344b1f83e2ac0acda7d77035ef60cbf1fc089c1
7
+ data.tar.gz: 532f0f8367f68521eaf6b3017961a89ea94eb5b04c46d8eab7d21fa81ac4face6da40120346ae99945e0b2d5eb0e806f1f4821492f82fd29368f5df2061471a1
data/.rubocop.yml CHANGED
@@ -3,6 +3,7 @@ AllCops:
3
3
  - db/seeds.rb
4
4
  - spec/fixtures/**
5
5
 
6
+ # 日本語でのコメントを許可する
6
7
  AsciiComments:
7
8
  Enabled: false
8
9
 
@@ -17,3 +18,7 @@ Documentation:
17
18
  # WindowsだとEndOfLine copが動作しないため無効にしている
18
19
  EndOfLine:
19
20
  Enabled: false
21
+
22
+ # diffが少なくなるためハッシュや配列の最後のカンマは許可する
23
+ TrailingComma:
24
+ Enabled: false
data/.travis.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  language: ruby
2
2
 
3
+ cache: bundler
4
+
3
5
  rvm:
4
6
  - 2.0.0
5
7
 
data/LEGAL CHANGED
@@ -11,3 +11,35 @@ public/fonts/fontawesome-webfont.woff:
11
11
 
12
12
  These's license is SIL Open Font License (OFL) 1.1:
13
13
  http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL .
14
+
15
+ vendor/assets/javascripts/blockly/**/*, public/blockly/**/*:
16
+
17
+ These's license is Apache License Version 2.0, January 2011:
18
+ http://www.apache.org/licenses/ .
19
+
20
+ vendor/assets/javascripts/jquery.blockUI.js:
21
+
22
+ Copyright © 2007-2013 M. Alsup.
23
+
24
+ The BlockUI plugin is dual licensed under the MIT and GPL licenses.
25
+
26
+ You may use either license. The MIT license is recommended for most
27
+ projects because it is simple and easy to understand and it places
28
+ almost no restrictions on what you can do with the plugin.
29
+
30
+ If the GPL suits your project better you are also free to use the
31
+ plugin under that license.
32
+
33
+ You do not have to do anything special to choose one license or the
34
+ other and you don't have to notify anyone which license you are
35
+ using. You are free to use the BlockUI plugin in commercial projects
36
+ as long as the copyright header is left intact.
37
+
38
+ https://github.com/malsup/blockui
39
+
40
+ public/favicon.ico, public/apple-touch-icon.png, public/large.png,
41
+ public/square.png, public/tiny.png, public/wide.png:
42
+
43
+ Copyright (C) Hikari Arakawa (Smalruby Project) 2013,
44
+ licensed under CC BY-SA 2.1 JP:
45
+ http://creativecommons.org/licenses/by-sa/2.1/jp/ .
data/Rakefile CHANGED
@@ -6,4 +6,4 @@ require File.expand_path('../config/application', __FILE__)
6
6
  SmalrubyEditor::Application.load_tasks
7
7
 
8
8
  task(:default).clear
9
- task default: [:rubocop, :spec]
9
+ task default: [:rubocop, :spec, :teaspoon]
@@ -0,0 +1,126 @@
1
+ <xml xmlns="http://www.w3.org/1999/xhtml">
2
+ <character name="car1" costumes="car2.png" angle="0" y="0" x="0" />
3
+ <character name="car2" costumes="car3.png" angle="0" y="415" x="0" />
4
+ <block type="ruby_comment" y="25" x="34">
5
+ <field name="COMMENT">逃げる車</field>
6
+ <next>
7
+ <block type="character_new">
8
+ <field name="NAME">car1</field>
9
+ <statement name="DO">
10
+ <block type="events_on_start">
11
+ <statement name="DO">
12
+ <block type="control_loop">
13
+ <statement name="DO">
14
+ <block type="motion_move" inline="true">
15
+ <value name="STEP">
16
+ <block type="math_number">
17
+ <field name="NUM">6</field>
18
+ </block>
19
+ </value>
20
+ <next>
21
+ <block type="control_if" inline="true">
22
+ <value name="COND">
23
+ <block type="motion_reach_wall" />
24
+ </value>
25
+ <statement name="THEN">
26
+ <block type="motion_turn" />
27
+ </statement>
28
+ </block>
29
+ </next>
30
+ </block>
31
+ </statement>
32
+ </block>
33
+ </statement>
34
+ <next>
35
+ <block type="events_on_key_push_or_down">
36
+ <field name="KEY">K_LEFT</field>
37
+ <field name="POD">down</field>
38
+ <statement name="DO">
39
+ <block type="motion_rotate_left" inline="true">
40
+ <value name="ANGLE">
41
+ <block type="math_number">
42
+ <field name="NUM">15</field>
43
+ </block>
44
+ </value>
45
+ </block>
46
+ </statement>
47
+ <next>
48
+ <block type="events_on_key_push_or_down">
49
+ <field name="KEY">K_RIGHT</field>
50
+ <field name="POD">down</field>
51
+ <statement name="DO">
52
+ <block type="motion_rotate_right" inline="true">
53
+ <value name="ANGLE">
54
+ <block type="math_number">
55
+ <field name="NUM">15</field>
56
+ </block>
57
+ </value>
58
+ </block>
59
+ </statement>
60
+ </block>
61
+ </next>
62
+ </block>
63
+ </next>
64
+ </block>
65
+ </statement>
66
+ </block>
67
+ </next>
68
+ </block>
69
+ <block type="ruby_comment" y="23" x="480">
70
+ <field name="COMMENT">追いかける車</field>
71
+ <next>
72
+ <block type="character_new">
73
+ <field name="NAME">car2</field>
74
+ <statement name="DO">
75
+ <block type="events_on_start">
76
+ <statement name="DO">
77
+ <block type="control_loop">
78
+ <statement name="DO">
79
+ <block type="motion_point_towards_character">
80
+ <field name="VAR">car1</field>
81
+ <next>
82
+ <block type="motion_move" inline="true">
83
+ <value name="STEP">
84
+ <block type="math_number">
85
+ <field name="NUM">3</field>
86
+ </block>
87
+ </value>
88
+ <next>
89
+ <block type="control_if_else" inline="true">
90
+ <value name="COND">
91
+ <block type="sensing_hit">
92
+ <field name="CHAR">car1</field>
93
+ </block>
94
+ </value>
95
+ <statement name="THEN">
96
+ <block type="looks_say" inline="true">
97
+ <value name="TEXT">
98
+ <block type="text">
99
+ <field name="TEXT">追いつきました!</field>
100
+ </block>
101
+ </value>
102
+ </block>
103
+ </statement>
104
+ <statement name="ELSE">
105
+ <block type="looks_say" inline="true">
106
+ <value name="TEXT">
107
+ <block type="text">
108
+ <field name="TEXT" />
109
+ </block>
110
+ </value>
111
+ </block>
112
+ </statement>
113
+ </block>
114
+ </next>
115
+ </block>
116
+ </next>
117
+ </block>
118
+ </statement>
119
+ </block>
120
+ </statement>
121
+ </block>
122
+ </statement>
123
+ </block>
124
+ </next>
125
+ </block>
126
+ </xml>
@@ -0,0 +1,83 @@
1
+ <xml xmlns="http://www.w3.org/1999/xhtml">
2
+ <character name="frog1" x="261" y="191" angle="0" costumes="frog1.png" />
3
+ <block type="hardware_init_hardware" x="40" y="6" />
4
+ <block type="character_new" x="45" y="50">
5
+ <field name="NAME">frog1</field>
6
+ <statement name="DO">
7
+ <block type="events_on_click">
8
+ <statement name="DO">
9
+ <block type="looks_say" inline="true">
10
+ <value name="TEXT">
11
+ <block type="text">
12
+ <field name="TEXT">ライトをぴかっとさせるでよ♪</field>
13
+ </block>
14
+ </value>
15
+ <next>
16
+ <block type="hardware_rgb_led_on">
17
+ <field name="AC">anode</field>
18
+ <field name="PIN">D3</field>
19
+ <field name="COLOUR">#3333ff</field>
20
+ <next>
21
+ <block type="control_sleep" inline="true">
22
+ <value name="SEC">
23
+ <block type="math_number">
24
+ <field name="NUM">1</field>
25
+ </block>
26
+ </value>
27
+ <next>
28
+ <block type="hardware_rgb_led_on">
29
+ <field name="AC">anode</field>
30
+ <field name="PIN">D3</field>
31
+ <field name="COLOUR">#ffff99</field>
32
+ <next>
33
+ <block type="control_sleep" inline="true">
34
+ <value name="SEC">
35
+ <block type="math_number">
36
+ <field name="NUM">1</field>
37
+ </block>
38
+ </value>
39
+ <next>
40
+ <block type="hardware_rgb_led_on">
41
+ <field name="AC">anode</field>
42
+ <field name="PIN">D3</field>
43
+ <field name="COLOUR">#ff0000</field>
44
+ <next>
45
+ <block type="control_sleep" inline="true">
46
+ <value name="SEC">
47
+ <block type="math_number">
48
+ <field name="NUM">1</field>
49
+ </block>
50
+ </value>
51
+ <next>
52
+ <block type="hardware_rgb_led_off">
53
+ <field name="AC">anode</field>
54
+ <field name="PIN">D3</field>
55
+ <next>
56
+ <block type="looks_say" inline="true">
57
+ <value name="TEXT">
58
+ <block type="text">
59
+ <field name="TEXT" />
60
+ </block>
61
+ </value>
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
+ </next>
76
+ </block>
77
+ </next>
78
+ </block>
79
+ </statement>
80
+ </block>
81
+ </statement>
82
+ </block>
83
+ </xml>
Binary file
@@ -12,10 +12,27 @@
12
12
  //
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
+ //= require jquery.ui.draggable
16
+ //= require jquery.ui.droppable
17
+ //= require jquery.blockUI
15
18
  //= require turbolinks
16
19
  //= require ace/ace
17
20
  //= require ace/theme-clouds.js
18
21
  //= require ace/mode-ruby.js
19
22
  //= require bootstrap.js
20
23
  //= require jquery-fileupload/basic
21
- //= require_tree .
24
+ //= require blockly/blockly_compressed
25
+ //= require blockly/blocks_compressed
26
+ //= require blockly/msg/js/ja
27
+ //= require underscore
28
+ //= require backbone
29
+ //= require smalruby
30
+ //= require_tree ../templates
31
+ //= require_tree ./models
32
+ //= require_tree ./collections
33
+ //= require_tree ./views
34
+ //= require_tree ./routers
35
+ //= require ./block_mode
36
+ //= require_tree ./generators
37
+ //= require_tree ./blocks
38
+ //= require ./ruby_mode
@@ -0,0 +1,10 @@
1
+ $ ->
2
+ Blockly.HSV_SATURATION = 1.0
3
+ Blockly.HSV_VALUE = 0.8
4
+
5
+ Blockly.inject document.getElementById('blockly-div'),
6
+ path: '/blockly/'
7
+ toolbox: document.getElementById('toolbox')
8
+ trashcan: true
9
+
10
+ Blockly.Toolbox.tree_.expandAll()
@@ -0,0 +1,34 @@
1
+ # Blocklyが提供しているブロック
2
+
3
+ <% category = 'math' %>
4
+
5
+ <% n = "#{category}_number" %>
6
+ Blockly.Ruby['<%= n %>'] = (block) ->
7
+ code = parseFloat(@getFieldValue('NUM'))
8
+ order = if code < 0 then Blockly.Ruby.ORDER_UNARY_SIGN else Blockly.Ruby.ORDER_ATOMIC
9
+ [code, order]
10
+
11
+
12
+ <% category = 'text' %>
13
+
14
+ <% n = "#{category}" %>
15
+ Blockly.Ruby['<%= n %>'] = (block) ->
16
+ code = Blockly.Ruby.quote_(@getFieldValue('TEXT'))
17
+ [code, Blockly.Ruby.ORDER_ATOMIC]
18
+
19
+
20
+ # 変数
21
+ <% category = 'variables' %>
22
+
23
+ # [▼](変数)
24
+ <% n = "#{category}_get" %>
25
+ Blockly.Ruby['<%= n %>'] = (block) ->
26
+ name = Blockly.Ruby.variableDB_.getName(block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE)
27
+ [name, Blockly.Ruby.ORDER_ATOMIC]
28
+
29
+ # セット[▼]宛先
30
+ <% n = "#{category}_set" %>
31
+ Blockly.Ruby['<%= n %>'] = (block) ->
32
+ val = Blockly.Ruby.valueToCode(block, 'VALUE', Blockly.Ruby.ORDER_NONE) || '0'
33
+ name = Blockly.Ruby.variableDB_.getName(block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE)
34
+ name + ' = ' + val + '\n';
@@ -0,0 +1,76 @@
1
+ # 「キャラクター」ジャンル
2
+
3
+ <%
4
+ category = 'character'
5
+ color = 198
6
+ %>
7
+
8
+ # キャラクター
9
+ <% n = "#{category}_new" %>
10
+ Blockly.Blocks['<%= n %>'] =
11
+ init: ->
12
+ @setHelpUrl('')
13
+ @setColour(<%= color %>)
14
+
15
+ size = Blockly.BlockSvg.FIELD_HEIGHT * 2
16
+ imageField = new Blockly.FieldImage(null, size, size)
17
+
18
+ nameField = new Blockly.FieldLabel('')
19
+ # HACK: ラベルをXMLとして出力させるためにEDITABLEをtrueにしている
20
+ nameField.EDITABLE = true
21
+ # HACK: 画像とラベルの縦位置を合わせる
22
+ nameField.textElement_.setAttribute('y', 10)
23
+ nameField.setText = _.bind(@nameFieldSetText_, @)
24
+
25
+ @appendDummyInput()
26
+ .appendField(imageField, 'COSTUME')
27
+ .appendField(nameField, 'NAME')
28
+ @appendStatementInput('DO')
29
+ @setPreviousStatement(true)
30
+ @setNextStatement(true)
31
+ @setTooltip('')
32
+
33
+ dispose: (healStack, animate) ->
34
+ @character.off 'change', @changeHandler
35
+ @character.unlink?(@)
36
+ Blockly.Block.prototype.dispose.apply(@, arguments)
37
+
38
+ nameFieldSetText_: (name) ->
39
+ charSet = Smalruby.Collections.CharacterSet
40
+ char = charSet.findWhere({ name: name })
41
+ if char
42
+ @setCharacter(char)
43
+ else
44
+ @fieldLableSetText_(@getField_('NAME'), name)
45
+
46
+ fieldLableSetText_: (field, text) ->
47
+ Blockly.FieldLabel.prototype.setText.call(field, text)
48
+
49
+ setCharacter: (character) ->
50
+ if @changeHandler
51
+ @character.off 'change', @changeHandler
52
+
53
+ @character = character
54
+ @setFieldValue(character.costumeUrl(), 'COSTUME')
55
+ @fieldLableSetText_(@getField_('NAME'), character.get('name'))
56
+ character.link(@)
57
+
58
+ @changeHandler = (model) =>
59
+ @setFieldValue(model.costumeUrl(), 'COSTUME')
60
+ @fieldLableSetText_(@getField_('NAME'), character.get('name'))
61
+
62
+ character.on 'change', @changeHandler
63
+
64
+ @
65
+
66
+ Blockly.Ruby['<%= n %>'] = (block) ->
67
+ c = block.character
68
+ Blockly.Ruby.definitions_["character_#{c.get('name')}"] =
69
+ "#{c.get('name')} = Character.new(costume: #{Blockly.Ruby.quote_(c.costume())}, x: #{c.get('x')}, y: #{c.get('y')}, angle: #{c.get('angle')})"
70
+ Blockly.Ruby.cs_().push(c)
71
+ try
72
+ targetBlock = block.getInputTargetBlock('DO')
73
+ code = Blockly.Ruby.blockToCode(targetBlock) || '\n'
74
+ finally
75
+ Blockly.Ruby.cs_().pop()
76
+ code