excursion 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/excursion.js +62 -0
- data/lib/excursion/version.rb +1 -1
- metadata +2 -1
@@ -0,0 +1,62 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
var Application = function(app) {
|
4
|
+
for (prop in app) {
|
5
|
+
this[prop] = app[prop];
|
6
|
+
}
|
7
|
+
|
8
|
+
for (route in this.routes) {
|
9
|
+
(function(thisApp) {
|
10
|
+
var routeName = route;
|
11
|
+
var path = thisApp.routes[routeName];
|
12
|
+
var parts = path.match(/(\(\.)?:[a-z0-9_]+\)?/gi);
|
13
|
+
thisApp[routeName + '_path'] = function() {
|
14
|
+
var replaced = path;
|
15
|
+
|
16
|
+
if (arguments.length == 1 && typeof arguments[0] == 'object') {
|
17
|
+
var args = arguments[0];
|
18
|
+
} else {
|
19
|
+
var args = arguments;
|
20
|
+
}
|
21
|
+
|
22
|
+
for (p in parts) {
|
23
|
+
if (parts[p] == '(.:format)' && !args[p]) {
|
24
|
+
replaced = replaced.replace(parts[p], '');
|
25
|
+
} else {
|
26
|
+
replaced = replaced.replace(parts[p], args[p]);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
return replaced;
|
31
|
+
};
|
32
|
+
thisApp[routeName + '_url'] = function() {
|
33
|
+
var urlOpts = thisApp.default_url_options.host;
|
34
|
+
if (thisApp.default_url_options.port && parseInt(thisApp.default_url_options.port) != 80)
|
35
|
+
urlOpts += ':' + thisApp.default_url_options.port;
|
36
|
+
|
37
|
+
return urlOpts + thisApp[routeName + '_path'](arguments);
|
38
|
+
};
|
39
|
+
}(this));
|
40
|
+
}
|
41
|
+
};
|
42
|
+
Application.prototype = {
|
43
|
+
name: null,
|
44
|
+
default_url_options: {},
|
45
|
+
routes: {},
|
46
|
+
};
|
47
|
+
|
48
|
+
Excursion = {
|
49
|
+
registerApplication: function(app, name) {
|
50
|
+
if (!name)
|
51
|
+
name = app.name;
|
52
|
+
|
53
|
+
this[name] = new Application(app);
|
54
|
+
},
|
55
|
+
|
56
|
+
loadPool: function(pool) {
|
57
|
+
for (app in pool) {
|
58
|
+
this.registerApplication(pool[app]);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
};
|
62
|
+
}());
|
data/lib/excursion/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excursion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/generators/excursion/active_record_generator.rb
|
112
112
|
- lib/generators/excursion/templates/migration.rb
|
113
113
|
- lib/excursion.rb
|
114
|
+
- app/assets/javascripts/excursion.js
|
114
115
|
- spec/excursion_spec.rb
|
115
116
|
- spec/dummy/public/500.html
|
116
117
|
- spec/dummy/public/index.html
|