smalruby-editor 0.2.6-x86-mingw32 → 0.2.7-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 (97) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/Guardfile +2 -0
  4. data/app/assets/javascripts/blocks/hardware.js.coffee.erb +1 -1
  5. data/app/assets/javascripts/fix_blockly.js.erb +0 -50
  6. data/app/assets/javascripts/generators/ruby.js.coffee.erb +18 -4
  7. data/app/assets/javascripts/models/source_code.js +1 -1
  8. data/app/assets/javascripts/msg/en_us.js +1 -0
  9. data/app/assets/javascripts/msg/ja.js +4 -0
  10. data/app/assets/javascripts/smalruby.js.coffee.erb +50 -6
  11. data/app/assets/javascripts/views/main_menu_view.js.coffee.erb +14 -4
  12. data/app/assets/javascripts/views/preference_modal_view.js.coffee.erb +71 -0
  13. data/app/assets/javascripts/views/signin_modal_view.js.coffee.erb +5 -4
  14. data/app/assets/stylesheets/application.css +1 -0
  15. data/app/assets/stylesheets/preference-modal.css.scss +22 -0
  16. data/app/assets/stylesheets/toolbox.css.scss.erb +36 -0
  17. data/app/controllers/application_controller.rb +20 -4
  18. data/app/controllers/editor_controller.rb +4 -0
  19. data/app/controllers/sessions_controller.rb +7 -4
  20. data/app/controllers/source_codes_controller.rb +2 -2
  21. data/app/controllers/users_controller.rb +22 -0
  22. data/app/helpers/application_helper.rb +4 -4
  23. data/app/helpers/sessions_helper.rb +0 -0
  24. data/app/helpers/users_helper.rb +10 -0
  25. data/app/models/concerns/ruby_to_block/block/hardware_init_hardware.rb +0 -6
  26. data/app/models/concerns/ruby_to_block/block/hardware_operation.rb +0 -0
  27. data/app/models/preference.rb +71 -0
  28. data/app/models/source_code.rb +4 -0
  29. data/app/models/user.rb +26 -0
  30. data/app/views/editor/_block_tab.html.haml +5 -6
  31. data/app/views/editor/_load_modal.html.haml +2 -2
  32. data/app/views/editor/_preference_modal.html.haml +16 -0
  33. data/app/views/editor/_signin_modal.html.haml +1 -1
  34. data/app/views/editor/_toolbox_default.html.haml +86 -79
  35. data/app/views/editor/{_toolbox_raspberrypi.html.haml → _toolbox_smalrubot.html.haml} +72 -105
  36. data/app/views/editor/_toolbox_smalrubot_s1.html.haml +1 -196
  37. data/app/views/editor/_toolbox_smalrubot_v3.html.haml +1 -196
  38. data/app/views/editor/index.html.haml +11 -4
  39. data/app/views/editor/toolbox.html.haml +1 -0
  40. data/app/views/layouts/application.html.erb +1 -1
  41. data/app/views/users/preferences.html.haml +34 -0
  42. data/config/application.rb +1 -1
  43. data/config/locales/en.yml +30 -0
  44. data/config/locales/ja.yml +30 -0
  45. data/config/routes.rb +4 -57
  46. data/db/migrate/20150513061200_create_users.rb +10 -0
  47. data/db/migrate/20150513061250_add_index_name_on_users.rb +9 -0
  48. data/db/schema.rb +10 -1
  49. data/lib/smalruby_editor.rb +22 -24
  50. data/lib/smalruby_editor/version.rb +1 -1
  51. data/smalruby-editor.gemspec +0 -0
  52. data/spec/acceptance/block_mode/blocks/hardware/button_pressed_or_released.feature +2 -0
  53. data/spec/acceptance/block_mode/blocks/hardware/init_hardware.feature +1 -0
  54. data/spec/acceptance/block_mode/blocks/hardware/led_turn_off.feature +11 -1
  55. data/spec/acceptance/block_mode/blocks/hardware/led_turn_on.feature +11 -1
  56. data/spec/acceptance/block_mode/blocks/hardware/motor_driver.feature +7 -1
  57. data/spec/acceptance/block_mode/blocks/hardware/motor_driver_speed.feature +2 -0
  58. data/spec/acceptance/block_mode/blocks/hardware/rgb_led_set_color.feature +9 -12
  59. data/spec/acceptance/block_mode/blocks/hardware/rgb_led_turn_off.feature +9 -12
  60. data/spec/acceptance/block_mode/blocks/hardware/sensor_value.feature +59 -60
  61. data/spec/acceptance/block_mode/blocks/hardware/servo_set_position.feature +76 -67
  62. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action.feature +9 -12
  63. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action_with_sec.feature +9 -11
  64. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_dc_motor_power_ratio.feature +11 -12
  65. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_led_turn_on_or_off.feature +9 -10
  66. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_action.feature +9 -12
  67. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_action_with_sec.feature +9 -11
  68. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_dc_motor_power_ratio.feature +11 -12
  69. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_led_turn_on_or_off.feature +9 -12
  70. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_sensor_value.feature +11 -12
  71. data/spec/acceptance/block_mode/blocks/hardware/two_wheel_drive_car.feature +7 -1
  72. data/spec/acceptance/block_mode/blocks/hardware/two_wheel_drive_car_speed.feature +2 -0
  73. data/spec/acceptance/standalone/preference.feature +92 -0
  74. data/{demos → spec/fixtures/files}/hardware_led.rb.xml +0 -0
  75. data/spec/javascripts/models/source_code_spec.coffee +0 -0
  76. data/spec/models/concerns/ruby_to_block/block/hardware__smalrubot_spec.rb +1 -1
  77. data/spec/models/concerns/ruby_to_block/block/hardware_spec.rb +4 -4
  78. data/spec/models/concerns/ruby_to_block_spec.rb +1 -1
  79. data/spec/models/source_code_spec.rb +1 -11
  80. data/spec/spec_helper.rb +8 -0
  81. data/spec/steps/base_steps.rb +68 -16
  82. data/spec/steps/standalone_steps.rb +21 -0
  83. data/spec/steps/text_editor_steps.rb +8 -8
  84. data/spec/support/feature_helper.rb +13 -0
  85. data/vendor/assets/javascripts/blockly/blockly_compressed.js +500 -454
  86. data/vendor/assets/javascripts/blockly/blocks_compressed.js +29 -28
  87. data/vendor/assets/javascripts/blockly/msg/js/ja.js +2 -1
  88. metadata +33 -35
  89. data/app/assets/stylesheets/toolbox_default.css.scss.erb +0 -34
  90. data/app/assets/stylesheets/toolbox_raspberrypi.css.scss.erb +0 -32
  91. data/app/assets/stylesheets/toolbox_smalrubot_s1.css.scss.erb +0 -32
  92. data/app/assets/stylesheets/toolbox_smalrubot_v3.css.scss.erb +0 -32
  93. data/demos/adjust_2wd_car.rb.xml +0 -179
  94. data/lib/smalruby_editor/config.rb +0 -24
  95. data/spec/controllers/editor_controller_spec.rb +0 -12
  96. data/spec/controllers/sessions_controller_spec.rb +0 -74
  97. data/spec/helpers/sessions_helper_spec.rb +0 -15
