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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16e2f41ebe0bcb080122de6d84382e4a82c550b0
4
- data.tar.gz: c1a2828d36962c91c92e3e3eaec07fd808ea3306
3
+ metadata.gz: 36b3c22c50c8c07b420ab96465f6a41e5e77ad41
4
+ data.tar.gz: fc4c48d4fcacd1f6d5342b8fd5a6eb4aa4ee9b67
5
5
  SHA512:
6
- metadata.gz: 5153febde2d8cb996df669b9c58753edb474b79ec59929c49e0483729ca52d9909ab27abe58478e3eed0f8661a7f6d75715baaf50382ed6ec29674c78fdeb57e
7
- data.tar.gz: 44d20b9087ca9195c4f16d57d142403b8fc14b3e464e8d8622dcc7fa20cd9bf7f895ec272a6cb0a4306f746a027042829ab5bb0d9b348392bff3fe59fcf16ae0
6
+ metadata.gz: 01f33c0fad38d3ae6c06b1533141d10a4a44e6fc1caea9b0c7f420dc759dce5fc2bdde12f2c2fbc5dfc3f4731d8fa5ce07f301dcb85dfafac13eae3cc66baa2e
7
+ data.tar.gz: 1f86adb56a2437f44c74ec5b764d0dbabc905bb3b75c96d381844313c8a407527819025761f7d4ea7b1cee9e61e4c4735dbd3d0cf17e3e4038a9392997c2e8e1
data/.rubocop.yml CHANGED
@@ -1,7 +1,10 @@
1
1
  AllCops:
2
2
  Excludes:
3
3
  - db/seeds.rb
