calatrava 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/.gitignore +9 -0
  2. data/.rvmrc +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +202 -0
  5. data/Plans.md +20 -0
  6. data/README.md +73 -0
  7. data/Rakefile +26 -0
  8. data/bin/calatrava +6 -0
  9. data/calatrava.gemspec +35 -0
  10. data/features/cli.feature +14 -0
  11. data/features/project.feature +48 -0
  12. data/features/step_definitions/template_steps.rb +8 -0
  13. data/features/support/env.rb +5 -0
  14. data/lib/calatrava/app.rb +30 -0
  15. data/lib/calatrava/manifest.rb +44 -0
  16. data/lib/calatrava/project.rb +218 -0
  17. data/lib/calatrava/resources_build_phase.rb +19 -0
  18. data/lib/calatrava/tasks/apache.rb +44 -0
  19. data/lib/calatrava/tasks/artifact.rb +24 -0
  20. data/lib/calatrava/tasks/assets.rb +6 -0
  21. data/lib/calatrava/tasks/automation.rb +38 -0
  22. data/lib/calatrava/tasks/bootstrap.rb +10 -0
  23. data/lib/calatrava/tasks/build.rb +1 -0
  24. data/lib/calatrava/tasks/configuration.rb +41 -0
  25. data/lib/calatrava/tasks/droid.rb +83 -0
  26. data/lib/calatrava/tasks/haml.rb +71 -0
  27. data/lib/calatrava/tasks/ios.rb +73 -0
  28. data/lib/calatrava/tasks/kernel.rb +52 -0
  29. data/lib/calatrava/tasks/precommit.rb +22 -0
  30. data/lib/calatrava/tasks/release.rb +17 -0
  31. data/lib/calatrava/tasks/shell.rb +17 -0
  32. data/lib/calatrava/tasks/web.rb +82 -0
  33. data/lib/calatrava/tasks.rb +93 -0
  34. data/lib/calatrava/template.rb +44 -0
  35. data/lib/calatrava/templates/.rvmrc.calatrava +2 -0
  36. data/lib/calatrava/templates/Gemfile.calatrava +4 -0
  37. data/lib/calatrava/templates/Rakefile +1 -0
  38. data/lib/calatrava/templates/assets/lib/ICanHaz.js +542 -0
  39. data/lib/calatrava/templates/assets/lib/underscore.js +1059 -0
  40. data/lib/calatrava/templates/assets/lib/zepto.js +1355 -0
  41. data/lib/calatrava/templates/build_env.sh +2 -0
  42. data/lib/calatrava/templates/config/environments.yml +17 -0
  43. data/lib/calatrava/templates/config/templates/env.coffee.erb +7 -0
  44. data/lib/calatrava/templates/config/templates/httpd.conf.erb +33 -0
  45. data/lib/calatrava/templates/droid/app/bridge.coffee +130 -0
  46. data/lib/calatrava/templates/droid/calatrava/ant/calatrava.xml +48 -0
  47. data/lib/calatrava/templates/droid/calatrava/calatrava-build.xml +91 -0
  48. data/lib/calatrava/templates/droid/calatrava/ivy.xml +8 -0
  49. data/lib/calatrava/templates/droid/calatrava/ivysettings.xml +12 -0
  50. data/lib/calatrava/templates/droid/calatrava/src/com/CALATRAVA_TMPL/AndroidManifest.xml.calatrava +20 -0
  51. data/lib/calatrava/templates/droid/calatrava/src/com/CALATRAVA_TMPL/ConversionForm.java.calatrava +27 -0
  52. data/lib/calatrava/templates/droid/calatrava/src/com/CALATRAVA_TMPL/Title.java.calatrava +23 -0
  53. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/CalatravaPage.java +13 -0
  54. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/AjaxRequestManager.java +166 -0
  55. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/AssetRepository.java +17 -0
  56. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/KernelBridge.java +25 -0
  57. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/Launcher.java +85 -0
  58. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PageRegistry.java +225 -0
  59. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RegisteredActivity.java +86 -0
  60. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RequestLoader.java +31 -0
  61. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RhinoService.java +212 -0
  62. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/shell/WebViewActivity.java +247 -0
  63. data/lib/calatrava/templates/droid/manifest.yml +1 -0
  64. data/lib/calatrava/templates/ios/Podfile.calatrava +5 -0
  65. data/lib/calatrava/templates/ios/manifest.yml +1 -0
  66. data/lib/calatrava/templates/ios/res/js/bridge.js +249 -0
  67. data/lib/calatrava/templates/ios/res/xibs/ProgressViewController.xib +334 -0
  68. data/lib/calatrava/templates/ios/res/xibs/WebViewController.xib +173 -0
  69. data/lib/calatrava/templates/ios/src/AppDelegate.h +8 -0
  70. data/lib/calatrava/templates/ios/src/AppDelegate.m +56 -0
  71. data/lib/calatrava/templates/ios/src/CALATRAVA_TMPL-Info.plist +45 -0
  72. data/lib/calatrava/templates/ios/src/CALATRAVA_TMPL-Prefix.pch +14 -0
  73. data/lib/calatrava/templates/ios/src/ConversionFormViewController.h +16 -0
  74. data/lib/calatrava/templates/ios/src/ConversionFormViewController.m +179 -0
  75. data/lib/calatrava/templates/ios/src/ConversionFormViewController.xib +357 -0
  76. data/lib/calatrava/templates/ios/src/en.lproj/InfoPlist.strings +2 -0
  77. data/lib/calatrava/templates/ios/src/main.m +10 -0
  78. data/lib/calatrava/templates/ios/test/AJAXConnectionTest.m +21 -0
  79. data/lib/calatrava/templates/ios/test/AppTests-Prefix.pch +8 -0
  80. data/lib/calatrava/templates/ios/test/CalatravaiOSTests-Info.plist +22 -0
  81. data/lib/calatrava/templates/ios/test/TWBridgePageRegistryTest.m +15 -0
  82. data/lib/calatrava/templates/ios/test/en.lproj/InfoPlist.strings +2 -0
  83. data/lib/calatrava/templates/kernel/.gitignore +1 -0
  84. data/lib/calatrava/templates/kernel/app/calatrava.coffee +8 -0
  85. data/lib/calatrava/templates/kernel/app/converter/controller.converter.coffee +50 -0
  86. data/lib/calatrava/templates/kernel/app/converter/init.converter.coffee +11 -0
  87. data/lib/calatrava/templates/kernel/app/pageHelper.coffee +17 -0
  88. data/lib/calatrava/templates/kernel/features/support/bridge.coffee +124 -0
  89. data/lib/calatrava/templates/kernel/features/support/spec_helper.js +49 -0
  90. data/lib/calatrava/templates/kernel/spec/converter/controller.converter.spec.coffee +37 -0
  91. data/lib/calatrava/templates/kernel/spec/environment.spec_helper.coffee +25 -0
  92. data/lib/calatrava/templates/kernel/spec/spec_helper.js +49 -0
  93. data/lib/calatrava/templates/kernel/spec/stubView.coffee +18 -0
  94. data/lib/calatrava/templates/kernel/watchr.rb +17 -0
  95. data/lib/calatrava/templates/package.json +20 -0
  96. data/lib/calatrava/templates/shell/layouts/single_page.haml +23 -0
  97. data/lib/calatrava/templates/shell/pages/converter/conversionForm.haml +12 -0
  98. data/lib/calatrava/templates/shell/pages/converter/page.conversionForm.coffee +42 -0
  99. data/lib/calatrava/templates/shell/shell.scss +1 -0
  100. data/lib/calatrava/templates/shell/support/shell.coffee +21 -0
  101. data/lib/calatrava/templates/web/apache/conf/mime.types +1357 -0
  102. data/lib/calatrava/templates/web/app/source/bridge.coffee +158 -0
  103. data/lib/calatrava/templates/web/app/source/init.coffee +14 -0
  104. data/lib/calatrava/templates/web/app/views/index.haml +18 -0
  105. data/lib/calatrava/templates/web/deploy/instance.sh +10 -0
  106. data/lib/calatrava/templates/web/manifest.yml +1 -0
  107. data/lib/calatrava/version.rb +3 -0
  108. data/lib/calatrava.rb +5 -0
  109. metadata +302 -0
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .DS_Store
6
+ /lib/calatrava/templates/ios/App/App.xcodeproj/project.xcworkspace/xcuserdata/*
7
+ tmp/*
8
+ test/*
9
+ currencyConverter/*
data/.rvmrc ADDED
@@ -0,0 +1,2 @@
1
+ rvm_install_on_use_flag=1
2
+ rvm --create use ruby-1.9.3-p0@calatrava
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ # Specify your gem's dependencies in calatrava.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/Plans.md ADDED
@@ -0,0 +1,20 @@
1
+ Calatrava will be a Ruby gem that you use to create projects. Running
2
+ `calatrava <app>` will create a directory for a new app.
3
+
4
+ This directory will contain the recommended directory tree, and a
5
+ Rakefile that uses the Calatrava build tasks.
6
+
7
+ The directory tree will contain the following directories:
8
+
9
+ * `kernel`: the shared logic re-used across all platforms.
10
+ * `shell`: the HTML UI that may be shared across many platforms.
11
+ * `ios`: a directory containing an Xcode project for the iOS app.
12
+ * `droid`: a directory containing the Android project.
13
+ * `web`: a directory containing a single-page JavaScript application
14
+ built from the `kernel` and `shell`.
15
+ * `features`: a directory to put your cucumber features in.
16
+
17
+ The rake tasks will be responsible for building the kernel and shell,
18
+ and it's expected that these tasks will be used to build the other
19
+ applications.
20
+
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Dependencies
2
+
3
+ It should be as easy to get started with Calatrava as
4
+ possible. However, there are still a small number of dependencies that
5
+ need to be installed beforehand.
6
+
7
+ 1. [rvm](http://rvm.io). Calatrava projects are configured to use
8
+ `rvm` by default. You could use Calatrava without it, but you will
9
+ then need to make sure you have Ruby 1.9.3 installed however you
10
+ prefer.
11
+
12
+ 2. [bundler](http://gembundler.com/). Install in either your `rvm`
13
+ global gemset, or wherever else makes sense for your setup.
14
+
15
+ 3. Xcode. You'll have to get this from the Mac App Store. Once
16
+ installed, make sure you download and install the command line
17
+ tools, and make sure you run `xcode-select`. Calatrava doesn't
18
+ actually directly use Xcode except when building iOS apps, so you
19
+ can use it on a non-Mac as long as you don't run the iOS build
20
+ targets.
21
+
22
+ 4. Android SDK. I recommend installing using
23
+ [homebrew](http://mxcl.github.com/homebrew/) if you're on a
24
+ Mac. But however you get hold of it, the `android` command is
25
+ expected to be on the path.
26
+
27
+ 5. [Node.js](http://nodejs.org/). Only used to run tests, not part of
28
+ any production code. Again, if you're on a Mac I recommend
29
+ installing using homebrew.
30
+
31
+ # Getting Started
32
+
33
+ Once you have the dependenices installed, there are just six simple
34
+ steps to creating and building your first Calatrava cross-platform
35
+ mobile app.
36
+
37
+ 1. Install the Calatrava gem: `gem install calatrava`
38
+
39
+ 2. Create your Calatrava project: `calatrava create
40
+ <project-name>`
41
+
42
+ 3. `cd <project-name>`. If you're using `rvm` you will be prompted to
43
+ trust a new `.rvmrc`.
44
+
45
+ 4. `bundle install`
46
+
47
+ 5. `rake bootstrap`
48
+
49
+ 6. To build and run the Mobile Web app: `rake web:apache:start`
50
+
51
+ Then browse to [`http://localhost:8888`](http://localhost:8888) in
52
+ your favourite browser.
53
+
54
+ 7. To build and install the Android app: `rake droid:deploy`
55
+
56
+ You will need to have an Android emulator running, or a device
57
+ connected.
58
+
59
+ 8. To build and run the iOS app open the Xcode workspace in the `ios`
60
+ directory, and then build and run the target named after your
61
+ project.
62
+
63
+ # Working with Calatrava while it's under Development
64
+
65
+ 1. Clone this repo.
66
+
67
+ 2. `cd` into the repo.
68
+
69
+ 3. Run `bin/calatrava create <project-name> --dev`
70
+
71
+ The `--dev` switch will create a new project that refers to the
72
+ `calatrava` gem as a path on disk. This is much more convenient if
73
+ you're experimenting with Calatrava, or working on it.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+ require 'cucumber'
4
+ require 'cucumber/rake/task'
5
+
6
+ namespace :test do
7
+ RSpec::Core::RakeTask.new(:rspec) do |t|
8
+ t.rspec_opts = "--color"
9
+ end
10
+
11
+ Cucumber::Rake::Task.new(:features) do |t|
12
+ t.cucumber_opts = "features --format pretty"
13
+ end
14
+ end
15
+
16
+ desc "Run all tests"
17
+ task :test => ['test:rspec', 'test:features']
18
+
19
+ desc "Create a test project"
20
+ task :run do
21
+ sh "bin/calatrava create test --dev"
22
+ end
23
+
24
+ namespace :gem do
25
+ Bundler::GemHelper.install_tasks
26
+ end
data/bin/calatrava ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'calatrava'
5
+
6
+ Calatrava::App.start
data/calatrava.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "calatrava/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "calatrava"
7
+ s.version = Calatrava::Version
8
+ s.authors = ["Giles Alexander"]
9
+ s.email = ["gga@thoughtworks.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Cross-platform mobile apps with native UIs}
12
+ s.description = %q{A framework to build cross-platform mobile apps with high quality native UIs.}
13
+
14
+ s.rubyforge_project = "calatrava"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency "rspec"
22
+ s.add_development_dependency "aruba"
23
+
24
+ s.add_runtime_dependency "rake"
25
+ s.add_runtime_dependency "thor"
26
+ s.add_runtime_dependency "haml"
27
+ s.add_runtime_dependency "sass"
28
+ s.add_runtime_dependency "mustache"
29
+ s.add_runtime_dependency "xcoder"
30
+ s.add_runtime_dependency "xcodeproj"
31
+ s.add_runtime_dependency "cucumber"
32
+ s.add_runtime_dependency "frank-cucumber"
33
+ s.add_runtime_dependency "watir-webdriver"
34
+ s.add_runtime_dependency "cocoapods"
35
+ end
@@ -0,0 +1,14 @@
1
+ Feature: Command line interface
2
+
3
+ In order to create cross platform mobile apps
4
+ As a mobile developer
5
+ I want an easy to use command line tool
6
+
7
+ Scenario: Command-line validations
8
+ When I run `calatrava create`
9
+ Then the output should contain "calatrava create requires at least 1 argument"
10
+ When I run `calatrava create project --template nonexistentdirectory`
11
+ Then the output should contain "template must exist"
12
+ Given an empty file named "alt-template-file"
13
+ When I run `calatrava create project --template alt-template-file`
14
+ Then the output should contain "template must be a directory"
@@ -0,0 +1,48 @@
1
+ Feature: Projects
2
+
3
+ In order to save money but still create the most awesome mobile app
4
+ As a cross-platform mobile developer
5
+ I want to use Calatrava to create a project
6
+
7
+ Scenario: Create a project using the standard Calatrava template
8
+ When I run `calatrava create simple`
9
+ Then the exit status should be 0
10
+ And the following directories should exist:
11
+ | simple |
12
+ | simple/config |
13
+ | simple/droid |
14
+ | simple/features |
15
+ | simple/ios |
16
+ | simple/kernel |
17
+ | simple/shell |
18
+ | simple/web |
19
+ And the file "simple/calatrava.yml" should contain "project_name: simple"
20
+
21
+ Scenario: Templates can have deeply nested directories and files
22
+ Given the following directories exist:
23
+ | nested |
24
+ | nested/dir |
25
+ | nested/dir/sub |
26
+ And the following files exist:
27
+ | nested/sample |
28
+ | nested/.config |
29
+ | nested/dir/sub/sample2 |
30
+ When I run `calatrava create proj --template nested`
31
+ Then the following directories should exist:
32
+ | proj |
33
+ | proj/dir |
34
+ | proj/dir/sub |
35
+ And the following files should exist:
36
+ | proj/sample |
37
+ | proj/.config |
38
+ | proj/dir/sub/sample2 |
39
+
40
+ Scenario: Template files can themselves be templates
41
+ Given a directory named "template"
42
+ And a file named "template/.tmpl.calatrava" with:
43
+ """
44
+ Sample {{ project_name }}
45
+ """
46
+ When I run `calatrava create templatized --template template`
47
+ Then a file named "templatized/.tmpl" should exist
48
+ And the file "templatized/.tmpl" should contain "Sample templatized"
@@ -0,0 +1,8 @@
1
+ Given /^the following directories exist:$/ do |directories|
2
+ directories.raw.each { |dir_row| create_dir(dir_row[0]) }
3
+ end
4
+
5
+ Given /^the following files exist:$/ do |files|
6
+ files.raw.each { |file_row| write_file(file_row[0], "") }
7
+ end
8
+
@@ -0,0 +1,5 @@
1
+ require 'aruba/cucumber'
2
+
3
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
4
+
5
+ ENV['RUBYLIB'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../lib')}#{File::PATH_SEPARATOR}#{ENV['RUBYLIB']}"
@@ -0,0 +1,30 @@
1
+ require 'thor'
2
+
3
+ module Calatrava
4
+
5
+ class App < Thor
6
+
7
+ desc "create <project-name>", "creates a new calatrava app project"
8
+ method_options :template => File.join(File.dirname(__FILE__), 'templates'), :dev => false
9
+ def create(project_name)
10
+ die "template must exist" unless File.exist?(options[:template])
11
+ die "template must be a directory" unless File.directory?(options[:template])
12
+
13
+ proj = Project.new(project_name,
14
+ :is_dev => options.dev?)
15
+ proj.create(Template.new(options[:template]))
16
+ end
17
+
18
+ no_tasks do
19
+
20
+ def die(message)
21
+ $stderr.puts message
22
+ exit 1
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
@@ -0,0 +1,44 @@
1
+ module Calatrava
2
+
3
+ class Manifest
4
+ def initialize(app_dir)
5
+ @feature_list = YAML.load(IO.read("#{app_dir}/manifest.yml"))
6
+ end
7
+
8
+ def features
9
+ @feature_list
10
+ end
11
+
12
+ def js_files
13
+ @feature_list.collect { |f| Dir["build/{kernel,shell}/js/#{f}/*.js"] }.flatten
14
+ end
15
+
16
+ def load_file(target_dir, js_load_path, options)
17
+ File.open("#{target_dir}/load_file.#{options[:type]}", "w+") do |f|
18
+ @feature_list.each do |feature|
19
+ coffee_files(feature, :include_pages => options[:include_pages]).each do |coffee_file|
20
+ js_src = File.join(js_load_path, File.basename(coffee_file, '.coffee') + ".js")
21
+ f.puts self.send(options[:type], js_src)
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ def coffee_files(feature, opts)
28
+ coffee_files = Dir["{kernel,shell}/{app,pages}/#{feature}/*.coffee"]
29
+ if !opts[:include_pages]
30
+ coffee_files = coffee_files.reject { |f| f =~ /page\./ }
31
+ end
32
+ coffee_files
33
+ end
34
+
35
+ def haml(js_src)
36
+ %{%script(type="text/javascript" src="#{js_src}")}
37
+ end
38
+
39
+ def text(js_src)
40
+ js_src
41
+ end
42
+ end
43
+
44
+ end