calatrava 0.6.6 → 0.6.7
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/.travis.yml +1 -0
- data/CHANGES.markdown +35 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +46 -1
- data/contracts/rate-exchange.jns +12 -0
- data/lib/calatrava/apache.rb +1 -1
- data/lib/calatrava/mobile_web_app.rb +7 -0
- data/lib/calatrava/templates/.auto_compile.rb +11 -0
- data/lib/calatrava/templates/.gitignore +24 -0
- data/lib/calatrava/templates/Gemfile.calatrava +6 -3
- data/lib/calatrava/templates/build_env.sh +2 -1
- data/lib/calatrava/templates/config/environments.yml +4 -4
- data/lib/calatrava/templates/config/templates/env.coffee.erb +3 -6
- data/lib/calatrava/templates/config/templates/httpd.conf.erb +1 -1
- data/lib/calatrava/templates/droid/calatrava/CALATRAVA_TMPL/AndroidManifest.xml.calatrava +1 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/AjaxRequestManager.java +1 -1
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/NativePageStateManager.java +32 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PageStateManager.java +13 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RegisteredActivity.java +28 -2
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/shell/WebViewActivity.java +12 -62
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/shell/WebViewPageStateManager.java +89 -0
- data/lib/calatrava/templates/ios/Podfile.calatrava +1 -1
- data/lib/calatrava/templates/kernel/app/calatrava.coffee +3 -3
- data/lib/calatrava/templates/kernel/app/converter/controller.converter.coffee +7 -5
- data/lib/calatrava/templates/kernel/app/converter/init.converter.coffee +1 -1
- data/lib/calatrava/templates/kernel/app/converter/repository.converter.coffee +11 -0
- data/lib/calatrava/templates/kernel/features/support/bridge.coffee +20 -25
- data/lib/calatrava/templates/kernel/features/support/spec_helper.js +4 -4
- data/lib/calatrava/templates/kernel/plugins/alert.coffee +2 -2
- data/lib/calatrava/templates/kernel/spec/converter/controller.converter.spec.coffee +42 -19
- data/lib/calatrava/templates/kernel/spec/converter/repository.converter.spec.coffee +27 -0
- data/lib/calatrava/templates/kernel/spec/environment.spec_helper.coffee +3 -7
- data/lib/calatrava/templates/kernel/spec/spec_helper.js +3 -2
- data/lib/calatrava/templates/web/app/source/bridge.coffee +3 -7
- data/lib/calatrava/templates/web/app/source/init.coffee +6 -3
- data/lib/calatrava/version.rb +1 -1
- data/tools/janus.jar +0 -0
- metadata +11 -2
data/.travis.yml
CHANGED
data/CHANGES.markdown
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## v0.6.7
|
|
2
|
+
|
|
3
|
+
New features:
|
|
4
|
+
* Compile Kernel/Shell coffeescript files automatically upon change,
|
|
5
|
+
when apache is running
|
|
6
|
+
* Enhance currency converter sample app to start using a remote service
|
|
7
|
+
|
|
8
|
+
Bugs Fixed:
|
|
9
|
+
* [Issue #54][i54]: [droid] Ajax IOExceptions aren't properly passed
|
|
10
|
+
around
|
|
11
|
+
* [Issue #71][i71]: [web] Passed forward the error response in a ajax
|
|
12
|
+
call failure
|
|
13
|
+
* [iOS Issue #9][ios-i9]: Fixes a startup crash
|
|
14
|
+
* [Issue #75][i75]: calatrava.confirm callback argument is not defined
|
|
15
|
+
* [Issue #63][i63]: Update stub namespace of the calatrava brigde for
|
|
16
|
+
template spec files
|
|
17
|
+
* [Issue #76][i76]: Enable render for Native Android views
|
|
18
|
+
* [Issue #33][i33]: 'env: node: No such file or directory" build error
|
|
19
|
+
in xcode trying to run base project
|
|
20
|
+
* [Issue #83][i83]: Bundler might install multiple cocoapods version
|
|
21
|
+
|
|
1
22
|
## v0.6.6
|
|
2
23
|
* Fix to add mac specific dependencies conditionally
|
|
3
24
|
|
|
@@ -124,6 +145,10 @@ Changes that will affect existing projects:
|
|
|
124
145
|
* [James Gregory](https://github.com/jagregory)
|
|
125
146
|
* [Sneha Venkatesh](https://github.com/snehayv)
|
|
126
147
|
* [Dan Tao](https://github.com/dtao)
|
|
148
|
+
* [Priyank Gupta](https://github.com/priyaaank)
|
|
149
|
+
* [Rick Carragher](https://github.com/rcarragher)
|
|
150
|
+
* [Pedro Leal](https://github.com/pedrombl)
|
|
151
|
+
* [Prasanna Pendse](https://github.com/prasanna)
|
|
127
152
|
|
|
128
153
|
[i5]: https://github.com/calatrava/calatrava/issues/5
|
|
129
154
|
[i12]: https://github.com/calatrava/calatrava/issues/12
|
|
@@ -147,3 +172,13 @@ Changes that will affect existing projects:
|
|
|
147
172
|
[i43]: https://github.com/calatrava/calatrava/issues/43
|
|
148
173
|
[ios-i1]: https://github.com/calatrava/calatrava-ios/issues/1
|
|
149
174
|
[ios-i4]: https://github.com/calatrava/calatrava-ios/pull/4
|
|
175
|
+
[i67]: https://github.com/calatrava/calatrava/pull/67
|
|
176
|
+
[i72]: https://github.com/calatrava/calatrava/issues/72
|
|
177
|
+
[i71]: https://github.com/calatrava/calatrava/pull/71
|
|
178
|
+
[i54]: https://github.com/calatrava/calatrava/pull/54
|
|
179
|
+
[ios-i9]: https://github.com/calatrava/calatrava-ios/pull/9
|
|
180
|
+
[i75]: https://github.com/calatrava/calatrava/issues/75
|
|
181
|
+
[i63]: https://github.com/calatrava/calatrava/pull/63
|
|
182
|
+
[i76]: https://github.com/calatrava/calatrava/pull/76
|
|
183
|
+
[i33]: https://github.com/calatrava/calatrava/issues/33
|
|
184
|
+
[i83]: https://github.com/calatrava/calatrava/issues/83
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
calatrava (0.6.
|
|
4
|
+
calatrava (0.6.6)
|
|
5
5
|
cucumber (~> 1.2.1)
|
|
6
6
|
haml (~> 3.1.7)
|
|
7
7
|
mustache (~> 0.99.4)
|
|
@@ -13,6 +13,10 @@ PATH
|
|
|
13
13
|
GEM
|
|
14
14
|
remote: https://rubygems.org/
|
|
15
15
|
specs:
|
|
16
|
+
activesupport (3.2.13)
|
|
17
|
+
i18n (= 0.6.1)
|
|
18
|
+
multi_json (~> 1.0)
|
|
19
|
+
addressable (2.3.4)
|
|
16
20
|
aruba (0.5.1)
|
|
17
21
|
childprocess (~> 0.3.6)
|
|
18
22
|
cucumber (>= 1.1.1)
|
|
@@ -20,19 +24,55 @@ GEM
|
|
|
20
24
|
builder (3.1.4)
|
|
21
25
|
childprocess (0.3.6)
|
|
22
26
|
ffi (~> 1.0, >= 1.0.6)
|
|
27
|
+
claide (0.2.0)
|
|
28
|
+
cocoapods (0.19.1)
|
|
29
|
+
activesupport (~> 3.2.13)
|
|
30
|
+
claide (~> 0.2.0)
|
|
31
|
+
cocoapods-core (= 0.19.1)
|
|
32
|
+
cocoapods-downloader (~> 0.1.0)
|
|
33
|
+
colored (~> 1.2)
|
|
34
|
+
escape (~> 0.0.4)
|
|
35
|
+
faraday (~> 0.8.1)
|
|
36
|
+
json (~> 1.7.3)
|
|
37
|
+
octokit (~> 1.7)
|
|
38
|
+
open4 (~> 1.3.0)
|
|
39
|
+
rake (~> 10.0.0)
|
|
40
|
+
xcodeproj (~> 0.5.5)
|
|
41
|
+
cocoapods-core (0.19.1)
|
|
42
|
+
activesupport (~> 3.2.13)
|
|
43
|
+
rake (~> 10.0.0)
|
|
44
|
+
cocoapods-downloader (0.1.0)
|
|
45
|
+
colored (1.2)
|
|
23
46
|
cucumber (1.2.1)
|
|
24
47
|
builder (>= 2.1.2)
|
|
25
48
|
diff-lcs (>= 1.1.3)
|
|
26
49
|
gherkin (~> 2.11.0)
|
|
27
50
|
json (>= 1.4.6)
|
|
28
51
|
diff-lcs (1.1.3)
|
|
52
|
+
escape (0.0.4)
|
|
53
|
+
faraday (0.8.7)
|
|
54
|
+
multipart-post (~> 1.1)
|
|
55
|
+
faraday_middleware (0.9.0)
|
|
56
|
+
faraday (>= 0.7.4, < 0.9)
|
|
29
57
|
ffi (1.2.0)
|
|
30
58
|
gherkin (2.11.5)
|
|
31
59
|
json (>= 1.4.6)
|
|
32
60
|
haml (3.1.8)
|
|
61
|
+
hashie (2.0.5)
|
|
62
|
+
i18n (0.6.1)
|
|
33
63
|
json (1.7.5)
|
|
34
64
|
multi_json (1.7.3)
|
|
65
|
+
multipart-post (1.2.0)
|
|
35
66
|
mustache (0.99.4)
|
|
67
|
+
netrc (0.7.7)
|
|
68
|
+
octokit (1.24.0)
|
|
69
|
+
addressable (~> 2.2)
|
|
70
|
+
faraday (~> 0.8)
|
|
71
|
+
faraday_middleware (~> 0.9)
|
|
72
|
+
hashie (~> 2.0)
|
|
73
|
+
multi_json (~> 1.3)
|
|
74
|
+
netrc (~> 0.7.7)
|
|
75
|
+
open4 (1.3.0)
|
|
36
76
|
rake (10.0.4)
|
|
37
77
|
rspec (2.12.0)
|
|
38
78
|
rspec-core (~> 2.12.0)
|
|
@@ -53,6 +93,9 @@ GEM
|
|
|
53
93
|
watir-webdriver (0.6.4)
|
|
54
94
|
selenium-webdriver (>= 2.18.0)
|
|
55
95
|
websocket (1.0.7)
|
|
96
|
+
xcodeproj (0.5.5)
|
|
97
|
+
activesupport (~> 3.2.13)
|
|
98
|
+
colored (~> 1.2)
|
|
56
99
|
|
|
57
100
|
PLATFORMS
|
|
58
101
|
ruby
|
|
@@ -60,4 +103,6 @@ PLATFORMS
|
|
|
60
103
|
DEPENDENCIES
|
|
61
104
|
aruba
|
|
62
105
|
calatrava!
|
|
106
|
+
cocoapods
|
|
63
107
|
rspec
|
|
108
|
+
xcodeproj
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(service
|
|
2
|
+
"Rate Exchange"
|
|
3
|
+
|
|
4
|
+
(contract "Get currency exchange rate"
|
|
5
|
+
(method :get)
|
|
6
|
+
(url "http://rate-exchange.appspot.com/currency?from=USD&to=INR")
|
|
7
|
+
|
|
8
|
+
(should-have :path "$.to" :equal-to "INR")
|
|
9
|
+
(should-have :path "$.from" :equal-to "USD")
|
|
10
|
+
(should-have :path "$.rate" :of-type :number)
|
|
11
|
+
)
|
|
12
|
+
)
|
data/lib/calatrava/apache.rb
CHANGED
|
@@ -75,7 +75,7 @@ module Calatrava
|
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
desc "launch a non-daemon apache instance on port 8888 which will serve our local app and also proxy to backend services"
|
|
78
|
-
task :start => ['web:build', apache_public_dir, apache_logs_dir, "#{apache_conf_dir}/httpd.conf"] do
|
|
78
|
+
task :start => ['web:build', apache_public_dir, apache_logs_dir, "#{apache_conf_dir}/httpd.conf", 'web:autocompile'] do
|
|
79
79
|
launch_apache
|
|
80
80
|
end
|
|
81
81
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
if Gem::Specification.find_all_by_name('filewatcher').count > 0
|
|
2
|
+
require 'filewatcher'
|
|
3
|
+
FileWatcher.new(Dir["kernel/app/**/*.coffee", "kernel/plugins/**/*coffee", "shell/**/*.coffee"]).watch do |filename|
|
|
4
|
+
puts "Recompiling file " + filename
|
|
5
|
+
system "node_modules/coffee-script/bin/coffee --compile --output web/public/scripts #{filename}"
|
|
6
|
+
end
|
|
7
|
+
else
|
|
8
|
+
$stderr.puts("*"*100)
|
|
9
|
+
$stderr.puts("File watcher gem is not present as part of gem set. Your kernel and shell files won't be auto compiled.")
|
|
10
|
+
$stderr.puts("*"*100)
|
|
11
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
artifacts/
|
|
2
|
+
config/result/
|
|
3
|
+
droid/*/ant/
|
|
4
|
+
droid/*/ivy/
|
|
5
|
+
droid/*/assets/calatrava/
|
|
6
|
+
droid/*/bin/
|
|
7
|
+
droid/*/gen/
|
|
8
|
+
node_modules/
|
|
9
|
+
.idea/
|
|
10
|
+
.node_updated
|
|
11
|
+
ios/public/
|
|
12
|
+
ios/*.xcworkspace/
|
|
13
|
+
.sass-cache/
|
|
14
|
+
.rake/
|
|
15
|
+
web/apache/conf/httpd.conf
|
|
16
|
+
web/apache/logs/
|
|
17
|
+
web/apache/public
|
|
18
|
+
web/public/
|
|
19
|
+
*.iml
|
|
20
|
+
.DS_Store
|
|
21
|
+
*.apk
|
|
22
|
+
*.ap_
|
|
23
|
+
*.dex
|
|
24
|
+
*.class
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
source :rubygems
|
|
2
2
|
|
|
3
|
-
gem "rake"
|
|
3
|
+
gem "rake", ">= 0.9.5"
|
|
4
4
|
gem "calatrava"{{#dev?}}, :path => '../'{{/dev?}}
|
|
5
|
-
{{#mac?}}gem "xcodeproj"
|
|
6
|
-
gem "cocoapods"{{/mac?}}
|
|
5
|
+
{{#mac?}}gem "xcodeproj", ">= 0.4.0"
|
|
6
|
+
gem "cocoapods", ">= 0.16.0"{{/mac?}}
|
|
7
|
+
|
|
8
|
+
#auto compile shell and kernel for webapp. If you remove this, it'll stop auto compiling
|
|
9
|
+
gem "filewatcher"
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
local:
|
|
2
|
-
api_endpoint : "http://
|
|
2
|
+
api_endpoint : "http://rate-exchange.appspot.com"
|
|
3
3
|
web_port : 8888
|
|
4
4
|
|
|
5
5
|
development:
|
|
6
|
-
api_endpoint : "http://
|
|
6
|
+
api_endpoint : "http://rate-exchange.appspot.com"
|
|
7
7
|
web_port : 8888
|
|
8
8
|
|
|
9
9
|
test:
|
|
10
|
-
api_endpoint : "http://
|
|
10
|
+
api_endpoint : "http://rate-exchange.appspot.com"
|
|
11
11
|
web_port : 8888
|
|
12
12
|
|
|
13
13
|
automation:
|
|
14
|
-
api_endpoint : "http://
|
|
14
|
+
api_endpoint : "http://rate-exchange.appspot.com"
|
|
15
15
|
web_port : 8889
|
|
16
16
|
|
|
17
17
|
production:
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
tw = root.tw
|
|
4
|
-
tw.bridge = tw.bridge ? {}
|
|
1
|
+
example ?= {}
|
|
2
|
+
example.converter ?= {}
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
serviceEndpoint: "<%= configuration['service_endpoint'] %>"
|
|
4
|
+
example.converter.apiEndpoint = "<%= configuration['api_endpoint'] %>" if _.isUndefined(example.converter.apiEndpoint)
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
package="com.{{ project_slug }}"
|
|
4
4
|
android:versionCode="1"
|
|
5
5
|
android:versionName="1.0">
|
|
6
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
6
7
|
<application android:label="@string/app_name"
|
|
7
8
|
android:name="{{ project_title }}">
|
|
8
9
|
<activity android:name=".Bootstrap"
|
data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/AjaxRequestManager.java
CHANGED
|
@@ -110,7 +110,7 @@ public class AjaxRequestManager {
|
|
|
110
110
|
} catch (IOException e) {
|
|
111
111
|
Log.d(TAG, "Request threw exception", e);
|
|
112
112
|
Log.d(TAG, "requestId: " + requestId);
|
|
113
|
-
rhino.invokeFailureCallback(requestId, 500,
|
|
113
|
+
rhino.invokeFailureCallback(requestId, 500, e.toString());
|
|
114
114
|
} finally {
|
|
115
115
|
Log.d(TAG, "About to hide loader");
|
|
116
116
|
context.sendBroadcast(new Intent("com.calatrava.ajax.finish"));
|
data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/NativePageStateManager.java
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package com.calatrava.bridge;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
|
|
5
|
+
public class NativePageStateManager implements PageStateManager {
|
|
6
|
+
|
|
7
|
+
private RegisteredActivity activity;
|
|
8
|
+
|
|
9
|
+
public NativePageStateManager(Activity activity) {
|
|
10
|
+
this.activity = (RegisteredActivity) activity;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Override
|
|
14
|
+
public void onCreateProcessing() {
|
|
15
|
+
activity.registerPage();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
public void onResumeProcessing() {
|
|
20
|
+
activity.pageOnScreen();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Override
|
|
24
|
+
public void onPauseProcessing() {
|
|
25
|
+
activity.pageOffScreen();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Override
|
|
29
|
+
public void onDestroyProcessing() {
|
|
30
|
+
activity.unRegisterPage();
|
|
31
|
+
}
|
|
32
|
+
}
|
data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RegisteredActivity.java
CHANGED
|
@@ -8,9 +8,10 @@ import android.util.Log;
|
|
|
8
8
|
|
|
9
9
|
public abstract class RegisteredActivity extends Activity {
|
|
10
10
|
private String TAG = RegisteredActivity.class.getSimpleName();
|
|
11
|
-
|
|
12
11
|
private RhinoService rhino;
|
|
12
|
+
|
|
13
13
|
private RequestLoader spinner = new RequestLoader(this);
|
|
14
|
+
protected PageStateManager pageStateManager;
|
|
14
15
|
|
|
15
16
|
private BroadcastReceiver receiver = new BroadcastReceiver() {
|
|
16
17
|
@Override
|
|
@@ -29,7 +30,13 @@ public abstract class RegisteredActivity extends Activity {
|
|
|
29
30
|
@Override
|
|
30
31
|
protected void onCreate(Bundle availableData) {
|
|
31
32
|
super.onCreate(availableData);
|
|
33
|
+
initializePageStateManager();
|
|
32
34
|
rhino = ((CalatravaApplication)getApplication()).getRhino();
|
|
35
|
+
pageStateManager.onCreateProcessing();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected void initializePageStateManager() {
|
|
39
|
+
pageStateManager = new NativePageStateManager(this);
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
@Override
|
|
@@ -38,27 +45,46 @@ public abstract class RegisteredActivity extends Activity {
|
|
|
38
45
|
registerReceiver(receiver, new IntentFilter("com.calatrava.ajax.start"));
|
|
39
46
|
registerReceiver(receiver, new IntentFilter("com.calatrava.ajax.finish"));
|
|
40
47
|
registerReceiver(receiver, new IntentFilter("com.calatrava.command"));
|
|
48
|
+
pageStateManager.onResumeProcessing();
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
@Override
|
|
44
52
|
protected void onPause() {
|
|
45
53
|
super.onPause();
|
|
46
54
|
unregisterReceiver(receiver);
|
|
55
|
+
pageStateManager.onPauseProcessing();
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
@Override
|
|
50
59
|
public void onDestroy() {
|
|
51
60
|
super.onDestroy();
|
|
61
|
+
pageStateManager.onDestroyProcessing();
|
|
52
62
|
}
|
|
53
63
|
|
|
54
64
|
public void triggerEvent(String event, String... extraArgs) {
|
|
55
65
|
PageRegistry.sharedRegistry().triggerEvent(getPageName(), event, extraArgs);
|
|
56
66
|
}
|
|
57
|
-
|
|
67
|
+
|
|
58
68
|
public void invokeWidgetCallback(String...args) {
|
|
59
69
|
rhino.callJsFunction("calatrava.inbound.invokeCallback", args);
|
|
60
70
|
}
|
|
61
71
|
|
|
72
|
+
public void pageOnScreen() {
|
|
73
|
+
PageRegistry.sharedRegistry().pageOnscreen(getPageName());
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public void pageOffScreen() {
|
|
77
|
+
PageRegistry.sharedRegistry().pageOffscreen(getPageName());
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public void registerPage() {
|
|
81
|
+
PageRegistry.sharedRegistry().registerPage(getPageName(), this);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public void unRegisterPage() {
|
|
85
|
+
PageRegistry.sharedRegistry().unregisterPage(getPageName());
|
|
86
|
+
}
|
|
87
|
+
|
|
62
88
|
protected abstract String getPageName();
|
|
63
89
|
|
|
64
90
|
public abstract String getFieldValue(String field);
|
|
@@ -7,15 +7,10 @@ import android.content.IntentFilter;
|
|
|
7
7
|
import android.graphics.Color;
|
|
8
8
|
import android.os.Bundle;
|
|
9
9
|
import android.util.Log;
|
|
10
|
-
import android.webkit.JsResult;
|
|
11
|
-
import android.webkit.WebChromeClient;
|
|
12
10
|
import android.webkit.WebView;
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
import com.calatrava.bridge.CalatravaApplication;
|
|
11
|
+
import com.calatrava.bridge.PageStateManager;
|
|
16
12
|
import com.calatrava.bridge.RegisteredActivity;
|
|
17
13
|
import com.calatrava.bridge.RhinoService;
|
|
18
|
-
import com.calatrava.bridge.PageRegistry;
|
|
19
14
|
|
|
20
15
|
import java.util.HashMap;
|
|
21
16
|
import java.util.List;
|
|
@@ -45,17 +40,18 @@ public abstract class WebViewActivity extends RegisteredActivity {
|
|
|
45
40
|
protected void onCreate(Bundle data)
|
|
46
41
|
{
|
|
47
42
|
super.onCreate(data);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Override
|
|
46
|
+
protected void initializePageStateManager() {
|
|
48
47
|
jsContainer = new JSContainer(getRhino(), getPageName());
|
|
49
|
-
|
|
48
|
+
webView = new WebView(this);
|
|
49
|
+
pageStateManager = new WebViewPageStateManager(this, jsContainer, getPageName(), webView);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
@Override
|
|
53
53
|
protected void onResume() {
|
|
54
54
|
super.onResume();
|
|
55
|
-
|
|
56
|
-
onPageLoadCompleted();
|
|
57
|
-
pageHasOpened();
|
|
58
|
-
|
|
59
55
|
registerReceiver(receiver, new IntentFilter("com.calatrava.dialog"));
|
|
60
56
|
}
|
|
61
57
|
|
|
@@ -63,15 +59,12 @@ public abstract class WebViewActivity extends RegisteredActivity {
|
|
|
63
59
|
protected void onPause() {
|
|
64
60
|
super.onPause();
|
|
65
61
|
|
|
66
|
-
PageRegistry.sharedRegistry().pageOffscreen(getPageName());
|
|
67
62
|
unregisterReceiver(receiver);
|
|
68
63
|
}
|
|
69
64
|
|
|
70
65
|
@Override
|
|
71
66
|
public void onDestroy() {
|
|
72
67
|
super.onDestroy();
|
|
73
|
-
|
|
74
|
-
PageRegistry.sharedRegistry().unregisterPage(getPageName());
|
|
75
68
|
}
|
|
76
69
|
|
|
77
70
|
public String getFieldValue(final String field) {
|
|
@@ -115,60 +108,17 @@ public abstract class WebViewActivity extends RegisteredActivity {
|
|
|
115
108
|
protected abstract List<String> getEvents();
|
|
116
109
|
|
|
117
110
|
protected abstract List<String> getFields();
|
|
118
|
-
|
|
111
|
+
|
|
119
112
|
protected int getBackgroundColor(){
|
|
120
113
|
return Color.TRANSPARENT;
|
|
121
114
|
}
|
|
122
115
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
webView = new WebView(this);
|
|
127
|
-
setContentView(webView);
|
|
128
|
-
|
|
129
|
-
webView.getSettings().setJavaScriptEnabled(true);
|
|
130
|
-
webView.getSettings().setDomStorageEnabled(true);
|
|
131
|
-
webView.setScrollBarStyle(webView.SCROLLBARS_OUTSIDE_OVERLAY);
|
|
132
|
-
webView.setScrollbarFadingEnabled(true);
|
|
133
|
-
webView.addJavascriptInterface(jsContainer, "container");
|
|
134
|
-
|
|
135
|
-
webView.setWebViewClient(new WebViewClient() {
|
|
136
|
-
@Override
|
|
137
|
-
public void onPageFinished(WebView view, String url) {
|
|
138
|
-
super.onPageFinished(view, url);
|
|
139
|
-
Log.d(TAG, "Webview finished loading a URL");
|
|
140
|
-
|
|
141
|
-
pageReady = true;
|
|
142
|
-
onPageLoadCompleted();
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
webView.setWebChromeClient(new WebChromeClient() {
|
|
147
|
-
@Override
|
|
148
|
-
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
|
|
149
|
-
Log.d(TAG, "Received JS alert: '" + message + "'");
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
webView.loadUrl("file:///android_asset/calatrava/views/" + getPageName() + ".html");
|
|
155
|
-
pageHasOpened();
|
|
116
|
+
public void pageReadiness(boolean pageState) {
|
|
117
|
+
this.pageReady = pageState;
|
|
156
118
|
}
|
|
157
119
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
private void onPageLoadCompleted() {
|
|
163
|
-
if (jsContainer != null && pageReady) {
|
|
164
|
-
jsContainer.onRenderComplete(null);
|
|
165
|
-
|
|
166
|
-
for (String field : getFields()) {
|
|
167
|
-
jsContainer.hasField(field);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
PageRegistry.sharedRegistry().pageOnscreen(getPageName());
|
|
171
|
-
}
|
|
120
|
+
public boolean pageState() {
|
|
121
|
+
return pageReady;
|
|
172
122
|
}
|
|
173
123
|
|
|
174
124
|
public class JSContainer {
|
data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/shell/WebViewPageStateManager.java
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
package com.calatrava.shell;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
import android.webkit.JsResult;
|
|
6
|
+
import android.webkit.WebChromeClient;
|
|
7
|
+
import android.webkit.WebView;
|
|
8
|
+
import android.webkit.WebViewClient;
|
|
9
|
+
import com.calatrava.bridge.PageStateManager;
|
|
10
|
+
|
|
11
|
+
public class WebViewPageStateManager implements PageStateManager {
|
|
12
|
+
|
|
13
|
+
private static final String TAG = WebViewPageStateManager.class.getSimpleName();
|
|
14
|
+
private WebViewActivity webViewActivity;
|
|
15
|
+
private WebViewActivity.JSContainer jsContainer;
|
|
16
|
+
private final String pageName;
|
|
17
|
+
private final WebView webView;
|
|
18
|
+
|
|
19
|
+
public WebViewPageStateManager(Activity activity, WebViewActivity.JSContainer jsContainer, String pageName, WebView webView) {
|
|
20
|
+
this.webViewActivity = (WebViewActivity) activity;
|
|
21
|
+
this.jsContainer = jsContainer;
|
|
22
|
+
this.pageName = pageName;
|
|
23
|
+
this.webView = webView;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public void onCreateProcessing() {
|
|
27
|
+
webViewActivity.registerPage();
|
|
28
|
+
|
|
29
|
+
webViewActivity.setContentView(webView);
|
|
30
|
+
|
|
31
|
+
webView.getSettings().setJavaScriptEnabled(true);
|
|
32
|
+
webView.getSettings().setDomStorageEnabled(true);
|
|
33
|
+
webView.setScrollBarStyle(webView.SCROLLBARS_OUTSIDE_OVERLAY);
|
|
34
|
+
webView.setScrollbarFadingEnabled(true);
|
|
35
|
+
webView.addJavascriptInterface(jsContainer, "container");
|
|
36
|
+
|
|
37
|
+
webView.setWebViewClient(new WebViewClient() {
|
|
38
|
+
@Override
|
|
39
|
+
public void onPageFinished(WebView view, String url) {
|
|
40
|
+
super.onPageFinished(view, url);
|
|
41
|
+
Log.d(TAG, "Webview finished loading a URL");
|
|
42
|
+
|
|
43
|
+
webViewActivity.pageReadiness(true);
|
|
44
|
+
onPageLoadCompleted();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
webView.setWebChromeClient(new WebChromeClient() {
|
|
49
|
+
@Override
|
|
50
|
+
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
|
|
51
|
+
Log.d(TAG, "Received JS alert: '" + message + "'");
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
webView.loadUrl("file:///android_asset/calatrava/views/" + pageName + ".html");
|
|
57
|
+
pageHasOpened();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public void onResumeProcessing() {
|
|
61
|
+
onPageLoadCompleted();
|
|
62
|
+
pageHasOpened();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public void onPauseProcessing() {
|
|
66
|
+
webViewActivity.pageOffScreen();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public void onDestroyProcessing() {
|
|
70
|
+
webViewActivity.unRegisterPage();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private void onPageLoadCompleted() {
|
|
74
|
+
if (jsContainer != null && webViewActivity.pageState()) {
|
|
75
|
+
jsContainer.onRenderComplete(null);
|
|
76
|
+
|
|
77
|
+
for (String field : webViewActivity.getFields()) {
|
|
78
|
+
jsContainer.hasField(field);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
webViewActivity.pageOnScreen();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private void pageHasOpened() {
|
|
86
|
+
webViewActivity.triggerEvent("pageOpened", new String[]{});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
}
|
|
@@ -3,7 +3,7 @@ platform :ios, '5.0'
|
|
|
3
3
|
xcodeproj '{{ project_name}}.xcodeproj'
|
|
4
4
|
|
|
5
5
|
{{^dev?}}
|
|
6
|
-
pod 'calatrava', :git => 'https://github.com/calatrava/calatrava-ios', :commit => '
|
|
6
|
+
pod 'calatrava', :git => 'https://github.com/calatrava/calatrava-ios', :commit => '50b05d43055bc6680ea55ce888ab692c00193c28'
|
|
7
7
|
{{/dev?}}
|
|
8
8
|
{{#dev?}}
|
|
9
9
|
pod 'calatrava', :local => '../../../calatrava-ios'
|
|
@@ -22,7 +22,7 @@ calatrava.inbound =
|
|
|
22
22
|
calatrava.bridge.requests.successfulResponse(requestId, response)
|
|
23
23
|
|
|
24
24
|
failureResponse: (requestId, errorCode, response) ->
|
|
25
|
-
calatrava.bridge.requests.failureResponse(requestId,errorCode, response)
|
|
25
|
+
calatrava.bridge.requests.failureResponse(requestId, errorCode, response)
|
|
26
26
|
|
|
27
27
|
fireTimer: (timerId) ->
|
|
28
28
|
calatrava.bridge.timers.fireTimer(timerId)
|
|
@@ -165,8 +165,8 @@ calatrava.bridge.requests = (() ->
|
|
|
165
165
|
successHandlersById[requestId](response) if successHandlersById[requestId]
|
|
166
166
|
clearHandlers(requestId)
|
|
167
167
|
|
|
168
|
-
failureResponse: (requestId, response) ->
|
|
169
|
-
failureHandlersById[requestId](response) if failureHandlersById[requestId]
|
|
168
|
+
failureResponse: (requestId, errorCode, response) ->
|
|
169
|
+
failureHandlersById[requestId](errorCode, response) if failureHandlersById[requestId]
|
|
170
170
|
clearHandlers(requestId)
|
|
171
171
|
)()
|
|
172
172
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
example ?= {}
|
|
2
2
|
example.converter ?= {}
|
|
3
3
|
|
|
4
|
-
example.converter.controller = ({views, changePage,
|
|
4
|
+
example.converter.controller = ({views, changePage, repository}) ->
|
|
5
5
|
currencies = ['USD', 'AUD', 'GBP', 'INR']
|
|
6
6
|
currencyRate =
|
|
7
7
|
USD: 1
|
|
@@ -19,10 +19,12 @@ example.converter.controller = ({views, changePage, ajax}) ->
|
|
|
19
19
|
selected: c == selectedCurrency
|
|
20
20
|
|
|
21
21
|
performConversion = (amount) ->
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
repository.exchangeRate
|
|
23
|
+
from: inCurrency
|
|
24
|
+
to: outCurrency
|
|
25
|
+
ifSucceeded: (rate) ->
|
|
26
|
+
views.conversionForm.render
|
|
27
|
+
out_amount: (Math.round(amount * rate * 100)) / 100
|
|
26
28
|
|
|
27
29
|
convert = () ->
|
|
28
30
|
views.conversionForm.get 'in_amount', (inAmount) ->
|
|
@@ -6,6 +6,6 @@ example.converter.start = ->
|
|
|
6
6
|
views:
|
|
7
7
|
conversionForm: calatrava.bridge.pages.pageNamed "conversionForm"
|
|
8
8
|
changePage: calatrava.bridge.changePage
|
|
9
|
-
|
|
9
|
+
repository: example.converter.repository calatrava.bridge.request
|
|
10
10
|
|
|
11
11
|
calatrava.bridge.changePage "conversionForm"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
example ?= {}
|
|
2
|
+
example.converter ?= {}
|
|
3
|
+
|
|
4
|
+
example.converter.repository = (ajax) ->
|
|
5
|
+
exchangeRate: (options) ->
|
|
6
|
+
ajax
|
|
7
|
+
url: "#{example.converter.apiEndpoint}/currency?from=#{options.from}&to=#{options.to}"
|
|
8
|
+
method: "GET"
|
|
9
|
+
success: (response) ->
|
|
10
|
+
options.ifSucceeded JSON.parse(response).rate
|
|
11
|
+
failure: options.elseFailed
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
calatrava ?= {}
|
|
2
|
+
calatrava.bridge = calatrava.bridge ? {}
|
|
3
3
|
|
|
4
4
|
generateRandomString = () ->
|
|
5
5
|
str = ''
|
|
@@ -8,15 +8,10 @@ generateRandomString = () ->
|
|
|
8
8
|
str = str + r.toString(16)
|
|
9
9
|
return str.toUpperCase();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
apiEndpoint: "http://localhost:4568"
|
|
14
|
-
sessionTimeout: 10
|
|
11
|
+
calatrava.bridge.dispatchEvent = (page, event) ->
|
|
12
|
+
calatrava.bridge.pages.pageNamed(page).dispatch(event)
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
tw.bridge.pages.pageNamed(page).dispatch(event)
|
|
18
|
-
|
|
19
|
-
class tw.bridge.Page
|
|
14
|
+
class calatrava.bridge.Page
|
|
20
15
|
constructor: (@pageName) ->
|
|
21
16
|
@fieldValues = {}
|
|
22
17
|
@handlerRegistry = {}
|
|
@@ -51,24 +46,24 @@ class tw.bridge.Page
|
|
|
51
46
|
allRenderObjects: () ->
|
|
52
47
|
@renderObjects
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
calatrava.bridge.changePage = (target) ->
|
|
50
|
+
calatrava.bridge.pages.setCurrent(target)
|
|
51
|
+
calatrava.bridge.changedPage = target
|
|
57
52
|
|
|
58
|
-
|
|
53
|
+
calatrava.bridge.pages = (() ->
|
|
59
54
|
pagesByName = {}
|
|
60
55
|
current = ""
|
|
61
56
|
|
|
62
57
|
pageNamed: (pageName) ->
|
|
63
58
|
if (!pagesByName[pageName])
|
|
64
|
-
pagesByName[pageName] = new
|
|
59
|
+
pagesByName[pageName] = new calatrava.bridge.Page(pageName)
|
|
65
60
|
pagesByName[pageName]
|
|
66
61
|
|
|
67
62
|
current: () -> pagesByName[current]
|
|
68
63
|
setCurrent: (newPage) -> current = newPage
|
|
69
64
|
)()
|
|
70
65
|
|
|
71
|
-
class
|
|
66
|
+
class calatrava.bridge.Widget
|
|
72
67
|
constructor: (@name, @options, @callback) ->
|
|
73
68
|
|
|
74
69
|
getCallback: ->
|
|
@@ -77,16 +72,16 @@ class tw.bridge.Widget
|
|
|
77
72
|
getOptions: ->
|
|
78
73
|
@options
|
|
79
74
|
|
|
80
|
-
|
|
75
|
+
calatrava.bridge.widgets = (()->
|
|
81
76
|
widgets = {}
|
|
82
77
|
display: (name, options, callback) ->
|
|
83
|
-
widgets[name] = new
|
|
78
|
+
widgets[name] = new calatrava.bridge.Widget(name, options, callback)
|
|
84
79
|
|
|
85
80
|
widget: (name) ->
|
|
86
81
|
widgets[name]
|
|
87
82
|
)()
|
|
88
83
|
|
|
89
|
-
|
|
84
|
+
calatrava.bridge.timers = (() ->
|
|
90
85
|
timers = {}
|
|
91
86
|
start: (timeout, callback) ->
|
|
92
87
|
timers["searchResultsExpired"] = callback
|
|
@@ -97,19 +92,19 @@ tw.bridge.timers = (() ->
|
|
|
97
92
|
timers[name]()
|
|
98
93
|
)()
|
|
99
94
|
|
|
100
|
-
|
|
95
|
+
calatrava.bridge.dialog = (() ->
|
|
101
96
|
display: (name) ->
|
|
102
97
|
)()
|
|
103
98
|
|
|
104
|
-
|
|
99
|
+
calatrava.bridge.request = (reqOptions) ->
|
|
105
100
|
# mock this for kernel features
|
|
106
|
-
response =
|
|
101
|
+
response = calatrava.bridge.requests.issue reqOptions
|
|
107
102
|
if response.status == 'successful'
|
|
108
103
|
reqOptions.success(response.body)
|
|
109
104
|
else
|
|
110
105
|
reqOptions.failure(response.body)
|
|
111
106
|
|
|
112
|
-
|
|
107
|
+
calatrava.bridge.requests = (() ->
|
|
113
108
|
storedRequests = []
|
|
114
109
|
|
|
115
110
|
stubRequest: (options) ->
|
|
@@ -119,6 +114,6 @@ tw.bridge.requests = (() ->
|
|
|
119
114
|
_.tap _.chain(storedRequests).filter((sr) -> sr.url.test(options.url)).last().value().response, (v) ->
|
|
120
115
|
)()
|
|
121
116
|
|
|
122
|
-
|
|
117
|
+
calatrava.bridge.alert = (message) ->
|
|
123
118
|
|
|
124
|
-
|
|
119
|
+
calatrava.bridge.trackEvent = () ->
|
|
@@ -14,7 +14,7 @@ date = require('date');
|
|
|
14
14
|
underscore = require('underscore');
|
|
15
15
|
_ = underscore;
|
|
16
16
|
|
|
17
|
-
exports.
|
|
17
|
+
exports.calatrava = require('bridge').calatrava;
|
|
18
18
|
|
|
19
19
|
function recursiveExtend(moduleToExtend, module) {
|
|
20
20
|
_.each(module, function (value, key) {
|
|
@@ -33,15 +33,15 @@ function getPageObjectForPageName(pageName){
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function getWidget(name) {
|
|
36
|
-
return
|
|
36
|
+
return calatrava.bridge.widgets.widget(name)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function showDialog(name) {
|
|
40
|
-
return
|
|
40
|
+
return calatrava.bridge.dialog.display(name)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function triggerTimer(name){
|
|
44
|
-
return
|
|
44
|
+
return calatrava.bridge.timers.triggerTimer(name)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
exports.getPageObjectForPageName = getPageObjectForPageName;
|
|
@@ -3,9 +3,9 @@ calatrava.alert = (message) ->
|
|
|
3
3
|
message: message
|
|
4
4
|
|
|
5
5
|
calatrava.confirm = (message, onOkExecute) ->
|
|
6
|
-
okCallbackHandle = calatrava.bridge.plugins.rememberCallback () ->
|
|
6
|
+
okCallbackHandle = calatrava.bridge.plugins.rememberCallback (result) ->
|
|
7
7
|
calatrava.bridge.plugins.deleteCallback(okCallbackHandle)
|
|
8
|
-
onOkExecute()
|
|
8
|
+
onOkExecute(result)
|
|
9
9
|
|
|
10
10
|
calatrava.bridge.plugins.call 'alert', 'displayConfirm',
|
|
11
11
|
message: message
|
|
@@ -4,34 +4,57 @@ example = exports.example
|
|
|
4
4
|
stubView = exports.stubView
|
|
5
5
|
|
|
6
6
|
describe 'converter controller', ->
|
|
7
|
-
ajax = null
|
|
8
|
-
changePage = null
|
|
9
|
-
views = null
|
|
10
|
-
|
|
11
7
|
beforeEach ->
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
views =
|
|
8
|
+
@changePage = jasmine.createSpy('page changer').andCallFake (targetPage) ->
|
|
9
|
+
if @views[targetPage].boundEvents['pageOpened']?
|
|
10
|
+
@views[targetPage].trigger 'pageOpened'
|
|
11
|
+
@views =
|
|
17
12
|
conversionForm: stubView.create('converterForm')
|
|
13
|
+
@exchangeRateRepository = jasmine.createSpy "fake repository"
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
changePage: changePage
|
|
21
|
-
views: views
|
|
22
|
-
|
|
15
|
+
example.converter.controller
|
|
16
|
+
changePage: @changePage
|
|
17
|
+
views: @views
|
|
18
|
+
repository:
|
|
19
|
+
exchangeRate: @exchangeRateRepository
|
|
23
20
|
|
|
24
21
|
it 'should bind the convert event', ->
|
|
25
|
-
expect(views.conversionForm.boundEvents['convert']).not.toBeUndefined()
|
|
22
|
+
expect(@views.conversionForm.boundEvents['convert']).not.toBeUndefined()
|
|
26
23
|
|
|
27
24
|
describe 'converting', ->
|
|
28
25
|
|
|
29
26
|
beforeEach ->
|
|
30
|
-
views.conversionForm.fieldContains 'in_currency', 'USD'
|
|
31
|
-
views.conversionForm.fieldContains 'out_currency', 'AUD'
|
|
32
|
-
views.conversionForm.fieldContains 'in_amount', 100
|
|
33
|
-
views.conversionForm.trigger 'convert'
|
|
27
|
+
@views.conversionForm.fieldContains 'in_currency', 'USD'
|
|
28
|
+
@views.conversionForm.fieldContains 'out_currency', 'AUD'
|
|
34
29
|
|
|
35
30
|
it 'should render the correctly converted amount', ->
|
|
36
|
-
|
|
31
|
+
@views.conversionForm.fieldContains 'in_amount', 100
|
|
32
|
+
@views.conversionForm.trigger 'convert'
|
|
33
|
+
@exchangeRateRepository.mostRecentCall.args[0].ifSucceeded(.96)
|
|
34
|
+
expect(@views.conversionForm.lastMessage()).toEqual
|
|
37
35
|
out_amount: 96
|
|
36
|
+
|
|
37
|
+
it 'should round-off amount to 2 decimal places', ->
|
|
38
|
+
@views.conversionForm.fieldContains 'in_amount', 1
|
|
39
|
+
@views.conversionForm.trigger 'convert'
|
|
40
|
+
@exchangeRateRepository.mostRecentCall.args[0].ifSucceeded(.3663)
|
|
41
|
+
expect(@views.conversionForm.lastMessage()).toEqual
|
|
42
|
+
out_amount: .37
|
|
43
|
+
|
|
44
|
+
it 'should confirm when amount is absent', ->
|
|
45
|
+
calatrava.confirm = jasmine.createSpy("confirmation dialog")
|
|
46
|
+
@views.conversionForm.fieldContains 'in_amount', ""
|
|
47
|
+
@views.conversionForm.trigger 'convert'
|
|
48
|
+
|
|
49
|
+
expect(calatrava.confirm).toHaveBeenCalled()
|
|
50
|
+
|
|
51
|
+
it 'should consider amount as 1 if amount is absent and confirmation accepted', ->
|
|
52
|
+
calatrava.confirm = jasmine.createSpy("confirmation dialog")
|
|
53
|
+
@views.conversionForm.fieldContains 'in_amount', ""
|
|
54
|
+
@views.conversionForm.trigger 'convert'
|
|
55
|
+
calatrava.confirm.mostRecentCall.args[1](true)
|
|
56
|
+
@exchangeRateRepository.mostRecentCall.args[0].ifSucceeded(.96)
|
|
57
|
+
|
|
58
|
+
expect(@views.conversionForm.lastMessage()).toEqual
|
|
59
|
+
out_amount: 0.96
|
|
60
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
exports = require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
example = exports.example
|
|
4
|
+
|
|
5
|
+
describe 'converter repository', ->
|
|
6
|
+
|
|
7
|
+
beforeEach ->
|
|
8
|
+
@ajax = jasmine.createSpy "ajax requester"
|
|
9
|
+
@onSuccess = jasmine.createSpy "success callback"
|
|
10
|
+
@onFailure = jasmine.createSpy "failure callback"
|
|
11
|
+
example.converter.apiEndpoint = "//endpoint"
|
|
12
|
+
example.converter.repository(@ajax).exchangeRate
|
|
13
|
+
from: "USD"
|
|
14
|
+
to: "INR"
|
|
15
|
+
ifSucceeded: @onSuccess
|
|
16
|
+
elseFailed: @onFailure
|
|
17
|
+
|
|
18
|
+
it 'should call appropriate API for exchange rate', ->
|
|
19
|
+
expect(@ajax.mostRecentCall.args[0].url).toEqual "//endpoint/currency?from=USD&to=INR"
|
|
20
|
+
|
|
21
|
+
it 'should call success callback with rate when request is successful', ->
|
|
22
|
+
@ajax.mostRecentCall.args[0].success "{\"rate\": 55}"
|
|
23
|
+
expect(@onSuccess).toHaveBeenCalledWith 55
|
|
24
|
+
|
|
25
|
+
it 'should call failure callback when request fails', ->
|
|
26
|
+
@ajax.mostRecentCall.args[0].failure "failure response"
|
|
27
|
+
expect(@onFailure).toHaveBeenCalledWith("failure response")
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
calatrava ?= {}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
calatrava =
|
|
4
4
|
bridge:
|
|
5
|
-
environment: () ->
|
|
6
|
-
serviceEndpoint: "test env"
|
|
7
|
-
sessionTimeout: 10
|
|
8
|
-
|
|
9
5
|
changePage: (page) ->
|
|
10
6
|
page.show()
|
|
11
7
|
|
|
@@ -22,4 +18,4 @@ tw =
|
|
|
22
18
|
dialog:
|
|
23
19
|
display: () ->
|
|
24
20
|
|
|
25
|
-
exports.
|
|
21
|
+
exports.calatrava = calatrava
|
|
@@ -12,7 +12,7 @@ _ = underscore;
|
|
|
12
12
|
|
|
13
13
|
stubView = require('stubView.coffee').stubView;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
calatrava = require('environment.spec_helper').calatrava;
|
|
16
16
|
|
|
17
17
|
function recursiveExtend(moduleToExtend, module) {
|
|
18
18
|
_.each(module, function (value, key) {
|
|
@@ -27,9 +27,10 @@ function recursiveExtend(moduleToExtend, module) {
|
|
|
27
27
|
|
|
28
28
|
example = {};
|
|
29
29
|
recursiveExtend(example, require('controller.converter').example);
|
|
30
|
+
recursiveExtend(example, require('repository.converter').example);
|
|
30
31
|
|
|
31
32
|
exports.stubView = stubView;
|
|
32
|
-
exports.
|
|
33
|
+
exports.calatrava = calatrava;
|
|
33
34
|
exports.appDir = __dirname + "/../app";
|
|
34
35
|
exports.example = example;
|
|
35
36
|
|
|
@@ -2,11 +2,6 @@ calatrava ?= {}
|
|
|
2
2
|
calatrava.bridge = calatrava.bridge ? {}
|
|
3
3
|
calatrava.bridge.web = calatrava.bridge.web ? {}
|
|
4
4
|
|
|
5
|
-
calatrava.bridge.environment = () ->
|
|
6
|
-
sessionTimeout: 600
|
|
7
|
-
serviceEndpoint: ""
|
|
8
|
-
apiEndpoint: ""
|
|
9
|
-
|
|
10
5
|
calatrava.bridge.web.ajax = (options) ->
|
|
11
6
|
loader = $("#loader")
|
|
12
7
|
|
|
@@ -63,10 +58,11 @@ calatrava.bridge.web.ajax = (options) ->
|
|
|
63
58
|
showLoader()
|
|
64
59
|
success: (response) ->
|
|
65
60
|
goToTop()
|
|
61
|
+
response = JSON.stringify(response) if _.isObject(response)
|
|
66
62
|
options.success(response)
|
|
67
|
-
error: () ->
|
|
63
|
+
error: (response) ->
|
|
68
64
|
showLoader()
|
|
69
|
-
options.failure() if options.failure?
|
|
65
|
+
options.failure(response.status, response.responseText) if options.failure?
|
|
70
66
|
complete: hideLoader
|
|
71
67
|
|
|
72
68
|
calatrava.bridge.web.page = (pageName, proxyId) ->
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
calatrava
|
|
1
|
+
example ?= {}
|
|
2
|
+
example.converter ?= {}
|
|
3
|
+
calatrava ?= {}
|
|
4
|
+
|
|
5
|
+
#cross-domain calls would fail for web. Using ProxyPass in httpd.conf instead.
|
|
6
|
+
example.converter.apiEndpoint = ""
|
|
4
7
|
|
|
5
8
|
# Hide all the sub-pages when first launching the app
|
|
6
9
|
$(document).ready ->
|
data/lib/calatrava/version.rb
CHANGED
data/tools/janus.jar
ADDED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: calatrava
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.7
|
|
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: 2013-
|
|
12
|
+
date: 2013-06-22 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rspec
|
|
@@ -178,6 +178,7 @@ files:
|
|
|
178
178
|
- Vagrantfile
|
|
179
179
|
- bin/calatrava
|
|
180
180
|
- calatrava.gemspec
|
|
181
|
+
- contracts/rate-exchange.jns
|
|
181
182
|
- ext/mkrf_conf.rb
|
|
182
183
|
- features/cli.feature
|
|
183
184
|
- features/project.feature
|
|
@@ -211,6 +212,8 @@ files:
|
|
|
211
212
|
- lib/calatrava/tasks/rake.rb
|
|
212
213
|
- lib/calatrava/tasks/release.rb
|
|
213
214
|
- lib/calatrava/template.rb
|
|
215
|
+
- lib/calatrava/templates/.auto_compile.rb
|
|
216
|
+
- lib/calatrava/templates/.gitignore
|
|
214
217
|
- lib/calatrava/templates/.ruby-gemset.calatrava
|
|
215
218
|
- lib/calatrava/templates/.ruby-version
|
|
216
219
|
- lib/calatrava/templates/Gemfile.calatrava
|
|
@@ -239,7 +242,9 @@ files:
|
|
|
239
242
|
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/AssetRepository.java
|
|
240
243
|
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/CalatravaApplication.java
|
|
241
244
|
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/KernelBridge.java
|
|
245
|
+
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/NativePageStateManager.java
|
|
242
246
|
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PageRegistry.java
|
|
247
|
+
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PageStateManager.java
|
|
243
248
|
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PluginCommand.java
|
|
244
249
|
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PluginRegistry.java
|
|
245
250
|
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RegisteredActivity.java
|
|
@@ -248,6 +253,7 @@ files:
|
|
|
248
253
|
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RequestLoader.java
|
|
249
254
|
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RhinoService.java
|
|
250
255
|
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/shell/WebViewActivity.java
|
|
256
|
+
- lib/calatrava/templates/droid/calatrava/src/com/calatrava/shell/WebViewPageStateManager.java
|
|
251
257
|
- lib/calatrava/templates/droid/manifest.yml
|
|
252
258
|
- lib/calatrava/templates/ios/Podfile.calatrava
|
|
253
259
|
- lib/calatrava/templates/ios/manifest.yml
|
|
@@ -269,11 +275,13 @@ files:
|
|
|
269
275
|
- lib/calatrava/templates/kernel/app/calatrava.coffee
|
|
270
276
|
- lib/calatrava/templates/kernel/app/converter/controller.converter.coffee
|
|
271
277
|
- lib/calatrava/templates/kernel/app/converter/init.converter.coffee
|
|
278
|
+
- lib/calatrava/templates/kernel/app/converter/repository.converter.coffee
|
|
272
279
|
- lib/calatrava/templates/kernel/app/pageHelper.coffee
|
|
273
280
|
- lib/calatrava/templates/kernel/features/support/bridge.coffee
|
|
274
281
|
- lib/calatrava/templates/kernel/features/support/spec_helper.js
|
|
275
282
|
- lib/calatrava/templates/kernel/plugins/alert.coffee
|
|
276
283
|
- lib/calatrava/templates/kernel/spec/converter/controller.converter.spec.coffee
|
|
284
|
+
- lib/calatrava/templates/kernel/spec/converter/repository.converter.spec.coffee
|
|
277
285
|
- lib/calatrava/templates/kernel/spec/environment.spec_helper.coffee
|
|
278
286
|
- lib/calatrava/templates/kernel/spec/spec_helper.js
|
|
279
287
|
- lib/calatrava/templates/kernel/spec/stubView.coffee
|
|
@@ -298,6 +306,7 @@ files:
|
|
|
298
306
|
- spec/output_file_spec.rb
|
|
299
307
|
- spec/shell_spec.rb
|
|
300
308
|
- spec/spec_helper.rb
|
|
309
|
+
- tools/janus.jar
|
|
301
310
|
homepage: http://calatrava.github.com
|
|
302
311
|
licenses: []
|
|
303
312
|
post_install_message:
|