|
1 | 1 | # frozen_string_literal: true
|
2 | 2 |
|
3 | 3 | Synvert::Rewriter.new 'rails', 'convert_configs_4_2_to_5_0' do
|
4 |
| - configure(parser: Synvert::PARSER_PARSER) |
| 4 | + configure(parser: Synvert::PRISM_PARSER) |
5 | 5 |
|
6 | 6 | description <<~EOS
|
7 | 7 | It converts rails configs 4.2 to 5.0
|
|
25 | 25 |
|
26 | 26 | within_file 'config/application.rb' do
|
27 | 27 | # remove config.raise_in_transactional_callbacks = true
|
28 |
| - with_node node_type: 'send', message: 'raise_in_transactional_callbacks=' do |
| 28 | + with_node node_type: 'call_node', name: 'raise_in_transactional_callbacks=' do |
29 | 29 | remove
|
30 | 30 | end
|
31 | 31 | end
|
|
34 | 34 | # config.static_cache_control = 'public, max-age=31536000'
|
35 | 35 | # =>
|
36 | 36 | # config.public_file_server.headers = { "Cache-Control" => 'public, max-age=31536000' }
|
37 |
| - with_node node_type: 'send', message: 'static_cache_control=' do |
| 37 | + with_node node_type: 'call_node', name: 'static_cache_control=' do |
38 | 38 | replace_with '{{receiver}}.public_file_server.headers = { "Cache-Control" => {{arguments}} }'
|
39 | 39 | end
|
40 | 40 |
|
41 | 41 | # config.serve_static_files = true
|
42 | 42 | # =>
|
43 | 43 | # config.public_file_server.enabled = true
|
44 |
| - with_node node_type: 'send', message: 'serve_static_files=' do |
45 |
| - replace :message, with: 'public_file_server.enabled =' |
| 44 | + with_node node_type: 'call_node', name: 'serve_static_files=' do |
| 45 | + replace :message, with: 'public_file_server.enabled' |
46 | 46 | end
|
47 | 47 |
|
48 | 48 | # config.middleware.use "Foo::Bar"
|
49 | 49 | # =>
|
50 | 50 | # config.middleware.use Foo::Bar
|
51 |
| - with_node node_type: 'send', |
| 51 | + with_node node_type: 'call_node', |
52 | 52 | receiver: {
|
53 |
| - node_type: 'send', |
| 53 | + node_type: 'call_node', |
54 | 54 | receiver: 'config',
|
55 |
| - message: 'middleware' |
| 55 | + name: 'middleware' |
56 | 56 | },
|
57 |
| - message: 'use', |
58 |
| - arguments: { |
59 |
| - first: { |
60 |
| - node_type: 'str' |
61 |
| - } |
62 |
| - } do |
63 |
| - replace 'arguments.first', with: "{{arguments.first.to_value}}" |
| 57 | + name: 'use', |
| 58 | + arguments: { node_type: 'arguments_node', arguments: { size: { gt: 0 }, first: { node_type: 'string_node' } } } do |
| 59 | + replace 'arguments.arguments.first', with: "{{arguments.arguments.first.to_value}}" |
64 | 60 | end
|
65 | 61 | end
|
66 | 62 |
|
67 |
| - new_code = <<~EOS |
| 63 | + new_code = <<~EOS.strip |
68 | 64 | # Be sure to restart your server when you modify this file.
|
69 | 65 | #
|
70 | 66 | # This file contains migration options to ease your Rails 5.0 upgrade.
|
|
90 | 86 | # Configure SSL options to enable HSTS with subdomains. Previous versions had false.
|
91 | 87 | Rails.application.config.ssl_options = { hsts: { subdomains: true } }
|
92 | 88 | EOS
|
93 |
| - add_file 'config/initializers/new_framework_defaults.rb', new_code.strip |
| 89 | + add_file 'config/initializers/new_framework_defaults.rb', new_code |
94 | 90 | end
|
0 commit comments