smalruby-editor 0.0.5 → 0.0.6
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 +4 -4
- data/.gitignore +1 -0
- data/.rspec +2 -1
- data/.rubocop.yml +18 -0
- data/.travis.yml +24 -23
- data/LEGAL +13 -0
- data/README.rdoc +1 -0
- data/Rakefile +3 -0
- data/app/assets/javascripts/application.js +1 -1
- data/app/assets/javascripts/editor.js.coffee +60 -15
- data/app/assets/stylesheets/application.css +1 -2
- data/app/assets/stylesheets/flatstrap-custom.css.scss +2 -0
- data/app/controllers/editor_controller.rb +0 -24
- data/app/controllers/source_codes_controller.rb +67 -0
- data/app/models/source_code.rb +42 -0
- data/app/views/editor/index.html.erb +5 -3
- data/bin/smalruby-editor +11 -0
- data/config/application.rb +8 -20
- data/config/boot.rb +3 -0
- data/config/environments/development.rb +2 -1
- data/config/environments/production.rb +12 -6
- data/config/environments/standalone.rb +3 -2
- data/config/environments/test.rb +14 -4
- data/config/initializers/backtrace_silencers.rb +4 -2
- data/config/initializers/session_store.rb +2 -1
- data/config/initializers/wrap_parameters.rb +2 -1
- data/config/routes.rb +10 -6
- data/config/unicorn.rb +7 -6
- data/db/migrate/20131216121603_create_source_codes.rb +9 -0
- data/db/migrate/20131219045113_add_filename_to_source_code.rb +5 -0
- data/db/schema.rb +8 -1
- data/lib/smalruby_editor.rb +29 -15
- data/lib/smalruby_editor/version.rb +1 -1
- data/lib/tasks/rspec.rake +2 -2
- data/lib/tasks/rubocop.rake +3 -0
- data/public/fonts/FontAwesome.otf +0 -0
- data/public/fonts/fontawesome-webfont.eot +0 -0
- data/public/fonts/fontawesome-webfont.ttf +0 -0
- data/public/fonts/fontawesome-webfont.woff +0 -0
- data/smalruby-editor.gemspec +3 -3
- data/spec/acceptance/readme.md +3 -0
- data/spec/acceptance/text_editor/base.feature +24 -0
- data/spec/acceptance/text_editor/check.feature +20 -0
- data/spec/acceptance/text_editor/load.feature +74 -0
- data/spec/acceptance/text_editor/save.feature +31 -0
- data/spec/controllers/editor_controller_spec.rb +2 -63
- data/spec/controllers/source_codes_controller_spec.rb +296 -0
- data/spec/models/source_code_spec.rb +44 -0
- data/spec/spec_helper.rb +123 -65
- data/spec/steps/ace_steps.rb +60 -0
- data/spec/steps/global_variable.rb +39 -0
- data/spec/steps/text_editor_steps.rb +160 -0
- data/spec/support/capybara.rb +17 -0
- metadata +49 -19
- data/spec/acceptance/editor.feature +0 -68
- data/spec/steps/editor_steps.rb +0 -123
data/config/application.rb
CHANGED
@@ -1,28 +1,16 @@
|
|
1
1
|
require File.expand_path('../boot', __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require "sprockets/railtie"
|
8
|
-
# require "rails/test_unit/railtie"
|
3
|
+
require 'active_record/railtie'
|
4
|
+
require 'action_controller/railtie'
|
5
|
+
require 'action_mailer/railtie'
|
6
|
+
require 'sprockets/railtie'
|
9
7
|
|
10
|
-
|
11
|
-
# you've limited to :test, :development, or :production.
|
12
|
-
Bundler.require(:default, Rails.env) if Rails.env != 'standalone'
|
8
|
+
Bundler.require(:default, Rails.env) unless Rails.env == 'standalone'
|
13
9
|
|
14
10
|
module SmalrubyEditor
|
15
11
|
class Application < Rails::Application
|
16
|
-
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
21
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
22
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
23
|
-
|
24
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
25
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
26
|
-
# config.i18n.default_locale = :de
|
12
|
+
config.time_zone = 'Tokyo'
|
13
|
+
# config.i18n.default_locale = :ja
|
14
|
+
config.colorize_logging = false
|
27
15
|
end
|
28
16
|
end
|
data/config/boot.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# Set up gems listed in the Gemfile.
|
2
2
|
if ENV['RAILS_ENV'] == 'standalone'
|
3
|
+
require 'pathname'
|
3
4
|
path = Pathname('../../smalruby-editor.gemspec').expand_path(__FILE__)
|
4
5
|
spec = Dir.chdir(path.dirname.to_s) {
|
6
|
+
# rubocop:disable Eval
|
5
7
|
eval(path.read, TOPLEVEL_BINDING, path.to_s)
|
8
|
+
# rubocop:enable Eval
|
6
9
|
}
|
7
10
|
spec.runtime_dependencies.each do |spec_dep|
|
8
11
|
require spec_dep.name
|
@@ -1,5 +1,6 @@
|
|
1
1
|
SmalrubyEditor::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in
|
2
|
+
# Settings specified here will take precedence over those in
|
3
|
+
# config/application.rb.
|
3
4
|
|
4
5
|
# In the development environment your application's code is reloaded on
|
5
6
|
# every request. This slows down response time but is perfect for development
|
@@ -1,5 +1,6 @@
|
|
1
1
|
SmalrubyEditor::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in
|
2
|
+
# Settings specified here will take precedence over those in
|
3
|
+
# config/application.rb.
|
3
4
|
|
4
5
|
# Code is not reloaded between requests.
|
5
6
|
config.cache_classes = true
|
@@ -16,7 +17,8 @@ SmalrubyEditor::Application.configure do
|
|
16
17
|
|
17
18
|
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
19
|
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
-
# For large-scale production use, consider using a caching reverse
|
20
|
+
# For large-scale production use, consider using a caching reverse
|
21
|
+
# proxy like nginx, varnish or squid.
|
20
22
|
# config.action_dispatch.rack_cache = true
|
21
23
|
|
22
24
|
# Disable Rails's static asset server (Apache or nginx will already do this).
|
@@ -39,7 +41,8 @@ SmalrubyEditor::Application.configure do
|
|
39
41
|
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
40
42
|
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
41
43
|
|
42
|
-
# Force all access to the app over SSL, use
|
44
|
+
# Force all access to the app over SSL, use
|
45
|
+
# Strict-Transport-Security, and use secure cookies.
|
43
46
|
# config.force_ssl = true
|
44
47
|
|
45
48
|
# Set to :debug to see everything in the log.
|
@@ -54,15 +57,18 @@ SmalrubyEditor::Application.configure do
|
|
54
57
|
# Use a different cache store in production.
|
55
58
|
# config.cache_store = :mem_cache_store
|
56
59
|
|
57
|
-
# Enable serving of images, stylesheets, and JavaScripts from an
|
60
|
+
# Enable serving of images, stylesheets, and JavaScripts from an
|
61
|
+
# asset server.
|
58
62
|
# config.action_controller.asset_host = "http://assets.example.com"
|
59
63
|
|
60
64
|
# Precompile additional assets.
|
61
|
-
# application.js, application.css, and all non-JS/CSS in app/assets
|
65
|
+
# application.js, application.css, and all non-JS/CSS in app/assets
|
66
|
+
# folder are already added.
|
62
67
|
# config.assets.precompile += %w( search.js )
|
63
68
|
|
64
69
|
# Ignore bad email addresses and do not raise email delivery errors.
|
65
|
-
# Set this to true and configure the email server for immediate
|
70
|
+
# Set this to true and configure the email server for immediate
|
71
|
+
# delivery to raise delivery errors.
|
66
72
|
# config.action_mailer.raise_delivery_errors = false
|
67
73
|
|
68
74
|
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
@@ -1,13 +1,14 @@
|
|
1
1
|
require_relative 'production'
|
2
2
|
|
3
3
|
SmalrubyEditor::Application.configure do
|
4
|
-
|
4
|
+
unless ENV['SMALRUBY_EDITOR_HOME']
|
5
5
|
fail 'you must set SMALRUBY_EDITOR_HOME environment variable.'
|
6
6
|
end
|
7
7
|
|
8
8
|
home_dir = SmalrubyEditor.create_home_directory
|
9
9
|
|
10
|
-
config.paths.add 'config/database',
|
10
|
+
config.paths.add 'config/database',
|
11
|
+
with: home_dir.join('config/database.yml')
|
11
12
|
config.paths.add 'log', with: home_dir.join("log/#{Rails.env}.log")
|
12
13
|
config.paths.add 'tmp', with: home_dir.join('tmp')
|
13
14
|
config.paths.add 'tmp/cache', with: home_dir.join('tmp/cache')
|
data/config/environments/test.rb
CHANGED
@@ -1,20 +1,30 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
SmalrubyEditor::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in
|
3
|
+
# Settings specified here will take precedence over those in
|
4
|
+
# config/application.rb.
|
3
5
|
|
4
6
|
# The test environment is used exclusively to run your application's
|
5
7
|
# test suite. You never need to work with it otherwise. Remember that
|
6
8
|
# your test database is "scratch space" for the test suite and is wiped
|
7
9
|
# and recreated between test runs. Don't rely on the data there!
|
8
|
-
|
10
|
+
|
11
|
+
# http://penguinlab.jp/blog/post/2256# より
|
12
|
+
# Spork 使用時はクラスをキャッシュしない
|
13
|
+
if defined?(Spork) && Spork.using_spork?
|
14
|
+
config.cache_classes = false
|
15
|
+
else
|
16
|
+
config.cache_classes = true
|
17
|
+
end
|
9
18
|
|
10
19
|
# Do not eager load code on boot. This avoids loading your whole application
|
11
20
|
# just for the purpose of running a single test. If you are using a tool that
|
12
21
|
# preloads Rails for running tests, you may have to set it to true.
|
13
22
|
config.eager_load = false
|
14
23
|
|
15
|
-
# Configure static asset server for tests with Cache-Control for
|
24
|
+
# Configure static asset server for tests with Cache-Control for
|
25
|
+
# performance.
|
16
26
|
config.serve_static_assets = true
|
17
|
-
config.static_cache_control =
|
27
|
+
config.static_cache_control = 'public, max-age=3600'
|
18
28
|
|
19
29
|
# Show full error reports and disable caching.
|
20
30
|
config.consider_all_requests_local = true
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
2
|
|
3
|
-
# You can add backtrace silencers for libraries that you're using but
|
3
|
+
# You can add backtrace silencers for libraries that you're using but
|
4
|
+
# don't wish to see in your backtraces.
|
4
5
|
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
6
|
|
6
|
-
# You can also remove all the silencers if you're trying to debug a
|
7
|
+
# You can also remove all the silencers if you're trying to debug a
|
8
|
+
# problem that might stem from framework code.
|
7
9
|
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# This file contains settings for ActionController::ParamsWrapper which
|
4
4
|
# is enabled by default.
|
5
5
|
|
6
|
-
# Enable parameter wrapping for JSON. You can disable this by setting
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting
|
7
|
+
# :format to an empty array.
|
7
8
|
ActiveSupport.on_load(:action_controller) do
|
8
9
|
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
9
10
|
end
|
data/config/routes.rb
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
SmalrubyEditor::Application.routes.draw do
|
3
3
|
root 'editor#index'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
resources :source_codes, only: [:create]
|
6
|
+
post 'source_codes/check'
|
7
|
+
delete 'source_codes/download'
|
8
|
+
post 'source_codes/load'
|
8
9
|
|
9
|
-
# The priority is based upon order of creation: first created ->
|
10
|
+
# The priority is based upon order of creation: first created ->
|
11
|
+
# highest priority.
|
10
12
|
# See how all your routes lay out with "rake routes".
|
11
13
|
|
12
14
|
# You can have the root of your site routed with "root"
|
@@ -15,10 +17,12 @@ SmalrubyEditor::Application.routes.draw do
|
|
15
17
|
# Example of regular route:
|
16
18
|
# get 'products/:id' => 'catalog#view'
|
17
19
|
|
18
|
-
# Example of named route that can be invoked with purchase_url(id:
|
20
|
+
# Example of named route that can be invoked with purchase_url(id:
|
21
|
+
# product.id)
|
19
22
|
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
20
23
|
|
21
|
-
# Example resource route (maps HTTP verbs to controller actions
|
24
|
+
# Example resource route (maps HTTP verbs to controller actions
|
25
|
+
# automatically):
|
22
26
|
# resources :products
|
23
27
|
|
24
28
|
# Example resource route with options:
|
data/config/unicorn.rb
CHANGED
@@ -1,22 +1,23 @@
|
|
1
|
-
worker_processes Integer(ENV[
|
1
|
+
worker_processes Integer(ENV['WEB_CONCURRENCY'] || 3)
|
2
2
|
timeout 15
|
3
3
|
preload_app true
|
4
4
|
|
5
|
+
# rubocop:disable Output
|
5
6
|
before_fork do |server, worker|
|
6
7
|
Signal.trap 'TERM' do
|
7
8
|
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
|
8
9
|
Process.kill 'QUIT', Process.pid
|
9
10
|
end
|
10
11
|
|
11
|
-
defined?(ActiveRecord::Base)
|
12
|
-
ActiveRecord::Base.connection.disconnect!
|
12
|
+
defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.disconnect!
|
13
13
|
end
|
14
14
|
|
15
15
|
after_fork do |server, worker|
|
16
16
|
Signal.trap 'TERM' do
|
17
|
-
puts 'Unicorn worker intercepting TERM and doing nothing.
|
17
|
+
puts 'Unicorn worker intercepting TERM and doing nothing.' \
|
18
|
+
' Wait for master to send QUIT'
|
18
19
|
end
|
19
20
|
|
20
|
-
defined?(ActiveRecord::Base)
|
21
|
-
ActiveRecord::Base.establish_connection
|
21
|
+
defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection
|
22
22
|
end
|
23
|
+
# rubocop:enable Output
|
data/db/schema.rb
CHANGED
@@ -11,6 +11,13 @@
|
|
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:
|
14
|
+
ActiveRecord::Schema.define(version: 20131219045113) do
|
15
|
+
|
16
|
+
create_table "source_codes", force: true do |t|
|
17
|
+
t.text "data"
|
18
|
+
t.datetime "created_at"
|
19
|
+
t.datetime "updated_at"
|
20
|
+
t.string "filename"
|
21
|
+
end
|
15
22
|
|
16
23
|
end
|
data/lib/smalruby_editor.rb
CHANGED
@@ -3,30 +3,44 @@ require 'smalruby_editor/version'
|
|
3
3
|
module SmalrubyEditor
|
4
4
|
def create_home_directory(home_dir = nil)
|
5
5
|
if home_dir.blank?
|
6
|
-
|
6
|
+
path = ENV['SMALRUBY_EDITOR_HOME'] || '~/.smalruby-editor'
|
7
|
+
home_dir = Pathname(path).expand_path
|
7
8
|
end
|
9
|
+
create_under_home_directories(home_dir)
|
10
|
+
create_database_yml(home_dir)
|
11
|
+
home_dir
|
12
|
+
end
|
13
|
+
module_function :create_home_directory
|
8
14
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
15
|
+
class << self
|
16
|
+
private
|
17
|
+
|
18
|
+
def create_under_home_directories(home_dir)
|
19
|
+
dirs = %w(log db config
|
20
|
+
tmp/cache tmp/pids tmp/sessions tmp/sockets).map { |s|
|
21
|
+
home_dir.join(s)
|
22
|
+
}
|
23
|
+
dirs.each do |dir|
|
24
|
+
FileUtils.mkdir_p(dir)
|
25
|
+
end
|
13
26
|
end
|
14
27
|
|
15
|
-
|
16
|
-
db_path = home_dir.join('db', 'standalone.sqlite3')
|
17
|
-
if !File.exist?(database_yml_path)
|
18
|
-
File.open(database_yml_path, 'w') do |f|
|
19
|
-
f.write(<<-EOS)
|
28
|
+
DATABASE_YML_TEMPLATE = <<-EOS
|
20
29
|
standalone:
|
21
30
|
adapter: sqlite3
|
22
|
-
database:
|
31
|
+
database: %db_path%
|
23
32
|
pool: 5
|
24
33
|
timeout: 5000
|
25
|
-
|
34
|
+
EOS
|
35
|
+
|
36
|
+
def create_database_yml(home_dir)
|
37
|
+
database_yml_path = home_dir.join('config', 'database.yml')
|
38
|
+
db_path = home_dir.join('db', 'standalone.sqlite3')
|
39
|
+
unless File.exist?(database_yml_path)
|
40
|
+
File.open(database_yml_path, 'w') do |f|
|
41
|
+
f.write(DATABASE_YML_TEMPLATE.gsub(/%db_path%/, db_path.to_s))
|
42
|
+
end
|
26
43
|
end
|
27
44
|
end
|
28
|
-
|
29
|
-
home_dir
|
30
45
|
end
|
31
|
-
module_function :create_home_directory
|
32
46
|
end
|
data/lib/tasks/rspec.rake
CHANGED
@@ -3,13 +3,13 @@ begin
|
|
3
3
|
task(:spec).clear
|
4
4
|
desc "Run all specs/features in spec directory"
|
5
5
|
RSpec::Core::RakeTask.new(:spec => 'db:test:prepare') do |t|
|
6
|
-
t.pattern = './spec{
|
6
|
+
t.pattern = './spec/{,**/}*{_spec.rb,.feature}'
|
7
7
|
end
|
8
8
|
|
9
9
|
namespace :spec do
|
10
10
|
desc "Run the code examples in spec/acceptance"
|
11
11
|
RSpec::Core::RakeTask.new(:acceptance => 'db:test:prepare') do |t|
|
12
|
-
t.pattern = './spec/acceptance/{
|
12
|
+
t.pattern = './spec/acceptance/{,**/}*.feature'
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/smalruby-editor.gemspec
CHANGED
@@ -29,18 +29,18 @@ Gem::Specification.new do |spec|
|
|
29
29
|
|
30
30
|
runtime_dependencies =
|
31
31
|
[
|
32
|
-
['rails', '
|
32
|
+
['rails', '4.0.2'],
|
33
33
|
['sqlite3'],
|
34
34
|
['sass-rails', '~> 4.0.0'],
|
35
35
|
['uglifier', '>= 1.3.0'],
|
36
36
|
['coffee-rails', '~> 4.0.0'],
|
37
37
|
['jquery-rails'],
|
38
38
|
['turbolinks'],
|
39
|
-
['jbuilder', '~>
|
39
|
+
['jbuilder', '~> 2.0'],
|
40
40
|
['ace-rails-ap'],
|
41
41
|
['flatstrap-sass'],
|
42
|
-
['font-awesome-rails'],
|
43
42
|
['jquery-fileupload-rails'],
|
43
|
+
['shared-mime-info'],
|
44
44
|
['launchy'],
|
45
45
|
]
|
46
46
|
runtime_dependencies.each do |args|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# language: ja
|
3
|
+
@javascript
|
4
|
+
機能: Base - 基本
|
5
|
+
シナリオ: トップページにアクセスしてエディタ画面を表示する
|
6
|
+
もし "トップページ" にアクセスする
|
7
|
+
|
8
|
+
ならば "Rubyタブ" が表示されていること
|
9
|
+
かつ "テキストエディタ" が表示されていること
|
10
|
+
かつ "プログラム名の入力欄" が表示されていること
|
11
|
+
かつ "セーブボタン" が表示されていること
|
12
|
+
かつ テキストエディタにフォーカスがあること
|
13
|
+
かつ テキストエディタの 0 行目の 0 文字目にカーソルがあること
|
14
|
+
|
15
|
+
シナリオ: プログラムを入力後にページを遷移する
|
16
|
+
前提 "エディタ" 画面を表示する
|
17
|
+
かつ テキストエディタに "puts 'Hello, World!'" を入力済みである
|
18
|
+
かつ プログラムの名前に "01.rb" を指定する
|
19
|
+
|
20
|
+
もし ページをリロードする
|
21
|
+
かつ 警告ダイアログの "dismiss" ボタンをクリックする
|
22
|
+
|
23
|
+
ならば テキストエディタのプログラムは "puts 'Hello, World!'" であること
|
24
|
+
かつ "プログラム名の入力欄" は "01.rb" であること
|