eyeballs 0.5.5 → 0.5.6
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/CHANGELOG +4 -0
- data/Rakefile +1 -1
- data/eyeballs.gemspec +2 -2
- data/src/drivers/jquery/modules/o_O.routes.js +45 -5
- data/test/unit/test_routing.html +16 -1
- metadata +4 -4
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
data/eyeballs.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{eyeballs}
|
|
8
|
-
s.version = "0.5.
|
|
8
|
+
s.version = "0.5.6"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Paul Campbell"]
|
|
12
|
-
s.date = %q{2010-08-
|
|
12
|
+
s.date = %q{2010-08-06}
|
|
13
13
|
s.default_executable = %q{eyeballs}
|
|
14
14
|
s.email = %q{paul@rslw.com}
|
|
15
15
|
s.executables = ["eyeballs"]
|
|
@@ -2,6 +2,7 @@ o_O.routes = {
|
|
|
2
2
|
|
|
3
3
|
rules: {},
|
|
4
4
|
urls: [],
|
|
5
|
+
regex_urls: [],
|
|
5
6
|
|
|
6
7
|
figure_action: function(options){
|
|
7
8
|
var parts = options.to.split('#');
|
|
@@ -22,15 +23,29 @@ o_O.routes = {
|
|
|
22
23
|
},
|
|
23
24
|
match: function(route, options){
|
|
24
25
|
var parsed_route = route.o_O_trim('/')
|
|
26
|
+
|
|
25
27
|
if(typeof prefix != 'undefined')
|
|
26
28
|
{
|
|
27
29
|
parsed_route = prefix + '/' + parsed_route
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
|
|
32
|
+
if(parsed_route.indexOf(':') >= 0)
|
|
33
|
+
{
|
|
34
|
+
var regex_to_match = parsed_route.replace(/:[^\/]*/g, '([^\/]*)');
|
|
35
|
+
o_O.routes.rules[parsed_route] = {
|
|
36
|
+
action: o_O.routes.figure_action(options),
|
|
37
|
+
matchers: parsed_route.match(/:[^\/]*/g)
|
|
38
|
+
};
|
|
39
|
+
o_O.routes.regex_urls.push({regex: regex_to_match, matcher:parsed_route});
|
|
40
|
+
}
|
|
41
|
+
else
|
|
42
|
+
{
|
|
43
|
+
o_O.routes.rules[parsed_route] = {
|
|
44
|
+
action: o_O.routes.figure_action(options),
|
|
45
|
+
with_args: options.with_args
|
|
46
|
+
};
|
|
47
|
+
o_O.routes.urls.push(parsed_route);
|
|
48
|
+
}
|
|
34
49
|
}
|
|
35
50
|
}
|
|
36
51
|
},
|
|
@@ -53,6 +68,31 @@ o_O.routes = {
|
|
|
53
68
|
{
|
|
54
69
|
o_O.routes.rules[hash].action(o_O.routes.rules[hash].with_args);
|
|
55
70
|
}
|
|
71
|
+
else
|
|
72
|
+
{
|
|
73
|
+
for(i = 0; i < o_O.routes.regex_urls.length; i++)
|
|
74
|
+
{
|
|
75
|
+
if(match = hash.match(o_O.routes.regex_urls[i].regex))
|
|
76
|
+
{
|
|
77
|
+
var rule = o_O.routes.rules[o_O.routes.regex_urls[i].matcher];
|
|
78
|
+
rule.action(function(attr){
|
|
79
|
+
var params = {}
|
|
80
|
+
for(j = 0; j < rule.matchers.length; j++)
|
|
81
|
+
{
|
|
82
|
+
params[rule.matchers[j].replace(/^:/, '')] = match[j+1];
|
|
83
|
+
}
|
|
84
|
+
if(attr)
|
|
85
|
+
{
|
|
86
|
+
return params[attr];
|
|
87
|
+
}
|
|
88
|
+
else
|
|
89
|
+
{
|
|
90
|
+
return params;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
56
96
|
});
|
|
57
97
|
|
|
58
98
|
$('a').live('click', function(){
|
data/test/unit/test_routing.html
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
<script src="../../src/drivers/jquery/modules/o_O.controller.js"></script>
|
|
13
13
|
<script src="../../src/drivers/jquery/modules/o_O.support.js"></script>
|
|
14
14
|
<script src="../../src/drivers/jquery/modules/o_O.routes.js"></script>
|
|
15
|
-
<script src="../../src/drivers/jquery/modules/o_O.routes.js"></script>
|
|
16
15
|
|
|
17
16
|
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
|
|
18
17
|
<script type="text/javascript" src="qunit.js"></script>
|
|
@@ -47,6 +46,9 @@
|
|
|
47
46
|
}
|
|
48
47
|
$('div#namespaced-index').html(out);
|
|
49
48
|
return 'awesome!'
|
|
49
|
+
},
|
|
50
|
+
sending_params: function(params){
|
|
51
|
+
$('div#with_params').html(params('test'));
|
|
50
52
|
}
|
|
51
53
|
});
|
|
52
54
|
|
|
@@ -56,6 +58,7 @@
|
|
|
56
58
|
map.namespace('my', function(my){
|
|
57
59
|
my.match('action', {to: "reviews#namespaced_index", with_args: 'test'})
|
|
58
60
|
})
|
|
61
|
+
map.match('/reviews/:test', {to: 'reviews#sending_params'})
|
|
59
62
|
})
|
|
60
63
|
|
|
61
64
|
$(document).ready(function(){
|
|
@@ -93,6 +96,15 @@
|
|
|
93
96
|
start();
|
|
94
97
|
},100)
|
|
95
98
|
})
|
|
99
|
+
|
|
100
|
+
asyncTest('withparams',function(){
|
|
101
|
+
$('a#with-params').trigger('click');
|
|
102
|
+
setTimeout(function(){
|
|
103
|
+
equals($('div#with_params').html(), 'something', "should pass the params");
|
|
104
|
+
start();
|
|
105
|
+
},100)
|
|
106
|
+
})
|
|
107
|
+
|
|
96
108
|
|
|
97
109
|
});
|
|
98
110
|
</script>
|
|
@@ -106,11 +118,14 @@
|
|
|
106
118
|
|
|
107
119
|
<a id="index-link" data-ajax-history="true" href="/reviews/index">Hello!</a>
|
|
108
120
|
<a id="namespaced-index-link" data-ajax-history="true" href="/my/action">Hello!</a>
|
|
121
|
+
|
|
122
|
+
<a id="with-params" data-ajax-history="true" href="/reviews/something">Hello!</a>
|
|
109
123
|
|
|
110
124
|
<div id="index">
|
|
111
125
|
</div>
|
|
112
126
|
<div id="namespaced-index">
|
|
113
127
|
</div>
|
|
114
128
|
<div id="root"></div>
|
|
129
|
+
<div id="with_params"></div>
|
|
115
130
|
</body>
|
|
116
131
|
</html>
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eyeballs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 7
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 5
|
|
9
|
-
-
|
|
10
|
-
version: 0.5.
|
|
9
|
+
- 6
|
|
10
|
+
version: 0.5.6
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Paul Campbell
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2010-08-
|
|
18
|
+
date: 2010-08-06 00:00:00 +01:00
|
|
19
19
|
default_executable: eyeballs
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|