rabl 0.14.1 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +2 -1
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +0 -1
  5. data/fixtures/ashared/NOTES +10 -0
  6. data/fixtures/ashared/views_rails_6/layouts/application.html.erb +13 -0
  7. data/fixtures/ashared/views_rails_6/posts/_show_footer_script.js.erb +1 -0
  8. data/fixtures/ashared/views_rails_6/posts/date.rabl +3 -0
  9. data/fixtures/ashared/views_rails_6/posts/index.html.erb +3 -0
  10. data/fixtures/ashared/views_rails_6/posts/index.rabl +12 -0
  11. data/fixtures/ashared/views_rails_6/posts/renderer.rabl +8 -0
  12. data/fixtures/ashared/views_rails_6/posts/renderer_partial.rabl +4 -0
  13. data/fixtures/ashared/views_rails_6/posts/show.html.erb +3 -0
  14. data/fixtures/ashared/views_rails_6/posts/show.rabl +25 -0
  15. data/fixtures/ashared/views_rails_6/posts/show.rabl_test_v1.rabl +7 -0
  16. data/fixtures/ashared/views_rails_6/users/index.json.rabl +3 -0
  17. data/fixtures/ashared/views_rails_6/users/phone_number.json.rabl +8 -0
  18. data/fixtures/ashared/views_rails_6/users/phone_number.xml.rabl +1 -0
  19. data/fixtures/ashared/views_rails_6/users/show.json.rabl +16 -0
  20. data/fixtures/ashared/views_rails_6/users/show.rabl_test_v1.rabl +3 -0
  21. data/fixtures/padrino_test/app/views +1 -1
  22. data/fixtures/padrino_test/db/migrate +1 -1
  23. data/fixtures/padrino_test/models +1 -1
  24. data/fixtures/padrino_test/test/app/controllers/posts_controller_test.rb +1 -1
  25. data/fixtures/padrino_test/test/app/controllers/users_controller_test.rb +1 -1
  26. data/fixtures/rails2/app/models +1 -1
  27. data/fixtures/rails2/app/views +1 -1
  28. data/fixtures/rails2/db/migrate +1 -1
  29. data/fixtures/rails2/test/functionals/posts_controller_test.rb +1 -1
  30. data/fixtures/rails2/test/functionals/users_controller_test.rb +1 -1
  31. data/fixtures/rails3/app/models +1 -1
  32. data/fixtures/rails3/app/views +1 -1
  33. data/fixtures/rails3/db/migrate +1 -1
  34. data/fixtures/rails3/test/functional/posts_controller_test.rb +1 -1
  35. data/fixtures/rails3/test/functional/users_controller_test.rb +1 -1
  36. data/fixtures/rails3_2/app/models +1 -1
  37. data/fixtures/rails3_2/app/views +1 -1
  38. data/fixtures/rails3_2/db/migrate +1 -1
  39. data/fixtures/rails3_2/test/functional/posts_controller_test.rb +1 -1
  40. data/fixtures/rails3_2/test/functional/users_controller_test.rb +1 -1
  41. data/fixtures/rails4/app/models +1 -1
  42. data/fixtures/rails4/app/views +1 -1
  43. data/fixtures/rails4/db/migrate +1 -1
  44. data/fixtures/rails4/test/functional/posts_controller_test.rb +1 -1
  45. data/fixtures/rails4/test/functional/users_controller_test.rb +1 -1
  46. data/fixtures/rails5/app/controllers/posts_controller.rb +1 -1
  47. data/fixtures/rails5/app/controllers/users_controller.rb +1 -1
  48. data/fixtures/rails5/app/helpers +1 -1
  49. data/fixtures/rails5/app/models +1 -1
  50. data/fixtures/rails5/app/views +1 -1
  51. data/fixtures/rails5/db/migrate +1 -1
  52. data/fixtures/rails5/test/functional/posts_controller_test.rb +1 -1
  53. data/fixtures/rails5/test/functional/users_controller_test.rb +1 -1
  54. data/fixtures/rails5_api/app/controllers/posts_controller.rb +1 -1
  55. data/fixtures/rails5_api/app/controllers/users_controller.rb +1 -1
  56. data/fixtures/rails5_api/app/helpers +1 -1
  57. data/fixtures/rails5_api/app/models +1 -1
  58. data/fixtures/rails5_api/app/views +1 -1
  59. data/fixtures/rails5_api/db/migrate +1 -1
  60. data/fixtures/rails5_api/test/functional/posts_controller_test.rb +1 -1
  61. data/fixtures/rails5_api/test/functional/users_controller_test.rb +1 -1
  62. data/fixtures/rails6/.gitignore +35 -0
  63. data/fixtures/rails6/Gemfile +58 -0
  64. data/fixtures/rails6/README.md +24 -0
  65. data/fixtures/rails6/Rakefile +14 -0
  66. data/fixtures/rails6/app/assets/config/manifest.js +2 -0
  67. data/fixtures/rails6/app/assets/images/.keep +0 -0
  68. data/fixtures/rails6/app/assets/stylesheets/application.css +15 -0
  69. data/fixtures/rails6/app/channels/application_cable/channel.rb +4 -0
  70. data/fixtures/rails6/app/channels/application_cable/connection.rb +4 -0
  71. data/fixtures/rails6/app/controllers/application_controller.rb +2 -0
  72. data/fixtures/rails6/app/controllers/concerns/.keep +0 -0
  73. data/fixtures/rails6/app/controllers/posts_controller.rb +17 -0
  74. data/fixtures/rails6/app/controllers/users_controller.rb +11 -0
  75. data/fixtures/rails6/app/helpers +1 -0
  76. data/fixtures/rails6/app/javascript/channels/consumer.js +6 -0
  77. data/fixtures/rails6/app/javascript/channels/index.js +5 -0
  78. data/fixtures/rails6/app/javascript/packs/application.js +17 -0
  79. data/fixtures/rails6/app/jobs/application_job.rb +7 -0
  80. data/fixtures/rails6/app/mailers/application_mailer.rb +4 -0
  81. data/fixtures/rails6/app/models +1 -0
  82. data/fixtures/rails6/app/views +1 -0
  83. data/fixtures/rails6/babel.config.js +72 -0
  84. data/fixtures/rails6/bin/bundle +105 -0
  85. data/fixtures/rails6/bin/rails +9 -0
  86. data/fixtures/rails6/bin/rake +9 -0
  87. data/fixtures/rails6/bin/setup +36 -0
  88. data/fixtures/rails6/bin/spring +17 -0
  89. data/fixtures/rails6/bin/webpack +19 -0
  90. data/fixtures/rails6/bin/webpack-dev-server +19 -0
  91. data/fixtures/rails6/bin/yarn +11 -0
  92. data/fixtures/rails6/config.ru +5 -0
  93. data/fixtures/rails6/config/application.rb +19 -0
  94. data/fixtures/rails6/config/boot.rb +4 -0
  95. data/fixtures/rails6/config/cable.yml +10 -0
  96. data/fixtures/rails6/config/credentials.yml.enc +1 -0
  97. data/fixtures/rails6/config/database.yml +25 -0
  98. data/fixtures/rails6/config/environment.rb +5 -0
  99. data/fixtures/rails6/config/environments/development.rb +62 -0
  100. data/fixtures/rails6/config/environments/production.rb +112 -0
  101. data/fixtures/rails6/config/environments/test.rb +48 -0
  102. data/fixtures/rails6/config/initializers/application_controller_renderer.rb +8 -0
  103. data/fixtures/rails6/config/initializers/assets.rb +14 -0
  104. data/fixtures/rails6/config/initializers/backtrace_silencers.rb +7 -0
  105. data/fixtures/rails6/config/initializers/content_security_policy.rb +27 -0
  106. data/fixtures/rails6/config/initializers/cookies_serializer.rb +5 -0
  107. data/fixtures/rails6/config/initializers/filter_parameter_logging.rb +4 -0
  108. data/fixtures/rails6/config/initializers/inflections.rb +16 -0
  109. data/fixtures/rails6/config/initializers/mime_types.rb +6 -0
  110. data/fixtures/rails6/config/initializers/wrap_parameters.rb +14 -0
  111. data/fixtures/rails6/config/locales/en.yml +33 -0
  112. data/fixtures/rails6/config/puma.rb +35 -0
  113. data/fixtures/rails6/config/routes.rb +8 -0
  114. data/fixtures/rails6/config/spring.rb +6 -0
  115. data/fixtures/rails6/config/storage.yml +34 -0
  116. data/fixtures/rails6/config/webpack/development.js +5 -0
  117. data/fixtures/rails6/config/webpack/environment.js +3 -0
  118. data/fixtures/rails6/config/webpack/production.js +5 -0
  119. data/fixtures/rails6/config/webpack/test.js +5 -0
  120. data/fixtures/rails6/config/webpacker.yml +95 -0
  121. data/fixtures/rails6/db/migrate/20111002092016_create_users.rb +11 -0
  122. data/fixtures/rails6/db/migrate/20111002092019_create_posts.rb +10 -0
  123. data/fixtures/rails6/db/migrate/20111002092024_create_phone_numbers.rb +12 -0
  124. data/fixtures/rails6/db/schema.rb +41 -0
  125. data/fixtures/rails6/db/seeds.rb +7 -0
  126. data/fixtures/rails6/lib/assets/.keep +0 -0
  127. data/fixtures/rails6/lib/tasks/.keep +0 -0
  128. data/fixtures/rails6/log/.keep +0 -0
  129. data/fixtures/rails6/package.json +15 -0
  130. data/fixtures/rails6/postcss.config.js +12 -0
  131. data/fixtures/rails6/public/404.html +67 -0
  132. data/fixtures/rails6/public/422.html +67 -0
  133. data/fixtures/rails6/public/500.html +66 -0
  134. data/fixtures/rails6/public/apple-touch-icon-precomposed.png +0 -0
  135. data/fixtures/rails6/public/apple-touch-icon.png +0 -0
  136. data/fixtures/rails6/public/favicon.ico +0 -0
  137. data/fixtures/rails6/public/robots.txt +1 -0
  138. data/fixtures/rails6/storage/.keep +0 -0
  139. data/fixtures/rails6/test/application_system_test_case.rb +5 -0
  140. data/fixtures/rails6/test/channels/application_cable/connection_test.rb +11 -0
  141. data/fixtures/rails6/test/controllers/.keep +0 -0
  142. data/fixtures/rails6/test/fixtures/.keep +0 -0
  143. data/fixtures/rails6/test/fixtures/files/.keep +0 -0
  144. data/fixtures/rails6/test/functional/posts_controller_test.rb +1 -0
  145. data/fixtures/rails6/test/functional/users_controller_test.rb +1 -0
  146. data/fixtures/rails6/test/helpers/.keep +0 -0
  147. data/fixtures/rails6/test/integration/.keep +0 -0
  148. data/fixtures/rails6/test/mailers/.keep +0 -0
  149. data/fixtures/rails6/test/models/.keep +0 -0
  150. data/fixtures/rails6/test/system/.keep +0 -0
  151. data/fixtures/rails6/test/test_helper.rb +27 -0
  152. data/fixtures/rails6/tmp/.keep +0 -0
  153. data/fixtures/rails6/vendor/.keep +0 -0
  154. data/fixtures/rails6/yarn.lock +7201 -0
  155. data/fixtures/sinatra_test/db/migrate +1 -1
  156. data/fixtures/sinatra_test/models +1 -1
  157. data/fixtures/sinatra_test/test/functional/posts_controller_test.rb +1 -1
  158. data/fixtures/sinatra_test/test/functional/users_controller_test.rb +1 -1
  159. data/fixtures/sinatra_test/views +1 -1
  160. data/lib/rabl.rb +3 -3
  161. data/lib/rabl/engine.rb +4 -2
  162. data/lib/rabl/railtie.rb +1 -1
  163. data/lib/rabl/template.rb +21 -1
  164. data/lib/rabl/version.rb +1 -1
  165. data/rabl.gemspec +0 -2
  166. data/test/integration/rails6/posts_controller_test.rb +185 -0
  167. data/test/integration/rails6/users_controller_test.rb +87 -0
  168. metadata +113 -4
