rename_params 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/rename_params/converters/hash_converter.rb +13 -0
- data/lib/rename_params/converters/method_converter.rb +14 -0
- data/lib/rename_params/converters/proc_converter.rb +13 -0
- data/lib/rename_params/macros.rb +43 -0
- data/lib/rename_params/params.rb +60 -0
- data/lib/rename_params/version.rb +3 -0
- data/lib/rename_params.rb +8 -0
- data/spec/converters/hash_converter_spec.rb +10 -0
- data/spec/converters/proc_converter_spec.rb +9 -0
- data/spec/macros_spec.rb +224 -0
- data/spec/params_spec.rb +38 -0
- data/spec/rails_helper.rb +7 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/support/apps/rails3_2.rb +87 -0
- data/spec/support/apps/rails4_2.rb +50 -0
- data/spec/support/apps/rails5_0.rb +48 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c798d948488ad8c11d028e24d9be8a81bb7bab9d
|
4
|
+
data.tar.gz: ed7f2081b347fbda162eecd6957e391659f9dd93
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 107d9b836dc24a3b3f10adff2f96b55663ba3f8db91aa735ac6f917324b00e73aee8db1c2f5b4ac7c89a4c641f65847530c7508776eda12b27e500f693b37232
|
7
|
+
data.tar.gz: 86d55fa956d238ccfbffb57f8c5268ffcc91a71d10b9d420396f651053c20a89bfc93e102baf0c3c991cbac2c35c550af839153b8952da4de7cb0ed642497377
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module RenameParams
|
2
|
+
module Macros
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def rename(*args)
|
7
|
+
current_param = args.shift
|
8
|
+
options = build_options(*args)
|
9
|
+
|
10
|
+
before_filter options[:filters] do
|
11
|
+
new_params = RenameParams::Params.new(params, self)
|
12
|
+
new_params.convert(current_param, options[:convert], options[:namespace])
|
13
|
+
new_params.rename(current_param, options[:to], options[:namespace])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def build_options(args = {})
|
20
|
+
{
|
21
|
+
to: args[:to],
|
22
|
+
convert: args[:convert],
|
23
|
+
namespace: namespace_options(args),
|
24
|
+
filters: filter_options(args)
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def namespace_options(args = {})
|
29
|
+
args[:namespace].is_a?(Array) ? args[:namespace] : [args[:namespace]].compact
|
30
|
+
end
|
31
|
+
|
32
|
+
def filter_options(args = {})
|
33
|
+
{
|
34
|
+
only: args.delete(:only),
|
35
|
+
except: args.delete(:except)
|
36
|
+
}.reject { |_, v| v.nil? }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
ActionController::API.send(:include, RenameParams::Macros) if defined?(ActionController::API)
|
43
|
+
ActionController::Base.send(:include, RenameParams::Macros) if defined?(ActionController::Base)
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module RenameParams
|
2
|
+
class Params
|
3
|
+
|
4
|
+
attr_reader :params
|
5
|
+
delegate :[], to: :params
|
6
|
+
|
7
|
+
def initialize(params = {}, controller = nil)
|
8
|
+
@params = params
|
9
|
+
@controller = controller
|
10
|
+
end
|
11
|
+
|
12
|
+
def convert(key, converter, namespace = [])
|
13
|
+
converter = converter_class(converter)
|
14
|
+
|
15
|
+
if converter && has_key?(key, namespace)
|
16
|
+
new_value = converter.convert(get(key, namespace))
|
17
|
+
set(key, new_value)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def rename(key, new_key, namespace = [])
|
22
|
+
set(new_key, delete(key, namespace), namespace) if has_key?(key, namespace)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def set(key, value, namespace = [])
|
28
|
+
namespaced(namespace)[key] = value
|
29
|
+
end
|
30
|
+
|
31
|
+
def get(key, namespace = [])
|
32
|
+
namespaced(namespace)[key]
|
33
|
+
end
|
34
|
+
|
35
|
+
def has_key?(key, namespace = [])
|
36
|
+
namespaced = namespaced(namespace)
|
37
|
+
namespaced.present? && namespaced.has_key?(key)
|
38
|
+
end
|
39
|
+
|
40
|
+
def delete(key, namespace = [])
|
41
|
+
namespaced(namespace).delete(key)
|
42
|
+
end
|
43
|
+
|
44
|
+
def namespaced(namespace = [])
|
45
|
+
params = @params
|
46
|
+
namespace.each { |ns| params = params.present? ? params[ns] : nil }
|
47
|
+
params
|
48
|
+
end
|
49
|
+
|
50
|
+
def converter_class(converter)
|
51
|
+
if converter.is_a?(Hash)
|
52
|
+
RenameParams::Converters::HashConverter.new(converter)
|
53
|
+
elsif converter.is_a?(Proc)
|
54
|
+
RenameParams::Converters::ProcConverter.new(converter)
|
55
|
+
elsif converter.is_a?(Symbol)
|
56
|
+
RenameParams::Converters::MethodConverter.new(converter, @controller)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
require 'action_controller'
|
4
|
+
require 'rename_params/macros'
|
5
|
+
require 'rename_params/params'
|
6
|
+
require 'rename_params/converters/hash_converter'
|
7
|
+
require 'rename_params/converters/proc_converter'
|
8
|
+
require 'rename_params/converters/method_converter'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
describe RenameParams::Converters::HashConverter do
|
2
|
+
|
3
|
+
subject(:converter) { RenameParams::Converters::HashConverter.new(a: 'A', b: 'B') }
|
4
|
+
|
5
|
+
describe '#convert' do
|
6
|
+
it { expect(converter.convert(:a)).to eq 'A' }
|
7
|
+
it { expect(converter.convert(:b)).to eq 'B' }
|
8
|
+
it { expect(converter.convert(:c)).to be_nil }
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
describe RenameParams::Converters::ProcConverter do
|
2
|
+
|
3
|
+
subject(:converter) { RenameParams::Converters::ProcConverter.new(->(value) { value.to_i * 100 }) }
|
4
|
+
|
5
|
+
describe '#convert' do
|
6
|
+
it { expect(converter.convert(1)).to eq 100 }
|
7
|
+
it { expect(converter.convert(2)).to eq 200 }
|
8
|
+
end
|
9
|
+
end
|
data/spec/macros_spec.rb
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
describe RenameParams::Macros, type: :controller do
|
2
|
+
describe '.rename' do
|
3
|
+
|
4
|
+
context 'when not filtering' do
|
5
|
+
let(:default_params) { { 'controller' => 'anonymous', 'action' => 'index' } }
|
6
|
+
before { routes.draw { get 'index' => 'anonymous#index' } }
|
7
|
+
|
8
|
+
describe 'when just renaming params' do
|
9
|
+
controller(ActionController::Base) do
|
10
|
+
rename :username, to: :login
|
11
|
+
|
12
|
+
def index
|
13
|
+
head :ok
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'renames username to login' do
|
18
|
+
get :index, { username: 'aperson' }
|
19
|
+
expect(controller.params).to eq default_params.merge('login' => 'aperson')
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'if param is not sent' do
|
23
|
+
it 'leaves params as they were' do
|
24
|
+
get :index
|
25
|
+
expect(controller.params).to eq default_params
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'when converting values' do
|
31
|
+
context 'and using enum converter' do
|
32
|
+
controller(ActionController::Base) do
|
33
|
+
rename :admin, to: :role, convert: { true: ['admin'], false: [] }
|
34
|
+
|
35
|
+
def index
|
36
|
+
head :ok
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'renames admin to role and converts value' do
|
41
|
+
get :index, { admin: 'true' }
|
42
|
+
expect(controller.params).to eq default_params.merge('role' => ['admin'])
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'if param is not sent' do
|
46
|
+
it 'leaves params as they were' do
|
47
|
+
get :index
|
48
|
+
expect(controller.params).to eq default_params
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'and using a Proc converter' do
|
54
|
+
controller(ActionController::Base) do
|
55
|
+
rename :amount_due, to: :amount_due_in_cents, convert: ->(value) { value.to_i * 100 }
|
56
|
+
|
57
|
+
def index
|
58
|
+
head :ok
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'renames amount_due to amount_due_in_cents and converts value' do
|
63
|
+
get :index, { amount_due: 100 }
|
64
|
+
expect(controller.params).to eq default_params.merge('amount_due_in_cents' => 10000)
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'if param is not sent' do
|
68
|
+
it 'leaves params as they were' do
|
69
|
+
get :index
|
70
|
+
expect(controller.params).to eq default_params
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'and using a method converter' do
|
76
|
+
controller(ActionController::Base) do
|
77
|
+
rename :amount_due, to: :amount_due_in_cents, convert: :to_cents
|
78
|
+
|
79
|
+
def index
|
80
|
+
head :ok
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def to_cents(value)
|
86
|
+
value.to_f * 100
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'renames amount_due to amount_due_in_cents and converts value' do
|
91
|
+
get :index, { amount_due: 100 }
|
92
|
+
expect(controller.params).to eq default_params.merge('amount_due_in_cents' => 10000)
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'if param is not sent' do
|
96
|
+
it 'leaves params as they were' do
|
97
|
+
get :index
|
98
|
+
expect(controller.params).to eq default_params
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe 'when nested params' do
|
105
|
+
context 'using only one namespace' do
|
106
|
+
controller(ActionController::Base) do
|
107
|
+
rename :username, to: :login, namespace: :session
|
108
|
+
|
109
|
+
def index
|
110
|
+
head :ok
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'renames username to login' do
|
115
|
+
get :index, { 'session' => { 'username' => 'aperson' } }
|
116
|
+
expect(controller.params).to eq default_params.merge('session' => { 'login' => 'aperson' })
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'if param is not sent' do
|
120
|
+
it 'leaves params as they were' do
|
121
|
+
get :index, { 'session' => '' }
|
122
|
+
expect(controller.params).to eq default_params.merge('session' => '')
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context 'using more than one nest levels' do
|
128
|
+
controller(ActionController::Base) do
|
129
|
+
rename :username, to: :login, namespace: [:session, :credentials]
|
130
|
+
|
131
|
+
def index
|
132
|
+
head :ok
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'renames username to login' do
|
137
|
+
get :index, { 'session' => { 'credentials' => { 'username' => 'aperson' } } }
|
138
|
+
expect(controller.params).to eq default_params.merge('session' => { 'credentials' => { 'login' => 'aperson' } })
|
139
|
+
end
|
140
|
+
|
141
|
+
context 'if param is not sent' do
|
142
|
+
it 'leaves params as they were' do
|
143
|
+
get :index, { 'session' => { 'credentials' => '' } }
|
144
|
+
expect(controller.params).to eq default_params.merge('session' => { 'credentials' => '' })
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context 'if namespace is not sent' do
|
149
|
+
it 'leaves params as they were' do
|
150
|
+
get :index, { 'session' => '' }
|
151
|
+
expect(controller.params).to eq default_params.merge('session' => '')
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context 'when filtering' do
|
159
|
+
context 'using only' do
|
160
|
+
controller(ActionController::Base) do
|
161
|
+
rename :username, to: :login, only: :show
|
162
|
+
|
163
|
+
def index
|
164
|
+
head :ok
|
165
|
+
end
|
166
|
+
|
167
|
+
def show
|
168
|
+
head :ok
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe 'show' do
|
173
|
+
before { routes.draw { get 'show' => 'anonymous#show' } }
|
174
|
+
|
175
|
+
it 'renames username to login' do
|
176
|
+
get :show, { 'username' => 'aperson' }
|
177
|
+
expect(controller.params).to eq('controller' => 'anonymous', 'action' => 'show', 'login' => 'aperson')
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe 'index' do
|
182
|
+
before { routes.draw { get 'index' => 'anonymous#index' } }
|
183
|
+
|
184
|
+
it 'keeps username param' do
|
185
|
+
get :index, { 'username' => 'aperson' }
|
186
|
+
expect(controller.params).to eq('controller' => 'anonymous', 'action' => 'index', 'username' => 'aperson')
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'using except' do
|
192
|
+
controller(ActionController::Base) do
|
193
|
+
rename :username, to: :login, except: :show
|
194
|
+
|
195
|
+
def index
|
196
|
+
head :ok
|
197
|
+
end
|
198
|
+
|
199
|
+
def show
|
200
|
+
head :ok
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe 'show' do
|
205
|
+
before { routes.draw { get 'show' => 'anonymous#show' } }
|
206
|
+
|
207
|
+
it 'keeps username param' do
|
208
|
+
get :show, { 'username' => 'aperson' }
|
209
|
+
expect(controller.params).to eq('controller' => 'anonymous', 'action' => 'show', 'username' => 'aperson')
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe 'index' do
|
214
|
+
before { routes.draw { get 'index' => 'anonymous#index' } }
|
215
|
+
|
216
|
+
it 'renames username to login' do
|
217
|
+
get :index, { 'username' => 'aperson' }
|
218
|
+
expect(controller.params).to eq('controller' => 'anonymous', 'action' => 'index', 'login' => 'aperson')
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
data/spec/params_spec.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
describe RenameParams::Params do
|
2
|
+
|
3
|
+
subject(:params) { RenameParams::Params.new(a: 'A', b: 'B') }
|
4
|
+
|
5
|
+
describe '#rename' do
|
6
|
+
context 'when params includes given key' do
|
7
|
+
|
8
|
+
before { params.rename(:a, :c) }
|
9
|
+
|
10
|
+
it { expect(params[:a]).to be_nil }
|
11
|
+
it { expect(params[:b]).to eq 'B' }
|
12
|
+
it { expect(params[:c]).to eq 'A' }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'params does not include key' do
|
16
|
+
before { params.rename(:c, :d) }
|
17
|
+
|
18
|
+
it { expect(params[:a]).to eq 'A' }
|
19
|
+
it { expect(params[:b]).to eq 'B' }
|
20
|
+
it { expect(params[:c]).to be_nil }
|
21
|
+
it { expect(params[:d]).to be_nil }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#convert' do
|
26
|
+
context 'when using an Enum converter' do
|
27
|
+
before { params.convert(:b, { 'B' => 'D' }) }
|
28
|
+
|
29
|
+
it { expect(params[:b]).to eq 'D' }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when using a lambda converter' do
|
33
|
+
before { params.convert(:b, ->(old_value) { old_value * 2 }) }
|
34
|
+
|
35
|
+
it { expect(params[:b]).to eq 'BB' }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
ENV['RAILS_ENV'] = 'test'
|
2
|
+
ENV['DATABASE_URL'] = 'sqlite3://localhost/tmp/rename_params_test'
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rails'
|
6
|
+
case Rails.version
|
7
|
+
when '3.2.22.5'
|
8
|
+
require 'support/apps/rails3_2'
|
9
|
+
when '4.2.7.1'
|
10
|
+
require 'support/apps/rails4_2'
|
11
|
+
when '5.0.0.1'
|
12
|
+
require 'support/apps/rails5_0'
|
13
|
+
end
|
14
|
+
require 'rename_params'
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.expect_with :rspec do |expectations|
|
18
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
19
|
+
end
|
20
|
+
|
21
|
+
config.mock_with :rspec do |mocks|
|
22
|
+
mocks.verify_partial_doubles = true
|
23
|
+
end
|
24
|
+
|
25
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
26
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'rails/all'
|
2
|
+
|
3
|
+
module Rails32
|
4
|
+
class Application < Rails::Application
|
5
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
6
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
7
|
+
|
8
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
9
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
10
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
11
|
+
|
12
|
+
# Activate observers that should always be running.
|
13
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
14
|
+
|
15
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
16
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
17
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
18
|
+
|
19
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
20
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
21
|
+
# config.i18n.default_locale = :de
|
22
|
+
|
23
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
24
|
+
config.encoding = "utf-8"
|
25
|
+
|
26
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
27
|
+
config.filter_parameters += [:password]
|
28
|
+
|
29
|
+
# Enable escaping HTML in JSON.
|
30
|
+
config.active_support.escape_html_entities_in_json = true
|
31
|
+
|
32
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
33
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
34
|
+
# like if you have constraints or database-specific column types
|
35
|
+
# config.active_record.schema_format = :sql
|
36
|
+
|
37
|
+
# Enforce whitelist mode for mass assignment.
|
38
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
39
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
40
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
41
|
+
config.active_record.whitelist_attributes = true
|
42
|
+
|
43
|
+
# Enable the asset pipeline
|
44
|
+
config.assets.enabled = true
|
45
|
+
|
46
|
+
# Version of your assets, change this if you want to expire all your assets
|
47
|
+
config.assets.version = '1.0'
|
48
|
+
|
49
|
+
# Settings specified here will take precedence over those in config/application.rb
|
50
|
+
|
51
|
+
# The test environment is used exclusively to run your application's
|
52
|
+
# test suite. You never need to work with it otherwise. Remember that
|
53
|
+
# your test database is "scratch space" for the test suite and is wiped
|
54
|
+
# and recreated between test runs. Don't rely on the data there!
|
55
|
+
config.cache_classes = true
|
56
|
+
|
57
|
+
# Configure static asset server for tests with Cache-Control for performance
|
58
|
+
config.serve_static_assets = true
|
59
|
+
config.static_cache_control = "public, max-age=3600"
|
60
|
+
|
61
|
+
# Log error messages when you accidentally call methods on nil
|
62
|
+
config.whiny_nils = true
|
63
|
+
|
64
|
+
# Show full error reports and disable caching
|
65
|
+
config.consider_all_requests_local = true
|
66
|
+
config.action_controller.perform_caching = false
|
67
|
+
|
68
|
+
# Raise exceptions instead of rendering exception templates
|
69
|
+
config.action_dispatch.show_exceptions = false
|
70
|
+
|
71
|
+
# Disable request forgery protection in test environment
|
72
|
+
config.action_controller.allow_forgery_protection = false
|
73
|
+
|
74
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
75
|
+
# The :test delivery method accumulates sent emails in the
|
76
|
+
# ActionMailer::Base.deliveries array.
|
77
|
+
config.action_mailer.delivery_method = :test
|
78
|
+
|
79
|
+
# Raise exception on mass assignment protection for Active Record models
|
80
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
81
|
+
|
82
|
+
# Print deprecation notices to the stderr
|
83
|
+
config.active_support.deprecation = :stderr
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
Rails32::Application.initialize!
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rails/all'
|
2
|
+
|
3
|
+
module Rails42
|
4
|
+
class Application < Rails::Application
|
5
|
+
config.active_record.raise_in_transactional_callbacks = true
|
6
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
7
|
+
|
8
|
+
# In the development environment your application's code is reloaded on
|
9
|
+
# every request. This slows down response time but is perfect for development
|
10
|
+
# since you don't have to restart the web server when you make code changes.
|
11
|
+
config.cache_classes = false
|
12
|
+
|
13
|
+
# Do not eager load code on boot.
|
14
|
+
config.eager_load = false
|
15
|
+
|
16
|
+
# Show full error reports and disable caching.
|
17
|
+
config.consider_all_requests_local = true
|
18
|
+
config.action_controller.perform_caching = false
|
19
|
+
|
20
|
+
# Don't care if the mailer can't send.
|
21
|
+
config.action_mailer.raise_delivery_errors = false
|
22
|
+
|
23
|
+
# Print deprecation notices to the Rails logger.
|
24
|
+
config.active_support.deprecation = :log
|
25
|
+
|
26
|
+
# Raise an error on page load if there are pending migrations.
|
27
|
+
config.active_record.migration_error = :page_load
|
28
|
+
|
29
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
30
|
+
# This option may cause significant delays in view rendering with a large
|
31
|
+
# number of complex assets.
|
32
|
+
config.assets.debug = true
|
33
|
+
|
34
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
35
|
+
# yet still be able to expire them through the digest params.
|
36
|
+
config.assets.digest = true
|
37
|
+
|
38
|
+
# Adds additional error checking when serving assets at runtime.
|
39
|
+
# Checks for improperly declared sprockets dependencies.
|
40
|
+
# Raises helpful error messages.
|
41
|
+
config.assets.raise_runtime_errors = true
|
42
|
+
|
43
|
+
# Raises error for missing translations
|
44
|
+
# config.action_view.raise_on_missing_translations = true
|
45
|
+
|
46
|
+
config.secret_key_base = '49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
Rails.application.initialize!
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rails/all'
|
2
|
+
|
3
|
+
module Rails50
|
4
|
+
class Application < Rails::Application
|
5
|
+
# The test environment is used exclusively to run your application's
|
6
|
+
# test suite. You never need to work with it otherwise. Remember that
|
7
|
+
# your test database is "scratch space" for the test suite and is wiped
|
8
|
+
# and recreated between test runs. Don't rely on the data there!
|
9
|
+
config.cache_classes = true
|
10
|
+
|
11
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
12
|
+
# just for the purpose of running a single test. If you are using a tool that
|
13
|
+
# preloads Rails for running tests, you may have to set it to true.
|
14
|
+
config.eager_load = false
|
15
|
+
|
16
|
+
# Configure public file server for tests with Cache-Control for performance.
|
17
|
+
config.public_file_server.enabled = true
|
18
|
+
config.public_file_server.headers = {
|
19
|
+
'Cache-Control' => 'public, max-age=3600'
|
20
|
+
}
|
21
|
+
|
22
|
+
# Show full error reports and disable caching.
|
23
|
+
config.consider_all_requests_local = true
|
24
|
+
config.action_controller.perform_caching = false
|
25
|
+
|
26
|
+
# Raise exceptions instead of rendering exception templates.
|
27
|
+
config.action_dispatch.show_exceptions = false
|
28
|
+
|
29
|
+
# Disable request forgery protection in test environment.
|
30
|
+
config.action_controller.allow_forgery_protection = false
|
31
|
+
config.action_mailer.perform_caching = false
|
32
|
+
|
33
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
34
|
+
# The :test delivery method accumulates sent emails in the
|
35
|
+
# ActionMailer::Base.deliveries array.
|
36
|
+
config.action_mailer.delivery_method = :test
|
37
|
+
|
38
|
+
# Print deprecation notices to the stderr.
|
39
|
+
config.active_support.deprecation = :stderr
|
40
|
+
|
41
|
+
# Raises error for missing translations
|
42
|
+
# config.action_view.raise_on_missing_translations = true
|
43
|
+
|
44
|
+
config.secret_key_base = '49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Rails.application.initialize!
|
metadata
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rename_params
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.rc1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marcelo Casiraghi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: actionpack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: appraisal
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Simple params renaming for Rails applications
|
126
|
+
email: marcelo@paragon-labs.com
|
127
|
+
executables: []
|
128
|
+
extensions: []
|
129
|
+
extra_rdoc_files: []
|
130
|
+
files:
|
131
|
+
- lib/rename_params.rb
|
132
|
+
- lib/rename_params/converters/hash_converter.rb
|
133
|
+
- lib/rename_params/converters/method_converter.rb
|
134
|
+
- lib/rename_params/converters/proc_converter.rb
|
135
|
+
- lib/rename_params/macros.rb
|
136
|
+
- lib/rename_params/params.rb
|
137
|
+
- lib/rename_params/version.rb
|
138
|
+
- spec/converters/hash_converter_spec.rb
|
139
|
+
- spec/converters/proc_converter_spec.rb
|
140
|
+
- spec/macros_spec.rb
|
141
|
+
- spec/params_spec.rb
|
142
|
+
- spec/rails_helper.rb
|
143
|
+
- spec/spec_helper.rb
|
144
|
+
- spec/support/apps/rails3_2.rb
|
145
|
+
- spec/support/apps/rails4_2.rb
|
146
|
+
- spec/support/apps/rails5_0.rb
|
147
|
+
homepage: http://rubygems.org/gems/rename_params
|
148
|
+
licenses:
|
149
|
+
- MIT
|
150
|
+
metadata: {}
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">"
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: 1.3.1
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 2.5.1
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: Simple params renaming for Rails applications
|
171
|
+
test_files:
|
172
|
+
- spec/converters/hash_converter_spec.rb
|
173
|
+
- spec/converters/proc_converter_spec.rb
|
174
|
+
- spec/macros_spec.rb
|
175
|
+
- spec/params_spec.rb
|
176
|
+
- spec/rails_helper.rb
|
177
|
+
- spec/spec_helper.rb
|
178
|
+
- spec/support/apps/rails3_2.rb
|
179
|
+
- spec/support/apps/rails4_2.rb
|
180
|
+
- spec/support/apps/rails5_0.rb
|