crossroadsjs-rails 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rspec +2 -3
- data/README.md +1 -1
- data/crossroadsjs-rails.gemspec +1 -1
- data/lib/crossroadsjs/rails/version.rb +2 -2
- data/spec/crossroadsjs/rails/version_spec.rb +2 -2
- data/vendor/assets/javascripts/crossroads.js +35 -22
- data/vendor/assets/javascripts/crossroads.min.js +3 -4
- metadata +18 -3
- data/Rakefile +0 -5
data/.rspec
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
--
|
|
2
|
-
--format
|
|
3
|
-
--tty
|
|
1
|
+
--colour
|
|
2
|
+
--format Fuubar
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Crossroads.js for Rails [![Build Status][travis_ci_build_status]][travis_ci][![Dependency Status][gemnasium_dependency_status]][gemnasium]
|
|
2
2
|
|
|
3
|
-
Provides Crossroads.js (0.
|
|
3
|
+
Provides Crossroads.js (0.12.0) for use with Rails 3
|
|
4
4
|
|
|
5
5
|
[RubyGems][ruby_gems] | [Ruby Toolbox][ruby_toolbox] | [GitHub][github] | [Travis CI][travis_ci] | [Gemnasium][gemnasium] | [RubyDoc][ruby_doc]
|
|
6
6
|
|
data/crossroadsjs-rails.gemspec
CHANGED
|
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
|
|
14
14
|
s.add_dependency "railties", "~> 3.0"
|
|
15
15
|
|
|
16
|
+
s.add_development_dependency "fuubar", "~> 1.0"
|
|
16
17
|
s.add_development_dependency "rspec", "~> 2.0"
|
|
17
18
|
|
|
18
19
|
s.files = Dir[".gitignore"] +
|
|
@@ -20,7 +21,6 @@ Gem::Specification.new do |s|
|
|
|
20
21
|
Dir["Gemfile"] +
|
|
21
22
|
Dir["crossroadsjs-rails.gemspec"] +
|
|
22
23
|
Dir["LICENSE"] +
|
|
23
|
-
Dir["Rakefile"] +
|
|
24
24
|
Dir["README.md"] +
|
|
25
25
|
Dir["**/*.js"] +
|
|
26
26
|
Dir["**/*.rb"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Crossroadsjs::Rails do
|
|
4
|
-
it { Crossroadsjs::Rails::VERSION.should == "1.
|
|
5
|
-
it { Crossroadsjs::Rails::CROSSROADSJS_VERSION.should == "0.
|
|
4
|
+
it { Crossroadsjs::Rails::VERSION.should == "1.5.0" }
|
|
5
|
+
it { Crossroadsjs::Rails::CROSSROADSJS_VERSION.should == "0.12.0" }
|
|
6
6
|
end
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/** @license
|
|
2
2
|
* crossroads <http://millermedeiros.github.com/crossroads.js/>
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Version: 0.11.0 (2012/10/31 21:44)
|
|
3
|
+
* Author: Miller Medeiros | MIT License
|
|
4
|
+
* v0.12.0 (2013/01/21 13:47)
|
|
6
5
|
*/
|
|
7
6
|
|
|
8
|
-
(function (
|
|
9
|
-
|
|
7
|
+
(function () {
|
|
8
|
+
var factory = function (signals) {
|
|
10
9
|
|
|
11
10
|
var crossroads,
|
|
12
11
|
_hasOptionalGroupBug,
|
|
@@ -273,7 +272,7 @@ define(['signals'], function (signals) {
|
|
|
273
272
|
|
|
274
273
|
//"static" instance
|
|
275
274
|
crossroads = new Crossroads();
|
|
276
|
-
crossroads.VERSION = '0.
|
|
275
|
+
crossroads.VERSION = '0.12.0';
|
|
277
276
|
|
|
278
277
|
crossroads.NORM_AS_ARRAY = function (req, vals) {
|
|
279
278
|
return [vals.vals_];
|
|
@@ -292,7 +291,7 @@ define(['signals'], function (signals) {
|
|
|
292
291
|
*/
|
|
293
292
|
function Route(pattern, callback, priority, router) {
|
|
294
293
|
var isRegexPattern = isRegExp(pattern),
|
|
295
|
-
patternLexer =
|
|
294
|
+
patternLexer = router.patternLexer;
|
|
296
295
|
this._router = router;
|
|
297
296
|
this._pattern = pattern;
|
|
298
297
|
this._paramsIds = isRegexPattern? null : patternLexer.getParamIds(pattern);
|
|
@@ -383,7 +382,7 @@ define(['signals'], function (signals) {
|
|
|
383
382
|
|
|
384
383
|
_getParamsObject : function (request) {
|
|
385
384
|
var shouldTypecast = this._router.shouldTypecast,
|
|
386
|
-
values =
|
|
385
|
+
values = this._router.patternLexer.getParamValues(request, this._matchRegexp, shouldTypecast),
|
|
387
386
|
o = {},
|
|
388
387
|
n = values.length,
|
|
389
388
|
param, val;
|
|
@@ -430,7 +429,7 @@ define(['signals'], function (signals) {
|
|
|
430
429
|
},
|
|
431
430
|
|
|
432
431
|
interpolate : function(replacements) {
|
|
433
|
-
var str =
|
|
432
|
+
var str = this._router.patternLexer.interpolate(this._pattern, replacements);
|
|
434
433
|
if (! this._validateParams(str) ) {
|
|
435
434
|
throw new Error('Generated string doesn\'t validate against `Route.rules`.');
|
|
436
435
|
}
|
|
@@ -458,7 +457,7 @@ define(['signals'], function (signals) {
|
|
|
458
457
|
// Pattern Lexer ------
|
|
459
458
|
//=====================
|
|
460
459
|
|
|
461
|
-
|
|
460
|
+
Crossroads.prototype.patternLexer = (function () {
|
|
462
461
|
|
|
463
462
|
var
|
|
464
463
|
//match chars that should be escaped on string regexp
|
|
@@ -623,9 +622,19 @@ define(['signals'], function (signals) {
|
|
|
623
622
|
|
|
624
623
|
var replaceFn = function(match, prop){
|
|
625
624
|
var val;
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
625
|
+
prop = (prop.substr(0, 1) === '?')? prop.substr(1) : prop;
|
|
626
|
+
if (replacements[prop] != null) {
|
|
627
|
+
if (typeof replacements[prop] === 'object') {
|
|
628
|
+
var queryParts = [];
|
|
629
|
+
for(var key in replacements[prop]) {
|
|
630
|
+
queryParts.push(encodeURI(key + '=' + replacements[prop][key]));
|
|
631
|
+
}
|
|
632
|
+
val = '?' + queryParts.join('&');
|
|
633
|
+
} else {
|
|
634
|
+
// make sure value is a string see #gh-54
|
|
635
|
+
val = String(replacements[prop]);
|
|
636
|
+
}
|
|
637
|
+
|
|
629
638
|
if (match.indexOf('*') === -1 && val.indexOf('/') !== -1) {
|
|
630
639
|
throw new Error('Invalid value "'+ val +'" for segment "'+ match +'".');
|
|
631
640
|
}
|
|
@@ -672,12 +681,16 @@ define(['signals'], function (signals) {
|
|
|
672
681
|
|
|
673
682
|
|
|
674
683
|
return crossroads;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
if (typeof define === 'function' && define.amd) {
|
|
687
|
+
define(['signals'], factory);
|
|
688
|
+
} else if (typeof module !== 'undefined' && module.exports) { //Node
|
|
689
|
+
module.exports = factory(require('signals'));
|
|
690
|
+
} else {
|
|
691
|
+
/*jshint sub:true */
|
|
692
|
+
window['crossroads'] = factory(window['signals']);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
}());
|
|
696
|
+
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** @license
|
|
2
2
|
* crossroads <http://millermedeiros.github.com/crossroads.js/>
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Version: 0.11.0 (2012/10/31 21:44)
|
|
3
|
+
* Author: Miller Medeiros | MIT License
|
|
4
|
+
* v0.12.0 (2013/01/21 13:47)
|
|
6
5
|
*/
|
|
7
|
-
(function(
|
|
6
|
+
;(function(){var a=function(a){function e(a,b){if(a.indexOf)return a.indexOf(b);var c=a.length;while(c--)if(a[c]===b)return c;return-1}function f(a,b){var c=e(a,b);c!==-1&&a.splice(c,1)}function g(a,b){return"[object "+b+"]"===Object.prototype.toString.call(a)}function h(a){return g(a,"RegExp")}function i(a){return g(a,"Array")}function j(a){return typeof a=="function"}function k(a){var b;return a===null||a==="null"?b=null:a==="true"?b=!0:a==="false"?b=!1:a===d||a==="undefined"?b=d:a===""||isNaN(a)?b=a:b=parseFloat(a),b}function l(a){var b=a.length,c=[];while(b--)c[b]=k(a[b]);return c}function m(a,b){var c=(a||"").replace("?","").split("&"),d=c.length,e={},f,g;while(d--)f=c[d].split("="),g=b?k(f[1]):f[1],e[f[0]]=typeof g=="string"?decodeURIComponent(g):g;return e}function n(){this.bypassed=new a.Signal,this.routed=new a.Signal,this._routes=[],this._prevRoutes=[],this._piped=[],this.resetState()}function o(b,c,d,e){var f=h(b),g=e.patternLexer;this._router=e,this._pattern=b,this._paramsIds=f?null:g.getParamIds(b),this._optionalParamsIds=f?null:g.getOptionalParamsIds(b),this._matchRegexp=f?b:g.compilePattern(b,e.ignoreCase),this.matched=new a.Signal,this.switched=new a.Signal,c&&this.matched.add(c),this._priority=d||0}var b,c,d;return c=/t(.+)?/.exec("t")[1]==="",n.prototype={greedy:!1,greedyEnabled:!0,ignoreCase:!0,ignoreState:!1,shouldTypecast:!1,normalizeFn:null,resetState:function(){this._prevRoutes.length=0,this._prevMatchedRequest=null,this._prevBypassedRequest=null},create:function(){return new n},addRoute:function(a,b,c){var d=new o(a,b,c,this);return this._sortedInsert(d),d},removeRoute:function(a){f(this._routes,a),a._destroy()},removeAllRoutes:function(){var a=this.getNumRoutes();while(a--)this._routes[a]._destroy();this._routes.length=0},parse:function(a,b){a=a||"",b=b||[];if(!this.ignoreState&&(a===this._prevMatchedRequest||a===this._prevBypassedRequest))return;var c=this._getMatchedRoutes(a),d=0,e=c.length,f;if(e){this._prevMatchedRequest=a,this._notifyPrevRoutes(c,a),this._prevRoutes=c;while(d<e)f=c[d],f.route.matched.dispatch.apply(f.route.matched,b.concat(f.params)),f.isFirst=!d,this.routed.dispatch.apply(this.routed,b.concat([a,f])),d+=1}else this._prevBypassedRequest=a,this.bypassed.dispatch.apply(this.bypassed,b.concat([a]));this._pipeParse(a,b)},_notifyPrevRoutes:function(a,b){var c=0,d;while(d=this._prevRoutes[c++])d.route.switched&&this._didSwitch(d.route,a)&&d.route.switched.dispatch(b)},_didSwitch:function(a,b){var c,d=0;while(c=b[d++])if(c.route===a)return!1;return!0},_pipeParse:function(a,b){var c=0,d;while(d=this._piped[c++])d.parse(a,b)},getNumRoutes:function(){return this._routes.length},_sortedInsert:function(a){var b=this._routes,c=b.length;do--c;while(b[c]&&a._priority<=b[c]._priority);b.splice(c+1,0,a)},_getMatchedRoutes:function(a){var b=[],c=this._routes,d=c.length,e;while(e=c[--d]){(!b.length||this.greedy||e.greedy)&&e.match(a)&&b.push({route:e,params:e._getParamsArray(a)});if(!this.greedyEnabled&&b.length)break}return b},pipe:function(a){this._piped.push(a)},unpipe:function(a){f(this._piped,a)},toString:function(){return"[crossroads numRoutes:"+this.getNumRoutes()+"]"}},b=new n,b.VERSION="0.12.0",b.NORM_AS_ARRAY=function(a,b){return[b.vals_]},b.NORM_AS_OBJECT=function(a,b){return[b]},o.prototype={greedy:!1,rules:void 0,match:function(a){return a=a||"",this._matchRegexp.test(a)&&this._validateParams(a)},_validateParams:function(a){var b=this.rules,c=this._getParamsObject(a),d;for(d in b)if(d!=="normalize_"&&b.hasOwnProperty(d)&&!this._isValidParam(a,d,c))return!1;return!0},_isValidParam:function(a,b,c){var d=this.rules[b],f=c[b],g=!1,k=b.indexOf("?")===0;return f==null&&this._optionalParamsIds&&e(this._optionalParamsIds,b)!==-1?g=!0:h(d)?(k&&(f=c[b+"_"]),g=d.test(f)):i(d)?(k&&(f=c[b+"_"]),g=this._isValidArrayRule(d,f)):j(d)&&(g=d(f,a,c)),g},_isValidArrayRule:function(a,b){if(!this._router.ignoreCase)return e(a,b)!==-1;typeof b=="string"&&(b=b.toLowerCase());var c=a.length,d,f;while(c--){d=a[c],f=typeof d=="string"?d.toLowerCase():d;if(f===b)return!0}return!1},_getParamsObject:function(a){var b=this._router.shouldTypecast,d=this._router.patternLexer.getParamValues(a,this._matchRegexp,b),f={},g=d.length,h,i;while(g--)i=d[g],this._paramsIds&&(h=this._paramsIds[g],h.indexOf("?")===0&&i&&(f[h+"_"]=i,i=m(i,b),d[g]=i),c&&i===""&&e(this._optionalParamsIds,h)!==-1&&(i=void 0,d[g]=i),f[h]=i),f[g]=i;return f.request_=b?k(a):a,f.vals_=d,f},_getParamsArray:function(a){var b=this.rules?this.rules.normalize_:null,c;return b=b||this._router.normalizeFn,b&&j(b)?c=b(a,this._getParamsObject(a)):c=this._getParamsObject(a).vals_,c},interpolate:function(a){var b=this._router.patternLexer.interpolate(this._pattern,a);if(!this._validateParams(b))throw new Error("Generated string doesn't validate against `Route.rules`.");return b},dispose:function(){this._router.removeRoute(this)},_destroy:function(){this.matched.dispose(),this.switched.dispose(),this.matched=this.switched=this._pattern=this._matchRegexp=null},toString:function(){return'[Route pattern:"'+this._pattern+'", numListeners:'+this.matched.getNumListeners()+"]"}},n.prototype.patternLexer=function(){function j(){var a,b;for(a in e)e.hasOwnProperty(a)&&(b=e[a],b.id="__CR_"+a+"__",b.save="save"in b?b.save.replace("{{id}}",b.id):b.id,b.rRestore=new RegExp(b.id,"g"))}function k(a,b){var c=[],d;a.lastIndex=0;while(d=a.exec(b))c.push(d[1]);return c}function m(a){return k(d,a)}function n(a){return k(e.OP.rgx,a)}function o(d,e){return d=d||"",d&&(i===f?d=d.replace(b,""):i===h&&(d=d.replace(c,"")),d=p(d,"rgx","save"),d=d.replace(a,"\\$&"),d=p(d,"rRestore","res"),i===f&&(d="\\/?"+d)),i!==g&&(d+="\\/?"),new RegExp("^"+d+"$",e?"i":"")}function p(a,b,c){var d,f;for(f in e)e.hasOwnProperty(f)&&(d=e[f],a=a.replace(d[b],d[c]));return a}function q(a,b,c){var d=b.exec(a);return d&&(d.shift(),c&&(d=l(d))),d}function r(a,b){if(typeof a!="string")throw new Error("Route pattern should be a string.");var c=function(a,c){var d;c=c.substr(0,1)==="?"?c.substr(1):c;if(b[c]!=null){if(typeof b[c]=="object"){var e=[];for(var f in b[c])e.push(encodeURI(f+"="+b[c][f]));d="?"+e.join("&")}else d=String(b[c]);if(a.indexOf("*")===-1&&d.indexOf("/")!==-1)throw new Error('Invalid value "'+d+'" for segment "'+a+'".')}else{if(a.indexOf("{")!==-1)throw new Error("The segment "+a+" is required.");d=""}return d};return e.OS.trail||(e.OS.trail=new RegExp("(?:"+e.OS.id+")+$")),a.replace(e.OS.rgx,e.OS.save).replace(d,c).replace(e.OS.trail,"").replace(e.OS.rRestore,"/")}var a=/[\\.+*?\^$\[\](){}\/'#]/g,b=/^\/|\/$/g,c=/\/$/g,d=/(?:\{|:)([^}:]+)(?:\}|:)/g,e={OS:{rgx:/([:}]|\w(?=\/))\/?(:|(?:\{\?))/g,save:"$1{{id}}$2",res:"\\/?"},RS:{rgx:/([:}])\/?(\{)/g,save:"$1{{id}}$2",res:"\\/"},RQ:{rgx:/\{\?([^}]+)\}/g,res:"\\?([^#]+)"},OQ:{rgx:/:\?([^:]+):/g,res:"(?:\\?([^#]*))?"},OR:{rgx:/:([^:]+)\*:/g,res:"(.*)?"},RR:{rgx:/\{([^}]+)\*\}/g,res:"(.+)"},RP:{rgx:/\{([^}]+)\}/g,res:"([^\\/?]+)"},OP:{rgx:/:([^:]+):/g,res:"([^\\/?]+)?/?"}},f=1,g=2,h=3,i=f;return j(),{strict:function(){i=g},loose:function(){i=f},legacy:function(){i=h},getParamIds:m,getOptionalParamsIds:n,getParamValues:q,compilePattern:o,interpolate:r}}(),b};typeof define=="function"&&define.amd?define(["signals"],a):typeof module!="undefined"&&module.exports?module.exports=a(require("signals")):window.crossroads=a(window.signals)})();
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: crossroadsjs-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2013-02-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: railties
|
|
@@ -27,6 +27,22 @@ dependencies:
|
|
|
27
27
|
- - ~>
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
29
|
version: '3.0'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: fuubar
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ~>
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '1.0'
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ~>
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '1.0'
|
|
30
46
|
- !ruby/object:Gem::Dependency
|
|
31
47
|
name: rspec
|
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -54,7 +70,6 @@ files:
|
|
|
54
70
|
- Gemfile
|
|
55
71
|
- crossroadsjs-rails.gemspec
|
|
56
72
|
- LICENSE
|
|
57
|
-
- Rakefile
|
|
58
73
|
- README.md
|
|
59
74
|
- vendor/assets/javascripts/crossroads.js
|
|
60
75
|
- vendor/assets/javascripts/crossroads.min.js
|