Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for rails 5 - test rails-edge on travis allowing failure #151

Merged
merged 1 commit into from
Jun 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ branches:
- master

matrix:
include:
- gemfile: gemfiles/rails_edge.gemfile
rvm: 2.2
allow_failures:
- rvm: jruby-19mode
- rvm: ruby-head
- rvm: jruby-head
- gemfile: gemfiles/rails_edge.gemfile
rvm: 2.2
5 changes: 5 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ end
gem "sprockets", "~> 3.0"
end
end

appraise "rails-edge" do
gem "railties", github: 'rails/rails'
gem "sprockets", "~> 3.0"
end
8 changes: 8 additions & 0 deletions gemfiles/rails_edge.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "railties", :github => "rails/rails"
gem "sprockets", "~> 3.0"

gemspec :path => "../"
4 changes: 2 additions & 2 deletions lib/js_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ def build_route_if_match(route, parent_route=nil)

def any_match?(route, parent_route, matchers)
full_route = [parent_route.try(:name), route.name].compact.join('_')

matchers = Array(matchers)
matchers.any? {|regex| full_route =~ regex}
end

def build_js(route, parent_route)
name = [parent_route.try(:name), route.name].compact
parent_spec = parent_route.try(:path).try(:spec)
required_parts, optional_parts = route.required_parts.clone, route.optional_parts.clone
required_parts, optional_parts = route.required_parts.clone, (route.parts-route.required_parts)
optional_parts.push(required_parts.delete :format) if required_parts.include?(:format)
route_name = generate_route_name(name, (:path unless @options[:compact]))
url_link = generate_url_link(name, route_name, required_parts, route)
Expand Down
56 changes: 19 additions & 37 deletions lib/routes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function() {
var NodeTypes, ParameterMissing, Utils, createGlobalJsRoutesObject, defaults, root,
__hasProp = {}.hasOwnProperty;
hasProp = {}.hasOwnProperty;

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

Expand All @@ -19,8 +19,7 @@

Utils = {
serialize: function(object, prefix) {
var element, i, key, prop, result, s, _i, _len;

var element, i, j, key, len, prop, result, s;
if (prefix == null) {
prefix = null;
}
Expand All @@ -37,27 +36,27 @@
s = [];
switch (this.get_object_type(object)) {
case "array":
for (i = _i = 0, _len = object.length; _i < _len; i = ++_i) {
for (i = j = 0, len = object.length; j < len; i = ++j) {
element = object[i];
s.push(this.serialize(element, prefix + "[]"));
}
break;
case "object":
for (key in object) {
if (!__hasProp.call(object, key)) continue;
if (!hasProp.call(object, key)) continue;
prop = object[key];
if (!(prop != null)) {
continue;
}
if (prefix != null) {
key = "" + prefix + "[" + key + "]";
key = prefix + "[" + key + "]";
}
s.push(this.serialize(prop, key));
}
break;
default:
if (object) {
s.push("" + (encodeURIComponent(prefix.toString())) + "=" + (encodeURIComponent(object.toString())));
s.push((encodeURIComponent(prefix.toString())) + "=" + (encodeURIComponent(object.toString())));
}
}
if (!s.length) {
Expand All @@ -67,27 +66,24 @@
},
clean_path: function(path) {
var last_index;

path = path.split("://");
last_index = path.length - 1;
path[last_index] = path[last_index].replace(/\/+/g, "/");
return path.join("://");
},
set_default_url_options: function(optional_parts, options) {
var i, part, _i, _len, _results;

_results = [];
for (i = _i = 0, _len = optional_parts.length; _i < _len; i = ++_i) {
var i, j, len, part, results;
results = [];
for (i = j = 0, len = optional_parts.length; j < len; i = ++j) {
part = optional_parts[i];
if (!options.hasOwnProperty(part) && defaults.default_url_options.hasOwnProperty(part)) {
_results.push(options[part] = defaults.default_url_options[part]);
results.push(options[part] = defaults.default_url_options[part]);
}
}
return _results;
return results;
},
extract_anchor: function(options) {
var anchor;

anchor = "";
if (options.hasOwnProperty("anchor")) {
anchor = "#" + options.anchor;
Expand All @@ -97,7 +93,6 @@
},
extract_trailing_slash: function(options) {
var trailing_slash;

trailing_slash = false;
if (defaults.default_url_options.hasOwnProperty("trailing_slash")) {
trailing_slash = defaults.default_url_options.trailing_slash;
Expand All @@ -110,7 +105,6 @@
},
extract_options: function(number_of_params, args) {
var last_el;

last_el = args[args.length - 1];
if (args.length > number_of_params || ((last_el != null) && "object" === this.get_object_type(last_el) && !this.look_like_serialized_model(last_el))) {
return args.pop();
Expand All @@ -123,7 +117,6 @@
},
path_identifier: function(object) {
var property;

if (object === 0) {
return "0";
}
Expand All @@ -147,23 +140,21 @@
},
clone: function(obj) {
var attr, copy, key;

if ((obj == null) || "object" !== this.get_object_type(obj)) {
return obj;
}
copy = obj.constructor();
for (key in obj) {
if (!__hasProp.call(obj, key)) continue;
if (!hasProp.call(obj, key)) continue;
attr = obj[key];
copy[key] = attr;
}
return copy;
},
prepare_parameters: function(required_parameters, actual_parameters, options) {
var i, result, val, _i, _len;

var i, j, len, result, val;
result = this.clone(options) || {};
for (i = _i = 0, _len = required_parameters.length; _i < _len; i = ++_i) {
for (i = j = 0, len = required_parameters.length; j < len; i = ++j) {
val = required_parameters[i];
if (i < actual_parameters.length) {
result[val] = actual_parameters[i];
Expand All @@ -173,7 +164,6 @@
},
build_path: function(required_parameters, optional_parts, route, args) {
var anchor, opts, parameters, result, trailing_slash, url, url_params;

args = Array.prototype.slice.call(args);
opts = this.extract_options(required_parameters.length, args);
if (args.length > required_parameters.length) {
Expand All @@ -196,7 +186,6 @@
},
visit: function(route, parameters, optional) {
var left, left_part, right, right_part, type, value;

if (optional == null) {
optional = false;
}
Expand Down Expand Up @@ -235,7 +224,6 @@
},
build_path_spec: function(route, wildcard) {
var left, right, type;

if (wildcard == null) {
wildcard = false;
}
Expand Down Expand Up @@ -264,7 +252,6 @@
},
visit_globbing: function(route, parameters, optional) {
var left, right, type, value;

type = route[0], left = route[1], right = route[2];
if (left.replace(/^\*/i, "") !== left) {
route[1] = left = left.replace(/^\*/i, "");
Expand All @@ -285,16 +272,14 @@
},
get_prefix: function() {
var prefix;

prefix = defaults.prefix;
if (prefix !== "") {
prefix = (prefix.match("/$") ? prefix : "" + prefix + "/");
prefix = (prefix.match("/$") ? prefix : prefix + "/");
}
return prefix;
},
route: function(required_parts, optional_parts, route_spec) {
var path_fn;

path_fn = function() {
return Utils.build_path(required_parts, optional_parts, route_spec, arguments);
};
Expand All @@ -306,15 +291,14 @@
},
_classToTypeCache: null,
_classToType: function() {
var name, _i, _len, _ref;

var j, len, name, ref;
if (this._classToTypeCache != null) {
return this._classToTypeCache;
}
this._classToTypeCache = {};
_ref = "Boolean Number String Function Array Date RegExp Object Error".split(" ");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i];
ref = "Boolean Number String Function Array Date RegExp Object Error".split(" ");
for (j = 0, len = ref.length; j < len; j++) {
name = ref[j];
this._classToTypeCache["[object " + name + "]"] = name.toLowerCase();
}
return this._classToTypeCache;
Expand All @@ -336,10 +320,8 @@

createGlobalJsRoutesObject = function() {
var namespace;

namespace = function(mainRoot, namespaceString) {
var current, parts;

parts = (namespaceString ? namespaceString.split(".") : []);
if (!parts.length) {
return;
Expand Down