calatrava 0.0.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/Rakefile +7 -1
  2. data/calatrava.gemspec +2 -2
  3. data/features/sample_app.feature +27 -0
  4. data/features/step_definitions/app_steps.rb +3 -0
  5. data/features/support/calatrava_app.rb +31 -0
  6. data/features/support/env.rb +18 -0
  7. data/lib/calatrava/project.rb +5 -2
  8. data/lib/calatrava/tasks/apache.rb +20 -10
  9. data/lib/calatrava/tasks/droid.rb +1 -1
  10. data/lib/calatrava/tasks/web.rb +5 -0
  11. data/lib/calatrava/templates/droid/app/bridge.coffee +21 -120
  12. data/lib/calatrava/templates/droid/calatrava/{src/com/CALATRAVA_TMPL → CALATRAVA_TMPL}/AndroidManifest.xml.calatrava +2 -2
  13. data/lib/calatrava/templates/droid/calatrava/{calatrava-build.xml → CALATRAVA_TMPL/build.xml.calatrava} +1 -1
  14. data/lib/calatrava/templates/droid/calatrava/src/com/CALATRAVA_TMPL/ConversionForm.java.calatrava +4 -4
  15. data/lib/calatrava/templates/droid/calatrava/src/com/CALATRAVA_TMPL/Title.java.calatrava +2 -2
  16. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/KernelBridge.java +1 -0
  17. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PageRegistry.java +13 -1
  18. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RegisteredActivity.java +7 -1
  19. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RhinoService.java +12 -7
  20. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/shell/WebViewActivity.java +2 -4
  21. data/lib/calatrava/templates/ios/src/ConversionFormViewController.h +4 -0
  22. data/lib/calatrava/templates/ios/src/ConversionFormViewController.m +36 -3
  23. data/lib/calatrava/templates/ios/src/ConversionFormViewController.xib +144 -20
  24. data/lib/calatrava/templates/kernel/app/calatrava.coffee +171 -3
  25. data/lib/calatrava/templates/kernel/app/converter/controller.converter.coffee +37 -42
  26. data/lib/calatrava/templates/kernel/app/converter/init.converter.coffee +4 -4
  27. data/lib/calatrava/templates/kernel/spec/converter/controller.converter.spec.coffee +6 -6
  28. data/lib/calatrava/templates/kernel/spec/stubView.coffee +18 -2
  29. data/lib/calatrava/templates/package.json +0 -1
  30. data/lib/calatrava/templates/shell/pages/converter/conversionForm.haml +6 -4
  31. data/lib/calatrava/templates/shell/pages/converter/page.conversionForm.coffee +18 -24
  32. data/lib/calatrava/templates/shell/stylesheets/shell.scss +0 -0
  33. data/lib/calatrava/templates/web/app/source/bridge.coffee +61 -93
  34. data/lib/calatrava/version.rb +1 -1
  35. metadata +39 -34
  36. data/lib/calatrava/templates/ios/res/js/bridge.js +0 -249
  37. data/lib/calatrava/templates/shell/shell.scss +0 -1