4
+ - db/schema.rb
4
5
  - spec/fixtures/**
6
+ - vendor/*
7
+ - work/*
5
8
 
6
9
  # 日本語でのコメントを許可する
7
10
  AsciiComments:
data/Guardfile CHANGED
@@ -9,17 +9,15 @@
9
9
 
10
10
  TEMPFILE_BY_EMACS = %r{/\.?\#[^\/]+$}
11
11
 
12
+ ignore(TEMPFILE_BY_EMACS)
13
+
12
14
  group :red_green_refactor, halt_on_fail: true do
13
15
  guard :rubocop, all_on_start: false do
14
- ignore(TEMPFILE_BY_EMACS)
15
-
16
16
  watch(%r{.+\.rb$})
17
17
  watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
18
18
  end
19
19
 
20
20
  guard :rspec, cmd: 'bundle exec bin/rspec' do
21
- ignore(TEMPFILE_BY_EMACS)
22
-
23
21
  watch(%r{^spec/.+_spec\.rb$})
24
22
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
25
23
  watch('spec/spec_helper.rb') { "spec" }
@@ -42,8 +40,6 @@ group :red_green_refactor, halt_on_fail: true do
42
40
  end
43
41
 
44
42
  guard 'livereload' do
45
- ignore(TEMPFILE_BY_EMACS)
46
-
47
43
  watch(%r{app/views/.+\.(erb|haml|slim)$})
48
44
  watch(%r{app/helpers/.+\.rb})
49
45
  watch(%r{public/.+\.(css|js|html)})
data/LEGAL CHANGED
@@ -44,3 +44,9 @@ public/square.png, public/tiny.png, public/wide.png:
44
44
  Smalruby) 2013. このイメージキャラクター、もしくはその派生版は、Ru
45
45
  byプログラミング少年団とスモウルビー:Smalrubyに関連する文脈で誰で
46
46
  も自由に利用できるが、それらは荒川ひかりによる保証を示すものではない。
47
+
48
+ vendor/assets/javascripts/strftime-min.js:
49
+
50
+ Copyright 2010 - 2013 Sami Samhuri sami@samhuri.net
51
+
52
+ MIT license (http://sjs.mit-license.org/)
data/README.rdoc CHANGED
@@ -1,5 +1,7 @@
1
1
  == smalruby-editor
2
2
 
3
+ {<img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/smalruby/smalruby-editor">}[https://gitter.im/smalruby/smalruby-editor?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge]
4
+
3
5
  {<img src="https://badge.fury.io/rb/smalruby-editor.png" alt="Gem Version" />}[http://badge.fury.io/rb/smalruby-editor]
4
6
  {<img src="https://travis-ci.org/smalruby/smalruby-editor.png?branch=master" alt="Build Status" />}[https://travis-ci.org/smalruby/smalruby-editor]
5
7
  {<img src="https://coveralls.io/repos/smalruby/smalruby-editor/badge.png?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/smalruby/smalruby-editor?branch=master]
@@ -15,6 +15,7 @@
15
15
  //= require jquery.ui.draggable
16
16
  //= require jquery.ui.droppable
17
17
  //= require jquery.blockUI
18
+ //= require strftime-min
18
19
  //= require ace/ace
19
20
  //= require ace/theme-clouds.js
20
21
  //= require ace/mode-ruby.js
@@ -679,3 +679,40 @@ Blockly.Blocks['<%= n %>'] =
679
679
  Blockly.Ruby['<%= n %>'] = (block) ->
680
680
  lor = @getFieldValue('LOR')
681
681
  Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.#{lor}_ir_photoreflector_value")
682
+
683
+ # Smalrubot s1 left/right dc motor power ratio
684
+ <% n = "#{category}_#{subcategory}_dc_motor_power_ratio" %>
685
+ Blockly.Blocks['<%= n %>'] =
686
+ init: ()->
687
+ @setHelpUrl('')
688
+ @setColour(<%= colors[:sensing] %>)
689
+ @interpolateMsg(<%= bm(".#{subcategory}_dc_motor_power_ratio") %>,
690
+ ['LOR', new Blockly.FieldDropdown(lorDropdown)],
691
+ Blockly.ALIGN_RIGHT)
692
+ @setOutput(true, 'Number')
693
+ @setTooltip('')
694
+
695
+ Blockly.Ruby['<%= n %>'] = (block) ->
696
+ lor = @getFieldValue('LOR')
697
+ Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.#{lor}_dc_motor_power_ratio")
698
+
699
+ # set Smalrubot s1 left/right dc motor power ratio
700
+ <% n = "#{category}_#{subcategory}_dc_motor_set_power_ratio" %>
701
+ Blockly.Blocks['<%= n %>'] =
702
+ init: ()->
703
+ @setHelpUrl('')
704
+ @setColour(<%= colors[:motion] %>)
705
+ @interpolateMsg(<%= bm(".#{subcategory}_dc_motor_set_power_ratio") %>,
706
+ ['LOR', new Blockly.FieldDropdown(lorDropdown)],
707
+ ['SPEED', ['Number'], Blockly.ALIGN_RIGHT],
708
+ Blockly.ALIGN_RIGHT)
709
+ @setInputsInline(true)
710
+ @setPreviousStatement(true)
711
+ @setNextStatement(true)
712
+ @setTooltip('')
713
+
714
+ Blockly.Ruby['<%= n %>'] = (block) ->
715
+ lor = @getFieldValue('LOR')
716
+ speed = Blockly.Ruby.valueToCode(@, 'SPEED', Blockly.Ruby.ORDER_NONE) || '100'
717
+ Blockly.Ruby.characterSetVariable_("<%= subcategory %>.#{lor}_dc_motor_power_ratio",
718
+ speed)
@@ -0,0 +1,123 @@
1
+ /**
2
+ * ソースコードを表現するモデル
3
+ */
4
+ Smalruby.SourceCode = Backbone.Model.extend({
5
+ defaults: {
6
+ filename: null,
7
+ data: null
8
+ },
9
+
10
+ initialize: function() {
11
+ if (!this.get('filename')) {
12
+ var filename = Smalruby.Views.MainMenuView.getFilename();
13
+ if (filename.length == 0) {
14
+ filename = Smalruby.SourceCode.defaultFilename();
15
+ }
16
+ this.set('filename', filename);
17
+ }
18
+
19
+ if (!this.get('data')) {
20
+ if (this.get('filename').match(/\.xml$/)) {
21
+ var data = Smalruby.dumpXml();
22
+ }
23
+ else {
24
+ if (window.blockMode) {
25
+ var data = Blockly.Ruby.workspaceToCode();
26
+ }
27
+ else {
28
+ var data = window.textEditor.getSession().getDocument().getValue();
29
+ }
30
+ }
31
+ this.set('data', data);
32
+ }
33
+ },
34
+
35
+ getRbxmlFilename: function() {
36
+ var filename = this.get('filename');
37
+ if (filename.match(/\.rb\.xml$/)) {
38
+ return filename;
39
+ }
40
+ else {
41
+ if (filename.match(/\.rb$/)) {
42
+ return filename + '.xml';
43
+ }
44
+ else if (filename.match(/\.xml$/)) {
45
+ return filename.replace(/\.xml$/, '.rb.xml');
46
+ }
47
+ else {
48
+ return filename + '.rb.xml';
49
+ }
50
+ }
51
+ },
52
+
53
+ run: function() {
54
+ return this.post_('run');
55
+ },
56
+
57
+ check: function() {
58
+ return this.post_('check');
59
+ },
60
+
61
+ save2: function() {
62
+ return this.post_('');
63
+ },
64
+
65
+ write: function(force) {
66
+ if (force == null) {
67
+ force = false;
68
+ }
69
+ var action = 'write';
70
+ if (force) {
71
+ action += '?force=1';
72
+ }
73
+ return this.delete_(action);
74
+ },
75
+
76
+ toBlocks: function() {
77
+ return this.post_('to_blocks', 'html');
78
+ },
79
+
80
+ post_: function(action, dataType) {
81
+ if (dataType == null) {
82
+ dataType = 'json';
83
+ }
84
+ dfr = $.Deferred();
85
+ $.ajax({
86
+ url: '/source_codes/' + action,
87
+ type: 'POST',
88
+ data: {
89
+ source_code: {
90
+ filename: this.get('filename'),
91
+ data: this.get('data')
92
+ }
93
+ },
94
+ dataType: dataType,
95
+ success: function(data, textStatus, jqXHR) {
96
+ return dfr.resolve(data);
97
+ },
98
+ error: dfr.reject
99
+ });
100
+ return dfr.promise();
101
+ },
102
+
103
+ delete_: function(action) {
104
+ dfr = $.Deferred();
105
+ $.ajax({
106
+ url: '/source_codes/' + action,
107
+ type: 'DELETE',
108
+ dataType: 'json',
109
+ success: function(data, textStatus, jqXHR) {
110
+ return dfr.resolve(data);
111
+ },
112
+ error: dfr.reject
113
+ });
114
+ return dfr.promise();
115
+ }
116
+ }, {
117
+ defaultFilename: function(now) {
118
+ if (now == null) {
119
+ now = new Date();
120
+ }
121
+ return strftime('program_%y%m%d_%H%M%S.rb', now);
122
+ }
123
+ });
@@ -263,6 +263,8 @@ Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_LED_TURN_ON_OR_OFF = '%2 Smalrubot s1 %
263
263
  Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_ACTION = '%1 Smalrubot s1';
