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.
Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +1 -1
  3. data/.gitignore +15 -1
  4. data/.rubocop.yml +10 -2
  5. data/.ruby-version +1 -1
  6. data/.travis.yml +6 -0
  7. data/Gemfile +32 -0
  8. data/README.md +169 -6
  9. data/Rakefile +11 -0
  10. data/Vagrantfile +1 -1
  11. data/bin/rails +25 -0
  12. data/bootstrap.sh +2 -3
  13. data/dev.yml +4 -4
  14. data/ext/enterprise_script_service/Rakefile +5 -4
  15. data/ext/enterprise_script_service/mruby_config.rb +1 -0
  16. data/lib/script_core.rb +17 -15
  17. data/lib/script_core/engine.rb +1 -0
  18. data/lib/script_core/executable.rb +1 -1
  19. data/lib/script_core/railtie.rb +8 -0
  20. data/lib/script_core/spawner.rb +1 -0
  21. data/lib/script_core/version.rb +1 -1
  22. data/lib/tasks/mruby/engine.gembox.example +19 -0
  23. data/lib/tasks/mruby/lib/.keep +0 -0
  24. data/lib/tasks/script_core.rake +111 -0
  25. data/script/regression +7 -5
  26. data/script_core.gemspec +2 -2
  27. data/spec/dummy/Rakefile +8 -0
  28. data/spec/dummy/app/assets/config/manifest.js +3 -0
  29. data/spec/dummy/app/assets/images/.keep +0 -0
  30. data/spec/dummy/app/assets/javascripts/application.es6 +56 -0
  31. data/spec/dummy/app/assets/stylesheets/application.scss +65 -0
  32. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  33. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  34. data/spec/dummy/app/controllers/fields/application_controller.rb +25 -0
  35. data/spec/dummy/app/controllers/fields/options_controller.rb +26 -0
  36. data/spec/dummy/app/controllers/fields/validations_controller.rb +26 -0
  37. data/spec/dummy/app/controllers/forms/application_controller.rb +14 -0
  38. data/spec/dummy/app/controllers/forms/fields_controller.rb +56 -0
  39. data/spec/dummy/app/controllers/forms/formulas/application_controller.rb +19 -0
  40. data/spec/dummy/app/controllers/forms/formulas/playgrounds_controller.rb +29 -0
  41. data/spec/dummy/app/controllers/forms/formulas_controller.rb +56 -0
  42. data/spec/dummy/app/controllers/forms_controller.rb +58 -0
  43. data/spec/dummy/app/controllers/home_controller.rb +7 -0
  44. data/spec/dummy/app/controllers/nested_forms/application_controller.rb +12 -0
  45. data/spec/dummy/app/controllers/nested_forms/fields_controller.rb +50 -0
  46. data/spec/dummy/app/controllers/playgrounds_controller.rb +29 -0
  47. data/spec/dummy/app/decorators/.keep +0 -0
  48. data/spec/dummy/app/helpers/application_helper.rb +21 -0
  49. data/spec/dummy/app/helpers/fields_helper.rb +32 -0
  50. data/spec/dummy/app/helpers/forms_helper.rb +14 -0
  51. data/spec/dummy/app/jobs/application_job.rb +4 -0
  52. data/spec/dummy/app/lib/script_engine.rb +22 -0
  53. data/spec/dummy/app/models/application_record.rb +8 -0
  54. data/spec/dummy/app/models/concerns/.keep +0 -0
  55. data/spec/dummy/app/models/concerns/acts_as_default_value.rb +152 -0
  56. data/spec/dummy/app/models/concerns/enum_attribute_localizable.rb +32 -0
  57. data/spec/dummy/app/models/concerns/fields/validations/acceptance.rb +18 -0
  58. data/spec/dummy/app/models/concerns/fields/validations/confirmation.rb +18 -0
  59. data/spec/dummy/app/models/concerns/fields/validations/exclusion.rb +35 -0
  60. data/spec/dummy/app/models/concerns/fields/validations/format.rb +45 -0
  61. data/spec/dummy/app/models/concerns/fields/validations/inclusion.rb +35 -0
  62. data/spec/dummy/app/models/concerns/fields/validations/length.rb +59 -0
  63. data/spec/dummy/app/models/concerns/fields/validations/numericality.rb +56 -0
  64. data/spec/dummy/app/models/concerns/fields/validations/presence.rb +18 -0
  65. data/spec/dummy/app/models/concerns/form_core/acts_as_default_value.rb +143 -0
  66. data/spec/dummy/app/models/field.rb +67 -0
  67. data/spec/dummy/app/models/field_options.rb +90 -0
  68. data/spec/dummy/app/models/fields.rb +10 -0
  69. data/spec/dummy/app/models/fields/boolean_field.rb +12 -0
  70. data/spec/dummy/app/models/fields/decimal_field.rb +12 -0
  71. data/spec/dummy/app/models/fields/integer_field.rb +20 -0
  72. data/spec/dummy/app/models/fields/multiple_nested_form_field.rb +35 -0
  73. data/spec/dummy/app/models/fields/nested_form_field.rb +37 -0
  74. data/spec/dummy/app/models/fields/options/boolean_field.rb +6 -0
  75. data/spec/dummy/app/models/fields/options/decimal_field.rb +12 -0
  76. data/spec/dummy/app/models/fields/options/integer_field.rb +13 -0
  77. data/spec/dummy/app/models/fields/options/multiple_nested_form_field.rb +6 -0
  78. data/spec/dummy/app/models/fields/options/nested_form_field.rb +6 -0
  79. data/spec/dummy/app/models/fields/options/text_field.rb +7 -0
  80. data/spec/dummy/app/models/fields/text_field.rb +12 -0
  81. data/spec/dummy/app/models/fields/validations/boolean_field.rb +7 -0
  82. data/spec/dummy/app/models/fields/validations/decimal_field.rb +8 -0
  83. data/spec/dummy/app/models/fields/validations/integer_field.rb +8 -0
  84. data/spec/dummy/app/models/fields/validations/multiple_nested_form_field.rb +8 -0
  85. data/spec/dummy/app/models/fields/validations/nested_form_field.rb +7 -0
  86. data/spec/dummy/app/models/fields/validations/text_field.rb +9 -0
  87. data/spec/dummy/app/models/form.rb +8 -0
  88. data/spec/dummy/app/models/formula.rb +8 -0
  89. data/spec/dummy/app/models/metal_form.rb +9 -0
  90. data/spec/dummy/app/models/nested_form.rb +5 -0
  91. data/spec/dummy/app/models/virtual_model.rb +23 -0
  92. data/spec/dummy/app/presenters/application_presenter.rb +11 -0
  93. data/spec/dummy/app/presenters/concerns/fields/presenter_for_number_field.rb +36 -0
  94. data/spec/dummy/app/presenters/fields/boolean_field_presenter.rb +13 -0
  95. data/spec/dummy/app/presenters/fields/composite_field_presenter.rb +13 -0
  96. data/spec/dummy/app/presenters/fields/decimal_field_presenter.rb +7 -0
  97. data/spec/dummy/app/presenters/fields/field_presenter.rb +44 -0
  98. data/spec/dummy/app/presenters/fields/integer_field_presenter.rb +11 -0
  99. data/spec/dummy/app/presenters/fields/multiple_nested_form_field_presenter.rb +9 -0
  100. data/spec/dummy/app/presenters/fields/nested_form_field_presenter.rb +9 -0
  101. data/spec/dummy/app/presenters/fields/text_field_presenter.rb +10 -0
  102. data/spec/dummy/app/views/_form_core/field_options/_decimal_field.html.erb +9 -0
  103. data/spec/dummy/app/views/_form_core/field_options/_integer_field.html.erb +10 -0
  104. data/spec/dummy/app/views/_form_core/field_options/_text_field.html.erb +12 -0
  105. data/spec/dummy/app/views/_form_core/fields/_boolean_field.html.erb +11 -0
  106. data/spec/dummy/app/views/_form_core/fields/_decimal_field.html.erb +9 -0
  107. data/spec/dummy/app/views/_form_core/fields/_integer_field.html.erb +9 -0
  108. data/spec/dummy/app/views/_form_core/fields/_multiple_nested_form_field.html.erb +23 -0
  109. data/spec/dummy/app/views/_form_core/fields/_nested_form.html.erb +37 -0
  110. data/spec/dummy/app/views/_form_core/fields/_nested_form_field.html.erb +42 -0
  111. data/spec/dummy/app/views/_form_core/fields/_text_field.html.erb +13 -0
  112. data/spec/dummy/app/views/_form_core/preview/_form.html.erb +17 -0
  113. data/spec/dummy/app/views/_form_core/preview/_nested_form.html.erb +22 -0
  114. data/spec/dummy/app/views/_form_core/render/_form.html.erb +39 -0
  115. data/spec/dummy/app/views/_form_core/validations/_acceptance.html.erb +12 -0
  116. data/spec/dummy/app/views/_form_core/validations/_confirmation.html.erb +12 -0
  117. data/spec/dummy/app/views/_form_core/validations/_exclusion.html.erb +2 -0
  118. data/spec/dummy/app/views/_form_core/validations/_format.html.erb +37 -0
  119. data/spec/dummy/app/views/_form_core/validations/_inclusion.html.erb +2 -0
  120. data/spec/dummy/app/views/_form_core/validations/_length.html.erb +44 -0
  121. data/spec/dummy/app/views/_form_core/validations/_numericality.html.erb +45 -0
  122. data/spec/dummy/app/views/_form_core/validations/_presence.html.erb +12 -0
  123. data/spec/dummy/app/views/fields/options/_form.html.erb +29 -0
  124. data/spec/dummy/app/views/fields/options/edit.html.erb +6 -0
  125. data/spec/dummy/app/views/fields/validations/_form.html.erb +34 -0
  126. data/spec/dummy/app/views/fields/validations/edit.html.erb +6 -0
  127. data/spec/dummy/app/views/forms/_form.html.erb +41 -0
  128. data/spec/dummy/app/views/forms/edit.html.erb +6 -0
  129. data/spec/dummy/app/views/forms/fields/_form.html.erb +71 -0
  130. data/spec/dummy/app/views/forms/fields/edit.html.erb +6 -0
  131. data/spec/dummy/app/views/forms/fields/index.html.erb +42 -0
  132. data/spec/dummy/app/views/forms/fields/new.html.erb +6 -0
  133. data/spec/dummy/app/views/forms/formulas/_form.html.erb +41 -0
  134. data/spec/dummy/app/views/forms/formulas/edit.html.erb +6 -0
  135. data/spec/dummy/app/views/forms/formulas/index.html.erb +28 -0
  136. data/spec/dummy/app/views/forms/formulas/new.html.erb +6 -0
  137. data/spec/dummy/app/views/forms/formulas/playgrounds/create.html.erb +48 -0
  138. data/spec/dummy/app/views/forms/formulas/playgrounds/show.html.erb +14 -0
  139. data/spec/dummy/app/views/forms/index.html.erb +31 -0
  140. data/spec/dummy/app/views/forms/new.html.erb +6 -0
  141. data/spec/dummy/app/views/home/index.html.erb +5 -0
  142. data/spec/dummy/app/views/layouts/_alert.html.erb +4 -0
  143. data/spec/dummy/app/views/layouts/_footer.html.erb +13 -0
  144. data/spec/dummy/app/views/layouts/_nav.html.erb +11 -0
  145. data/spec/dummy/app/views/layouts/_notice.html.erb +4 -0
  146. data/spec/dummy/app/views/layouts/application.html.erb +25 -0
  147. data/spec/dummy/app/views/layouts/forms.html.erb +33 -0
  148. data/spec/dummy/app/views/nested_forms/fields/_form.html.erb +68 -0
  149. data/spec/dummy/app/views/nested_forms/fields/edit.html.erb +6 -0
  150. data/spec/dummy/app/views/nested_forms/fields/index.html.erb +39 -0
  151. data/spec/dummy/app/views/nested_forms/fields/new.html.erb +6 -0
  152. data/spec/dummy/app/views/playgrounds/_form.html.erb +13 -0
  153. data/spec/dummy/app/views/playgrounds/create.html.erb +51 -0
  154. data/spec/dummy/app/views/playgrounds/show.html.erb +7 -0
  155. data/spec/dummy/bin/bundle +5 -0
  156. data/spec/dummy/bin/rails +6 -0
  157. data/spec/dummy/bin/rake +6 -0
  158. data/spec/dummy/bin/setup +40 -0
  159. data/spec/dummy/bin/update +35 -0
  160. data/spec/dummy/bin/yarn +13 -0
  161. data/spec/dummy/config.ru +7 -0
  162. data/spec/dummy/config/application.rb +35 -0
  163. data/spec/dummy/config/boot.rb +7 -0
  164. data/spec/dummy/config/database.yml +25 -0
  165. data/spec/dummy/config/environment.rb +7 -0
  166. data/spec/dummy/config/environments/development.rb +58 -0
  167. data/spec/dummy/config/environments/production.rb +85 -0
  168. data/spec/dummy/config/environments/test.rb +41 -0
  169. data/spec/dummy/config/initializers/application_controller_renderer.rb +10 -0
  170. data/spec/dummy/config/initializers/assets.rb +16 -0
  171. data/spec/dummy/config/initializers/backtrace_silencers.rb +9 -0
  172. data/spec/dummy/config/initializers/content_security_policy.rb +27 -0
  173. data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
  174. data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  175. data/spec/dummy/config/initializers/form_core.rb +4 -0
  176. data/spec/dummy/config/initializers/inflections.rb +18 -0
  177. data/spec/dummy/config/initializers/mime_types.rb +6 -0
  178. data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
  179. data/spec/dummy/config/locales/en.yml +33 -0
  180. data/spec/dummy/config/puma.rb +36 -0
  181. data/spec/dummy/config/routes.rb +31 -0
  182. data/spec/dummy/config/spring.rb +8 -0
  183. data/spec/dummy/config/storage.yml +34 -0
  184. data/spec/dummy/db/migrate/20180916202025_create_forms.form_core.rb +12 -0
  185. data/spec/dummy/db/migrate/20180916202026_add_columns_to_forms.rb +10 -0
  186. data/spec/dummy/db/migrate/20180916202027_add_attachable_to_forms.rb +9 -0
  187. data/spec/dummy/db/migrate/20180916202030_create_fields.form_core.rb +17 -0
  188. data/spec/dummy/db/migrate/20180916202121_add_columns_to_fields.rb +10 -0
  189. data/spec/dummy/db/migrate/20180916202124_add_position_to_fields.rb +9 -0
  190. data/spec/dummy/db/migrate/20181111111412_create_formulas.rb +13 -0
  191. data/spec/dummy/db/schema.rb +52 -0
  192. data/spec/dummy/lib/assets/.keep +0 -0
  193. data/spec/dummy/lib/monkey_patches/active_support.rb +3 -0
  194. data/spec/dummy/lib/monkey_patches/active_support/concern+prependable.rb +28 -0
  195. data/spec/dummy/lib/monkey_patches/big_decimal.rb +8 -0
  196. data/spec/dummy/log/.keep +0 -0
  197. data/spec/dummy/mruby/engine.gembox +19 -0
  198. data/spec/dummy/mruby/lib/.keep +0 -0
  199. data/spec/dummy/mruby/lib/core_ext.rb +62 -0
  200. data/spec/dummy/mruby/lib/harden.rb +1 -0
  201. data/spec/dummy/mruby/lib/input.rb +20 -0
  202. data/spec/dummy/mruby/lib/io.rb +19 -0
  203. data/spec/dummy/mruby/lib/output.rb +35 -0
  204. data/spec/dummy/mruby/lib/script_kernel.rb +12 -0
  205. data/spec/dummy/package.json +5 -0
  206. data/spec/dummy/public/404.html +67 -0
  207. data/spec/dummy/public/422.html +67 -0
  208. data/spec/dummy/public/500.html +66 -0
  209. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  210. data/spec/dummy/public/apple-touch-icon.png +0 -0
  211. data/spec/dummy/public/favicon.ico +0 -0
  212. data/spec/dummy/storage/.keep +0 -0
  213. data/spec/dummy/test/controllers/.keep +0 -0
  214. data/spec/dummy/test/fixtures/.keep +0 -0
  215. data/spec/dummy/test/models/.keep +0 -0
  216. data/spec/script_core_spec.rb +2 -2
  217. data/spec/spec_helper.rb +2 -2
  218. metadata +199 -5
  219. data/circle.yml +0 -9
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ %w[
4
+ .ruby-version
5
+ .rbenv-vars
6
+ tmp/restart.txt
7
+ tmp/caching-dev.txt
8
+ ].each { |path| Spring.watch(path) }
@@ -0,0 +1,34 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
8
+
9
+ # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
+ # amazon:
11
+ # service: S3
12
+ # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
+ # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
+ # region: us-east-1
15
+ # bucket: your_own_bucket
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket
23
+
24
+ # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # storage_account_name: your_account_name
28
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
+ # container: your_container_name
30
+
31
+ # mirror:
32
+ # service: Mirror
33
+ # primary: local
34
+ # mirrors: [ amazon, google, microsoft ]
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This migration comes from form_core (originally 20170430190404)
4
+ class CreateForms < ActiveRecord::Migration[5.2]
5
+ def change
6
+ create_table :forms do |t|
7
+ t.string :type, null: false, index: true
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddColumnsToForms < ActiveRecord::Migration[5.2]
4
+ def change
5
+ change_table :forms do |t|
6
+ t.string :title, default: ""
7
+ t.text :description, default: ""
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddAttachableToForms < ActiveRecord::Migration[5.2]
4
+ def change
5
+ change_table :forms do |t|
6
+ t.references :attachable, polymorphic: true, index: true
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This migration comes from form_core (originally 20170430191336)
4
+ class CreateFields < ActiveRecord::Migration[5.2]
5
+ def change
6
+ create_table :fields do |t|
7
+ t.string :name, null: false
8
+ t.integer :accessibility, null: false
9
+ t.text :validations
10
+ t.text :options
11
+ t.string :type, null: false, index: true
12
+ t.references :form, foreign_key: true
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddColumnsToFields < ActiveRecord::Migration[5.2]
4
+ def change
5
+ change_table :fields do |t|
6
+ t.string :label, default: ""
7
+ t.string :hint, default: ""
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddPositionToFields < ActiveRecord::Migration[5.2]
4
+ def change
5
+ change_table :fields do |t|
6
+ t.integer :position
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateFormulas < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :formulas do |t|
6
+ t.string :name
7
+ t.text :body
8
+ t.references :form, foreign_key: true
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,52 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 2018_11_11_111412) do
14
+
15
+ create_table "fields", force: :cascade do |t|
16
+ t.string "name", null: false
17
+ t.integer "accessibility", null: false
18
+ t.text "validations"
19
+ t.text "options"
20
+ t.string "type", null: false
21
+ t.integer "form_id"
22
+ t.datetime "created_at", null: false
23
+ t.datetime "updated_at", null: false
24
+ t.string "label", default: ""
25
+ t.string "hint", default: ""
26
+ t.integer "position"
27
+ t.index ["form_id"], name: "index_fields_on_form_id"
28
+ t.index ["type"], name: "index_fields_on_type"
29
+ end
30
+
31
+ create_table "forms", force: :cascade do |t|
32
+ t.string "type", null: false
33
+ t.datetime "created_at", null: false
34
+ t.datetime "updated_at", null: false
35
+ t.string "title", default: ""
36
+ t.text "description", default: ""
37
+ t.string "attachable_type"
38
+ t.integer "attachable_id"
39
+ t.index ["attachable_type", "attachable_id"], name: "index_forms_on_attachable_type_and_attachable_id"
40
+ t.index ["type"], name: "index_forms_on_type"
41
+ end
42
+
43
+ create_table "formulas", force: :cascade do |t|
44
+ t.string "name"
45
+ t.text "body"
46
+ t.integer "form_id"
47
+ t.datetime "created_at", null: false
48
+ t.datetime "updated_at", null: false
49
+ t.index ["form_id"], name: "index_formulas_on_form_id"
50
+ end
51
+
52
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "active_support/concern+prependable"
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Cheated from https://gitlab.com/gitlab-org/gitlab-ee/blob/master/config/initializers/0_as_concern.rb
4
+ # This module is based on: https://gist.github.com/bcardarella/5735987
5
+
6
+ module Prependable
7
+ def prepend_features(base)
8
+ if base.instance_variable_defined?(:@_dependencies)
9
+ base.instance_variable_get(:@_dependencies) << self
10
+ false
11
+ else
12
+ return false if base < self
13
+
14
+ super
15
+ base.singleton_class.send(:prepend, const_get("ClassMethods")) if const_defined?(:ClassMethods)
16
+ @_dependencies.each { |dep| base.send(:prepend, dep) }
17
+ base.class_eval(&@_included_block) if instance_variable_defined?(:@_included_block)
18
+ end
19
+ end
20
+ end
21
+
22
+ module ActiveSupport
23
+ module Concern
24
+ prepend Prependable
25
+
26
+ alias prepended included
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class BigDecimal
4
+ # TODO: TEMP FIX BECAUSE SCRIPT_CORE NOT DONE YET.
5
+ def to_msgpack(*args)
6
+ to_f.to_msgpack(*args)
7
+ end
8
+ end
File without changes
@@ -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,62 @@
1
+ class FalseClass
2
+ def dup
3
+ self
4
+ end
5
+ end
6
+
7
+ class TrueClass
8
+ def dup
9
+ self
10
+ end
11
+ end
12
+
13
+ class Method
14
+ def dup
15
+ self
16
+ end
17
+ end
18
+
19
+ class NilClass
20
+ def dup
21
+ self
22
+ end
23
+ end
24
+
25
+ class Numeric
26
+ def dup
27
+ self
28
+ end
29
+ end
30
+
31
+ class Decimal
32
+ def dup
33
+ self
34
+ end
35
+ end
36
+
37
+ class Symbol
38
+ def dup
39
+ self
40
+ end
41
+ end
42
+
43
+ class Object
44
+ def deep_dup
45
+ dup
46
+ end
47
+ end
48
+
49
+ class Hash
50
+ def deep_dup
51
+ # Different with Shopify's
52
+ each_with_object(dup) do |(key, value), hash|
53
+ hash[key.deep_dup] = value.deep_dup
54
+ end
55
+ end
56
+ end
57
+
58
+ class Array
59
+ def deep_dup
60
+ map { |it| it.deep_dup }
61
+ end
62
+ end
@@ -0,0 +1 @@
1
+ Kernel.remove_method :object_id
@@ -0,0 +1,20 @@
1
+ module Input
2
+ class << self
3
+ def load(input)
4
+ @input = input || {}
5
+ @input.freeze
6
+ end
7
+
8
+ def [](key)
9
+ @input[key]
10
+ end
11
+
12
+ def to_s
13
+ @input.to_s
14
+ end
15
+
16
+ def value
17
+ @input
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ class << self
2
+ attr_accessor :stdout_buffer
3
+ end
4
+
5
+ SCRIPT__TOP = self
6
+ SCRIPT__TOP.stdout_buffer = ""
7
+
8
+ module Kernel
9
+ def puts(*args)
10
+ unless args.empty?
11
+ args.each do |arg|
12
+ SCRIPT__TOP.stdout_buffer << arg.to_s
13
+ SCRIPT__TOP.stdout_buffer << "\n"
14
+ end
15
+ else
16
+ SCRIPT__TOP.stdout_buffer << "\n"
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,35 @@
1
+ module Output
2
+ class << self
3
+ SUPPORTED_CLASSES = [Symbol, FalseClass, TrueClass, Float, Integer, String]
4
+
5
+ attr_accessor :value
6
+
7
+ def dump
8
+ return nil if value.nil?
9
+ unless value_type_supported?(value)
10
+ raise "Output can't pass to host Ruby."
11
+ end
12
+
13
+ value
14
+ end
15
+
16
+ private
17
+
18
+ def value_type_supported?(value)
19
+ return true if value.nil?
20
+
21
+ if value.is_a? Hash
22
+ return false if value.keys.map { |i| value_type_supported?(i) }.any? { |i| !i }
23
+ return false if value.values.map { |i| value_type_supported?(i) }.any? { |i| !i }
24
+ elsif value.is_a? Array
25
+ return false if value.map { |i| value_type_supported?(i) }.any? { |i| !i }
26
+ end
27
+
28
+ for klass in SUPPORTED_CLASSES
29
+ return true if value.is_a? klass
30
+ end
31
+
32
+ false
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,12 @@
1
+ def prepare_input
2
+ Input.load @input
3
+ remove_instance_variable "@input"
4
+ end
5
+
6
+ def prepare_output
7
+ instance_variable_set :@output, Output.dump
8
+ end
9
+
10
+ def set_output(value)
11
+ Output.value = value
12
+ end
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "dummy",
3
+ "private": true,
4
+ "dependencies": {}
5
+ }
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>