smalruby-editor 0.2.2 → 0.2.3

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,8 @@
1
+ (function(){function i(c,a,b){return g(c,a,b)}function g(c,a,b,j){j=j||{};a&&!n(a)&&(b=a,a=void 0);a=a||new Date;b=b||o;b.formats=b.formats||{};var i=a.getTime(),h=j.timezone,e=typeof h;if(j.utc||e=="number"||e=="string")a=p(a);if(h){if(e=="string")var k=h[0]=="-"?-1:1,q=parseInt(h.slice(1,3),10),r=parseInt(h.slice(3,5),10),h=k*(60*q+r);e&&(a=new Date(a.getTime()+h*6E4))}return c.replace(/%([-_0]?.)/g,function(c,e){var d;if(e.length==2){d=e[0];if(d=="-")d="";else if(d=="_")d=" ";else if(d=="0")d=
2
+ "0";else return c;e=e[1]}switch(e){case "A":return b.days[a.getDay()];case "a":return b.shortDays[a.getDay()];case "B":return b.months[a.getMonth()];case "b":return b.shortMonths[a.getMonth()];case "C":return f(Math.floor(a.getFullYear()/100),d);case "D":return g(b.formats.D||"%m/%d/%y",a,b);case "d":return f(a.getDate(),d);case "e":return f(a.getDate(),d==null?" ":d);case "F":return g(b.formats.F||"%Y-%m-%d",a,b);case "H":return f(a.getHours(),d);case "h":return b.shortMonths[a.getMonth()];case "I":return f(l(a),
3
+ d);case "j":return d=new Date(a.getFullYear(),0,1),d=Math.ceil((a.getTime()-d.getTime())/864E5),f(d,3);case "k":return f(a.getHours(),d==null?" ":d);case "L":return f(Math.floor(i%1E3),3);case "l":return f(l(a),d==null?" ":d);case "M":return f(a.getMinutes(),d);case "m":return f(a.getMonth()+1,d);case "n":return"\n";case "o":return String(a.getDate())+s(a.getDate());case "P":return a.getHours()<12?b.am:b.pm;case "p":return a.getHours()<12?b.AM:b.PM;case "R":return g(b.formats.R||"%H:%M",a,b);case "r":return g(b.formats.r||
4
+ "%I:%M:%S %p",a,b);case "S":return f(a.getSeconds(),d);case "s":return Math.floor(i/1E3);case "T":return g(b.formats.T||"%H:%M:%S",a,b);case "t":return"\t";case "U":return f(m(a,"sunday"),d);case "u":return d=a.getDay(),d==0?7:d;case "v":return g(b.formats.v||"%e-%b-%Y",a,b);case "W":return f(m(a,"monday"),d);case "w":return a.getDay();case "Y":return a.getFullYear();case "y":return d=String(a.getFullYear()),d.slice(d.length-2);case "Z":return j.utc?"GMT":(d=a.toString().match(/\(([\w\s]+)\)/))&&
5
+ d[1]||"";case "z":return j.utc?"+0000":(d=typeof h=="number"?h:-a.getTimezoneOffset(),(d<0?"-":"+")+f(Math.floor(Math.abs(d)/60))+f(Math.abs(d)%60));default:return e}})}function p(c){var a=(c.getTimezoneOffset()||0)*6E4;return new Date(c.getTime()+a)}function n(c){for(var a=0,b=k.length,a=0;a<b;++a)if(typeof c[k[a]]!="function")return!1;return!0}function f(c,a,b){typeof a==="number"&&(b=a,a="0");a==null&&(a="0");b=b||2;c=String(c);if(a)for(;c.length<b;)c=a+c;return c}function l(c){c=c.getHours();
6
+ c==0?c=12:c>12&&(c-=12);return c}function s(c){var a=c%10;c%=100;if(c>=11&&c<=13||a===0||a>=4)return"th";switch(a){case 1:return"st";case 2:return"nd";case 3:return"rd"}}function m(c,a){var a=a||"sunday",b=c.getDay();a=="monday"&&(b==0?b=6:b--);var e=new Date(c.getFullYear(),0,1);return Math.floor(((c-e)/864E5+7-b)/7)}var e;e=typeof module!=="undefined"?module.exports=i:function(){return this||(0,eval)("this")}();var o={days:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),shortDays:"Sun Mon Tue Wed Thu Fri Sat".split(" "),
7
+ months:"January February March April May June July August September October November December".split(" "),shortMonths:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),AM:"AM",PM:"PM",am:"am",pm:"pm"};e.strftime=i;e.strftimeTZ=i.strftimeTZ=function(c,a,b,e){if((typeof b=="number"||typeof b=="string")&&e==null)e=b,b=void 0;return g(c,a,b,{timezone:e})};e.strftimeUTC=i.strftimeUTC=function(c,a,b){return g(c,a,b,{utc:!0})};e.localizedStrftime=i.localizedStrftime=function(c){return function(a,
8
+ b){return g(a,b,c)}};var k=["getTime","getTimezoneOffset","getDay","getDate","getMonth","getFullYear","getYear","getHours","getMinutes","getSeconds"]})();
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smalruby-editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouji Takao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-01 00:00:00.000000000 Z
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 0.1.3
201
+ version: 0.1.4
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 0.1.3
208
+ version: 0.1.4
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: therubyracer
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -297,7 +297,7 @@ files:
297
297
  - app/assets/javascripts/models/.keep
