script_core 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +1 -1
- data/.gitignore +15 -1
- data/.rubocop.yml +10 -2
- data/.ruby-version +1 -1
- data/.travis.yml +6 -0
- data/Gemfile +32 -0
- data/README.md +169 -6
- data/Rakefile +11 -0
- data/Vagrantfile +1 -1
- data/bin/rails +25 -0
- data/bootstrap.sh +2 -3
- data/dev.yml +4 -4
- data/ext/enterprise_script_service/Rakefile +5 -4
- data/ext/enterprise_script_service/mruby_config.rb +1 -0
- data/lib/script_core.rb +17 -15
- data/lib/script_core/engine.rb +1 -0
- data/lib/script_core/executable.rb +1 -1
- data/lib/script_core/railtie.rb +8 -0
- data/lib/script_core/spawner.rb +1 -0
- data/lib/script_core/version.rb +1 -1
- data/lib/tasks/mruby/engine.gembox.example +19 -0
- data/lib/tasks/mruby/lib/.keep +0 -0
- data/lib/tasks/script_core.rake +111 -0
- data/script/regression +7 -5
- data/script_core.gemspec +2 -2
- data/spec/dummy/Rakefile +8 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.es6 +56 -0
- data/spec/dummy/app/assets/stylesheets/application.scss +65 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/fields/application_controller.rb +25 -0
- data/spec/dummy/app/controllers/fields/options_controller.rb +26 -0
- data/spec/dummy/app/controllers/fields/validations_controller.rb +26 -0
- data/spec/dummy/app/controllers/forms/application_controller.rb +14 -0
- data/spec/dummy/app/controllers/forms/fields_controller.rb +56 -0
- data/spec/dummy/app/controllers/forms/formulas/application_controller.rb +19 -0
- data/spec/dummy/app/controllers/forms/formulas/playgrounds_controller.rb +29 -0
- data/spec/dummy/app/controllers/forms/formulas_controller.rb +56 -0
- data/spec/dummy/app/controllers/forms_controller.rb +58 -0
- data/spec/dummy/app/controllers/home_controller.rb +7 -0
- data/spec/dummy/app/controllers/nested_forms/application_controller.rb +12 -0
- data/spec/dummy/app/controllers/nested_forms/fields_controller.rb +50 -0
- data/spec/dummy/app/controllers/playgrounds_controller.rb +29 -0
- data/spec/dummy/app/decorators/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +21 -0
- data/spec/dummy/app/helpers/fields_helper.rb +32 -0
- data/spec/dummy/app/helpers/forms_helper.rb +14 -0
- data/spec/dummy/app/jobs/application_job.rb +4 -0
- data/spec/dummy/app/lib/script_engine.rb +22 -0
- data/spec/dummy/app/models/application_record.rb +8 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/concerns/acts_as_default_value.rb +152 -0
- data/spec/dummy/app/models/concerns/enum_attribute_localizable.rb +32 -0
- data/spec/dummy/app/models/concerns/fields/validations/acceptance.rb +18 -0
- data/spec/dummy/app/models/concerns/fields/validations/confirmation.rb +18 -0
- data/spec/dummy/app/models/concerns/fields/validations/exclusion.rb +35 -0
- data/spec/dummy/app/models/concerns/fields/validations/format.rb +45 -0
- data/spec/dummy/app/models/concerns/fields/validations/inclusion.rb +35 -0
- data/spec/dummy/app/models/concerns/fields/validations/length.rb +59 -0
- data/spec/dummy/app/models/concerns/fields/validations/numericality.rb +56 -0
- data/spec/dummy/app/models/concerns/fields/validations/presence.rb +18 -0
- data/spec/dummy/app/models/concerns/form_core/acts_as_default_value.rb +143 -0
- data/spec/dummy/app/models/field.rb +67 -0
- data/spec/dummy/app/models/field_options.rb +90 -0
- data/spec/dummy/app/models/fields.rb +10 -0
- data/spec/dummy/app/models/fields/boolean_field.rb +12 -0
- data/spec/dummy/app/models/fields/decimal_field.rb +12 -0
- data/spec/dummy/app/models/fields/integer_field.rb +20 -0
- data/spec/dummy/app/models/fields/multiple_nested_form_field.rb +35 -0
- data/spec/dummy/app/models/fields/nested_form_field.rb +37 -0
- data/spec/dummy/app/models/fields/options/boolean_field.rb +6 -0
- data/spec/dummy/app/models/fields/options/decimal_field.rb +12 -0
- data/spec/dummy/app/models/fields/options/integer_field.rb +13 -0
- data/spec/dummy/app/models/fields/options/multiple_nested_form_field.rb +6 -0
- data/spec/dummy/app/models/fields/options/nested_form_field.rb +6 -0
- data/spec/dummy/app/models/fields/options/text_field.rb +7 -0
- data/spec/dummy/app/models/fields/text_field.rb +12 -0
- data/spec/dummy/app/models/fields/validations/boolean_field.rb +7 -0
- data/spec/dummy/app/models/fields/validations/decimal_field.rb +8 -0
- data/spec/dummy/app/models/fields/validations/integer_field.rb +8 -0
- data/spec/dummy/app/models/fields/validations/multiple_nested_form_field.rb +8 -0
- data/spec/dummy/app/models/fields/validations/nested_form_field.rb +7 -0
- data/spec/dummy/app/models/fields/validations/text_field.rb +9 -0
- data/spec/dummy/app/models/form.rb +8 -0
- data/spec/dummy/app/models/formula.rb +8 -0
- data/spec/dummy/app/models/metal_form.rb +9 -0
- data/spec/dummy/app/models/nested_form.rb +5 -0
- data/spec/dummy/app/models/virtual_model.rb +23 -0
- data/spec/dummy/app/presenters/application_presenter.rb +11 -0
- data/spec/dummy/app/presenters/concerns/fields/presenter_for_number_field.rb +36 -0
- data/spec/dummy/app/presenters/fields/boolean_field_presenter.rb +13 -0
- data/spec/dummy/app/presenters/fields/composite_field_presenter.rb +13 -0
- data/spec/dummy/app/presenters/fields/decimal_field_presenter.rb +7 -0
- data/spec/dummy/app/presenters/fields/field_presenter.rb +44 -0
- data/spec/dummy/app/presenters/fields/integer_field_presenter.rb +11 -0
- data/spec/dummy/app/presenters/fields/multiple_nested_form_field_presenter.rb +9 -0
- data/spec/dummy/app/presenters/fields/nested_form_field_presenter.rb +9 -0
- data/spec/dummy/app/presenters/fields/text_field_presenter.rb +10 -0
- data/spec/dummy/app/views/_form_core/field_options/_decimal_field.html.erb +9 -0
- data/spec/dummy/app/views/_form_core/field_options/_integer_field.html.erb +10 -0
- data/spec/dummy/app/views/_form_core/field_options/_text_field.html.erb +12 -0
- data/spec/dummy/app/views/_form_core/fields/_boolean_field.html.erb +11 -0
- data/spec/dummy/app/views/_form_core/fields/_decimal_field.html.erb +9 -0
- data/spec/dummy/app/views/_form_core/fields/_integer_field.html.erb +9 -0
- data/spec/dummy/app/views/_form_core/fields/_multiple_nested_form_field.html.erb +23 -0
- data/spec/dummy/app/views/_form_core/fields/_nested_form.html.erb +37 -0
- data/spec/dummy/app/views/_form_core/fields/_nested_form_field.html.erb +42 -0
- data/spec/dummy/app/views/_form_core/fields/_text_field.html.erb +13 -0
- data/spec/dummy/app/views/_form_core/preview/_form.html.erb +17 -0
- data/spec/dummy/app/views/_form_core/preview/_nested_form.html.erb +22 -0
- data/spec/dummy/app/views/_form_core/render/_form.html.erb +39 -0
- data/spec/dummy/app/views/_form_core/validations/_acceptance.html.erb +12 -0
- data/spec/dummy/app/views/_form_core/validations/_confirmation.html.erb +12 -0
- data/spec/dummy/app/views/_form_core/validations/_exclusion.html.erb +2 -0
- data/spec/dummy/app/views/_form_core/validations/_format.html.erb +37 -0
- data/spec/dummy/app/views/_form_core/validations/_inclusion.html.erb +2 -0
- data/spec/dummy/app/views/_form_core/validations/_length.html.erb +44 -0
- data/spec/dummy/app/views/_form_core/validations/_numericality.html.erb +45 -0
- data/spec/dummy/app/views/_form_core/validations/_presence.html.erb +12 -0
- data/spec/dummy/app/views/fields/options/_form.html.erb +29 -0
- data/spec/dummy/app/views/fields/options/edit.html.erb +6 -0
- data/spec/dummy/app/views/fields/validations/_form.html.erb +34 -0
- data/spec/dummy/app/views/fields/validations/edit.html.erb +6 -0
- data/spec/dummy/app/views/forms/_form.html.erb +41 -0
- data/spec/dummy/app/views/forms/edit.html.erb +6 -0
- data/spec/dummy/app/views/forms/fields/_form.html.erb +71 -0
- data/spec/dummy/app/views/forms/fields/edit.html.erb +6 -0
- data/spec/dummy/app/views/forms/fields/index.html.erb +42 -0
- data/spec/dummy/app/views/forms/fields/new.html.erb +6 -0
- data/spec/dummy/app/views/forms/formulas/_form.html.erb +41 -0
- data/spec/dummy/app/views/forms/formulas/edit.html.erb +6 -0
- data/spec/dummy/app/views/forms/formulas/index.html.erb +28 -0
- data/spec/dummy/app/views/forms/formulas/new.html.erb +6 -0
- data/spec/dummy/app/views/forms/formulas/playgrounds/create.html.erb +48 -0
- data/spec/dummy/app/views/forms/formulas/playgrounds/show.html.erb +14 -0
- data/spec/dummy/app/views/forms/index.html.erb +31 -0
- data/spec/dummy/app/views/forms/new.html.erb +6 -0
- data/spec/dummy/app/views/home/index.html.erb +5 -0
- data/spec/dummy/app/views/layouts/_alert.html.erb +4 -0
- data/spec/dummy/app/views/layouts/_footer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/_nav.html.erb +11 -0
- data/spec/dummy/app/views/layouts/_notice.html.erb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +25 -0
- data/spec/dummy/app/views/layouts/forms.html.erb +33 -0
- data/spec/dummy/app/views/nested_forms/fields/_form.html.erb +68 -0
- data/spec/dummy/app/views/nested_forms/fields/edit.html.erb +6 -0
- data/spec/dummy/app/views/nested_forms/fields/index.html.erb +39 -0
- data/spec/dummy/app/views/nested_forms/fields/new.html.erb +6 -0
- data/spec/dummy/app/views/playgrounds/_form.html.erb +13 -0
- data/spec/dummy/app/views/playgrounds/create.html.erb +51 -0
- data/spec/dummy/app/views/playgrounds/show.html.erb +7 -0
- data/spec/dummy/bin/bundle +5 -0
- data/spec/dummy/bin/rails +6 -0
- data/spec/dummy/bin/rake +6 -0
- data/spec/dummy/bin/setup +40 -0
- data/spec/dummy/bin/update +35 -0
- data/spec/dummy/bin/yarn +13 -0
- data/spec/dummy/config.ru +7 -0
- data/spec/dummy/config/application.rb +35 -0
- data/spec/dummy/config/boot.rb +7 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +7 -0
- data/spec/dummy/config/environments/development.rb +58 -0
- data/spec/dummy/config/environments/production.rb +85 -0
- data/spec/dummy/config/environments/test.rb +41 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +10 -0
- data/spec/dummy/config/initializers/assets.rb +16 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +9 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +27 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/spec/dummy/config/initializers/form_core.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +18 -0
- data/spec/dummy/config/initializers/mime_types.rb +6 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +36 -0
- data/spec/dummy/config/routes.rb +31 -0
- data/spec/dummy/config/spring.rb +8 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/db/migrate/20180916202025_create_forms.form_core.rb +12 -0
- data/spec/dummy/db/migrate/20180916202026_add_columns_to_forms.rb +10 -0
- data/spec/dummy/db/migrate/20180916202027_add_attachable_to_forms.rb +9 -0
- data/spec/dummy/db/migrate/20180916202030_create_fields.form_core.rb +17 -0
- data/spec/dummy/db/migrate/20180916202121_add_columns_to_fields.rb +10 -0
- data/spec/dummy/db/migrate/20180916202124_add_position_to_fields.rb +9 -0
- data/spec/dummy/db/migrate/20181111111412_create_formulas.rb +13 -0
- data/spec/dummy/db/schema.rb +52 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/monkey_patches/active_support.rb +3 -0
- data/spec/dummy/lib/monkey_patches/active_support/concern+prependable.rb +28 -0
- data/spec/dummy/lib/monkey_patches/big_decimal.rb +8 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/mruby/engine.gembox +19 -0
- data/spec/dummy/mruby/lib/.keep +0 -0
- data/spec/dummy/mruby/lib/core_ext.rb +62 -0
- data/spec/dummy/mruby/lib/harden.rb +1 -0
- data/spec/dummy/mruby/lib/input.rb +20 -0
- data/spec/dummy/mruby/lib/io.rb +19 -0
- data/spec/dummy/mruby/lib/output.rb +35 -0
- data/spec/dummy/mruby/lib/script_kernel.rb +12 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/storage/.keep +0 -0
- data/spec/dummy/test/controllers/.keep +0 -0
- data/spec/dummy/test/fixtures/.keep +0 -0
- data/spec/dummy/test/models/.keep +0 -0
- data/spec/script_core_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- metadata +199 -5
- data/circle.yml +0 -9
@@ -5,6 +5,7 @@
|
|
5
5
|
mruby_engine_gembox_path =
|
6
6
|
if ENV["MRUBY_ENGINE_GEMBOX_PATH"] && File.exist?(ENV["MRUBY_ENGINE_GEMBOX_PATH"])
|
7
7
|
raise "`#{ENV['MRUBY_ENGINE_GEMBOX_PATH']}` require `.gembox` extension" unless ENV["MRUBY_ENGINE_GEMBOX_PATH"].end_with?(".gembox")
|
8
|
+
|
8
9
|
Pathname.new ENV["MRUBY_ENGINE_GEMBOX_PATH"][0..-8]
|
9
10
|
else
|
10
11
|
Pathname.new(__FILE__).dirname.join("mruby_engine")
|
data/lib/script_core.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require "forwardable"
|
4
|
+
require "msgpack"
|
5
|
+
require "open3"
|
6
|
+
require "pathname"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
8
|
+
require "script_core/engine_error"
|
9
|
+
require "script_core/message_processor"
|
10
|
+
require "script_core/protocol"
|
11
|
+
require "script_core/result"
|
12
|
+
require "script_core/runner"
|
13
|
+
require "script_core/service_channel"
|
14
|
+
require "script_core/service_process"
|
15
|
+
require "script_core/spawner"
|
16
|
+
require "script_core/stat"
|
17
|
+
require "script_core/executable"
|
18
|
+
require "script_core/engine"
|
19
|
+
|
20
|
+
require "script_core/railtie" if defined?(Rails)
|
19
21
|
|
20
22
|
module ScriptCore
|
21
23
|
DEFAULT_BIN_PATH = Pathname.new(__dir__).parent.join("bin")
|
data/lib/script_core/engine.rb
CHANGED
@@ -8,6 +8,7 @@ def initialize(bin_path = ScriptCore::DEFAULT_BIN_PATH,
|
|
8
8
|
executable_name: "enterprise_script_service",
|
9
9
|
instructions_name: "enterprise_script_service.mrb")
|
10
10
|
raise Errno::ENOENT, "No such directory - #{bin_path}" unless File.directory?(bin_path)
|
11
|
+
|
11
12
|
@bin_path = bin_path
|
12
13
|
|
13
14
|
@executable = ScriptCore::Executable.new(@bin_path.join(executable_name))
|
@@ -12,7 +12,7 @@ def initialize(executable_path)
|
|
12
12
|
@executable_path = executable_path.to_s
|
13
13
|
end
|
14
14
|
|
15
|
-
def run(input
|
15
|
+
def run(input: {}, sources:, instructions: nil,
|
16
16
|
timeout: 1, instruction_quota: 100_000, instruction_quota_start: 0, memory_quota: 8 << 20,
|
17
17
|
environment_variables: {})
|
18
18
|
packer = ScriptCore::Protocol.packer_factory.packer
|
data/lib/script_core/spawner.rb
CHANGED
data/lib/script_core/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
MRuby::GemBox.new do |conf|
|
2
|
+
conf.gem(github: "jasl-lab/mruby-mpdecimal", branch: "master")
|
3
|
+
|
4
|
+
conf.gem(core: "mruby-math")
|
5
|
+
conf.gem(core: "mruby-time")
|
6
|
+
conf.gem(core: "mruby-struct")
|
7
|
+
conf.gem(core: "mruby-enum-ext")
|
8
|
+
conf.gem(core: "mruby-string-ext")
|
9
|
+
conf.gem(core: "mruby-numeric-ext")
|
10
|
+
conf.gem(core: "mruby-array-ext")
|
11
|
+
conf.gem(core: "mruby-hash-ext")
|
12
|
+
conf.gem(core: "mruby-range-ext")
|
13
|
+
conf.gem(core: "mruby-proc-ext")
|
14
|
+
conf.gem(core: "mruby-symbol-ext")
|
15
|
+
conf.gem(core: "mruby-object-ext")
|
16
|
+
conf.gem(core: "mruby-toplevel-ext")
|
17
|
+
conf.gem(core: "mruby-kernel-ext")
|
18
|
+
conf.gem(core: "mruby-compiler")
|
19
|
+
end
|
File without changes
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
SCRIPT_CORE_ROOT = Pathname.new(__dir__).join("../..")
|
4
|
+
TEMPLATE_ROOT = File.expand_path("mruby", __dir__)
|
5
|
+
DEFAULT_ENGINE_NAME = "mruby"
|
6
|
+
|
7
|
+
namespace :script_core do
|
8
|
+
namespace :engine do
|
9
|
+
desc "Create a skeletal engine that can be customize at the path you specify"
|
10
|
+
task :new do
|
11
|
+
ARGV.each { |a| task(a.to_sym) {} }
|
12
|
+
|
13
|
+
name = ARGV[1] || DEFAULT_ENGINE_NAME
|
14
|
+
unless /\A[a-z_]+\Z/.match?(name)
|
15
|
+
puts "Engine name can only be `a` to `z` and `_`."
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
|
19
|
+
dest_dir = Rails.root.join(name)
|
20
|
+
if File.exist?(dest_dir)
|
21
|
+
puts "#{dest_dir} exists, you need to remove it first."
|
22
|
+
exit 1
|
23
|
+
end
|
24
|
+
|
25
|
+
FileUtils.cp_r TEMPLATE_ROOT, dest_dir
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Build engine executables"
|
29
|
+
task :build do
|
30
|
+
ARGV.each { |a| task(a.to_sym) {} }
|
31
|
+
|
32
|
+
name = ARGV[1] || DEFAULT_ENGINE_NAME
|
33
|
+
unless /\A[a-z_]+\Z/.match?(name)
|
34
|
+
puts "Must provide a valid engine name."
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
|
38
|
+
engine_root = Rails.root.join(name)
|
39
|
+
unless Dir.exist?(engine_root)
|
40
|
+
puts "Engine home `#{engine_root}` doesn't exists."
|
41
|
+
puts "You should run `rake script_core:engine:new #{name}` to create it first."
|
42
|
+
exit 1
|
43
|
+
end
|
44
|
+
|
45
|
+
env_vars = "TARGET_DIR=#{engine_root}"
|
46
|
+
|
47
|
+
gembox_file = engine_root.join("engine.gembox")
|
48
|
+
if File.exist?(gembox_file)
|
49
|
+
puts "Found customized gembox."
|
50
|
+
env_vars += " MRUBY_ENGINE_GEMBOX_PATH=#{gembox_file}"
|
51
|
+
end
|
52
|
+
|
53
|
+
Dir.chdir(SCRIPT_CORE_ROOT.join("ext/enterprise_script_service")) do
|
54
|
+
sh("#{env_vars} #{Rails.root.join('bin/bundle')} exec rake")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "Compile engine lib"
|
59
|
+
task :compile_lib do
|
60
|
+
ARGV.each { |a| task(a.to_sym) {} }
|
61
|
+
|
62
|
+
name = ARGV[1] || DEFAULT_ENGINE_NAME
|
63
|
+
unless /\A[a-z_]+\Z/.match?(name)
|
64
|
+
puts "Must provide a valid engine name."
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
engine_root = Rails.root.join(name)
|
69
|
+
unless Dir.exist?(engine_root)
|
70
|
+
puts "Engine home `#{engine_root}` doesn't exists."
|
71
|
+
puts "You should run `rake script_core:engine:new #{name}` to create it first."
|
72
|
+
exit 1
|
73
|
+
end
|
74
|
+
|
75
|
+
unless File.exist?(engine_root.join("bin/mrbc"))
|
76
|
+
puts "Engine haven't built yet."
|
77
|
+
puts "You should run `rake script_core:engine:build #{name}` first."
|
78
|
+
exit 1
|
79
|
+
end
|
80
|
+
|
81
|
+
lib_files = Dir["#{engine_root.join('lib')}/**/*.rb"]
|
82
|
+
if lib_files.empty?
|
83
|
+
puts "Empty lib, no need to compile"
|
84
|
+
exit 0
|
85
|
+
end
|
86
|
+
|
87
|
+
Dir.chdir(engine_root.join("bin")) do
|
88
|
+
sh("./mrbc -o enterprise_script_service.mrb #{lib_files.join(' ')}")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
desc "Clean engine compiled files"
|
93
|
+
task :clean do
|
94
|
+
ARGV.each { |a| task(a.to_sym) {} }
|
95
|
+
|
96
|
+
name = ARGV[1] || DEFAULT_ENGINE_NAME
|
97
|
+
unless /\A[a-z_]+\Z/.match?(name)
|
98
|
+
puts "Must provide a valid engine name."
|
99
|
+
exit 1
|
100
|
+
end
|
101
|
+
|
102
|
+
engine_root = Rails.root.join(name)
|
103
|
+
unless Dir.exist?(engine_root)
|
104
|
+
puts "Engine home `#{engine_root}` doesn't exists."
|
105
|
+
exit 1
|
106
|
+
end
|
107
|
+
|
108
|
+
FileUtils.remove_dir engine_root.join("bin")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
data/script/regression
CHANGED
@@ -9,19 +9,21 @@ def expected_result?(file)
|
|
9
9
|
return true if $CHILD_STATUS.success?
|
10
10
|
return true if $CHILD_STATUS.exitstatus == 1
|
11
11
|
return true if OUT_OF_MEMORY_EXPECTED.include?(file) && $CHILD_STATUS.termsig == 9
|
12
|
+
|
12
13
|
false
|
13
14
|
end
|
14
15
|
|
15
16
|
pwd = Pathname.new(__FILE__).dirname
|
16
17
|
mruby = pwd.join("../ext/enterprise_script_service/mruby/bin/mruby").to_s
|
17
|
-
|
18
|
+
test_dir = pwd.join("../tests/regression")
|
18
19
|
|
19
20
|
failures = false
|
20
21
|
|
21
|
-
Dir.entries(
|
22
|
-
|
23
|
-
next unless File.file?(
|
24
|
-
|
22
|
+
Dir.entries(test_dir).sort.each do |file|
|
23
|
+
file_path = test_dir.join(file)
|
24
|
+
next unless File.file?(file_path)
|
25
|
+
|
26
|
+
cmd = "#{mruby} #{file_path}"
|
25
27
|
system(cmd)
|
26
28
|
|
27
29
|
if expected_result?(file)
|
data/script_core.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "pathname"
|
4
4
|
|
5
|
-
lib = File.expand_path("
|
5
|
+
lib = File.expand_path("lib", __dir__)
|
6
6
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
7
7
|
|
8
8
|
require "script_core/version"
|
@@ -35,7 +35,7 @@
|
|
35
35
|
spec.extensions = ["ext/enterprise_script_service/Rakefile"]
|
36
36
|
spec.homepage = "https://github.com/rails-engine/script_core"
|
37
37
|
spec.license = "MIT"
|
38
|
-
spec.required_ruby_version = ">= 2.
|
38
|
+
spec.required_ruby_version = ">= 2.4"
|
39
39
|
|
40
40
|
spec.add_dependency("msgpack", "~> 1.0")
|
41
41
|
spec.add_dependency("rake-compiler", "~> 1.0")
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
4
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
5
|
+
|
6
|
+
require_relative "config/application"
|
7
|
+
|
8
|
+
Rails.application.load_tasks
|
File without changes
|
@@ -0,0 +1,56 @@
|
|
1
|
+
//= require rails-ujs
|
2
|
+
//= require turbolinks
|
3
|
+
//= require jquery3
|
4
|
+
|
5
|
+
//= require selectize
|
6
|
+
//= require cocoon
|
7
|
+
|
8
|
+
// Cheat form https://github.com/jgthms/bulma/blob/master/docs/_javascript/main.js
|
9
|
+
document.addEventListener('DOMContentLoaded', () => {
|
10
|
+
|
11
|
+
// Dropdowns
|
12
|
+
|
13
|
+
const $dropdowns = getAll('.dropdown:not(.is-hoverable)');
|
14
|
+
|
15
|
+
if ($dropdowns.length > 0) {
|
16
|
+
$dropdowns.forEach($el => {
|
17
|
+
$el.addEventListener('click', event => {
|
18
|
+
event.stopPropagation();
|
19
|
+
$el.classList.toggle('is-active');
|
20
|
+
});
|
21
|
+
});
|
22
|
+
|
23
|
+
document.addEventListener('click', event => {
|
24
|
+
closeDropdowns();
|
25
|
+
});
|
26
|
+
}
|
27
|
+
|
28
|
+
function closeDropdowns() {
|
29
|
+
$dropdowns.forEach($el => {
|
30
|
+
$el.classList.remove('is-active');
|
31
|
+
});
|
32
|
+
}
|
33
|
+
|
34
|
+
// Functions
|
35
|
+
|
36
|
+
function getAll(selector) {
|
37
|
+
return Array.prototype.slice.call(document.querySelectorAll(selector), 0);
|
38
|
+
}
|
39
|
+
|
40
|
+
// Utils
|
41
|
+
|
42
|
+
function removeFromArray(array, value) {
|
43
|
+
if (array.includes(value)) {
|
44
|
+
const value_index = array.indexOf(value);
|
45
|
+
array.splice(value_index, 1);
|
46
|
+
}
|
47
|
+
|
48
|
+
return array;
|
49
|
+
}
|
50
|
+
|
51
|
+
Array.prototype.diff = function (a) {
|
52
|
+
return this.filter(function (i) {
|
53
|
+
return a.indexOf(i) < 0;
|
54
|
+
});
|
55
|
+
};
|
56
|
+
});
|
@@ -0,0 +1,65 @@
|
|
1
|
+
@import "selectize";
|
2
|
+
@import "bulma";
|
3
|
+
|
4
|
+
body {
|
5
|
+
display: flex;
|
6
|
+
min-height: 100vh;
|
7
|
+
flex-direction: column;
|
8
|
+
|
9
|
+
& nav.nav {
|
10
|
+
a.brand {
|
11
|
+
padding: 0.5rem 0.75em 0.5em 0;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
& .main {
|
16
|
+
flex: 1;
|
17
|
+
}
|
18
|
+
|
19
|
+
& footer.footer {
|
20
|
+
padding: 3rem 1.5rem 3rem;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
.flash {
|
25
|
+
overflow: hidden;
|
26
|
+
top: 0;
|
27
|
+
left: 0;
|
28
|
+
right: 0;
|
29
|
+
line-height: 2.5;
|
30
|
+
background: $info;
|
31
|
+
color: $text-invert;
|
32
|
+
text-align: center;
|
33
|
+
}
|
34
|
+
|
35
|
+
#alert {
|
36
|
+
background: $danger;
|
37
|
+
}
|
38
|
+
|
39
|
+
.nested_form_field {
|
40
|
+
.collection {
|
41
|
+
.nested_form {
|
42
|
+
border: 1px solid $green;
|
43
|
+
padding: 0.5em;
|
44
|
+
margin-left: 0.75em;
|
45
|
+
margin-bottom: 0.75rem;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
.content {
|
51
|
+
.nested-content {
|
52
|
+
margin-left: 0.75em;
|
53
|
+
margin-bottom: 1em;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
.message-body.content {
|
58
|
+
> :first-child {
|
59
|
+
margin-top: 0;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
.field {
|
64
|
+
flex: 1;
|
65
|
+
}
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Fields::ApplicationController < ApplicationController
|
4
|
+
before_action :set_field
|
5
|
+
|
6
|
+
protected
|
7
|
+
|
8
|
+
# Use callbacks to share common setup or constraints between actions.
|
9
|
+
def set_field
|
10
|
+
@field = Field.find(params[:field_id])
|
11
|
+
end
|
12
|
+
|
13
|
+
def fields_url
|
14
|
+
form = @field.form
|
15
|
+
|
16
|
+
case form
|
17
|
+
when Form
|
18
|
+
form_fields_url(form)
|
19
|
+
when NestedForm
|
20
|
+
nested_form_fields_url(form)
|
21
|
+
else
|
22
|
+
raise "Unknown form: #{form.class}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|