@@ -78,8 +78,15 @@
78
78
  %i.icon-off
79
79
  = t('.reset')
80
80
  - if standalone?
81
+ %li.divider.signed-in-menu{style: "display: #{signed_in? ? '' : 'none'}"}
81
82
  %li
82
- %a#signout-button{style: "display: #{signed_in? ? '' : 'none'}"}
83
+ %a#preference-button.signed-in-menu{style: "display: #{signed_in? ? '' : 'none'}"}
84
+ %h4
85
+ %i.icon-cog
86
+ = t('.preference')
87
+ %li.divider.signed-in-menu{style: "display: #{signed_in? ? '' : 'none'}"}
88
+ %li
89
+ %a#signout-button.signed-in-menu{style: "display: #{signed_in? ? '' : 'none'}"}
83
90
  %h4
84
91
  %i.icon-eject
85
92
  = t('.logout')
@@ -113,11 +120,11 @@
113
120
  = render 'signin_modal'
114
121
  = render 'load_modal'
115
122
  = render 'reset_modal'
123
+ = render 'preference_modal'
116
124
 
117
125
  - if session[:username]
118
126
  :javascript
119
127
  window.Smalruby.username = '#{h session[:username]}';
120
128
 
121
- - if SmalrubyEditor::Config.features.is_a?(Array)
122
- :javascript
123
- window.Smalruby.Features = #{SmalrubyEditor::Config.features.to_json};
129
+ :javascript
130
+ window.Smalruby.Preferences = #{current_preferences.to_json};
@@ -0,0 +1 @@
1
+ = render "toolbox_#{toolbox_name}"
@@ -5,6 +5,7 @@
5
5
  <%= t('common.smalruby_editor', version: SmalrubyEditor::VERSION) %>