298
298
  - app/assets/javascripts/models/character.js.coffee
299
299
  - app/assets/javascripts/models/scene.js.coffee
300
- - app/assets/javascripts/models/source_code.js.coffee
300
+ - app/assets/javascripts/models/source_code.js
301
301
  - app/assets/javascripts/msg/en_us.js
302
302
  - app/assets/javascripts/msg/ja.js
303
303
  - app/assets/javascripts/routers/.keep
@@ -315,6 +315,7 @@ files:
315
315
  - app/assets/stylesheets/load-modal.css.scss
316
316
  - app/assets/stylesheets/toolbox.css.scss.erb
317
317
  - app/assets/stylesheets/toolbox_default.css.scss.erb
318
+ - app/assets/stylesheets/toolbox_raspberrypi.css.scss.erb
318
319
  - app/assets/stylesheets/toolbox_smalrubot_s1.css.scss.erb
319
320
  - app/assets/stylesheets/toolbox_smalrubot_v3.css.scss.erb
320
321
  - app/assets/templates/.keep
@@ -360,12 +361,16 @@ files:
360
361
  - app/models/concerns/ruby_to_block/block/hardware_sensor_value.rb
361
362
  - app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action.rb
362
363
  - app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action_with_sec.rb
364
+ - app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_dc_motor_power_ratio.rb
365
+ - app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_dc_motor_set_power_ratio.rb
363
366
  - app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_ir_photoreflector_value.rb
364
367
  - app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_led_turn_on_or_off.rb
365
368
  - app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_action.rb
366
369
  - app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_action_with_sec.rb
367
370
  - app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_led_turn_on_or_off.rb
368
371
  - app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_light_sensor_value.rb
372
+ - app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_motor_set_speed.rb
373
+ - app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_motor_speed.rb
369
374
  - app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_touch_sensor_pressed_or_released.rb
370
375
  - app/models/concerns/ruby_to_block/block/hardware_two_wheel_drive_car.rb
371
376
  - app/models/concerns/ruby_to_block/block/hardware_two_wheel_drive_car_commands.rb
@@ -421,6 +426,7 @@ files:
421
426
  - app/views/editor/_reset_modal.html.haml
422
427
  - app/views/editor/_signin_modal.html.haml
423
428
  - app/views/editor/_toolbox_default.html.haml
429
+ - app/views/editor/_toolbox_raspberrypi.html.haml
424
430
  - app/views/editor/_toolbox_smalrubot_s1.html.haml
425
431
  - app/views/editor/_toolbox_smalrubot_v3.html.haml
426
432
  - app/views/editor/demo.html.erb
@@ -480,10 +486,10 @@ files:
480
486
  - public/422.html
481
487
  - public/500.html
482
488
  - public/apple-touch-icon.png
483
- - public/assets/application-71c4890fe0ea2e896fc0acff41cdb0ad.js
484
- - public/assets/application-71c4890fe0ea2e896fc0acff41cdb0ad.js.gz
485
489
  - public/assets/application-c196e243630d74071981a16041bf391d.css
486
490
  - public/assets/application-c196e243630d74071981a16041bf391d.css.gz
