crossroadsjs-rails 1.2.0 → 1.2.1
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/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.9.
|
3
|
+
Provides Crossroads.js (0.9.1) 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
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Crossroadsjs::Rails do
|
4
|
-
it { Crossroadsjs::Rails::VERSION.should == "1.2.
|
5
|
-
it { Crossroadsjs::Rails::CROSSROADSJS_VERSION.should == "0.9.
|
4
|
+
it { Crossroadsjs::Rails::VERSION.should == "1.2.1" }
|
5
|
+
it { Crossroadsjs::Rails::CROSSROADSJS_VERSION.should == "0.9.1" }
|
6
6
|
end
|
@@ -2,18 +2,23 @@
|
|
2
2
|
* crossroads <http://millermedeiros.github.com/crossroads.js/>
|
3
3
|
* License: MIT
|
4
4
|
* Author: Miller Medeiros
|
5
|
-
* Version: 0.9.
|
5
|
+
* Version: 0.9.1 (2012/7/29 15:56)
|
6
6
|
*/
|
7
7
|
|
8
8
|
(function (define) {
|
9
9
|
define(['signals'], function (signals) {
|
10
10
|
|
11
11
|
var crossroads,
|
12
|
+
_hasOptionalGroupBug,
|
12
13
|
UNDEF;
|
13
14
|
|
14
15
|
// Helpers -----------
|
15
16
|
//====================
|
16
17
|
|
18
|
+
// IE 7-8 capture optional groups as empty strings while other browsers
|
19
|
+
// capture as `undefined`
|
20
|
+
_hasOptionalGroupBug = (/t(.+)?/).exec('t')[1] === '';
|
21
|
+
|
17
22
|
function arrayIndexOf(arr, val) {
|
18
23
|
if (arr.indexOf) {
|
19
24
|
return arr.indexOf(val);
|
@@ -225,7 +230,7 @@ define(['signals'], function (signals) {
|
|
225
230
|
|
226
231
|
//"static" instance
|
227
232
|
crossroads = new Crossroads();
|
228
|
-
crossroads.VERSION = '0.9.
|
233
|
+
crossroads.VERSION = '0.9.1';
|
229
234
|
|
230
235
|
crossroads.NORM_AS_ARRAY = function (req, vals) {
|
231
236
|
return [vals.vals_];
|
@@ -247,8 +252,8 @@ define(['signals'], function (signals) {
|
|
247
252
|
patternLexer = crossroads.patternLexer;
|
248
253
|
this._router = router;
|
249
254
|
this._pattern = pattern;
|
250
|
-
this._paramsIds = isRegexPattern? null : patternLexer.getParamIds(
|
251
|
-
this._optionalParamsIds = isRegexPattern? null : patternLexer.getOptionalParamsIds(
|
255
|
+
this._paramsIds = isRegexPattern? null : patternLexer.getParamIds(pattern);
|
256
|
+
this._optionalParamsIds = isRegexPattern? null : patternLexer.getOptionalParamsIds(pattern);
|
252
257
|
this._matchRegexp = isRegexPattern? pattern : patternLexer.compilePattern(pattern);
|
253
258
|
this.matched = new signals.Signal();
|
254
259
|
this.switched = new signals.Signal();
|
@@ -329,6 +334,13 @@ define(['signals'], function (signals) {
|
|
329
334
|
val = decodeQueryString(val);
|
330
335
|
values[n] = val;
|
331
336
|
}
|
337
|
+
// IE will capture optional groups as empty strings while other
|
338
|
+
// browsers will capture `undefined` so normalize behavior.
|
339
|
+
// see: #gh-58, #gh-59, #gh-60
|
340
|
+
if ( _hasOptionalGroupBug && val === '' && arrayIndexOf(this._optionalParamsIds, param) !== -1 ) {
|
341
|
+
val = void(0);
|
342
|
+
values[n] = val;
|
343
|
+
}
|
332
344
|
o[param] = val;
|
333
345
|
}
|
334
346
|
//alias to paths and for RegExp pattern
|
@@ -468,6 +480,10 @@ define(['signals'], function (signals) {
|
|
468
480
|
|
469
481
|
function captureVals(regex, pattern) {
|
470
482
|
var vals = [], match;
|
483
|
+
// very important to reset lastIndex since RegExp can have "g" flag
|
484
|
+
// and multiple runs might affect the result, specially if matching
|
485
|
+
// same string multiple times on IE 7-8
|
486
|
+
regex.lastIndex = 0;
|
471
487
|
while (match = regex.exec(pattern)) {
|
472
488
|
vals.push(match[1]);
|
473
489
|
}
|
@@ -542,7 +558,8 @@ define(['signals'], function (signals) {
|
|
542
558
|
var replaceFn = function(match, prop){
|
543
559
|
var val;
|
544
560
|
if (prop in replacements) {
|
545
|
-
|
561
|
+
// make sure value is a string see #gh-54
|
562
|
+
val = String(replacements[prop]);
|
546
563
|
if (match.indexOf('*') === -1 && val.indexOf('/') !== -1) {
|
547
564
|
throw new Error('Invalid value "'+ val +'" for segment "'+ match +'".');
|
548
565
|
}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
* crossroads <http://millermedeiros.github.com/crossroads.js/>
|
3
3
|
* License: MIT
|
4
4
|
* Author: Miller Medeiros
|
5
|
-
* Version: 0.9.
|
5
|
+
* Version: 0.9.1 (2012/7/29 15:56)
|
6
6
|
*/
|
7
|
-
(function(a){a(["signals"],function(a){function
|
7
|
+
(function(a){a(["signals"],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){return"[object "+b+"]"===Object.prototype.toString.call(a)}function g(a){return f(a,"RegExp")}function h(a){return f(a,"Array")}function i(a){return typeof a=="function"}function j(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 k(a){var b=a.length,c=[];while(b--)c[b]=j(a[b]);return c}function l(a){var b=(a||"").replace("?","").split("&"),c=b.length,d={},e,f;while(c--)e=b[c].split("="),f=j(e[1]),d[e[0]]=typeof f=="string"?decodeURIComponent(f):f;return d}function m(){this._routes=[],this._prevRoutes=[],this.bypassed=new a.Signal,this.routed=new a.Signal}function n(c,d,e,f){var h=g(c),i=b.patternLexer;this._router=f,this._pattern=c,this._paramsIds=h?null:i.getParamIds(c),this._optionalParamsIds=h?null:i.getOptionalParamsIds(c),this._matchRegexp=h?c:i.compilePattern(c),this.matched=new a.Signal,this.switched=new a.Signal,d&&this.matched.add(d),this._priority=e||0}var b,c,d;return c=/t(.+)?/.exec("t")[1]==="",m.prototype={greedy:!1,greedyEnabled:!0,normalizeFn:null,create:function(){return new m},shouldTypecast:!1,addRoute:function(a,b,c){var d=new n(a,b,c,this);return this._sortedInsert(d),d},removeRoute:function(a){var b=e(this._routes,a);b!==-1&&this._routes.splice(b,1),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||[];var c=this._getMatchedRoutes(a),d=0,e=c.length,f;if(e){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.bypassed.dispatch.apply(this.bypassed,b.concat([a]))},_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},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},toString:function(){return"[crossroads numRoutes:"+this.getNumRoutes()+"]"}},b=new m,b.VERSION="0.9.1",b.NORM_AS_ARRAY=function(a,b){return[b.vals_]},b.NORM_AS_OBJECT=function(a,b){return[b]},n.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],j=!1,k=b.indexOf("?")===0;return f==null&&this._optionalParamsIds&&e(this._optionalParamsIds,b)!==-1?j=!0:g(d)?(k&&(f=c[b+"_"]),j=d.test(f)):h(d)?(k&&(f=c[b+"_"]),j=e(d,f)!==-1):i(d)&&(j=d(f,a,c)),j},_getParamsObject:function(a){var d=this._router.shouldTypecast,f=b.patternLexer.getParamValues(a,this._matchRegexp,d),g={},h=f.length,i,k;while(h--)k=f[h],this._paramsIds&&(i=this._paramsIds[h],i.indexOf("?")===0&&k&&(g[i+"_"]=k,k=l(k),f[h]=k),c&&k===""&&e(this._optionalParamsIds,i)!==-1&&(k=void 0,f[h]=k),g[i]=k),g[h]=k;return g.request_=d?j(a):a,g.vals_=f,g},_getParamsArray:function(a){var b=this.rules?this.rules.normalize_:null,c;return b=b||this._router.normalizeFn,b&&i(b)?c=b(a,this._getParamsObject(a)):c=this._getParamsObject(a).vals_,c},interpolate:function(a){var c=b.patternLexer.interpolate(this._pattern,a);if(!this._validateParams(c))throw new Error("Generated string doesn't validate against `Route.rules`.");return c},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()+"]"}},b.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 l(a,b){var c=[],d;a.lastIndex=0;while(d=a.exec(b))c.push(d[1]);return c}function m(a){return l(d,a)}function n(a){return l(e.OP.rgx,a)}function o(d){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+"$")}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=k(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;if(c in b){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:function(a,b){typeof module!="undefined"&&module.exports?module.exports=b(require(a[0])):window.crossroads=b(window[a[0]])})
|
metadata
CHANGED
@@ -1,48 +1,48 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crossroadsjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
version: 1.2.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Phil Ostler
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
17
18
|
requirements:
|
18
19
|
- - ~>
|
19
20
|
- !ruby/object:Gem::Version
|
20
21
|
version: '3.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
25
|
none: false
|
22
|
-
requirement: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3.0'
|
27
|
-
none: false
|
28
|
-
prerelease: false
|
29
|
-
type: :runtime
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rspec
|
32
|
-
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
33
34
|
requirements:
|
34
35
|
- - ~>
|
35
36
|
- !ruby/object:Gem::Version
|
36
37
|
version: '2.0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
41
|
none: false
|
38
|
-
requirement: !ruby/object:Gem::Requirement
|
39
42
|
requirements:
|
40
43
|
- - ~>
|
41
44
|
- !ruby/object:Gem::Version
|
42
45
|
version: '2.0'
|
43
|
-
none: false
|
44
|
-
prerelease: false
|
45
|
-
type: :development
|
46
46
|
description: Provides Crossroads.js for use with Rails 3
|
47
47
|
email: philostler@gmail.com
|
48
48
|
executables: []
|
@@ -58,37 +58,36 @@ files:
|
|
58
58
|
- README.md
|
59
59
|
- vendor/assets/javascripts/crossroads.js
|
60
60
|
- vendor/assets/javascripts/crossroads.min.js
|
61
|
-
- lib/crossroadsjs-rails.rb
|
62
|
-
- lib/crossroadsjs/rails.rb
|
63
61
|
- lib/crossroadsjs/rails/engine.rb
|
64
62
|
- lib/crossroadsjs/rails/railtie.rb
|
65
63
|
- lib/crossroadsjs/rails/version.rb
|
64
|
+
- lib/crossroadsjs/rails.rb
|
65
|
+
- lib/crossroadsjs-rails.rb
|
66
66
|
- lib/generators/crossroadsjs/install/install_generator.rb
|
67
|
-
- spec/spec_helper.rb
|
68
67
|
- spec/crossroadsjs/rails/version_spec.rb
|
68
|
+
- spec/spec_helper.rb
|
69
69
|
homepage: http://github.com/philostler/crossroadsjs-rails
|
70
70
|
licenses: []
|
71
|
-
post_install_message:
|
71
|
+
post_install_message:
|
72
72
|
rdoc_options: []
|
73
73
|
require_paths:
|
74
74
|
- lib
|
75
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
76
77
|
requirements:
|
77
78
|
- - ! '>='
|
78
79
|
- !ruby/object:Gem::Version
|
79
80
|
version: '0'
|
80
|
-
none: false
|
81
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
82
83
|
requirements:
|
83
84
|
- - ! '>='
|
84
85
|
- !ruby/object:Gem::Version
|
85
86
|
version: '0'
|
86
|
-
none: false
|
87
87
|
requirements: []
|
88
|
-
rubyforge_project:
|
88
|
+
rubyforge_project:
|
89
89
|
rubygems_version: 1.8.24
|
90
|
-
signing_key:
|
90
|
+
signing_key:
|
91
91
|
specification_version: 3
|
92
92
|
summary: Crossroads.js for Rails
|
93
93
|
test_files: []
|
94
|
-
...
|