264
264
  Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_ACTION_WITH_SEC = '%1 Smalrubot s1 for %2 secs';
265
265
  Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_IR_PHOTOREFLECTOR_VALUE = 'Smalrubot s1 %1 IR Photoreflector';
266
+ Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_DC_MOTOR_POWER_RATIO = 'Smalrubot s1 %1 dc motor power ratio';
267
+ Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_DC_MOTOR_SET_POWER_RATIO = 'set Smalrubot s1 %1 dc motor power ratio to %2 %';
266
268
 
267
269
 
268
270
  // blocks/operators.js.coffee.erb
@@ -263,6 +263,8 @@ Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_LED_TURN_ON_OR_OFF = '★スモウル
263
263
  Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_ACTION = '■スモウルボットS1を %1';
264
264
  Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_ACTION_WITH_SEC = '■スモウルボットS1を %2 秒 %1';
265
265
  Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_IR_PHOTOREFLECTOR_VALUE = '◎スモウルボットS1の %1 のセンサー';
266
+ Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_DC_MOTOR_POWER_RATIO = '◎スモウルボットS1の %1 DCモーターの速度(%)';
267
+ Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_S1_DC_MOTOR_SET_POWER_RATIO = '■スモウルボットS1の %1 DCモーターの速度を %2 (%) にする';
266
268
 
267
269
 
268
270
  // blocks/operators.js.coffee.erb
@@ -183,7 +183,7 @@ window.Smalruby =
183
183
  name
184
184
 
185
185
  addCharacterFromBeginning: ->
186
- if @isEnabled('add_character_from_beginning')
186
+ if !@isEnabled('disabled_add_character_from_beginning')
187
187
  constume = 'cat1.png'
188
188
  c = new Smalruby.Character
189
189
  name: @Collections.CharacterSet.uniqueName(constume)
@@ -67,6 +67,8 @@ Smalruby.CharacterModalView = Backbone.View.extend
67
67
 
68
68
  render: ->
69
69
  @onChange(@model)
70
+ @$el.modal
71
+ backdrop: 'static'
70
72
  @$el.modal('show')
71
73
 
72
74
  # HACK: ダイアログを表示して500ms程度待たないと画像のサイズが取得できなかった