491
+ - public/assets/application-eece3e01e35f8f689e2e282a168f6059.js
492
+ - public/assets/application-eece3e01e35f8f689e2e282a168f6059.js.gz
487
493
  - public/assets/blockly/msg/js/en_us-d5e1938b2d57c1df954f4411b9165d10.js
488
494
  - public/assets/blockly/msg/js/en_us-d5e1938b2d57c1df954f4411b9165d10.js.gz
489
495
  - public/assets/blockly/msg/js/ja-9f676d46458a2802b8f5a797c90ae8a4.js
@@ -504,16 +510,18 @@ files:
504
510
  - public/assets/jquery-ui/ui-icons_888888_256x240-ce584ffa171c3ea9a018cf0d7bec65c8.png
505
511
  - public/assets/jquery-ui/ui-icons_cd0a0a_256x240-747e96029e8dedcabc224e5f7d1f2ede.png
506
512
  - public/assets/loading-e77296be32d066d3e29d3bf9803fa417.gif
507
- - public/assets/manifest-f3d29c6d66b959abe4294a899733e4f0.json
508
- - public/assets/msg/en_us-213fb4a57884078038725a2991776f47.js
509
- - public/assets/msg/en_us-213fb4a57884078038725a2991776f47.js.gz
510
- - public/assets/msg/ja-aeface7456b479021e977a0387204036.js
511
- - public/assets/msg/ja-aeface7456b479021e977a0387204036.js.gz
513
+ - public/assets/manifest-8e00411c7cb501aff0a597682558b4a3.json
514
+ - public/assets/msg/en_us-3eb2f104a6bad9c60226ff7475013874.js
515
+ - public/assets/msg/en_us-3eb2f104a6bad9c60226ff7475013874.js.gz
516
+ - public/assets/msg/ja-8450d011b1f093dc4b6b7c467e5bcae4.js
517
+ - public/assets/msg/ja-8450d011b1f093dc4b6b7c467e5bcae4.js.gz
512
518
  - public/assets/progressbar-ee8fb1222f286f625bbf7332844a6a0c.gif
513
519
  - public/assets/toolbox_default-e023d3f7a2cc7cc1f54a1224577b3c26.css
514
520
  - public/assets/toolbox_default-e023d3f7a2cc7cc1f54a1224577b3c26.css.gz
515
- - public/assets/toolbox_smalrubot_s1-18d28dc4b99723b60a3f538b742027df.css
516
- - public/assets/toolbox_smalrubot_s1-18d28dc4b99723b60a3f538b742027df.css.gz
521
+ - public/assets/toolbox_raspberrypi-c25b8ac975fbc79031ecf87e74027694.css
522
+ - public/assets/toolbox_raspberrypi-c25b8ac975fbc79031ecf87e74027694.css.gz
523
+ - public/assets/toolbox_smalrubot_s1-9af26ff13d4496890c4a391f65f95bcd.css
524
+ - public/assets/toolbox_smalrubot_s1-9af26ff13d4496890c4a391f65f95bcd.css.gz
517
525
  - public/assets/toolbox_smalrubot_v3-9af26ff13d4496890c4a391f65f95bcd.css
518
526
  - public/assets/toolbox_smalrubot_v3-9af26ff13d4496890c4a391f65f95bcd.css.gz
519
527
  - public/blockly/media/1x1.gif
@@ -597,6 +605,7 @@ files:
597
605
  - spec/acceptance/block_mode/blocks/hardware/servo_set_position.feature
598
606
  - spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action.feature
599
607
  - spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action_with_sec.feature
608
+ - spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_dc_motor_power_ratio.feature
600
609
  - spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_ir_photoreflector_value.feature
601
610
  - spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_led_turn_on_or_off.feature
602
611
  - spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_action.feature
@@ -680,6 +689,7 @@ files:
680
689
  - spec/models/concerns/ruby_to_block/block/control_loop_spec.rb
681
690
  - spec/models/concerns/ruby_to_block/block/events_on_start_spec.rb
682
691
  - spec/models/concerns/ruby_to_block/block/hardware__smalrubot_s1_spec.rb
692
+ - spec/models/concerns/ruby_to_block/block/hardware__smalrubot_v3_spec.rb
683
693
  - spec/models/concerns/ruby_to_block/block/hardware_spec.rb
684
694
  - spec/models/concerns/ruby_to_block/block/looks_say_spec.rb
