smalruby-editor 0.1.14-x86-mingw32 → 0.1.15-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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6eeaebdd461ff5ee1f2fa15a017e5988ca4ba51
4
- data.tar.gz: ea4e9b481fcedebda9e6e8f2406ce98619057087
3
+ metadata.gz: 2d53fa32a3b8707706add17ac92e087881b7d4f2
4
+ data.tar.gz: 842742995256fbc29130fbdd9de50b906ed1fd49
5
5
  SHA512:
6
- metadata.gz: 10f36913b0ff9dadff5adfa96d061375bd77ff1036703f467881438317504f00fb5a09bba4f5527513f0d0e550c5e6f0a6c4040b9339d50ba4cbc04dd84ac900
7
- data.tar.gz: 7bacf71a6e92d0b9899c48587fdc7179d348f96ce47112a65daec66cd78e1448585d6028490259d87034da19d8e606e93882a255f71bb20bb33afc48ef1d115b
6
+ metadata.gz: 9bab4b91459b18253fca144251ddcbb68a445f2f6cb12702b645a1e5ff894c2411b301bea079d4557875c2b9174e4973044dc8f1a0008b9c4c45da1adf34d4c1
7
+ data.tar.gz: 32d4a35fb1a7a727b91f8ef59f860589ffa59e2b1810a2338eda4c01a06de5b2a70c4745ab36c58c636dcefdf56643ea285b5196ff87ed356a42e4e121a60ec1
@@ -4,3 +4,48 @@
4
4
  category = 'pen'
5
5
  color = 160
6
6
  %>
7
+
8
+ # ペンを下ろす
9
+ # ペンを上げる
10
+ # <%
11
+ [
12
+ ['down_pen', 'ペンを下ろす'],
13
+ ['up_pen', 'ペンを上げる'],
14
+ ].each do |suffix, label|
15
+ n = "#{category}_#{suffix}"
16
+ %>
17
+
18
+ Blockly.Blocks['<%= n %>'] =
19
+ init: ()->
20
+ @setHelpUrl('')
21
+ @setColour(<%= color %>)
22
+ @appendDummyInput()
23
+ .appendField('<%= label %>')
24
+ @setPreviousStatement(true)
25
+ @setNextStatement(true)
26
+ @setTooltip('')
27
+
28
+ Blockly.Ruby['<%= n %>'] = (block) ->
29
+ Blockly.Ruby.characterMethodCall_('<%= suffix %>')
30
+ <% end %>
31
+
32
+ # ペンの色を[カラー]にする
33
+ <% n = "#{category}_set_pen_color" %>
34
+ Blockly.Blocks['<%= n %>'] =
35
+ init: ()->
36
+ @setHelpUrl('')
37
+ @setColour(<%= color %>)
38
+ @appendDummyInput()
39
+ .appendField('ペンの色を')
40
+ .appendField(new Blockly.FieldColour('#ff0000'), 'COLOUR')
41
+ .appendField('にする')
42
+ @setPreviousStatement(true)
43
+ @setNextStatement(true)
44
+ @setTooltip('')
45
+
46
+ Blockly.Ruby['<%= n %>'] = (block) ->
47
+ c = @getFieldValue('COLOUR')
48
+ red = parseInt(c[1..2], 16)
49
+ green = parseInt(c[3..4], 16)
50
+ blue = parseInt(c[5..6], 16)
51
+ Blockly.Ruby.characterSetVariable_('pen_color', "[#{red}, #{green}, #{blue}]")
@@ -21,7 +21,7 @@ Smalruby.SourceCode = Backbone.Model.extend
21
21
  if window.blockMode
22
22
  data = Blockly.Ruby.workspaceToCode()
23
23
  else
24
- data =window.textEditor.getSession().getDocument().getValue()
24
+ data = window.textEditor.getSession().getDocument().getValue()
25
25
 
26
26
  @set('data', data)
27
27
 
@@ -2,6 +2,7 @@
2
2
  Smalruby.LoadModalView = Backbone.View.extend
3
3
  events:
4
4
  'click #load-modal-ok-button': 'onOk'
5
+ 'click #load-modal-remix-button': 'onRemix'
5
6
 
6
7
  initialize: ->
7
8
  @$el.find('#load-modal-find-from-computer').click (e) =>
@@ -11,6 +12,7 @@ Smalruby.LoadModalView = Backbone.View.extend
11
12
  render: ->
12
13
  @type = null
13
14
  @program = null
15
+ @setRemix(false)
14
16
  @unselect()
15
17
 
16
18
  elLocalPrograms = @$el.find('#load-modal-local-programs')
@@ -60,6 +62,7 @@ Smalruby.LoadModalView = Backbone.View.extend
60
62
  data:
61
63
  source_code:
62
64
  filename: @program.filename
65
+ remix: @remix
63
66
  dataType: 'json'
64
67
  success: (data, textStatus, jqXHR) ->
65
68
  Smalruby.Views.MainMenuView.load(data.source_code)
@@ -71,6 +74,7 @@ Smalruby.LoadModalView = Backbone.View.extend
71
74
  data:
72
75
  source_code:
73
76
  filename: @program.filename
77
+ remix: @remix
74
78
  dataType: 'json'
75
79
  success: (data, textStatus, jqXHR) ->
76
80
  Smalruby.Views.MainMenuView.load(data.source_code)
@@ -80,6 +84,18 @@ Smalruby.LoadModalView = Backbone.View.extend
80
84
 
81
85
  @$el.modal('hide')
82
86
 
87
+ onRemix: ->
88
+ @setRemix(!@remix)
89
+
90
+ setRemix: (remix) ->
91
+ @remix = remix
92
+ e = $('#load-modal-remix-button')
93
+ buttonClass = 'btn-success'
94
+ if @remix
95
+ e.addClass(buttonClass)
96
+ else
97
+ e.removeClass(buttonClass)
98
+
83
99
  onLocalProgramClick: (e, program) ->
84
100
  @select(e.currentTarget, 'local', program)
85
101
 
@@ -28,6 +28,7 @@
28
28
  225
29
29
  264
30
30
  296
31
+ 160
31
32
  33
32
33
  43
33
34
  43
@@ -88,7 +88,7 @@ class SourceCodesController < ApplicationController
88
88
  program_path = local_program_paths.find { |path|
89
89
  rb_basename(path) == filename
90
90
  }
91
- load_local_file(program_path)
91
+ load_local_file(program_path, source_code_params[:remix])
92
92
  end
93
93
 
94
94
  def load_demo
@@ -96,7 +96,7 @@ class SourceCodesController < ApplicationController
96
96
  program_path = demo_program_paths.find { |path|
97
97
  rb_basename(path) == filename
98
98
  }
99
- load_local_file(program_path)
99
+ load_local_file(program_path, source_code_params[:remix])
100
100
  end
101
101
 
102
102
  def run
@@ -124,7 +124,7 @@ class SourceCodesController < ApplicationController
124
124
  private
125
125
 
126
126
  def source_code_params
127
- params.require(:source_code).permit(:data, :filename)
127
+ params.require(:source_code).permit(:data, :filename, :remix)
128
128
  end
129
129
 
130
130
  def get_file_info(file)
@@ -194,10 +194,16 @@ class SourceCodesController < ApplicationController
194
194
  path
195
195
  end
196
196
 
197
- def load_local_file(path)
197
+ def load_local_file(path, remix)
198
198
  if path
199
+ if remix == 'true'
200
+ filename = SourceCode.make_remix_filename("~/#{session[:username]}",
201
+ path.basename.to_s)
202
+ else
203
+ filename = path.basename.to_s
204
+ end
199
205
  info = {
200
- filename: path.basename.to_s,
206
+ filename: filename,
201
207
  type: MIME.check(path.to_s).try(:content_type) || 'text/plain',
202
208
  data: NKF.nkf('-w', path.read),
203
209
  size: path.size,
@@ -16,6 +16,26 @@ class SourceCode < ActiveRecord::Base
16
16
  validate :validate_filename
17
17
  validates :data, presence: true, allow_blank: true
18
18
 
19
+ MAX_REMIX_COUNT = 1000
20
+
21
+ # リミックス用のファイル名を生成する
22
+ def self.make_remix_filename(home_dir, filename)
23
+ home_dir = Pathname(home_dir).expand_path
24
+ filename = filename.dup
25
+ ext = filename.slice!(/\.rb(\.xml)?$/)
26
+ filename.slice!(/(_remix(\d+)?)+$/)
27
+ basename = "#{filename}_remix"
28
+ MAX_REMIX_COUNT.times do |i|
29
+ suffix = (i == 0 ? '' : sprintf('%02d', i + 1))
30
+ remix_name = "#{basename}#{suffix}"
31
+ if !home_dir.join("#{remix_name}.rb").exist? &&
32
+ !home_dir.join("#{remix_name}.rb.xml").exist?
33
+ return "#{remix_name}#{ext}"
34
+ end
35
+ end
36
+ fail "reach max remix count...: #{filename}"
37
+ end
38
+
19
39
  # シンタックスをチェックする
20
40
  def check_syntax
21
41
  _, stderr_str, status = *open3_capture3_ruby_c
@@ -27,6 +27,10 @@
27
27
  Computer
28
28
 
29
29
  .modal-footer
30
+ .pull-left
31
+ %button#load-modal-remix-button.btn<
32
+ %i.icon-refresh
33
+ リミックス
30
34
  %button.btn{:"data-dismiss" => "modal", :"aria-hidden" => "true"}<
31
35
  %i.icon-remove
32
36
  やめる
@@ -134,6 +134,17 @@
134
134
  -# 変数:ボリューム
135
135
  -#%block{:type => "#{category}_volume"}
136
136
 
137
+ - category = 'pen'
138
+ %category{:name => 'ペン'}
139
+ -# ペンを下ろす
140
+ %block{:type => "#{category}_down_pen"}
141
+
142
+ -# ペンを上げる
143
+ %block{:type => "#{category}_up_pen"}
144
+
145
+ -# ペンの色を[カラー]にする
146
+ %block{:type => "#{category}_set_pen_color"}
147
+
137
148
  - category = 'events'
138
149
  %category{:name => '~のとき'}
139
150
  -# まずは
@@ -1,3 +1,3 @@
1
1
  module SmalrubyEditor
2
- VERSION = '0.1.14'
2
+ VERSION = '0.1.15'
3
3
  end
@@ -68,7 +68,7 @@ Gem::Specification.new do |spec|
68
68
  ['launchy'],
69
69
  ['mime-types', '~> 1.16'],
70
70
  ['haml-rails'],
71
- ['smalruby', '~> 0.0.22'],
71
+ ['smalruby', '~> 0.0.23'],
72
72
  ]