@@ -46,7 +46,7 @@ Smalruby.CharacterSelectorView = Backbone.View.extend({
46
46
  removeButton.click (e) =>
47
47
  e.preventDefault()
48
48
  @removeCharacter_(character)
49
- if character.get('using')
49
+ if Smalruby.isEnabled('disabled_new_character') || character.get('using')
50
50
  removeButton.hide()
51
51
 
52
52
  img = html.find('img')
@@ -105,7 +105,7 @@ Smalruby.CharacterSelectorView = Backbone.View.extend({
105
105
  @prevXY = newBlock.getRelativeToSurfaceXY()
106
106
 
107
107
  removeCharacter_: (character) ->
108
- unless character.get('using')
108
+ if !Smalruby.isEnabled('disabled_new_character') && !character.get('using')
109
109
  Smalruby.Collections.CharacterSet.remove(character)
110
110
 
111
111
  }, {
@@ -33,6 +33,8 @@ Smalruby.LoadModalView = Backbone.View.extend
33
33
  @$el.find('.modal-body').unblock()
34
34
  null # HACK: if return unblock(), does not call fail().
35
35
 
36
+ @$el.modal
37
+ backdrop: 'static'
36
38
  @$el.modal('show')
37
39
 
38
40
  dfr = $.Deferred()
@@ -4,6 +4,8 @@ Smalruby.ResetModalView = Backbone.View.extend
4
4
  'click #reset-modal-ok-button': 'onOk'
5
5
 
6
6
  render: ->
7
+ @$el.modal
8
+ backdrop: 'static'
7
9
  @$el.modal('show')
8
10
 
9
11
  onOk: (e) ->
File without changes
File without changes
@@ -0,0 +1,32 @@
1
+ <%
2
+ require 'smalruby_editor'
3
+ colors = SmalrubyEditor::COLORS
4
+
5
+ hues = [
6
+ colors[:motion],
7
+ colors[:looks],
8
+ colors[:sound],
9
+ colors[:data],
10
+ colors[:events],
11
+ colors[:control],
12
+ colors[:sensing],
13
+ colors[:operators],
14
+ ]
15
+
16
+ colors = hues.map { |h|
17
+ [SmalrubyEditor.hsv_to_rgb(h, 100, 80),
18
+ SmalrubyEditor.hsv_to_rgb(h, 100, 100)]
19
+ }
20
+
21
+ colors.each.with_index(1) do |(color, active_color), index|
22
+ %>
23
+ div[aria-level="1"][aria-posinset="<%= index %>"] {
24
+ .blocklyTreeRow {
25
+ background-color: #<%= color %> !important;
26
+ }
27
+
28
+ .blocklyTreeRow.blocklyTreeSelected {
29
+ background-color: #<%= active_color %> !important;
30
+ }
31
+ }
32
+ <% end %>
@@ -10,6 +10,7 @@
10
10
  colors[:control],
11
11
  colors[:sensing],
12
12
  colors[:operators],
13
+ colors[:etc],
13
14
  ]
14
15
 
15
16
  colors = hues.map { |h|
File without changes
@@ -4,6 +4,11 @@ module ApplicationHelper
4
4
  "modal hide#{raspberrypi? ? '' : ' fade'}"
5
5
  end
6
6
 
7
+ # default locale name for Blockly messages
8
+ def blockly_message_default_locale_name
9
+ 'en_us'
10
+ end
11
+
7
12
  # Blocklyのメッセージのlocaleの名前を返す
8
13
  #
9
14
  # Blocklyではenがen_usであるため
@@ -0,0 +1,26 @@
1
+ module RubyToBlock
2
+ module Block
3
+ class HardwareSmalrubotS1DcMotorPowerRatio < Value
4
+ include CharacterOperation
5
+ include HardwareOperation
6
+
7
+ blocknize '^\s*' + CHAR_RE +
8
+ 'smalrubot_s1\.' +
9
+ LOR_RE + '_dc_motor_power_ratio\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
@@ -0,0 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+ module RubyToBlock
3
+ module Block
4
+ class HardwareSmalrubotS1DcMotorSetPowerRatio < CharacterMethodCall
5
+ include HardwareOperation
6
+
7
+ blocknize '^\s*' + CHAR_RE +
8
+ 'smalrubot_s1\.' +
9
+ LOR_RE + '_dc_motor_power_ratio\s*=\s*(\S+)\s*$',
10
+ statement: true, inline: true
11
+
12
+ def self.process_match_data(md, context)
13
+ md2 = regexp.match(md[type])
14
+ add_character_method_call_block(context, md2[1],
15
+ new(fields: { LOR: md2[2] }),
16
+ SPEED: md2[3])
17
+ true
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+ module RubyToBlock
3
+ module Block
4
+ class HardwareSmalrubotV3MotorSetSpeed < CharacterMethodCall
5
+ include HardwareOperation
6
+
7
+ blocknize '^\s*' + CHAR_RE +
8
+ 'smalrubot_v3\.' +
9
+ LOR_RE + '_motor_speed\s*=\s*(\S+)\s*$',
10
+ statement: true, inline: true
11
+
12
+ def self.process_match_data(md, context)
13
+ md2 = regexp.match(md[type])
14
+ add_character_method_call_block(context, md2[1],
15
+ new(fields: { LOR: md2[2] }),
16
+ SPEED: md2[3])
17
+ true
18
+ end
19
+ end
20
+ end
21
+ end