opal-rails 1.1.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/{main.yml → build.yml} +13 -6
  3. data/.gitignore +1 -0
  4. data/Appraisals +17 -16
  5. data/CHANGELOG.md +49 -0
  6. data/Gemfile +8 -3
  7. data/README.md +50 -16
  8. data/app/helpers/opal_helper.rb +6 -5
  9. data/bin/rackup +29 -0
  10. data/bin/rails +8 -0
  11. data/bin/rails-engine +13 -0
  12. data/bin/rails-sandbox +18 -0
  13. data/bin/rake +29 -0
  14. data/bin/rspec +29 -0
  15. data/bin/sandbox +39 -0
  16. data/bin/sandbox-setup +14 -0
  17. data/bin/setup +8 -0
  18. data/config.ru +1 -2
  19. data/gemfiles/rails_6_0_opal_1_0.gemfile +1 -3
  20. data/gemfiles/rails_6_0_opal_1_1.gemfile +9 -0
  21. data/gemfiles/rails_6_0_opal_1_3.gemfile +10 -0
  22. data/gemfiles/rails_6_0_opal_1_4.gemfile +10 -0
  23. data/gemfiles/rails_6_1_opal_1_0.gemfile +10 -0
  24. data/gemfiles/rails_6_1_opal_1_1.gemfile +9 -0
  25. data/gemfiles/rails_6_1_opal_1_3.gemfile +10 -0
  26. data/gemfiles/rails_6_1_opal_1_4.gemfile +10 -0
  27. data/gemfiles/rails_7_0_opal_1_0.gemfile +10 -0
  28. data/gemfiles/rails_7_0_opal_1_3.gemfile +10 -0
  29. data/gemfiles/rails_7_0_opal_1_4.gemfile +10 -0
  30. data/lib/assets/javascripts/opal_ujs.js.rb +1 -4
  31. data/lib/generators/opal/assets/assets_generator.rb +7 -0
  32. data/lib/{rails/generators → generators}/opal/assets/templates/javascript.js.rb +0 -0
  33. data/lib/generators/opal/install/USAGE +8 -0
  34. data/lib/generators/opal/install/install_generator.rb +14 -0
  35. data/lib/generators/opal/install/templates/application.js.rb +12 -0
  36. data/lib/generators/opal/install/templates/initializer.rb +22 -0
  37. data/lib/opal/rails/engine.rb +1 -0
  38. data/lib/opal/rails/template_handler.rb +4 -2
  39. data/lib/opal/rails/version.rb +1 -1
  40. data/lib/opal/rails.rb +0 -4
  41. data/opal-rails.gemspec +45 -40
  42. data/spec/helpers/opal_helper_spec.rb +23 -9
  43. data/spec/integration/source_map_spec.rb +9 -5
  44. data/spec/support/test_app.rb +1 -2
  45. data/test_apps/{application_controller.rb → app/application_controller.rb} +1 -1
  46. data/test_apps/app/assets/config/manifest.js +1 -0
  47. data/test_apps/{assets → app/assets}/javascripts/application.js.rb +1 -0
  48. data/test_apps/{assets → app/assets}/javascripts/bar.rb +0 -0
  49. data/test_apps/{assets → app/assets}/javascripts/foo.js.rb +0 -0
  50. data/test_apps/{assets → app/assets}/javascripts/source_map_example.js.rb +0 -0
  51. data/test_apps/{assets → app/assets}/javascripts/with_assignments.js.rb +0 -0
  52. data/test_apps/{rails6.rb → rails.rb} +1 -3
  53. metadata +56 -83
  54. data/gemfiles/rails_5_1_opal_1_0.gemfile +0 -12
  55. data/gemfiles/rails_5_1_opal_master.gemfile +0 -11
  56. data/gemfiles/rails_5_2_opal_1_0.gemfile +0 -12
  57. data/gemfiles/rails_5_2_opal_master.gemfile +0 -11
  58. data/gemfiles/rails_6_0_opal_master.gemfile +0 -11
  59. data/lib/rails/generators/opal/assets/assets_generator.rb +0 -12
  60. data/test_apps/rails5.rb +0 -50
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d61bba3aec7f4e72f6415ff750bc0a41af46a8ce59a701c566b8f85fb5468d7
4
- data.tar.gz: ce19e5c523a251b03a06ef8b2b322e45238909d6bdb4b6a169bcf8c08e6f8223
3
+ metadata.gz: aee279d2054d467d1e1c9088a1342fe8d75e7ec2affce2504b61b9b885cdb38b
4
+ data.tar.gz: 4828f47994349fff41a915fd3e21ea7b83052b3eb1ca5c56d3b09fe77676f22d
5
5
  SHA512:
6
- metadata.gz: fc73e4fc9f70678e509496a0bb17d05b2da13072b0e1568067a82d5839ee0c5f2054646883eb8506d79a86314b5f1b755a7f5d6dc4f2bee88fbafcb907ceabe4
7
- data.tar.gz: 3d653b799aa04cd98e4272df376c62c3df95c29195279e0d734d272166018b84fcd922f490f5cb9a03d6cb6c32174b00bfd4ebf1459a24173db0c17a5b8e665d
6
+ metadata.gz: 44de5b40a2352e01fe1f830f35a79ffa4509078002bef98689fbd4827ed5e53b34b141155dddd982515debc70b018c1eece879ca2957bcbfc9c81bca9600b764
7
+ data.tar.gz: 8b89cfd6f4778b746f8977f0bb20729766603b97840b56068bfa3ad04113aa8ac9cd2859616885b226c0252dd4114e00b2053aaee828715cbcd0bf94e49b7e5e
@@ -1,13 +1,20 @@
1
- name: CI
2
- on: [push]
1
+ on:
2
+ pull_request:
3
+ branches:
4
+ - master
5
+ push:
6
+ branches:
7
+ - ci-check
8
+ - "*/ci-check"
9
+ - master
3
10
 
4
11
  jobs:
5
12
  build:
6
13
  strategy:
7
14
  matrix:
8
- ruby: ['2.5.x', '2.6.x']
9
- rails: ['rails_5_1', 'rails_5_2', 'rails_6_0']
10
- opal: ['opal_1_0', 'opal_master']
15
+ ruby: ['2.7', '3.0'] # ['3.1'] - enable once Rails 7.0.1 is released
16
+ rails: ['rails_6_0', 'rails_6_1', 'rails_7_0']
17
+ opal: ['opal_1_0', 'opal_1_3', 'opal_1_4']
11
18
  runs-on: ubuntu-latest
12
19
 
13
20
  steps:
@@ -17,7 +24,7 @@ jobs:
17
24
  sudo apt-get install -y sqlite3 libsqlite3-dev
18
25
  - uses: actions/checkout@v1
19
26
  - name: Set up Ruby
20
- uses: actions/setup-ruby@v1
27
+ uses: ruby/setup-ruby@v1
21
28
  with:
22
29
  ruby-version: ${{ matrix.ruby }}
23
30
  - name: Install Dependencies
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ /sandbox
1
2
  /.bundle/