6
6
  </title>
7
7
  <%= favicon_link_tag %>
8
+ <meta charset="UTF-8">
8
9
  <link rel="apple-touch-icon" href="apple-touch-icon.png" />
9
10
  <meta name="application-name" content="Smalruby" />
10
11
  <meta name="msapplication-TileColor" content="#0088cc" />
@@ -13,7 +14,6 @@
13
14
  <meta name="msapplication-wide310x150logo" content="wide.png" />
14
15
  <meta name="msapplication-square310x310logo" content="large.png" />
15
16
  <%= stylesheet_link_tag "application", media: "all" %>
16
- <%= stylesheet_link_tag "toolbox_#{toolbox_css_name}", media: "all" %>
17
17
  <%= javascript_include_tag "application" %>
18
18
  <%= javascript_include_tag "blockly/msg/js/#{blockly_message_locale_name}" %>
19
19
  <%= javascript_include_tag "msg/#{blockly_message_default_locale_name}" %>
@@ -0,0 +1,34 @@
1
+ .modal-body#preference-modal-content
2
+ = form_for(current_user, html: { class: "form-horizontal", method: "PATCH" }) do |f|
3
+ = f.fields_for(:preferences, OpenStruct.new(f.object.preferences)) do |f2|
4
+ .page-header
5
+ %h4
6
+ %i.icon-th-large
7
+ = t('.toolbox')
8
+
9
+ .control-group
10
+ = f2.label(:toolbox_name, class: "control-label")
11
+ .controls
12
+ - options = Preference.toolbox_names.map { |n| [t(n, scope: "toolbox_names"), n] }
13
+ = f2.select(:toolbox_name, options)
14
+
15
+ - Preference.make_toolbox_name_to_preference_names_hash.each do |toolbox_name, preference_names|
16
+ - preference_names.each do |n|
17
+ .control-group{class: "toolbox_preferences #{toolbox_name}"}
18
+ .controls
19
+ = f2.label(n, class: "checkbox") do
20
+ = preferences_field(f2, n)
21
+ = t(n, scope: "helpers.label.user[preferences]")
22
+
23
+ - if Preference.general_preference_names.length > 0
24
+ .page-header
25
+ %h4
26
+ %i.icon-th-large
27
+ = t('.general')
28
+
29
+ - Preference.general_preference_names.each do |n|
30
+ .control-group
31
+ .controls
32
+ = f2.label(n, class: "checkbox") do
33
+ = preferences_field(f2, n)
34
+ = t(n, scope: "helpers.label.user[preferences]")
@@ -10,7 +10,7 @@ Bundler.require(:default, Rails.env) unless Rails.env == 'standalone'
10
10
  module SmalrubyEditor
11
11
  class Application < Rails::Application
12
12
  config.time_zone = 'Tokyo'
13
- I18n.enforce_available_locales = true
13
+ I18n.enforce_available_locales = false
14
14
  config.i18n.default_locale = :ja
15
15
  config.colorize_logging = false
16
16
  config.filter_parameters += [:data]