@@ -0,0 +1,24 @@
1
+ # README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
@@ -0,0 +1,14 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+ require 'rake/testtask'
6
+
7
+ Rails.application.load_tasks
8
+
9
+ Rake::TestTask.new("test:rabl") do |test|
10
+ test.pattern = "test/functional/**/*_test.rb"
11
+ test.verbose = true
12
+ test.warning = false
13
+ end
14
+
@@ -0,0 +1,2 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../stylesheets .css
File without changes
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
6
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
File without changes
@@ -0,0 +1,17 @@
1
+ class PostsController < ApplicationController
2
+
3
+ respond_to :json, :xml, :html, :rabl_test_v1
4
+
5
+ def index
6
+ @posts = Post.order('id ASC').load
7
+ end
8
+
9
+ def show
10
+ @post = Post.find(params[:id])
11
+ end
12
+
13
+ def renderer
14
+ post = Post.find(params[:id])
15
+ render json: Rabl.render(post, 'posts/renderer', view_path: 'app/views', format: :json, scope: view_context)
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ class UsersController < ApplicationController
2
+ respond_to :json
3
+
4
+ def index
5
+ @users = User.order('username ASC').load
6
+ end
7
+
8
+ def show
9
+ @user = User.find(params[:id])
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ ../../ashared/helpers
@@ -0,0 +1,6 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+
4
+ import { createConsumer } from "@rails/actioncable"
5
+
6
+ export default createConsumer()
@@ -0,0 +1,5 @@
1
+ // Load all the channels within this directory and all subdirectories.
2
+ // Channel files must be named *_channel.js.
3
+
4
+ const channels = require.context('.', true, /_channel\.js$/)
5
+ channels.keys().forEach(channels)
@@ -0,0 +1,17 @@
1
+ // This file is automatically compiled by Webpack, along with any other files
2
+ // present in this directory. You're encouraged to place your actual application logic in
3
+ // a relevant structure within app/javascript and only use these pack files to reference
4
+ // that code so it'll be compiled.
5
+
6
+ require("@rails/ujs").start()
7
+ require("turbolinks").start()
8
+ require("@rails/activestorage").start()
9
+ require("channels")
10
+
11
+
12
+ // Uncomment to copy all static images under ../images to the output folder and reference
13
+ // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
14
+ // or the `imagePath` JavaScript helper below.
15
+ //
16
+ // const images = require.context('../images', true)
17
+ // const imagePath = (name) => images(name, true)
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1 @@
1
+ ../../ashared/models
@@ -0,0 +1 @@
1
+ ../../ashared/views_rails_6/
@@ -0,0 +1,72 @@
1
+ module.exports = function(api) {
2
+ var validEnv = ['development', 'test', 'production']
3
+ var currentEnv = api.env()
4
+ var isDevelopmentEnv = api.env('development')
5
+ var isProductionEnv = api.env('production')
6
+ var isTestEnv = api.env('test')
7
+
8
+ if (!validEnv.includes(currentEnv)) {
9
+ throw new Error(
10
+ 'Please specify a valid `NODE_ENV` or ' +
11
+ '`BABEL_ENV` environment variables. Valid values are "development", ' +
12
+ '"test", and "production". Instead, received: ' +
13
+ JSON.stringify(currentEnv) +
14
+ '.'
15
+ )
16
+ }
17
+
18
+ return {
19
+ presets: [
20
+ isTestEnv && [
21
+ require('@babel/preset-env').default,
22
+ {
23
+ targets: {
24
+ node: 'current'
25
+ }
26
+ }
27
+ ],
28
+ (isProductionEnv || isDevelopmentEnv) && [
29
+ require('@babel/preset-env').default,
30
+ {
31
+ forceAllTransforms: true,
32
+ useBuiltIns: 'entry',
33
+ corejs: 3,
34
+ modules: false,
35
+ exclude: ['transform-typeof-symbol']
36
+ }
37
+ ]
38
+ ].filter(Boolean),
39
+ plugins: [
40
+ require('babel-plugin-macros'),
41
+ require('@babel/plugin-syntax-dynamic-import').default,
42
+ isTestEnv && require('babel-plugin-dynamic-import-node'),
43
+ require('@babel/plugin-transform-destructuring').default,
44
+ [
45
+ require('@babel/plugin-proposal-class-properties').default,
46
+ {
47
+ loose: true
48
+ }
49
+ ],
50
+ [
51
+ require('@babel/plugin-proposal-object-rest-spread').default,
52
+ {
53
+ useBuiltIns: true
54
+ }
55
+ ],
56
+ [
57
+ require('@babel/plugin-transform-runtime').default,
58
+ {
59
+ helpers: false,
60
+ regenerator: true,
61
+ corejs: false
62
+ }
63
+ ],
64
+ [
65
+ require('@babel/plugin-transform-regenerator').default,
66
+ {
67
+ async: false
68
+ }
69
+ ]
70
+ ].filter(Boolean)
71
+ }
72
+ }
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1 || ">= 0.a"
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||= begin
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version || "#{Gem::Requirement.default}.a"
67
+ end
68
+ end
69
+
70
+ def load_bundler!
71
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
72
+
73
+ # must dup string for RG < 1.8 compatibility
74
+ activate_bundler(bundler_version.dup)
75
+ end
76
+
77
+ def activate_bundler(bundler_version)
78
+ if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
79
+ bundler_version = "< 2"
80
+ end
81
+ gem_error = activation_error_handling do
82
+ gem "bundler", bundler_version
83
+ end
84
+ return if gem_error.nil?
85
+ require_error = activation_error_handling do
86
+ require "bundler/version"
87
+ end
88
+ return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
89
+ warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
90
+ exit 42
91
+ end
92
+
93
+ def activation_error_handling
94
+ yield
95
+ nil
96
+ rescue StandardError, LoadError => e
97
+ e
98
+ end
99
+ end
100
+
101
+ m.load_bundler!
102
+
103
+ if m.invoked_as_script?
104
+ load Gem.bin_path("bundler", "bundle")
105
+ end
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ APP_PATH = File.expand_path('../config/application', __dir__)
8
+ require_relative '../config/boot'
9
+ require 'rails/commands'
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ require_relative '../config/boot'
8
+ require 'rake'
9
+ Rake.application.run
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path('..', __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to setup or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at anytime and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies
21
+ # system('bin/yarn')
22
+
23
+ # puts "\n== Copying sample files =="
24
+ # unless File.exist?('config/database.yml')
25
+ # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
26
+ # end
27
+
28
+ puts "\n== Preparing database =="
29
+ system! 'bin/rails db:prepare'
30
+
31
+ puts "\n== Removing old logs and tempfiles =="
32
+ system! 'bin/rails log:clear tmp:clear'
33
+
34
+ puts "\n== Restarting application server =="
35
+ system! 'bin/rails restart'
36
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file loads Spring without using Bundler, in order to be fast.
4
+ # It gets overwritten when you run the `spring binstub` command.
5
+
6
+ unless defined?(Spring)
7
+ require 'rubygems'
8
+ require 'bundler'
9
+
10
+ lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11
+ spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
12
+ if spring
13
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14
+ gem 'spring', spring.version
15
+ require 'spring/binstub'
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "rubygems"
11
+ require "bundler/setup"
12
+
13
+ require "webpacker"
14
+ require "webpacker/webpack_runner"
15
+
16
+ APP_ROOT = File.expand_path("..", __dir__)
17
+ Dir.chdir(APP_ROOT) do
18
+ Webpacker::WebpackRunner.run(ARGV)
19
+ end