@@ -1,249 +0,0 @@
1
- var tw = tw || {};
2
- tw.bridge = tw.bridge || {};
3
-
4
- // json.js does stupid things to the Object prototype
5
- Object.prototype.toJSONString = "";
6
- Object.prototype.parseJSON = "";
7
-
8
- function generateRandomString(){
9
- var str = '';
10
- var i;
11
- for (i = 0; i < 32; ++i) {
12
- var r = Math.floor(Math.random() * 16);
13
- str = str + r.toString(16);
14
- }
15
- return str.toUpperCase();
16
- }
17
-
18
- function bridgeDispatch(proxyId) {
19
- var extraArgs = _.map(_.toArray(arguments).slice(1), function(obj) { return obj.valueOf(); });
20
- var proxyPage = tw.bridge.pages.pageByProxyId(proxyId);
21
- proxyPage.dispatch.apply(proxyPage, extraArgs);
22
- }
23
-
24
- function bridgeSuccessfulResponse(requestId, response) {
25
- tw.bridge.requests.successfulResponse(requestId, response);
26
- }
27
-
28
- function bridgeFailureResponse(requestId, errorCode, response) {
29
- tw.bridge.requests.failureResponse(requestId, errorCode, response);
30
- }
31
-
32
- function bridgeFireTimer(timerId) {
33
- tw.bridge.timers.fireTimer(timerId);
34
- }
35
-
36
- function bridgeInvokeCallback(widgetName) {
37
- var extraArgs = _.map(_.toArray(arguments).slice(1), function(obj) { return obj.valueOf(); });
38
- tw.bridge.widgets.callback(widgetName).apply(this, extraArgs);
39
- }
40
-
41
- tw.bridge.changePage = function(target) {
42
- tw.bridge.runtime.changePage(target);
43
- return target;
44
- };
45
-
46
- tw.bridge.widgets = (function() {
47
- var callbacks;
48
- callbacks = {};
49
- return {
50
- display: function(name, options, callback) {
51
- TWBridgePageRegistry.sharedRegistry.displayWidget_withOptions(name, options);
52
- return callbacks[name] = callback;
53
- },
54
- callback: function(name) {
55
- return callbacks[name];
56
- }
57
- };
58
- })();
59
-
60
- tw.bridge.alert = function(message) {
61
- TWBridgePageRegistry.sharedRegistry.alert(message);
62
- };
63
-
64
- tw.bridge.openUrl = function(url) {
65
- tw.bridge.runtime.openUrl(url);
66
- };
67
-
68
- tw.bridge.trackEvent = function(event) {
69
- };
70
-
71
- tw.bridge.log = function(message) {
72
- tw.bridge.runtime.log(message);
73
- };
74
-
75
- tw.bridge.request = function(options) {
76
- if (options.contentType) {
77
- options.customHeaders = options.customHeaders || {};
78
- options.customHeaders['Content-Type'] = options.contentType;
79
- }
80
- tw.bridge.requests.issue(
81
- options.url,
82
- options.method,
83
- options.body,
84
- options.success,
85
- options.failure,
86
- options.customHeaders);
87
- };
88
-
89
- tw.bridge.pageObject = function(pageName) {
90
- var proxyId = generateRandomString(),
91
- handlerRegistry = {};
92
-
93
- tw.bridge.runtime.registerProxyForPage(proxyId, pageName);
94
-
95
- function bind(event, handler) {
96
- handlerRegistry[event] = handler;
97
- tw.bridge.runtime.attachProxyEventHandler(proxyId, event);
98
- }
99
-
100
- function dispatch(event) {
101
- args = _.toArray(arguments).slice(1);
102
- if (handlerRegistry[event]) {
103
- handlerRegistry[event].apply(this, args);
104
- }
105
- }
106
-
107
- function get(field) {
108
- return tw.bridge.runtime.valueOfProxyField(proxyId, field);
109
- }
110
-
111
- function cleanValues(jsObject) {
112
- _.each(_.keys(jsObject), function(key) {
113
- if (jsObject[key] === null || jsObject[key] === undefined) {
114
- delete jsObject[key];
115
- } else if (jsObject[key] === false) {
116
- jsObject[key] = 0;
117
- } else {
118
- tw.bridge.log("key = '" + key + "'; value = '" + jsObject[key] + "'");
119
- if (jsObject[key] instanceof Object) {
120
- cleanValues(jsObject[key]);
121
- }
122
- }
123
- });
124
- }
125
-
126
- function render(viewObject) {
127
- // Clean off properties that cause problems when marshalling
128
- if (viewObject.hasOwnProperty('toJSONString')) {
129
- viewObject.toJSONString = null;
130
- }
131
-
132
- // Delete any keys that have a null value to avoid the Obj-C JSON
133
- // serialization failure
134
- if (viewObject != undefined) {
135
- cleanValues(viewObject);
136
- }
137
- if (viewObject.hasOwnProperty('parseJSON')) {
138
- viewObject.parseJSON = null;
139
- }
140
-
141
- tw.bridge.runtime.renderProxy(viewObject, proxyId);
142
- }
143
-
144
- return {
145
- proxyId: proxyId,
146
- bind: bind,
147
- dispatch: dispatch,
148
- get: get,
149
- render: render
150
- };
151
- };
152
-
153
- tw.bridge.pages = (function() {
154
- var pagesByName = {},
155
- pagesByProxyId = {};
156
-
157
- function pageNamed(pageName) {
158
- if (!pagesByName[pageName]) {
159
- var page = tw.bridge.pageObject(pageName);
160
- pagesByName[pageName] = page;
161
- pagesByProxyId[page.proxyId] = page;
162
- }
163
- return pagesByName[pageName];
164
- }
165
-
166
- function pageByProxyId(proxyId) {
167
- return pagesByProxyId[proxyId];
168
- }
169
-
170
- return {
171
- pageNamed: pageNamed,
172
- pageByProxyId: pageByProxyId
173
- };
174
- }());
175
-
176
- tw.bridge.requests = (function() {
177
- var successHandlersById = {},
178
- failureHandlersById = {};
179
-
180
- function issue(url, method, body, success, failure, customHeaders) {
181
- var requestId = generateRandomString();
182
- bodyStr = body;
183
-
184
- if (bodyStr && bodyStr.constructor !== String) {
185
- bodyStr = JSON.stringify(body);
186
- }
187
-
188
- successHandlersById[requestId] = success;
189
- failureHandlersById[requestId] = failure;
190
- tw.bridge.runtime.issueRequest({
191
- requestId: requestId,
192
- url: url,
193
- method: method,
194
- body: bodyStr,
195
- headers: customHeaders
196
- });
197
- }
198
-
199
- function successfulResponse(requestId, response) {
200
- successHandlersById[requestId](response);
201
- clearHandlers(requestId);
202
- }
203
-
204
- function failureResponse(requestId, errorCode, response) {
205
- failureHandlersById[requestId](errorCode, response);
206
- clearHandlers(requestId);
207
- }
208
-
209
- function clearHandlers(requestId) {
210
- successHandlersById[requestId] = null;
211
- failureHandlersById[requestId] = null;
212
- }
213
-
214
- return {
215
- successfulResponse: successfulResponse,
216
- failureResponse: failureResponse,
217
- issue: issue
218
- };
219
- }());
220
-
221
- tw.bridge.timers = (function () {
222
- callbacks = {};
223
-
224
- return {
225
- start: function(timeout, callback) {
226
- var timerId = generateRandomString();
227
- callbacks[timerId] = callback;
228
- tw.bridge.runtime.startTimerWithTimeout(timerId, timeout);
229
- return timerId;
230
- },
231
- fireTimer: function(timerId) {
232
- if (callbacks[timerId]) {
233
- callbacks[timerId]();
234
- }
235
- },
236
- clearTimer: function(timerId) {
237
- delete callbacks[timerId];
238
- }
239
- };
240
- }());
241
-
242
- tw.bridge.dialog = (function() {
243
- return {
244
- display: function(name) {
245
- TWBridgePageRegistry.sharedRegistry.displayDialog(name)
246
- }
247
- };
248
- }());
249
-
@@ -1 +0,0 @@
1
- # Define your custom styles for all platforms here.