@@ -6,6 +6,7 @@ en:
6
6
  reset: &reset "Reset"
7
7
  login: &login "Login"
8
8
  name: "Name"
9
+ processing: "Processing..."
9
10
 
10
11
  controllers:
11
12
  source_codes:
@@ -13,6 +14,26 @@ en:
13
14
  not_exist: " does not exist."
14
15
  exist: " already exist."
15
16
 
17
+ toolbox_names:
18
+ default: "Normal"
19
+ smalrubot_s1: "Smalrubot S1"
20
+ smalrubot_v3: "Smalrubot V3"
21
+
22
+ helpers:
23
+ label:
24
+ "user[preferences]":
25
+ toolbox_name: "Toolbox"
26
+
27
+ toolbox__default__enabled_hardware_blocks: "Enabled hardware blocks on default"
28
+ toolbox__default__enabled_smalrubot_v3_blocks: "Enabled smalrubot v3 blocks on default"
29
+ toolbox__default__enabled_smalrubot_s1_blocks: "Enabled smalrubot s1 blocks on default"
30
+
31
+ disabled_add_character_from_beginning: "Disabled add character from beginning"
32
+ disabled_new_character: "Disabled new character"
33
+ enabled_auto_init_hardware: "Auto init hardware"
34
+ enabled_readonly_ruby_mode: "Readonly ruby mode"
35
+ enabled_must_signin: "Must signin"
36
+
16
37
  editor:
17
38
  index:
18
39
  block: "Block"
@@ -23,6 +44,7 @@ en:
23
44
  save: "Save"
24
45
  check: "Check"
25
46
  reset: *reset
47
+ preference: "Preference"
26
48
  logout: "Logout"
27
49
  login: *login
28
50
 
@@ -64,6 +86,14 @@ en:
64
86
  title: "Are you sure you want to reset ?"
65
87
  message: "Your program will disappear!"
66
88
 
89
+ preference_modal:
90
+ title: "Preference"
91
+
67
92
  signin_modal:
68
93
  message: "Input your name<br>not to mix with other people's program."
69
94
  username_placeholder: "username, ID, nickname, etc..."
95
+
96
+ users:
97
+ preferences:
98
+ toolbox: "Toolbox"
99
+ general: "General"
@@ -6,6 +6,7 @@ ja:
6
6
  reset: &reset "リセット"
7
7
  login: &login "ログイン"
8
8
  name: "名前"
9
+ processing: "処理中"
9
10
 
10
11
  controllers:
11
12
  source_codes:
@@ -13,6 +14,26 @@ ja:
13
14
  not_exist: "はありません"
14
15
  exist: "すでに同じ名前のプログラムがあります"
15
16
 
17
+ toolbox_names:
18
+ default: "通常"
19
+ smalrubot_s1: "スモウルボットS1"
20
+ smalrubot_v3: "スモウルボットV3"
21
+
22
+ helpers:
23
+ label:
24
+ "user[preferences]":
25
+ toolbox_name: "ツールボックスの種類"
26
+
27
+ toolbox__default__enabled_hardware_blocks: "ハードウェアブロックを使う"
28
+ toolbox__default__enabled_smalrubot_s1_blocks: "スモウルボットS1のブロックを使う"
29
+ toolbox__default__enabled_smalrubot_v3_blocks: "スモウルボットV3のブロックを使う"
30
+
31
+ disabled_add_character_from_beginning: "最初にキャラクターを追加しない"
32
+ disabled_new_character: "キャラクターの追加を禁止する"
33
+ enabled_auto_init_hardware: "自動でハードウェアを準備する"
34
+ enabled_readonly_ruby_mode: "プログラムを直接入力できないようにする"
35
+ enabled_must_signin: "ログインしないと使えないようにする"
36
+
16
37
  editor:
17
38
  index:
18
39
  block: "ブロック"
@@ -23,6 +44,7 @@ ja:
23
44
  save: "セーブ"
24
45
  check: "チェック"
25
46
  reset: *reset
47
+ preference: "設定"
26
48
  logout: "ログアウト"
27
49
  login: *login
