calatrava 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.markdown +40 -0
- data/README.md +5 -0
- data/calatrava.gemspec +2 -3
- data/lib/calatrava/apache.rb +126 -0
- data/lib/calatrava/app.rb +2 -2
- data/lib/calatrava/app_builder.rb +68 -0
- data/lib/calatrava/configuration.rb +73 -0
- data/lib/calatrava/droid_app.rb +46 -0
- data/lib/calatrava/ios_app.rb +40 -0
- data/lib/calatrava/kernel.rb +79 -0
- data/lib/calatrava/manifest.rb +34 -11
- data/lib/calatrava/mobile_web_app.rb +74 -0
- data/lib/calatrava/project.rb +7 -191
- data/lib/calatrava/project_script.rb +186 -0
- data/lib/calatrava/shell.rb +43 -0
- data/lib/calatrava/tasks/assets.rb +4 -0
- data/lib/calatrava/tasks/automation.rb +4 -10
- data/lib/calatrava/tasks/haml.rb +9 -10
- data/lib/calatrava/tasks.rb +9 -85
- data/lib/calatrava/templates/config/templates/httpd.conf.erb +9 -9
- data/lib/calatrava/templates/droid/app/bridge.coffee +3 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/CalatravaPlugin.java +13 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/AlertPlugin.java +61 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/AnnotationRegistrar.java +71 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/KernelBridge.java +3 -4
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/Launcher.java +2 -1
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PageRegistry.java +8 -29
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PluginCommand.java +8 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PluginRegistry.java +112 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RegisteredActivity.java +3 -14
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RegisteredPlugin.java +10 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/Registration.java +8 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RhinoService.java +1 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/shell/WebViewActivity.java +1 -1
- data/lib/calatrava/templates/ios/Podfile.calatrava +6 -1
- data/lib/calatrava/templates/ios/src/ConversionFormViewController.m +1 -1
- data/lib/calatrava/templates/kernel/app/calatrava.coffee +32 -5
- data/lib/calatrava/templates/kernel/app/converter/controller.converter.coffee +11 -4
- data/lib/calatrava/templates/kernel/plugins/alert.coffee +9 -0
- data/lib/calatrava/templates/shell/layouts/single_page.haml +3 -3
- data/lib/calatrava/templates/web/app/source/alert.web.coffee +13 -0
- data/lib/calatrava/templates/web/app/source/bridge.coffee +10 -0
- data/lib/calatrava/templates/web/app/views/index.haml +5 -5
- data/lib/calatrava/version.rb +1 -1
- data/lib/calatrava.rb +15 -1
- data/spec/app_builder_spec.rb +46 -0
- data/spec/kernel_spec.rb +51 -0
- data/spec/manifest_spec.rb +62 -0
- data/spec/mobile_web_app_spec.rb +49 -0
- data/spec/shell_spec.rb +54 -0
- data/spec/spec_helper.rb +4 -0
- metadata +60 -49
- data/Plans.md +0 -20
- data/lib/calatrava/tasks/apache.rb +0 -54
- data/lib/calatrava/tasks/build.rb +0 -1
- data/lib/calatrava/tasks/configuration.rb +0 -41
- data/lib/calatrava/tasks/droid.rb +0 -83
- data/lib/calatrava/tasks/ios.rb +0 -73
- data/lib/calatrava/tasks/kernel.rb +0 -52
- data/lib/calatrava/tasks/shell.rb +0 -17
- data/lib/calatrava/tasks/web.rb +0 -87
data/CHANGES.markdown
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
## v0.6.0
|
2
|
+
|
3
|
+
* Added
|
4
|
+
[plugin support](https://github.com/calatrava/calatrava/wiki/Plugins)
|
5
|
+
* Added an alert plugin implementation:
|
6
|
+
`web/app/source/alert.web.coffee`,
|
7
|
+
`droid/test/src/com/calatrava/bridge/AlertPlugin.java` and
|
8
|
+
`ios/Pods/calatrava/calatrava-ios/Bridge/AlertPlugin.m`.
|
9
|
+
* Substantial re-writing of the build tasks. Should largely not be
|
10
|
+
externally visible, except there are a lot less tasks now.
|
11
|
+
|
12
|
+
Bugs fixed:
|
13
|
+
* [Issue #5][i5]: Creates the droid build with default name of the
|
14
|
+
project as 'test' instead of the project name
|
15
|
+
* [Issue #12][i12]: Failing AJAX - Typo in calatrava.inbound
|
16
|
+
* [Issue #13][i13]: Problem Building on Xcode (4.5.1) - Can't Find
|
17
|
+
Bundler
|
18
|
+
* [Issue #14][i14]: Cosmetic: ios/public misplaced during calatrava
|
19
|
+
create
|
20
|
+
* [Issue #15][i15]: Uncaught TypeError: Object #<Object> has no
|
21
|
+
method 'success'
|
22
|
+
|
23
|
+
Changes that will affect existing projects:
|
24
|
+
* Edited httpd conf template: `config/templates/httpd.conf.erb`
|
25
|
+
* Edited the single page Haml template: `web/app/views/index.haml`
|
26
|
+
|
27
|
+
## v0.5.0
|
28
|
+
|
29
|
+
* First public release
|
30
|
+
|
31
|
+
## Contributors:
|
32
|
+
* [Giles Alexander](https://github.com/gga)
|
33
|
+
* [Vivek Jain](https://github.com/vivekjain10)
|
34
|
+
* [Renaud Tircher](https://github.com/rtircher)
|
35
|
+
|
36
|
+
[i5]: https://github.com/calatrava/calatrava/issues/5
|
37
|
+
[i12]: https://github.com/calatrava/calatrava/issues/12
|
38
|
+
[i13]: https://github.com/calatrava/calatrava/issues/13
|
39
|
+
[i14]: https://github.com/calatrava/calatrava/issues/14
|
40
|
+
[i15]: https://github.com/calatrava/calatrava/issues/15
|
data/README.md
CHANGED
@@ -4,6 +4,11 @@ It should be as easy to get started with Calatrava as
|
|
4
4
|
possible. However, there are still a small number of dependencies that
|
5
5
|
need to be installed beforehand.
|
6
6
|
|
7
|
+
*Note*: Currently, Calatrava only supports development on Macs. this
|
8
|
+
will probably always be the case for iOS apps, but there are plans to
|
9
|
+
at least support Linux for Android and Mobile Web. Windows is a
|
10
|
+
little further off. Pull requests welcomed.
|
11
|
+
|
7
12
|
1. [rvm](http://rvm.io). Calatrava projects are configured to use
|
8
13
|
`rvm` by default. You could use Calatrava without it, but you will
|
9
14
|
then need to make sure you have Ruby 1.9.3 installed however you
|
data/calatrava.gemspec
CHANGED
@@ -26,10 +26,9 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_runtime_dependency "haml"
|
27
27
|
s.add_runtime_dependency "sass"
|
28
28
|
s.add_runtime_dependency "mustache"
|
29
|
-
s.add_runtime_dependency "xcoder"
|
30
|
-
s.add_runtime_dependency "xcodeproj"
|
31
29
|
s.add_runtime_dependency "cucumber"
|
32
|
-
s.add_runtime_dependency "frank-cucumber"
|
33
30
|
s.add_runtime_dependency "watir-webdriver"
|
31
|
+
s.add_runtime_dependency "frank-cucumber"
|
32
|
+
s.add_runtime_dependency "xcodeproj"
|
34
33
|
s.add_runtime_dependency "cocoapods"
|
35
34
|
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
module Calatrava
|
2
|
+
|
3
|
+
class Apache
|
4
|
+
include Rake::DSL
|
5
|
+
|
6
|
+
Calatrava::Configuration.extra do |c|
|
7
|
+
if `uname -a`.chomp["amzn1"]
|
8
|
+
c.runtime :modules_path, "/usr/lib64/httpd/modules"
|
9
|
+
c.runtime :load_log_module, true
|
10
|
+
elsif `uname`.chomp == "Linux"
|
11
|
+
c.runtime :modules_path, "/usr/lib/apache2/modules"
|
12
|
+
c.runtime :load_log_module, false
|
13
|
+
elsif `uname`.chomp == "Darwin"
|
14
|
+
c.runtime :modules_path, "/usr/libexec/apache2"
|
15
|
+
c.runtime :load_log_module, true
|
16
|
+
else
|
17
|
+
raise "Calatrava does not support running apache on this platform."
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def apache_dir
|
22
|
+
"web/apache"
|
23
|
+
end
|
24
|
+
|
25
|
+
def apache_public_dir
|
26
|
+
"#{apache_dir}/public"
|
27
|
+
end
|
28
|
+
|
29
|
+
def apache_logs_dir
|
30
|
+
"#{apache_dir}/logs"
|
31
|
+
end
|
32
|
+
|
33
|
+
def apache_conf_dir
|
34
|
+
"#{apache_dir}/conf"
|
35
|
+
end
|
36
|
+
|
37
|
+
def httpd(command, opts = {})
|
38
|
+
ensure_httpd
|
39
|
+
cmd = %Q{#{@httpd} -d #{apache_dir} -f conf/httpd.conf -e DEBUG -k #{command} -DNO_DETACH -DFOREGROUND}
|
40
|
+
puts cmd
|
41
|
+
if opts[:background]
|
42
|
+
fork do
|
43
|
+
exec cmd
|
44
|
+
end
|
45
|
+
else
|
46
|
+
exec cmd
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def configure_apache
|
51
|
+
cp Calatrava::Project.current.config.path("httpd.conf"), apache_conf_dir
|
52
|
+
end
|
53
|
+
|
54
|
+
def launch_apache(opts = {})
|
55
|
+
if !opts[:background]
|
56
|
+
puts
|
57
|
+
puts "\t\t" + "*"*40
|
58
|
+
puts "\t\t" + "*** STARTING APACHE ON PORT 8888 ***"
|
59
|
+
puts "\t\t" + "*"*40
|
60
|
+
puts
|
61
|
+
end
|
62
|
+
|
63
|
+
httpd :start, opts
|
64
|
+
end
|
65
|
+
|
66
|
+
def stop_apache
|
67
|
+
httpd 'graceful-stop'
|
68
|
+
end
|
69
|
+
|
70
|
+
def reload_apache
|
71
|
+
httpd :restart
|
72
|
+
end
|
73
|
+
|
74
|
+
def ensure_httpd
|
75
|
+
if !@httpd
|
76
|
+
if `uname -a`.chomp["amzn1"]
|
77
|
+
@httpd = "httpd"
|
78
|
+
elsif `uname`.chomp == "Linux"
|
79
|
+
@httpd = "apache2"
|
80
|
+
elsif `uname`.chomp == "Darwin"
|
81
|
+
@httpd = "httpd"
|
82
|
+
else
|
83
|
+
raise "Calatrava does not support running apache on this platform."
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def install_tasks
|
89
|
+
directory apache_logs_dir
|
90
|
+
file apache_public_dir do
|
91
|
+
cd apache_dir do
|
92
|
+
ln_s "../public", "public"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
desc "launch a non-daemon apache instance on port 8888 which will serve our local app and also proxy to backend services"
|
97
|
+
task :start => ['web:build', apache_public_dir, apache_logs_dir] do
|
98
|
+
configure_apache
|
99
|
+
launch_apache
|
100
|
+
end
|
101
|
+
|
102
|
+
task :background => ['web:build', apache_public_dir, apache_logs_dir] do
|
103
|
+
configure_apache
|
104
|
+
launch_apache :background => true
|
105
|
+
end
|
106
|
+
|
107
|
+
desc "Reload the apache configuration"
|
108
|
+
task :reload do
|
109
|
+
reload_apache
|
110
|
+
end
|
111
|
+
|
112
|
+
desc "Stop the apache configuration"
|
113
|
+
task :stop do
|
114
|
+
stop_apache
|
115
|
+
end
|
116
|
+
|
117
|
+
desc "Cleans apache config"
|
118
|
+
task :clean do
|
119
|
+
rm_rf apache_logs_dir
|
120
|
+
rm_rf File.join(apache_conf_dir, 'httpd.conf')
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
data/lib/calatrava/app.rb
CHANGED
@@ -10,8 +10,8 @@ module Calatrava
|
|
10
10
|
die "template must exist" unless File.exist?(options[:template])
|
11
11
|
die "template must be a directory" unless File.directory?(options[:template])
|
12
12
|
|
13
|
-
proj =
|
14
|
-
|
13
|
+
proj = ProjectScript.new(project_name,
|
14
|
+
:is_dev => options.dev?)
|
15
15
|
proj.create(Template.new(options[:template]))
|
16
16
|
end
|
17
17
|
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Calatrava
|
2
|
+
|
3
|
+
class AppBuilder
|
4
|
+
include Rake::DSL
|
5
|
+
|
6
|
+
def initialize(output_dir, manifest)
|
7
|
+
@output_dir, @manifest = output_dir, manifest
|
8
|
+
end
|
9
|
+
|
10
|
+
def build_dir ; @output_dir ; end
|
11
|
+
def build_html_dir ; "#{build_dir}/views" ; end
|
12
|
+
def build_scripts_dir ; "#{build_dir}/scripts" ; end
|
13
|
+
def build_images_dir ; "#{build_dir}/images" ; end
|
14
|
+
def build_styles_dir ; "#{build_dir}/styles" ; end
|
15
|
+
|
16
|
+
def coffee_files
|
17
|
+
@manifest.coffee_files + [Calatrava::Project.current.config.path('env.coffee')]
|
18
|
+
end
|
19
|
+
|
20
|
+
def js_file(cf)
|
21
|
+
"#{build_scripts_dir}/#{File.basename(cf, '.coffee')}.js"
|
22
|
+
end
|
23
|
+
|
24
|
+
def load_instructions
|
25
|
+
build_path = Pathname.new(File.dirname(build_dir))
|
26
|
+
@manifest.kernel_bootstrap.collect do |cf|
|
27
|
+
Pathname.new(js_file(cf)).relative_path_from(build_path).to_s
|
28
|
+
end.join($/)
|
29
|
+
end
|
30
|
+
|
31
|
+
def haml_files
|
32
|
+
@manifest.haml_files
|
33
|
+
end
|
34
|
+
|
35
|
+
def builder_task
|
36
|
+
directory build_html_dir
|
37
|
+
directory build_images_dir
|
38
|
+
directory build_scripts_dir
|
39
|
+
|
40
|
+
app_files = haml_files.collect do |hf|
|
41
|
+
file "#{build_html_dir}/#{File.basename(hf, '.haml')}.html" => [build_html_dir, hf] do
|
42
|
+
HamlSupport::compile_hybrid_page hf, build_html_dir, :platform => 'ios'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
app_files += coffee_files.collect do |cf|
|
47
|
+
file js_file(cf) => [build_scripts_dir, cf] do
|
48
|
+
coffee cf, build_scripts_dir
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
app_files += @manifest.css_tasks(build_styles_dir)
|
53
|
+
app_files << file("#{build_dir}/load_file.txt" => build_dir) do |t|
|
54
|
+
File.open(t.name, "w+") { |f| f.puts load_instructions }
|
55
|
+
end
|
56
|
+
|
57
|
+
task :shared => [build_images_dir, build_scripts_dir] do
|
58
|
+
cp_ne "assets/images/*", build_images_dir
|
59
|
+
cp_ne "assets/lib/*.js", build_scripts_dir
|
60
|
+
cp_ne "ios/res/js/*.js", build_scripts_dir
|
61
|
+
end
|
62
|
+
|
63
|
+
task :app => [:shared] + app_files
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Calatrava
|
4
|
+
|
5
|
+
class Configuration
|
6
|
+
include Rake::DSL
|
7
|
+
|
8
|
+
@@extras = []
|
9
|
+
def self.extra(&configurator)
|
10
|
+
@@extras << configurator
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@runtime = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
def config_result_dir
|
18
|
+
"config/result"
|
19
|
+
end
|
20
|
+
def config_yaml
|
21
|
+
"config/environments.yml"
|
22
|
+
end
|
23
|
+
def config_template_dir
|
24
|
+
"config/templates"
|
25
|
+
end
|
26
|
+
def templates
|
27
|
+
Rake::FileList["#{config_template_dir}/*.erb"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def config_for(environment)
|
31
|
+
@@extras.each { |e| e.call(self) }
|
32
|
+
@runtime.merge(YAML::load(File.open(config_yaml))[environment])
|
33
|
+
end
|
34
|
+
|
35
|
+
def runtime(key, value)
|
36
|
+
@runtime[key] = value
|
37
|
+
end
|
38
|
+
|
39
|
+
def evaluate_template(template_path, configuration)
|
40
|
+
file_path = File.join(config_result_dir, File.basename(template_path).gsub(".erb", ''))
|
41
|
+
puts "Config: #{File.basename(template_path)} -> #{File.basename(file_path)}"
|
42
|
+
result = ERB.new(IO.read(template_path)).result(binding)
|
43
|
+
IO.write(file_path, result)
|
44
|
+
end
|
45
|
+
|
46
|
+
def path(file)
|
47
|
+
env = ENV['CALATRAVA_ENV'] || "development"
|
48
|
+
puts "CALATRAVA_ENV = '#{env}'"
|
49
|
+
full_path = artifact_path(File.join(env, file))
|
50
|
+
full_path
|
51
|
+
end
|
52
|
+
|
53
|
+
def install_tasks
|
54
|
+
directory config_result_dir
|
55
|
+
|
56
|
+
%w{local development test automation production}.each do |environment|
|
57
|
+
desc "Create config files for #{environment} environment"
|
58
|
+
task environment.to_sym => [:clean, config_result_dir] do
|
59
|
+
configuration = config_for(environment)
|
60
|
+
templates.each do |template|
|
61
|
+
evaluate_template(template, configuration)
|
62
|
+
end
|
63
|
+
artifact_dir(config_result_dir, environment)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
task :clean do
|
68
|
+
rm_rf config_result_dir
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Calatrava
|
2
|
+
|
3
|
+
class DroidApp
|
4
|
+
include Rake::DSL
|
5
|
+
|
6
|
+
def initialize(path, proj_name, manifest)
|
7
|
+
@path, @proj_name, @manifest = path, proj_name, manifest
|
8
|
+
@app_builder = AppBuilder.new("droid/#{@proj_name}/assets/calatrava", @manifest)
|
9
|
+
end
|
10
|
+
|
11
|
+
def install_tasks
|
12
|
+
app_task = @app_builder.builder_task
|
13
|
+
|
14
|
+
app_task.prerequisites << file(@app_builder.js_file('droid/app/bridge.coffee') => 'droid/app/bridge.coffee') do
|
15
|
+
coffee 'droid/app/bridge.coffee', @app_builder.build_scripts_dir
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Builds the Android app"
|
19
|
+
task :build => app_task do
|
20
|
+
cd "droid/#{@proj_name}" do
|
21
|
+
sh "ant clean debug"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Publishes the built Android app as an artifact"
|
26
|
+
task :publish => :build do
|
27
|
+
artifact("droid/#{@proj_name}/bin/#{@proj_name}-debug.apk", ENV['CALATRAVA_ENV'])
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Deploy app to device/emulator"
|
31
|
+
task :deploy => :publish do
|
32
|
+
sh "adb install -r artifacts/#{ENV['CALATRAVA_ENV']}/#{@proj_name}-debug.apk"
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Clean droid"
|
36
|
+
task :clean do
|
37
|
+
rm_rf @app_builder.build_dir
|
38
|
+
cd "droid/#{@proj_name}" do
|
39
|
+
sh "ant clean"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Calatrava
|
2
|
+
|
3
|
+
class IosApp
|
4
|
+
include Rake::DSL
|
5
|
+
|
6
|
+
def initialize(path, manifest)
|
7
|
+
@path, @manifest = path, manifest
|
8
|
+
@app_builder = AppBuilder.new('ios/public', @manifest)
|
9
|
+
end
|
10
|
+
|
11
|
+
def install_tasks
|
12
|
+
app_task = @app_builder.builder_task
|
13
|
+
|
14
|
+
desc "Builds the iOS app"
|
15
|
+
task :build => app_task do
|
16
|
+
ENV['CMDLINE_BUILD'] = 'true'
|
17
|
+
proj_name = Calatrava::Project.current.name
|
18
|
+
cd 'ios' do
|
19
|
+
sh "xcodebuild -workspace #{proj_name}.xcworkspace -scheme #{proj_name} -sdk iphonesimulator"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Clean ios public directory"
|
24
|
+
task :clean do
|
25
|
+
sh "rm -rf #{@app_builder.build_dir}"
|
26
|
+
end
|
27
|
+
|
28
|
+
namespace :xcode do
|
29
|
+
task :prebuild do
|
30
|
+
if !ENV['CMDLINE_BUILD']
|
31
|
+
Rake::Task['configure:development'].invoke
|
32
|
+
app_task.invoke
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
module Calatrava
|
4
|
+
|
5
|
+
class Kernel
|
6
|
+
include Rake::DSL
|
7
|
+
|
8
|
+
def initialize(root)
|
9
|
+
@path = root
|
10
|
+
end
|
11
|
+
|
12
|
+
def features
|
13
|
+
Dir.chdir @path do
|
14
|
+
Dir['kernel/app/*'].select { |n| File.directory? n }.collect do |n|
|
15
|
+
{
|
16
|
+
:name => File.basename(n),
|
17
|
+
:coffee => Dir["#{n}/*.coffee"]
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def coffee_files
|
24
|
+
Dir.chdir @path do
|
25
|
+
Dir["kernel/app/*.coffee"] + Dir["kernel/plugins/*.coffee"]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def coffee_path
|
30
|
+
(['app', 'app/plugins'] + features.collect { |m| "app/#{m[:name]}" }).join(':')
|
31
|
+
end
|
32
|
+
|
33
|
+
def prepare_for_features
|
34
|
+
sh "ln -sFfh kernel/features/step_definitions/ features/step_definitions"
|
35
|
+
sh "ln -sFfh kernel/features/support/ features/support"
|
36
|
+
end
|
37
|
+
|
38
|
+
def node_path_for_features
|
39
|
+
"#{coffee_path}:features/support:../assets/lib:features/step_definitions:../features/testdata"
|
40
|
+
end
|
41
|
+
|
42
|
+
def install_tasks
|
43
|
+
file '.node_updated' => 'package.json' do
|
44
|
+
sh "npm install && touch .node_updated"
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Run jasmine test. If specs not given in argument, runs all test"
|
48
|
+
task :spec => '.node_updated' do |t, args|
|
49
|
+
cd "kernel" do
|
50
|
+
ENV['NODE_PATH'] = "app:#{coffee_path}:spec:../assets/lib"
|
51
|
+
sh "../node_modules/jasmine-node/bin/jasmine-node --coffee --test-dir spec"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Run cucumber.js features for kernel"
|
56
|
+
task :features, [:file] => '.node_updated' do |t, args|
|
57
|
+
prepare_for_features
|
58
|
+
cd "kernel" do
|
59
|
+
ENV['NODE_PATH'] = node_path_for_features
|
60
|
+
features_to_be_run = args[:file] ? "#{kernel/features}/#{args[:file]}" : "features"
|
61
|
+
sh "../node_modules/cucumber/bin/cucumber.js --tags @all,@kernel --tags ~@wip '#{features_to_be_run}'"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
namespace :features do
|
66
|
+
task :wip => '.node_updated' do
|
67
|
+
prepare_for_features
|
68
|
+
cd "kernel" do
|
69
|
+
ENV['NODE_PATH'] = node_path_for_features
|
70
|
+
sh "../node_modules/cucumber/bin/cucumber.js --tags @wip --tags @kernel features"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
data/lib/calatrava/manifest.rb
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
module Calatrava
|
2
2
|
|
3
3
|
class Manifest
|
4
|
-
def initialize(app_dir)
|
5
|
-
@
|
4
|
+
def initialize(path, app_dir, kernel, shell)
|
5
|
+
@path, @kernel, @shell = path, kernel, shell
|
6
|
+
@feature_list = YAML.load(IO.read("#{@path}/#{app_dir}/manifest.yml"))
|
6
7
|
end
|
7
8
|
|
8
9
|
def features
|
9
10
|
@feature_list
|
10
11
|
end
|
11
12
|
|
12
|
-
def js_files
|
13
|
-
@feature_list.collect { |f| Dir["build/{kernel,shell}/js/#{f}/*.js"] }.flatten
|
14
|
-
end
|
15
|
-
|
16
13
|
def load_file(target_dir, js_load_path, options)
|
17
14
|
File.open("#{target_dir}/load_file.#{options[:type]}", "w+") do |f|
|
18
15
|
@feature_list.each do |feature|
|
@@ -24,12 +21,38 @@ module Calatrava
|
|
24
21
|
end
|
25
22
|
end
|
26
23
|
|
27
|
-
def coffee_files
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
def coffee_files
|
25
|
+
[@shell, @kernel].collect do |src|
|
26
|
+
src.coffee_files + feature_files(src, :coffee)
|
27
|
+
end.flatten
|
28
|
+
end
|
29
|
+
|
30
|
+
def kernel_bootstrap
|
31
|
+
@kernel.coffee_files + feature_files(@kernel, :coffee)
|
32
|
+
end
|
33
|
+
|
34
|
+
def haml_files
|
35
|
+
@shell.haml_files + feature_files(@shell, :haml)
|
36
|
+
end
|
37
|
+
|
38
|
+
def css_files
|
39
|
+
@shell.css_files
|
40
|
+
end
|
41
|
+
|
42
|
+
def css_tasks(output_dir)
|
43
|
+
css_files.collect do |style_file|
|
44
|
+
file "#{output_dir}/#{File.basename(style_file, '.*')}.css" => [output_dir, style_file] do |t|
|
45
|
+
if style_file =~ /css$/
|
46
|
+
cp style_file, output_dir
|
47
|
+
else
|
48
|
+
sh "sass #{style_file} #{t.name}"
|
49
|
+
end
|
50
|
+
end
|
31
51
|
end
|
32
|
-
|
52
|
+
end
|
53
|
+
|
54
|
+
def feature_files(source, type)
|
55
|
+
source.features.select { |f| @feature_list.include?(f[:name]) }.collect { |f| f[type] }.flatten
|
33
56
|
end
|
34
57
|
|
35
58
|
def haml(js_src)
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Calatrava
|
2
|
+
|
3
|
+
class MobileWebApp
|
4
|
+
include Rake::DSL
|
5
|
+
|
6
|
+
def initialize(path, manifest)
|
7
|
+
@path, @manifest = path, manifest
|
8
|
+
@apache = Apache.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def build_dir ; "#{@path}/web/public" ; end
|
12
|
+
def scripts_build_dir ; "#{build_dir}/scripts" ; end
|
13
|
+
def styles_build_dir ; "#{build_dir}/styles" ; end
|
14
|
+
|
15
|
+
def coffee_files
|
16
|
+
Dir.chdir @path do
|
17
|
+
core_coffee = ['bridge', 'init'].collect { |l| "web/app/source/#{l}.coffee" }
|
18
|
+
core_coffee += @manifest.coffee_files.select { |cf| cf =~ /calatrava.coffee$/ }
|
19
|
+
web_coffee = Dir['web/app/source/*.coffee'] - core_coffee
|
20
|
+
mf_coffee = @manifest.coffee_files.reject { |cf| cf =~ /calatrava.coffee$/ }
|
21
|
+
core_coffee + web_coffee + [Calatrava::Project.current.config.path('env.coffee')] + mf_coffee
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def haml_files
|
26
|
+
Dir.chdir(@path) { @manifest.haml_files }
|
27
|
+
end
|
28
|
+
|
29
|
+
def scripts
|
30
|
+
coffee_files.collect { |cf| "scripts/#{File.basename(cf, '.coffee')}.js" }
|
31
|
+
end
|
32
|
+
|
33
|
+
def install_tasks
|
34
|
+
directory build_dir
|
35
|
+
directory scripts_build_dir
|
36
|
+
|
37
|
+
app_files = coffee_files.collect do |cf|
|
38
|
+
file "#{scripts_build_dir}/#{File.basename(cf, '.coffee')}.js" => [scripts_build_dir, cf] do
|
39
|
+
coffee cf, scripts_build_dir
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
app_files << file("#{build_dir}/index.html" => ["web/app/views/index.haml"] + haml_files) do
|
44
|
+
HamlSupport::compile "web/app/views/index.haml", build_dir
|
45
|
+
end
|
46
|
+
|
47
|
+
app_files += @manifest.css_tasks(styles_build_dir)
|
48
|
+
|
49
|
+
task :shared do
|
50
|
+
cp_ne "assets/images/*", File.join(build_dir, 'images')
|
51
|
+
cp_ne "assets/lib/*.js", scripts_build_dir
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "Build the web app"
|
55
|
+
task :build => app_files + [:shared]
|
56
|
+
|
57
|
+
desc "Publishes the built web app as an artifact"
|
58
|
+
task :publish => :build do
|
59
|
+
artifact_dir(build_dir, 'web/public')
|
60
|
+
end
|
61
|
+
|
62
|
+
desc "Clean web app"
|
63
|
+
task :clean => 'apache:clean' do
|
64
|
+
rm_rf build_dir
|
65
|
+
end
|
66
|
+
|
67
|
+
namespace :apache do
|
68
|
+
@apache.install_tasks
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|