685
695
  - spec/models/concerns/ruby_to_block/block/looks_spec.rb
@@ -714,6 +724,7 @@ files:
714
724
  - vendor/assets/javascripts/blockly/msg/js/en_us.js
715
725
  - vendor/assets/javascripts/blockly/msg/js/ja.js
716
726
  - vendor/assets/javascripts/jquery.blockUI.js
727
+ - vendor/assets/javascripts/strftime-min.js
717
728
  - vendor/assets/stylesheets/.keep
718
729
  homepage: https://github.com/smalruby/smalruby-editor
719
730
  licenses:
@@ -774,6 +785,7 @@ test_files:
774
785
  - spec/acceptance/block_mode/blocks/hardware/servo_set_position.feature
775
786
  - spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action.feature
776
787
  - spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action_with_sec.feature
788
+ - spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_dc_motor_power_ratio.feature
777
789
  - spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_ir_photoreflector_value.feature
778
790
  - spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_led_turn_on_or_off.feature
779
791
  - spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_action.feature
@@ -857,6 +869,7 @@ test_files:
857
869
  - spec/models/concerns/ruby_to_block/block/control_loop_spec.rb
858
870
  - spec/models/concerns/ruby_to_block/block/events_on_start_spec.rb
859
871
  - spec/models/concerns/ruby_to_block/block/hardware__smalrubot_s1_spec.rb
872
+ - spec/models/concerns/ruby_to_block/block/hardware__smalrubot_v3_spec.rb
860
873
  - spec/models/concerns/ruby_to_block/block/hardware_spec.rb
861
874
  - spec/models/concerns/ruby_to_block/block/looks_say_spec.rb
862
875
  - spec/models/concerns/ruby_to_block/block/looks_spec.rb
@@ -1,80 +0,0 @@
1
- # ソースコードを表現するモデル
2
- Smalruby.SourceCode = Backbone.Model.extend
3
- defaults:
4
- filename: null
5
- data: null
6
-
7
- initialize: ->
8
- unless @get('filename')
9
- filename = Smalruby.Views.MainMenuView.getFilename()
10
- if filename.length == 0
11
- c = Smalruby.Collections.CharacterSet.first()
12
- if c
13
- filename = "#{c.get('name')}.rb"
14
- else
15
- filename = '1.rb'
16
- @set('filename', filename)
17
-
18
- unless @get('data')
19
- if @get('filename').match(/\.xml$/)
20
- data = Smalruby.dumpXml()
21
- else
22
- if window.blockMode
23
- data = Blockly.Ruby.workspaceToCode()
24
- else
25
- data = window.textEditor.getSession().getDocument().getValue()
26
-
27
- @set('data', data)
28
-
29
- getRbxmlFilename: ->
30
- filename = @get('filename')
31
- if filename.match(/\.rb\.xml$/)
32
- filename
33
- else
34
- if filename.match(/\.rb$/)
35
- filename + '.xml'
36
- else if filename.match(/\.xml$/)
37
- filename.replace(/\.xml$/, '.rb.xml')
38
- else
39
- filename + '.rb.xml'
40
-
41
- run: ->
42
- @post_('run')
43
-
44
- check: ->
45
- @post_('check')
46
-
47
- save2: ->
48
- @post_('')
49
-
50
- write: (force = false) ->
51
- action = 'write'
52
- action += '?force=1' if force
53
- @delete_(action)
54
-
55
- toBlocks: ->
56
- @post_('to_blocks', 'html')
57
-
58
- post_: (action, dataType = 'json') ->
59
- dfr = $.Deferred()
60
- $.ajax
61
- url: "/source_codes/#{action}"
62
- type: 'POST'
63
- data:
64
- source_code:
65
- filename: @get('filename')
66
- data: @get('data')
67
- dataType: dataType
68
- success: (data, textStatus, jqXHR) -> dfr.resolve(data)
69
- error: dfr.reject
70
- dfr.promise()
71
-
72
- delete_: (action) ->
73
- dfr = $.Deferred()
74
- $.ajax
75
- url: "/source_codes/#{action}"
76
- type: 'DELETE'
77
- dataType: 'json'
78
- success: (data, textStatus, jqXHR) -> dfr.resolve(data)
79
- error: dfr.reject
80
- dfr.promise()