calatrava 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/CHANGES.markdown +40 -0
  2. data/README.md +5 -0
  3. data/calatrava.gemspec +2 -3
  4. data/lib/calatrava/apache.rb +126 -0
  5. data/lib/calatrava/app.rb +2 -2
  6. data/lib/calatrava/app_builder.rb +68 -0
  7. data/lib/calatrava/configuration.rb +73 -0
  8. data/lib/calatrava/droid_app.rb +46 -0
  9. data/lib/calatrava/ios_app.rb +40 -0
  10. data/lib/calatrava/kernel.rb +79 -0
  11. data/lib/calatrava/manifest.rb +34 -11
  12. data/lib/calatrava/mobile_web_app.rb +74 -0
  13. data/lib/calatrava/project.rb +7 -191
  14. data/lib/calatrava/project_script.rb +186 -0
  15. data/lib/calatrava/shell.rb +43 -0
  16. data/lib/calatrava/tasks/assets.rb +4 -0
  17. data/lib/calatrava/tasks/automation.rb +4 -10
  18. data/lib/calatrava/tasks/haml.rb +9 -10
  19. data/lib/calatrava/tasks.rb +9 -85
  20. data/lib/calatrava/templates/config/templates/httpd.conf.erb +9 -9
  21. data/lib/calatrava/templates/droid/app/bridge.coffee +3 -0
  22. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/CalatravaPlugin.java +13 -0
  23. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/AlertPlugin.java +61 -0
  24. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/AnnotationRegistrar.java +71 -0
  25. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/KernelBridge.java +3 -4
  26. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/Launcher.java +2 -1
  27. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PageRegistry.java +8 -29
  28. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PluginCommand.java +8 -0
  29. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PluginRegistry.java +112 -0
  30. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RegisteredActivity.java +3 -14
  31. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RegisteredPlugin.java +10 -0
  32. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/Registration.java +8 -0
  33. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RhinoService.java +1 -0
  34. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/shell/WebViewActivity.java +1 -1
  35. data/lib/calatrava/templates/ios/Podfile.calatrava +6 -1
  36. data/lib/calatrava/templates/ios/src/ConversionFormViewController.m +1 -1
  37. data/lib/calatrava/templates/kernel/app/calatrava.coffee +32 -5
  38. data/lib/calatrava/templates/kernel/app/converter/controller.converter.coffee +11 -4
  39. data/lib/calatrava/templates/kernel/plugins/alert.coffee +9 -0
  40. data/lib/calatrava/templates/shell/layouts/single_page.haml +3 -3
  41. data/lib/calatrava/templates/web/app/source/alert.web.coffee +13 -0
  42. data/lib/calatrava/templates/web/app/source/bridge.coffee +10 -0
  43. data/lib/calatrava/templates/web/app/views/index.haml +5 -5
  44. data/lib/calatrava/version.rb +1 -1
  45. data/lib/calatrava.rb +15 -1
  46. data/spec/app_builder_spec.rb +46 -0
  47. data/spec/kernel_spec.rb +51 -0
  48. data/spec/manifest_spec.rb +62 -0
  49. data/spec/mobile_web_app_spec.rb +49 -0
  50. data/spec/shell_spec.rb +54 -0
  51. data/spec/spec_helper.rb +4 -0
  52. metadata +60 -49
  53. data/Plans.md +0 -20
  54. data/lib/calatrava/tasks/apache.rb +0 -54
  55. data/lib/calatrava/tasks/build.rb +0 -1
  56. data/lib/calatrava/tasks/configuration.rb +0 -41
  57. data/lib/calatrava/tasks/droid.rb +0 -83
  58. data/lib/calatrava/tasks/ios.rb +0 -73
  59. data/lib/calatrava/tasks/kernel.rb +0 -52
  60. data/lib/calatrava/tasks/shell.rb +0 -17
  61. data/lib/calatrava/tasks/web.rb +0 -87
