Skip to content

Commit 603ee67

Browse files
committed
Remove Rails 3.2 support
1 parent a2d68aa commit 603ee67

File tree

7 files changed

+11
-43
lines changed

7 files changed

+11
-43
lines changed

Appraisals

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
appraise "rails32" do
2-
gem "railties", "~> 3.2.22.5"
3-
gem 'tzinfo'
4-
end
5-
61
def define_appraisal(rails, version, sprockets)
72
sprockets.each do |sprocket|
83
appraise "#{rails}-sprockets-#{sprocket}" do
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<%# encoding: UTF-8 %>
2-
<%= JsRoutes.assert_usable_configuration! && JsRoutes.generate %>
2+
<%= JsRoutes.generate %>

gemfiles/rails32.gemfile

-8
This file was deleted.

lib/js_routes.rb

-11
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,6 @@ def generate!(file_name=nil, opts = {})
9898
new(opts).generate!(file_name)
9999
end
100100

101-
# Under rails 3.1.1 and higher, perform a check to ensure that the
102-
# full environment will be available during asset compilation.
103-
# This is required to ensure routes are loaded.
104-
def assert_usable_configuration!
105-
if 3 == Rails::VERSION::MAJOR && !Rails.application.config.assets.initialize_on_precompile
106-
raise("Cannot precompile js-routes unless environment is initialized. Please set config.assets.initialize_on_precompile to true.")
107-
end
108-
true
109-
end
110-
111101
def json(string)
112102
ActiveSupport::JSON.encode(string)
113103
end
@@ -130,7 +120,6 @@ def generate
130120
{
131121
"GEM_VERSION" => JsRoutes::VERSION,
132122
"ROUTES" => js_routes,
133-
"DEPRECATED_BEHAVIOR" => Rails.version < "4",
134123
"NODE_TYPES" => json(NODE_TYPES),
135124

136125
"APP_CLASS" => application.class.to_s,

lib/routes.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ Based on Rails routes of APP_CLASS
44
*/
55

66
(function() {
7-
var DeprecatedBehavior, NodeTypes, ParameterMissing, ReservedOptions, SpecialOptionsKey, Utils, root,
7+
var NodeTypes, ParameterMissing, ReservedOptions, SpecialOptionsKey, Utils, root,
88
hasProp = {}.hasOwnProperty,
99
slice = [].slice;
1010

1111
root = typeof exports !== "undefined" && exports !== null ? exports : this;
1212

13-
function ParameterMissing(message, fileName, lineNumber) {
14-
var instance = new Error(message, fileName, lineNumber);
15-
if(Object.setPrototypeOf) {
13+
ParameterMissing = function(message, fileName, lineNumber) {
14+
var instance;
15+
instance = new Error(message, fileName, lineNumber);
16+
if (Object.setPrototypeOf) {
1617
Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
1718
} else {
1819
instance.__proto__ = this.__proto__;
@@ -21,7 +22,7 @@ Based on Rails routes of APP_CLASS
2122
Error.captureStackTrace(instance, ParameterMissing);
2223
}
2324
return instance;
24-
}
25+
};
2526

2627
ParameterMissing.prototype = Object.create(Error.prototype, {
2728
constructor: {
@@ -32,7 +33,7 @@ Based on Rails routes of APP_CLASS
3233
}
3334
});
3435

35-
if (Object.setPrototypeOf){
36+
if (Object.setPrototypeOf) {
3637
Object.setPrototypeOf(ParameterMissing, Error);
3738
} else {
3839
ParameterMissing.__proto__ = Error;
@@ -42,8 +43,6 @@ Based on Rails routes of APP_CLASS
4243

4344
SpecialOptionsKey = SPECIAL_OPTIONS_KEY;
4445

45-
DeprecatedBehavior = DEPRECATED_BEHAVIOR;
46-
4746
ReservedOptions = ['anchor', 'trailing_slash', 'subdomain', 'host', 'port', 'protocol'];
4847

4948
Utils = {
@@ -202,7 +201,7 @@ Based on Rails routes of APP_CLASS
202201
if (actual_parameters.length > parts.length) {
203202
throw new Error("Too many parameters provided for path");
204203
}
205-
use_all_parts = DeprecatedBehavior || actual_parameters.length > required_parts.length;
204+
use_all_parts = actual_parameters.length > required_parts.length;
206205
parts_options = {};
207206
for (key in options) {
208207
if (!hasProp.call(options, key)) continue;

lib/routes.js.coffee

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ else
2929

3030
NodeTypes = NODE_TYPES
3131
SpecialOptionsKey = SPECIAL_OPTIONS_KEY
32-
DeprecatedBehavior = DEPRECATED_BEHAVIOR
3332

3433
ReservedOptions = [
3534
'anchor'
@@ -135,7 +134,7 @@ Utils =
135134
if actual_parameters.length > parts.length
136135
throw new Error("Too many parameters provided for path")
137136

138-
use_all_parts = DeprecatedBehavior or actual_parameters.length > required_parts.length
137+
use_all_parts = actual_parameters.length > required_parts.length
139138
parts_options = {}
140139

141140
for own key of options

spec/spec_helper.rb

+1-7
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,7 @@ class ::App < Rails::Application
6060
config.assets.enabled = true
6161
# initialize_on_precompile
6262
config.assets.initialize_on_precompile = true
63-
64-
if 3 == Rails::VERSION::MAJOR
65-
config.paths['config/routes'] << 'spec/config/routes.rb'
66-
else
67-
config.paths['config/routes.rb'] << 'spec/config/routes.rb'
68-
end
69-
63+
config.paths['config/routes.rb'] << 'spec/config/routes.rb'
7064
config.root = File.expand_path('../dummy', __FILE__)
7165
end
7266

0 commit comments

Comments
 (0)