28
50
 
@@ -64,6 +86,14 @@ ja:
64
86
  title: "本当にリセットしますか?"
65
87
  message: "作成中のプログラムが消えてしまうよ!"
66
88
 
89
+ preference_modal:
90
+ title: "設定"
91
+
67
92
  signin_modal:
68
93
  message: "あなたの名前をいれて、<br />ほかの人のプログラムとまざらないようにしよう♪"
69
94
  username_placeholder: "名前、生徒番号、ニックネームなど"
95
+
96
+ users:
97
+ preferences:
98
+ toolbox: "ツールボックス"
99
+ general: "一般"
data/config/routes.rb CHANGED
@@ -10,6 +10,8 @@ SmalrubyEditor::Application.routes.draw do
10
10
  resources :sessions, only: [:create, :destroy]
11
11
  match '/signout', to: 'sessions#destroy', via: 'delete'
12
12
 
13
+ resources :users, only: [:update]
14
+
13
15
  resources :source_codes, only: [:create, :index]
14
16
  post 'source_codes/check'
15
17
  delete 'source_codes/download'
@@ -20,61 +22,6 @@ SmalrubyEditor::Application.routes.draw do
20
22
  post 'source_codes/run'
21
23
  post 'source_codes/to_blocks'
22
24
 
23
- # The priority is based upon order of creation: first created ->
24
- # highest priority.
25
- # See how all your routes lay out with "rake routes".
26
-
27
- # You can have the root of your site routed with "root"
28
- # root 'welcome#index'
29
-
30
- # Example of regular route:
31
- # get 'products/:id' => 'catalog#view'
32
-
33
- # Example of named route that can be invoked with purchase_url(id:
34
- # product.id)
35
- # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
36
-
37
- # Example resource route (maps HTTP verbs to controller actions
38
- # automatically):
39
- # resources :products
40
-
41
- # Example resource route with options:
42
- # resources :products do
43
- # member do
44
- # get 'short'
45
- # post 'toggle'
46
- # end
47
- #
48
- # collection do
49
- # get 'sold'
50
- # end
51
- # end
52
-
53
- # Example resource route with sub-resources:
54
- # resources :products do
55
- # resources :comments, :sales
56
- # resource :seller
57
- # end
58
-
59
- # Example resource route with more complex sub-resources:
60
- # resources :products do
61
- # resources :comments
62
- # resources :sales do
63
- # get 'recent', on: :collection
64
- # end
65
- # end
66
-
67
- # Example resource route with concerns:
68
- # concern :toggleable do
69
- # post 'toggle'
70
- # end
71
- # resources :posts, concerns: :toggleable
72
- # resources :photos, concerns: :toggleable
73
-
74
- # Example resource route within a namespace:
75
- # namespace :admin do
76
- # # Directs /admin/products/* to Admin::ProductsController
77
- # # (app/controllers/admin/products_controller.rb)
78
- # resources :products
79
- # end
25
+ get 'preferences', to: 'users#preferences'
26
+ get 'toolbox', to: 'editor#toolbox'
80
27
  end
@@ -0,0 +1,10 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :name
5
+ t.text :preferences
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ class AddIndexNameOnUsers < ActiveRecord::Migration
2
+ def up
3
+ add_index :users, :name, :unique
4
+ end
5
+
6
+ def down
7
+ remove_index :users, :name
8
+ end
9
+ end
data/db/schema.rb CHANGED
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20131219045113) do
14
+ ActiveRecord::Schema.define(version: 20150513061250) do
15
15
 
16
16
  create_table "source_codes", force: true do |t|
17
17
  t.text "data"
@@ -20,4 +20,13 @@ ActiveRecord::Schema.define(version: 20131219045113) do
20
20
  t.string "filename"
21
21
  end
22
22
 
23
+ create_table "users", force: true do |t|
24
+ t.string "name"
25
+ t.text "preferences"
26
+ t.datetime "created_at"
27
+ t.datetime "updated_at"
28
+ end
29
+
30
+ add_index "users", ["name"], name: "index_users_on_name", unique: true, using: :btree
31
+
23
32
  end