@@ -1,83 +0,0 @@
1
- namespace :droid do
2
-
3
- version = "1.0"
4
- droid_manifest = Calatrava::Manifest.new('droid')
5
-
6
- html_views = droid_manifest.features.collect do |feature|
7
- html_dir = "droid/#{Calatrava::Project.current.name}/assets/hybrid/views"
8
- Dir["shell/pages/#{feature}/*.haml"].collect do |page|
9
- pageName = File.basename(page, '.haml')
10
- file "#{html_dir}/#{pageName}.html" => page do
11
- HamlSupport::compile_hybrid_page feature, page, html_dir
12
- end
13
- end
14
- end.flatten
15
-
16
- desc "Creates html from haml using Android layout"
17
- task :haml => [CONFIG[:droid][:html]] + html_views
18
-
19
- desc "Compile droid-specific coffee to javascript"
20
- task :coffee => CONFIG[:droid][:assets] do
21
- coffee File.join(CONFIG[:droid][:root], "app"), CONFIG[:droid][:js]
22
- end
23
-
24
- desc "Copies required assets for droid"
25
- task :shared => ["shell:scss", "shell:coffee", "kernel:coffee",
26
- CONFIG[:droid][:css], CONFIG[:droid][:imgs], CONFIG[:droid][:js],
27
- :config, CONFIG[:droid][:fonts]] do
28
- cp_ne "#{BUILD_CORE_CSS_DIR}/*.css", CONFIG[:droid][:css]
29
- cp_ne "#{ASSETS_IMG_DIR}/*", CONFIG[:droid][:imgs]
30
- cp_ne "assets/lib/*.js", CONFIG[:droid][:js]
31
-
32
- droid_manifest.js_files.each do |js_file|
33
- sh "cp #{js_file} #{CONFIG[:droid][:js]}"
34
- end
35
- droid_manifest.load_file("droid/#{Calatrava::Project.current.name}/assets/hybrid", 'hybrid/scripts', :type => :text, :include_pages => false)
36
-
37
- cp_ne "build/shell/js/**/*.js", CONFIG[:droid][:js]
38
- cp_ne "build/kernel/js/*.js", CONFIG[:droid][:js]
39
- cp_ne "#{ASSETS_FONTS_DIR}/*", CONFIG[:droid][:fonts]
40
- end
41
-
42
- task :app => [:shared, :haml, :coffee]
43
-
44
- desc "Prepares config for the app"
45
- task :config do
46
- env_coffee = config_path("env.coffee")
47
- coffee env_coffee, CONFIG[:droid][:js]
48
- end
49
-
50
- desc "Builds the complete Android app"
51
- task :build => [:app, :config, :write_build_number] do
52
- cd "droid/#{Calatrava::Project.current.name}" do
53
- sh "ant clean debug"
54
- end
55
- end
56
-
57
- desc "Update the app to show the correct build number"
58
- task :write_build_number do
59
- cd "droid/#{Calatrava::Project.current.name}" do
60
- sh %{cat AndroidManifest.xml | sed -E "s/android:versionName=\".*\"/android:versionName=\\"#{version}\\">/g" > AndroidManifest.xml.new}
61
- mv "AndroidManifest.xml.new", "AndroidManifest.xml"
62
- end
63
- end
64
-
65
- desc "Publishes the built Android app as an artifact"
66
- task :publish => :build do
67
- artifact("droid/#{Calatrava::Project.current.name}/bin/#{Calatrava::Project.current.name}-debug.apk", ENV['CALATRAVA_ENV'])
68
- end
69
-
70
- desc "Deploy app to device/emulator"
71
- task :deploy => :publish do
72
- sh "adb install -r artifacts/#{ENV['CALATRAVA_ENV']}/#{Calatrava::Project.current.name}-debug.apk"
73
- end
74
-
75
- desc "Clean droid public directory"
76
- task :clean do
77
- rm_rf CONFIG[:droid][:public]
78
- cd "droid/#{Calatrava::Project.current.name}" do
79
- sh "ant clean"
80
- end
81
- end
82
-
83
- end
@@ -1,73 +0,0 @@
1
- namespace :ios do
2
-
3
-
4
- ios_manifest = Calatrava::Manifest.new('ios')
5
-
6
- html_views = ios_manifest.features.collect do |feature|
7
- html_dir = "ios/public/views"
8
- Dir["shell/pages/#{feature}/*.haml"].collect do |page|
9
- pageName = File.basename(page, '.haml')
10
- file "#{html_dir}/#{pageName}.html" => page do
11
- HamlSupport::compile_hybrid_page feature, page, html_dir, :platform => 'ios'
12
- end
13
- end
14
- end.flatten
15
-
16
- desc "Creates html from haml using iPhone layout"
17
- task :haml => [CONFIG[:ios][:html]] + html_views
18
-
19
- directory 'ios/public/assets'
20
-
21
- desc "Copies required assets for ios"
22
- task :shared => ["shell:scss", "shell:coffee", "kernel:coffee", 'ios/public/assets',
23
- CONFIG[:ios][:css], CONFIG[:ios][:imgs], CONFIG[:ios][:js], :config, CONFIG[:ios][:fonts]] do
24
- cp_ne "#{BUILD_CORE_CSS_DIR}/*.css", CONFIG[:ios][:css]
25
- cp_ne "#{ASSETS_IMG_DIR}/*", CONFIG[:ios][:imgs]
26
- cp_ne "assets/lib/*.js", CONFIG[:ios][:js]
27
- cp_ne "ios/res/js/*.js", CONFIG[:ios][:js]
28
-
29
- ios_manifest.js_files.each do |js_file|
30
- sh "cp #{js_file} #{CONFIG[:ios][:js]}"
31
- end
32
- ios_manifest.load_file('ios/public/assets', '%@/public/assets/scripts', :type => :text, :include_pages => false)
33
-
34
- cp_ne "build/shell/js/**/*.js", CONFIG[:ios][:js]
35
- cp_ne "build/kernel/js/*.js", CONFIG[:ios][:js]
36
- cp_ne "#{ASSETS_FONTS_DIR}/*", CONFIG[:ios][:fonts]
37
- end
38
-
39
- task :app => [:shared, :haml]
40
-
41
- desc "Prepares config for the app"
42
- task :config do
43
- env_coffee = config_path("env.coffee")
44
- coffee env_coffee, CONFIG[:ios][:js]
45
- end
46
-
47
- task :configured_app => [:app, :config]
48
-
49
- desc "Builds the iOS app"
50
- task :build => :configured_app do
51
- ENV['CMDLINE_BUILD'] = 'true'
52
- Calatrava::Project.current.build_ios
53
- end
54
-
55
- desc "Publish the iOS app as an artifact"
56
- task :publish => :build do
57
- artifact(CONFIG[:ios][:xcode][:package_path], ENV['CALATRAVA_ENV'])
58
- end
59
-
60
- desc "Clean ios public directory"
61
- task :clean do
62
- sh "rm -rf #{CONFIG[:ios][:public]}/*"
63
- end
64
-
65
- namespace :xcode do
66
- task :prebuild do
67
- if !ENV['CMDLINE_BUILD']
68
- Rake::Task['configure:development'].invoke
69
- Rake::Task['ios:configured_app'].invoke
70
- end
71
- end
72
- end
73
- end
@@ -1,52 +0,0 @@
1
- namespace :kernel do
2
-
3
- directory "build/kernel/js"
4
-
5
- desc "Build kernel js files"
6
- task :coffee => "build/kernel/js" do
7
- coffee "kernel/app", "build/kernel/js"
8
- end
9
-
10
- desc "Clean built kernel"
11
- task :clean do
12
- rm_rf "build/kernel"
13
- end
14
-
15
- file '.node_updated' => 'package.json' do
16
- sh "npm install"
17
- sh "touch .node_updated"
18
- end
19
-
20
- desc "Run jasmine test. If specs not given in argument, runs all test"
21
- task :spec => '.node_updated' do |t, args|
22
- cd "kernel" do
23
- ENV['NODE_PATH'] = "app:#{Calatrava::Project.current.src_paths}:spec:../assets/lib"
24
- sh "../node_modules/jasmine-node/bin/jasmine-node --coffee --test-dir spec"
25
- end
26
- end
27
-
28
- desc "Run cucumber.js features for kernel"
29
- task :features, [:file] => ['.node_updated', :create_sim_link] do |t, args|
30
- cd "kernel" do
31
- ENV['NODE_PATH'] = "#{Calatrava::Project.current.src_paths}:features/support:../assets/lib:features/step_definitions:../features/testdata"
32
- features_to_be_run = args[:file] ? "#{kernel/features}/#{args[:file]}" : "features"
33
- sh "../node_modules/cucumber/bin/cucumber.js --tags @all,@kernel --tags ~@wip '#{features_to_be_run}'"
34
- end
35
- end
36
-
37
- namespace :features do
38
- task :wip => ['.node_updated', :create_sim_link] do
39
- cd "kernel" do
40
- ENV['NODE_PATH'] = "#{Calatrava::Project.current.src_paths}:features/support:../assets/lib:features/step_definitions:../features/testdata"
41
- sh "../node_modules/cucumber/bin/cucumber.js --tags @wip --tags @kernel features"
42
- end
43
- end
44
- end
45
-
46
- desc "create sim link for the kernels step_definitions and support folder"
47
- task :create_sim_link do
48
- sh "ln -sFfh kernel/features/step_definitions/ features/step_definitions"
49
- sh "ln -sFfh kernel/features/support/ features/support"
50
- end
51
-
52
- end
@@ -1,17 +0,0 @@
1
- namespace :shell do
2
-
3
- directory "build/shell/css"
4
- directory "build/shell/js"
5
-
6
- desc "Convert core scss to css"
7
- task :scss => "build/shell/css" do
8
- sh "sass --update shell/stylesheets"
9
- cp_ne "shell/stylesheets/*.css", "build/shell/css"
10
- end
11
-
12
- desc "Build shell js files"
13
- task :coffee => "build/shell/js" do
14
- coffee "shell", "build/shell/js"
15
- end
16
-
17
- end
@@ -1,87 +0,0 @@
1
- namespace :web do
2
-
3
- desc "Creates html from haml using web layout"
4
- task :haml => CONFIG[:web][:public] do
5
- HamlSupport::compile "#{CONFIG[:web][:layout]}/index.haml", CONFIG[:web][:public]
6
- end
7
-
8
- desc "Compile web-specific coffee to javascript"
9
- task :coffee => CONFIG[:web][:assets] do
10
- coffee File.join(CONFIG[:web][:root], "app", "source"), CONFIG[:web][:js]
11
- end
12
-
13
- task :shared => ["shell:scss", "shell:coffee", "kernel:coffee",
14
- CONFIG[:web][:css], CONFIG[:web][:imgs], CONFIG[:web][:js], CONFIG[:web][:fonts]] do
15
- cp_ne "build/shell/css/*.css", CONFIG[:web][:css]
16
- cp_ne "#{ASSETS_IMG_DIR}/*", CONFIG[:web][:imgs]
17
- cp_ne "assets/lib/*.js", CONFIG[:web][:js]
18
-
19
- web_manifest = Calatrava::Manifest.new('web')
20
-
21
- web_manifest.js_files.each do |js_file|
22
- sh "cp #{js_file} #{CONFIG[:web][:js]}"
23
- end
24
-
25
- web_manifest.load_file('web/app/views', 'scripts', :type => :haml, :include_pages => true)
26
-
27
- cp_ne "build/shell/js/**/*.js", CONFIG[:web][:js]
28
- cp_ne "build/kernel/js/*.js", CONFIG[:web][:js]
29
- cp_ne "#{ASSETS_FONTS_DIR}/*", CONFIG[:web][:fonts]
30
- end
31
-
32
- task :app => [:shared, :haml, :coffee]
33
-
34
- desc "Prepares config for the app"
35
- task :config do
36
- env_coffee = config_path("env.coffee")
37
- coffee env_coffee, CONFIG[:web][:js]
38
- end
39
-
40
- desc "Build the web app"
41
- task :build => [:app, :config]
42
-
43
- desc "Publishes the built web app as an artifact"
44
- task :publish => :build do
45
- artifact_dir(CONFIG[:web][:public], 'web/public')
46
- artifact config_path("mw.conf"), 'web'
47
- artifact 'web/deploy_mw.sh', 'web'
48
- end
49
-
50
- namespace :apache do
51
-
52
- file 'web/apache/public' do
53
- cd 'web/apache' do
54
- ln_s "../public", "public"
55
- end
56
- end
57
-
58
- desc "launch a non-daemon apache instance on port 8888 which will serve our local app and also proxy to backend services"
59
- task :start => [:build, 'web/apache/public', APACHE_LOGS_DIR] do
60
- configure_apache
61
- launch_apache
62
- end
63
-
64
- task :background => [:build, 'web/apache/public', APACHE_LOGS_DIR] do
65
- configure_apache
66
- launch_apache :background => true
67
- end
68
-
69
- desc "Reload the apache configuration"
70
- task :reload do
71
- reload_apache
72
- end
73
-
74
- desc "Stop the apache configuration"
75
- task :stop do
76
- stop_apache
77
- end
78
- end
79
-
80
- desc "Clean web public directory"
81
- task :clean do
82
- rm_rf CONFIG[:web][:public]
83
- rm_rf APACHE_LOGS_DIR
84
- rm_rf File.join(APACHE_DIR, 'conf', 'httpd.conf')
85
- end
86
-
87
- end