2
3
  /log/*.log
3
4
  /pkg/
data/Appraisals CHANGED
@@ -1,39 +1,40 @@
1
1
  current_ruby = Gem::Version.new(RUBY_VERSION)
2
- ruby_2_4_0 = Gem::Version.new('2.4.0')
3
2
  ruby_2_5_0 = Gem::Version.new('2.5.0')
3
+ ruby_2_7_0 = Gem::Version.new('2.7.0')
4
4
 
5
5
  ENV['OPAL_VERSION'] = nil # ensure the env is clean
6
6
 
7
7
  github = -> repo_name { "https://github.com/#{repo_name}.git" }
8
8
 
9
9
  {
10
+ opal_1_4: -> gemfile do
11
+ gemfile.gem 'opal', '~> 1.4.0'
12
+ gemfile.gem 'opal-sprockets'
13
+ end,
10
14
 
11
- opal_master: -> gemfile do
12
- gemfile.gem 'opal', git: github['opal/opal'], branch: :master
13
- gemfile.gem 'opal-rspec', git: github['opal/opal-rspec'], branch: :master
14
- gemfile.gem 'opal-sprockets', git: github['opal/opal-sprockets'], branch: :master
15
+ opal_1_3: -> gemfile do
16
+ gemfile.gem 'opal', '~> 1.3.0'
17
+ gemfile.gem 'opal-sprockets'
15
18
  end,
16
19
 
17
20
  opal_1_0: -> gemfile do
18
21
  gemfile.gem 'opal', '~> 1.0.0'
19
- gemfile.gem 'opal-rspec', git: github['opal/opal-rspec'], branch: :master
20
- gemfile.gem 'opal-jquery', git: github['opal/opal-jquery'], branch: :master
21
22
  gemfile.gem 'opal-sprockets'
22
23
  end,
23
24
 
24
25
  }.each do |opal_version, gem_opal|
25
- appraise "rails_5_1_#{opal_version}" do
26
- gem "rails", "~> 5.1.0"
26
+ appraise "rails_6_0_#{opal_version}" do
27
+ gem "rails", "~> 6.0.0"
27
28
  gem_opal[self]
28
- end if current_ruby >= ruby_2_4_0
29
+ end if current_ruby >= ruby_2_5_0
29
30
 
30
- appraise "rails_5_2_#{opal_version}" do
31
- gem "rails", "~> 5.2.0"
31
+ appraise "rails_6_1_#{opal_version}" do
32
+ gem "rails", "~> 6.1.0"
32
33
  gem_opal[self]
33
- end if current_ruby >= ruby_2_4_0
34
+ end if current_ruby >= ruby_2_5_0
34
35
 
35
- appraise "rails_6_0_#{opal_version}" do
36
- gem "rails", "~> 6.0.0"
36
+ appraise "rails_7_0_#{opal_version}" do
37
+ gem "rails", "~> 7.0.0"
37
38
  gem_opal[self]
38
- end if current_ruby >= ruby_2_5_0
39
+ end if current_ruby >= ruby_2_7_0
39
40
  end
data/CHANGELOG.md CHANGED
@@ -20,6 +20,55 @@ Whitespace conventions:
20
20
 
21
21
 
22
22
 
23
+ ## [2.0.2](https://github.com/opal/opal-rails/compare/v2.0.1...v2.0.2) - 2021-12-29
24
+
25
+
26
+ ### Added
27
+
28
+ - Allow Rails 7
29
+
30
+
31
+ ## [2.0.1](https://github.com/opal/opal-rails/compare/v2.0.0...v2.0.1) - 2021-03-03
32
+
33
+
34
+ ### Added
35
+
36
+ - The install generator now will add an `opal.rb` initializer with a default compiler configuration and the template assign support disabled
37
+
38
+ ### Fixed
39
+
40
+ - The install generator was missing a newline when changing the app layout
41
+
42
+
43
+ ## [2.0.0](https://github.com/opal/opal-rails/compare/v1.1.2...v2.0.0) - 2021-02-23
44
+
45
+ *This is a major version, since a number of dependencies are going to be opt-in and support for older Rails
46
+ and Sprockets versions is dropped*
47
+
48
+ ### Added
49
+
50
+ - Added support for Rails v6.1
51
+ - Added a generator for the initial setup (`bin/rails generate opal:install`) that will configure sprockets and create the main `application.js.rb`
52
+
53
+ ### Changed
54
+
55
+ - Now the template handler will encode/decode local and instance variables with ActiveSupport::JSON
56
+
57
+ ### Removed
58
+
59
+ - Removed support for Rails 5.x
60
+ - `opal-jquery` and `opal-activesupport` are no longer dependencies of `opal-rails`, if you need them you'll need to require and setup them manually
61
+
62
+
63
+ ## [1.1.2](https://github.com/opal/opal-rails/compare/v1.1.1...v1.1.2) - 2019-09-26
64
+
65
+
66
+ ### Fixed
67
+
68
+ - Default `skip_onload` to `true` when `javascript_asset_tag` is in debug mode, otherwise some assets may be loaded in the browser after the main source, thus being never loading by the Opal runtime.
69
+
70
+
71
+
23
72
 
24
73
  ## [1.1.1](https://github.com/opal/opal-rails/compare/v1.1.0...v1.1.1) - 2019-09-14
25
74
 
data/Gemfile CHANGED
@@ -2,10 +2,15 @@ source 'https://rubygems.org'
2
2
  gemspec
3
3
  github = -> repo { "https://github.com/#{repo}.git" }
4
4
 
5
- if ENV['OPAL_VERSION'] == 'master'
5
+ case ENV['OPAL_VERSION']
6
+ when 'local'
7
+ gem 'opal', path: '../opal'
8
+ gem 'opal-rspec', path: '../opal-rspec'
9
+ gem 'opal-sprockets', path: '../opal-sprockets'
10
+ gem 'pry'
11
+ when 'master'
6
12
  gem 'opal', git: github['opal/opal'], branch: :master
7
- gem 'opal-rspec', git: github['opal/opal-rspec'], branch: :master
8
13
  gem 'opal-sprockets', git: github['opal/opal-sprockets'], branch: :master
9
14
  end
10
15
 
11
- gem 'c_lexer'
16
+ gem 'net-smtp'
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Opal Rails
2
2
 
3
- [![Build Status](https://github.com/opal/opal-rails/workflows/CI/badge.svg)](https://github.com/opal/opal-rails/actions)
3
+ [![Build Status](https://github.com/opal/opal-rails/actions/workflows/build.yml/badge.svg)](https://github.com/opal/opal-rails/actions/workflows/build.yml)
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/31dda24adcecb836348f/maintainability)](https://codeclimate.com/github/opal/opal-rails/maintainability)
5
5
  [![Gem Version](https://badge.fury.io/rb/opal-rails.svg)](http://badge.fury.io/rb/opal-rails)
6
6
  ![fun guaranteed](https://img.shields.io/badge/fun-guaranteed-brightgreen.svg)
@@ -8,12 +8,13 @@
8
8
 
9
9
  _Rails bindings for [Opal](http://opalrb.com). ([Changelog](https://github.com/opal/opal-rails/blob/master/CHANGELOG.md))_
10
10
 
11
- ### Looking Webpack support? 👀
11
+ ### Looking for Webpack support? 👀
12
12
 
13
13
  If you want to integrate Opal via Webpack please refer to [opal-webpack-loader](https://github.com/isomorfeus/opal-webpack-loader#installation) installation instructions.
14
14
 
15
15
  ℹ️ Webpack and ES6 modules are not yet officially supported, but we're working on it thanks to the awesome work done in _opal-webpack-loader_.
16
16
 
17
+
17
18
  ## Installation
18
19
 
19
20
  In your `Gemfile`
@@ -22,36 +23,46 @@ In your `Gemfile`
22
23
  gem 'opal-rails'
23
24
  ```
24
25
 
25
- or when you build your new Rails app:
26
+ Add `app/assets/javascript` to your asset-pipeline manifest in `app/assets/config/manifest.js`:
26
27
 
27
- ```bash
28
- rails new <app-name> --javascript=opal
28
+ ```
29
+ bin/rails opal:install
29
30
  ```
30
31
 
31
32
 
32
33
  ### Configuration
33
34
 
34
- Add your configuration in `config/initializers/assets.rb` with the following contents:
35
+ #### For the compiler
36
+
37
+ Add your configuration for the compiler:
38
+
39
+ `config/initializers/opal.rb`
35
40
 
36
41
  ```ruby
37
42
  # Compiler options
38
- Rails.application.config.opal.method_missing = true
39
- Rails.application.config.opal.optimized_operators = true
40
- Rails.application.config.opal.arity_check = !Rails.env.production?
41
- Rails.application.config.opal.const_missing = true
43
+ Rails.application.config.opal.method_missing_enabled = true
44
+ Rails.application.config.opal.const_missing_enabled = true
45
+ Rails.application.config.opal.arity_check_enabled = true
46
+ Rails.application.config.opal.freezing_stubs_enabled = true
42
47
  Rails.application.config.opal.dynamic_require_severity = :ignore
48
+ ```
49
+
50
+ Check out the full list of the available configuration options at: [lib/opal/config.rb](https://github.com/opal/opal/blob/master/lib/opal/config.rb).
43
51
 
44
- # Other options
52
+ #### For template assigns
45
53
 
46
- # Send local and instance variables down to the view after converting
47
- # thier value with `.to_json`
54
+ Add your configuration for rendering assigns when using the template handler from actions:
55
+
56
+ `config/initializers/opal.rb`
57
+
58
+ ```ruby
48
59
  Rails.application.config.opal.assigns_in_templates = true
49
60
  Rails.application.config.opal.assigns_in_templates = :locals # only locals
50
61
  Rails.application.config.opal.assigns_in_templates = :ivars # only instance variables
51
62
  ```
52
63
 
53
- For a full list of the available configuration options for the compiler please refer to: [lib/opal/config.rb](https://github.com/opal/opal/blob/master/lib/opal/config.rb).
54
64
 
65
+ Local and instance variables will be sent down to the view after converting their values to JSON.
55
66
 
56
67
 
57
68
  ## Usage
@@ -190,7 +201,6 @@ Of course you need to require `haml-rails` separately since its presence is not
190
201
  Element.find('.comments').effect(:fade_in)
191
202
  end
192
203
  end
193
-
194
204
  ```
195
205
 
196
206
 
@@ -256,10 +266,34 @@ Opal.use_gem 'cannonbol'
256
266
  ```
257
267
 
258
268
 
269
+ ## Contributing
270
+
271
+ Run the specs:
272
+
273
+ ```
274
+ bin/setup
275
+ bin/rake
276
+ ```
277
+
278
+ Inspect the test app:
279
+
280
+ ```
281
+ bin/rackup
282
+ # visit localhost:9292
283
+ ```
284
+
285
+ Tinker with a sandbox app:
286
+
287
+ ```
288
+ bin/sandbox # will re-create the app
289
+ bin/rails s # will start the sandbox app server
290
+ # visit localhost:3000
291
+ ```
292
+
259
293
 
260
294
  ## License
261
295
 
262
- © 2012-2019 Elia Schito
296
+ © 2012-2021 Elia Schito
263
297
 
264
298
  Permission is hereby granted, free of charge, to any person obtaining a copy
265
299
  of this software and associated documentation files (the "Software"), to deal
@@ -10,20 +10,21 @@ module OpalHelper
10
10
  end
11
11
 
12
12
  def javascript_include_tag(*sources)
13
- options = sources.extract_options!
13
+ options = sources.extract_options!.symbolize_keys
14
+ debug = options[:debug] != false
14
15
  skip_loader = options.delete(:skip_opal_loader)
15
- skip_onload = options.delete(:force_opal_loader_tag)
16
+ force_opal_loader_tag = options.delete(:force_opal_loader_tag) || debug
16
17
 
17
- return super(*sources, options) if skip_loader
18
+ return super(*sources, options) if skip_loader && !force_opal_loader_tag
18
19
 
19
20
  script_tags = "".html_safe
20
21
  sources.each do |source|
21
22
  load_asset_code = Opal::Sprockets.load_asset(source)
22
23
  loading_code = "if(window.Opal && Opal.modules[#{source.to_json}]){#{load_asset_code}}"
23
24
 
24
- if skip_onload
25
+ if force_opal_loader_tag
25
26
  script_tags << super(source, options)
26
- script_tags << javascript_tag(loading_code)
27
+ script_tags << "\n".html_safe + javascript_tag(loading_code)
27
28
  else
28
29
  script_tags << super(source, options.merge(onload: loading_code))
29
30
  end
data/bin/rackup ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rackup' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rack", "rackup")
data/bin/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if %w[e engine].include? ARGV.first
4
+ ARGV.shift # remove the first argument
5
+ exec "#{__dir__}/rails-engine", *ARGV
6
+ else
7
+ exec "#{__dir__}/rails-sandbox", *ARGV
8
+ end
data/bin/rails-engine ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/opal/rails/engine', __dir__)
7
+
8
+ # Set up gems listed in the Gemfile.
9
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
10
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
+
12
+ require 'rails/all'
13
+ require 'rails/engine/commands'
data/bin/rails-sandbox ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ app_root = 'sandbox'
6
+
7
+ unless File.exist? "#{app_root}/bin/rails"
8
+ warn 'Creating the sandbox app...'
9
+ Dir.chdir "#{__dir__}/.." do
10
+ system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
11
+ warn 'Automatic creation of the sandbox app failed'
12
+ exit 1
13
+ end
14
+ end
15
+ end
16
+
17
+ Dir.chdir app_root
18
+ exec 'bin/rails', *ARGV
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/sandbox ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem_name="$(ruby -rpathname -e"puts Pathname(ARGV.first).join('../..').expand_path.glob('*.gemspec').first.basename('.gemspec')" -- $0)"
4
+
5
+ # Stay away from the bundler env of the containing extension.
6
+ function unbundled {
7
+ ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
8
+ }
9
+
10
+ rm -rf ./sandbox
11
+ unbundled bundle exec rails new sandbox \
12
+ --skip-bundle \
13
+ --skip-git \
14
+ --skip-keeps \
15
+ --skip-rc \
16
+ --skip-spring \
17
+ --skip-test \
18
+ $@
19
+
20
+ if [ ! -d "sandbox" ]; then
21
+ echo 'sandbox rails application failed'
22
+ exit 1
23
+ fi
24
+
25
+ cd ./sandbox
26
+ cat <<RUBY >> Gemfile
27
+ gem '$gem_name', path: '..'
28
+ RUBY
29
+
30
+ unbundled bundle install --gemfile Gemfile
31
+ unbundled bin/rails webpacker:install
32
+
33
+
34
+ cd .. # Back to the project root.
35
+ bin/sandbox-setup # Run any custom setup.
36
+
37
+ echo
38
+ echo "🚀 Sandbox app successfully created for $gem_name!"
39
+
data/bin/sandbox-setup ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pathname'
4
+
5
+ root = Pathname('sandbox')
6
+
7
+ system 'bin/rails g opal:install'
8
+ system 'bin/rails g controller home index -f'
9
+
10
+ root.join('config/routes.rb').write <<~RUBY
11
+ Rails.application.routes.draw do
12
+ root to: "home#index"
13
+ end
14
+ RUBY
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ gem install bundler --conservative
7
+
8
+ bundle update
data/config.ru CHANGED
@@ -2,9 +2,8 @@
2
2
 
3
3
  require 'bundler/setup'
4
4
  require 'rails'
5
- rails_version = Rails::VERSION::MAJOR
6
5
  ENV["RAILS_ENV"] = "test"
7
6
  ENV['DATABASE_URL'] = 'sqlite3::memory:'
8
- require_relative "test_apps/rails#{rails_version}"
7
+ require_relative "test_apps/rails"
9
8
 
10
9
  run RailsApp::Application
@@ -2,11 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "c_lexer"
5
+ gem "net-smtp"
6
6
  gem "rails", "~> 6.0.0"
7
7
  gem "opal", "~> 1.0.0"
8
- gem "opal-rspec", git: "https://github.com/opal/opal-rspec.git", branch: :master
9
- gem "opal-jquery", git: "https://github.com/opal/opal-jquery.git", branch: :master
10
8
  gem "opal-sprockets"
11
9
 
12
10
  gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 6.0.0"
6
+ gem "opal", "~> 1.1.0"
7
+ gem "opal-sprockets"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "net-smtp"
6
+ gem "rails", "~> 6.0.0"
7
+ gem "opal", "~> 1.3.0"
8
+ gem "opal-sprockets"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "net-smtp"
6
+ gem "rails", "~> 6.0.0"
7
+ gem "opal", "~> 1.4.0"
8
+ gem "opal-sprockets"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "net-smtp"
6
+ gem "rails", "~> 6.1.0"
7
+ gem "opal", "~> 1.0.0"
8
+ gem "opal-sprockets"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 6.1.0"
6
+ gem "opal", "~> 1.1.0"
7
+ gem "opal-sprockets"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "net-smtp"
6
+ gem "rails", "~> 6.1.0"
7
+ gem "opal", "~> 1.3.0"
8
+ gem "opal-sprockets"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "net-smtp"
6
+ gem "rails", "~> 6.1.0"
7
+ gem "opal", "~> 1.4.0"
8
+ gem "opal-sprockets"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "net-smtp"
6
+ gem "rails", "~> 7.0.0"
7
+ gem "opal", "~> 1.0.0"
8
+ gem "opal-sprockets"
9
+
10
+ gemspec path: "../"