73
73
  runtime_dependencies << ['therubyracer'] unless is_windows
74
74
  runtime_dependencies.each do |args|
File without changes
File without changes
File without changes
@@ -13,6 +13,29 @@ describe SourceCode, 'Rubyのソースコードを表現するモデル' do
13
13
  end
14
14
  end
15
15
 
16
+ describe '.make_remix_filename', 'リミックス用のファイル名を生成する' do
17
+ subject {
18
+ home_dir = Rails.root.join('spec/fixtures/files')
19
+ SourceCode.make_remix_filename(home_dir.to_s, filename)
20
+ }
21
+
22
+ {
23
+ '01.rb' => '01_remix03.rb',
24
+ '01.rb.xml' => '01_remix03.rb.xml',
25
+ '01_remix.rb' => '01_remix03.rb',
26
+ '01_remix02.rb' => '01_remix03.rb',
27
+ '01_remix03.rb' => '01_remix03.rb',
28
+ '02.rb' => '02_remix.rb',
29
+ '02.rb.xml' => '02_remix.rb.xml',
30
+ }.each do |_filename, _expected|
31
+ describe _filename do
32
+ let(:filename) { _filename }
33
+
34
+ it { should eq(_expected) }
35
+ end
36
+ end
37
+ end
38
+
16
39
  describe '#check_syntax', 'シンタックスをチェックする' do
17
40
  let(:source_code) {
18
41
  SourceCode.new(data: data)
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.1.14
4
+ version: 0.1.15
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Kouji Takao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-31 00:00:00.000000000 Z
11
+ date: 2014-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - ~>
186
186
  - !ruby/object:Gem::Version
187
- version: 0.0.22
187
+ version: 0.0.23
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - ~>
193
193
  - !ruby/object:Gem::Version
194
- version: 0.0.22
194
+ version: 0.0.23
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: bundler
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -540,6 +540,9 @@ files:
540
540
  - spec/controllers/source_codes_controller_spec.rb
541
541
  - spec/fixtures/files/01.rb
542
542
  - spec/fixtures/files/01.rb.xml
543
+ - spec/fixtures/files/01_remix.rb
544
+ - spec/fixtures/files/01_remix02.rb
545
+ - spec/fixtures/files/01_remix10.rb.xml
543
546
  - spec/fixtures/files/favicon.ico
544
547
  - spec/helpers/editor_helper_spec.rb
545
548
  - spec/helpers/sessions_helper_spec.rb
@@ -584,10 +587,10 @@ files:
584
587
  - vendor/assets/javascripts/blockly/msg/js/ja.js
585
588
  - vendor/assets/javascripts/jquery.blockUI.js
586
589
  - vendor/assets/stylesheets/.keep
587
- - public/assets/application-53d651da3309caa498cc0ca6616dbead.css
588
- - public/assets/application-53d651da3309caa498cc0ca6616dbead.css.gz
589
- - public/assets/application-d60babdd5a50329b329487cf793c2e29.js
590
- - public/assets/application-d60babdd5a50329b329487cf793c2e29.js.gz
590
+ - public/assets/application-51ab300acd1779bfba20b099e7000b7e.css
591
+ - public/assets/application-51ab300acd1779bfba20b099e7000b7e.css.gz
592
+ - public/assets/application-dc485e2270d6c5fce20c149d1e2c4f8d.js
593
+ - public/assets/application-dc485e2270d6c5fce20c149d1e2c4f8d.js.gz
591
594
  - public/assets/favicon-a37c90b368fd8ed436cb8f9e9396465c.ico
592
595
  - public/assets/jquery-ui/animated-overlay-c48c87b7a95316f4698484e3b85ee4aa.gif
593
596
  - public/assets/jquery-ui/ui-bg_flat_0_aaaaaa_40x100-58b63faadd031ca3db096dfdffd90224.png
@@ -716,6 +719,9 @@ test_files:
716
719
  - spec/controllers/source_codes_controller_spec.rb
717
720
  - spec/fixtures/files/01.rb
718
721
  - spec/fixtures/files/01.rb.xml
722
+ - spec/fixtures/files/01_remix.rb
723
+ - spec/fixtures/files/01_remix02.rb
724
+ - spec/fixtures/files/01_remix10.rb.xml
719
725
  - spec/fixtures/files/favicon.ico
720
726
  - spec/helpers/editor_helper_spec.rb
721
727
  - spec/helpers/sessions_helper_spec.rb