@@ -126,34 +126,32 @@ standalone:
126
126
  end
127
127
  end
128
128
 
129
- CONFIG_YML_TEMPLATE = <<-EOS
130
- #toolbox_name: default
131
- #toolbox_name: raspberrypi
132
- #toolbox_name: smalrubot_v3
133
- #toolbox_name: smalrubot_s1
134
- #toolbox_name: default
135
- #toolbox_css_name: default
136
- features:
137
- #- disabled_add_character_from_beginning
138
- #- disabled_new_character
139
- #- auto_init_hardware
140
- #- readonly_ruby_mode
141
- #- must_signin
142
- #- enabled_hardware_blocks_on_default
143
- #- enabled_2wd_car_blocks_on_default
144
- #- enabled_smalrubot_v3_blocks_on_default
145
- #- enabled_smalrubot_s1_blocks_on_default
146
- EOS
147
-
148
129
  def create_config_yml(home_dir)
149
- config_yml_path = home_dir.join('config', 'config.yml')
130
+ config_yml_path = home_dir.join("config", "config.yml")
150
131
  unless config_yml_path.exist?
151
- File.open(config_yml_path, 'w') do |f|
152
- f.write(CONFIG_YML_TEMPLATE)
132
+ File.open(config_yml_path, "w") do |f|
133
+ toolbox_name__preference_names =
134
+ Preference.make_toolbox_name_to_preference_names_hash
135
+ Preference.toolbox_names.each do |toolbox_name|
136
+ f.puts("#toolbox_name: #{toolbox_name}")
137
+ toolbox_name__preference_names.delete(toolbox_name).try(:each) do
138
+ |preference_name|
139
+ f.puts("##{preference_name}: true")
140
+ end
141
+ f.puts
142
+ end
143
+ preference_names_list =
144
+ toolbox_name__preference_names.values +
145
+ [Preference.general_preference_names,
146
+ Preference.admin_preference_names]
147
+ preference_names_list.each do |preference_names|
148
+ preference_names.each do |preference_name|
149
+ f.puts("##{preference_name}: true")
150
+ end
151
+ f.puts
152
+ end
153
153
  end
154
154
  end
155
155
  end
156
156
  end
157
157
  end
158
-
159
- require 'smalruby_editor/config'
@@ -1,3 +1,3 @@
1
1
  module SmalrubyEditor
2
- VERSION = '0.2.6'
2
+ VERSION = '0.2.7'
3
3
  end
File without changes
@@ -26,6 +26,8 @@
26
26
  """
27
27
  require "smalruby"
28
28
 
29
+ init_hardware
30
+
29
31
  p("")
30
32
 
31
33
  """
@@ -39,6 +39,7 @@
39
39
  require "smalruby"
40
40
 
41
41
  init_hardware
42
+
42
43
  car1 = Character.new(costume: "car1.png", x: 0, y: 0, angle: 0)
43
44
 
44
45
  """
@@ -15,7 +15,13 @@
15
15
  """
16
16
  かつ ブロックからソースコードを生成する
17
17
 
18
- ならば テキストエディタのプログラムは "" であること
18
+ ならば テキストエディタのプログラムは以下であること:
19
+ """
20
+ require "smalruby"
21
+
22
+ init_hardware
23
+
24
+ """
19
25
 
20
26
  シナリオ: キャラクターとブロックを配置する
21
27
  もし 次のブロックを配置する:
@@ -34,6 +40,8 @@
34
40
  """
35
41
  require "smalruby"
36
42
 
43
+ init_hardware
44
+
37
45
  car1 = Character.new(costume: "car1.png", x: 0, y: 0, angle: 0)
38
46
  car1.led("D13").turn_off
39
47
 
@@ -58,6 +66,8 @@
58
66
  """
59
67
  require "smalruby"
60
68
 
69
+ init_hardware
70
+
61
71
  car1 = Character.new(costume: "car1.png", x: 0, y: 0, angle: 0)
62
72
 
63
73
  car1.on(:start) do