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
@@ -0,0 +1,22 @@
1
+ namespace :precommit do
2
+ old_env = ''
3
+
4
+ task :dev_env do
5
+ ENV['CALATRAVA_ENV'] = 'development' unless ENV['CALATRAVA_ENV']
6
+ end
7
+
8
+ task :begin_automation do
9
+ old_env = ENV['CALATRAVA_ENV']
10
+ ENV['CALATRAVA_ENV'] = 'automation'
11
+ end
12
+
13
+ task :end_automation do
14
+ ENV['CALATRAVA_ENV'] = old_env
15
+ end
16
+
17
+ task :web_features => [:begin_automation, "configure:automation", "automation:acl:start", "automation:web:features", "automation:acl:stop", :end_automation]
18
+
19
+ desc "Run this before pushing"
20
+ task :mw => [:dev_env, "kernel:spec", "kernel:features", :web_features]
21
+
22
+ end
@@ -0,0 +1,17 @@
1
+ namespace :release do
2
+
3
+ promoted_path = 'promoted_dir'
4
+
5
+ directory promoted_path
6
+
7
+ desc "Acquires the promoted artifacts to be released"
8
+ task :files => promoted_path do
9
+ artifacts_url = "http://localhost:8080/job/#{ENV['PROMOTED_JOB_NAME']}/#{ENV['PROMOTED_NUMBER']}/artifact/artifacts/#{ENV['CALATRAVA_ENV']}"
10
+
11
+ cd promoted_path do
12
+ sh "curl -O '#{artifacts_url}/#{app_name}.ipa'"
13
+ sh "curl -O '#{artifacts_url}/#{app_name}.apk'"
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,82 @@
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
+ desc "Reload the apache configuration"
65
+ task :reload do
66
+ reload_apache
67
+ end
68
+
69
+ desc "Stop the apache configuration"
70
+ task :stop do
71
+ stop_apache
72
+ end
73
+ end
74
+
75
+ desc "Clean web public directory"
76
+ task :clean do
77
+ rm_rf CONFIG[:web][:public]
78
+ rm_rf APACHE_LOGS_DIR
79
+ rm_rf File.join(APACHE_DIR, 'conf', 'httpd.conf')
80
+ end
81
+
82
+ end
@@ -0,0 +1,93 @@
1
+ $: << File.dirname(__FILE__)
2
+ require 'calatrava'
3
+
4
+ Calatrava::Project.here('.')
5
+
6
+ def cp_ne(source, dest_dir)
7
+ cp Dir[source], dest_dir
8
+ end
9
+
10
+ ROOT_DIR = "."
11
+ BUILD_DIR = File.join(ROOT_DIR, 'build').freeze
12
+
13
+ SHELL_DIR = File.join(ROOT_DIR, 'shell').freeze
14
+ SHELL_LAYOUTS_DIR = File.join(SHELL_DIR, 'layouts').freeze
15
+ SHELL_VIEWS_DIR = File.join(SHELL_DIR, 'views').freeze
16
+ SHELL_PARTIALS_DIR = File.join(SHELL_DIR, 'partials').freeze
17
+ SHELL_JS_DIR = File.join(SHELL_DIR, 'support').freeze
18
+
19
+ FEATURES_DIR = File.join(ROOT_DIR, 'features').freeze
20
+ FEATURE_RESULTS_DIR = File.join(ROOT_DIR, 'results').freeze
21
+
22
+
23
+ KERNEL_DIR = File.join(ROOT_DIR, 'kernel').freeze
24
+ KERNEL_JS_DIR = File.join(KERNEL_DIR, 'app').freeze
25
+ KERNEL_SPEC_DIR = File.join(KERNEL_DIR, 'spec').freeze
26
+
27
+ BUILD_CORE_DIR = File.join(BUILD_DIR, 'core').freeze
28
+ BUILD_CORE_KERNEL_DIR = File.join(BUILD_CORE_DIR, 'kernel').freeze
29
+ BUILD_CORE_CSS_DIR = File.join(BUILD_CORE_DIR, 'stylesheets').freeze
30
+
31
+ ASSETS_DIR = File.join(ROOT_DIR, 'assets').freeze
32
+ ASSETS_IMG_DIR = File.join(ASSETS_DIR, 'images').freeze
33
+ ASSETS_LIB_DIR = File.join(ASSETS_DIR, 'lib').freeze
34
+ ASSETS_CSS_DIR = File.join(ASSETS_DIR, 'stylesheets').freeze
35
+ ASSETS_FONTS_DIR = File.join(ASSETS_DIR, 'fonts').freeze
36
+
37
+ APACHE_DIR = File.join(ROOT_DIR, 'web', 'apache').freeze
38
+ WEB_DIR = File.join(ROOT_DIR, 'web').freeze
39
+ APACHE_LOGS_DIR = File.join(APACHE_DIR, 'logs').freeze
40
+
41
+ CONFIG_DIR = File.join(ROOT_DIR, 'config').freeze
42
+ CONFIG_YAML = File.join(CONFIG_DIR, 'environments.yml').freeze
43
+ CONFIG_TEMPLATE_DIR = File.join(CONFIG_DIR, 'templates').freeze
44
+ CONFIG_RESULT_DIR = File.join(CONFIG_DIR, 'result').freeze
45
+ directory CONFIG_RESULT_DIR
46
+
47
+ CONFIG = {}
48
+
49
+ [:ios, :droid, :web].each do |os|
50
+ CONFIG[os] = {}
51
+ CONFIG[os][:root] = File.join(ROOT_DIR, os.to_s)
52
+ CONFIG[os][:public] = case os
53
+ when :droid
54
+ File.join(CONFIG[os][:root], Calatrava::Project.current.name, 'assets', 'hybrid').freeze
55
+ else
56
+ File.join(CONFIG[os][:root], 'public').freeze
57
+ end
58
+ CONFIG[os][:html] = File.join(CONFIG[os][:public], 'views').freeze
59
+ CONFIG[os][:assets] = case os
60
+ when :ios
61
+ File.join(CONFIG[os][:public], 'assets').freeze
62
+ else
63
+ CONFIG[os][:public]
64
+ end
65
+ CONFIG[os][:imgs] = File.join(CONFIG[os][:assets], 'images').freeze
66
+ CONFIG[os][:js] = File.join(CONFIG[os][:assets], 'scripts').freeze
67
+ CONFIG[os][:css] = File.join(CONFIG[os][:assets], 'styles').freeze
68
+ CONFIG[os][:fonts] = File.join(CONFIG[os][:assets], 'fonts').freeze
69
+ CONFIG[os][:layout] = File.join(CONFIG[os][:root], "app", "views").freeze
70
+
71
+ directory CONFIG[os][:public]
72
+ directory CONFIG[os][:html]
73
+ directory CONFIG[os][:assets]
74
+ directory CONFIG[os][:imgs]
75
+ directory CONFIG[os][:js]
76
+ directory CONFIG[os][:css]
77
+ directory CONFIG[os][:fonts]
78
+ end
79
+
80
+ CONFIG[:ios][:project_name] = Calatrava::Project.current.name
81
+ CONFIG[:ios][:app_dir] = File.join(CONFIG[:ios][:root], 'Source', Calatrava::Project.current.name)
82
+ CONFIG[:ios][:cucumber] = FEATURES_DIR
83
+
84
+ directory BUILD_CORE_DIR
85
+ directory BUILD_CORE_CSS_DIR
86
+ directory BUILD_CORE_KERNEL_DIR
87
+
88
+ Dir["#{File.join(File.dirname(__FILE__), 'tasks')}/*.rb"].each { |t| require t }
89
+
90
+ desc "Clean all directories"
91
+ task :clean => ["core:clean", "ios:clean", "bb:clean", "web:clean", "artifact:clean", "droid:clean"] do
92
+ rm_rf BUILD_DIR
93
+ end
@@ -0,0 +1,44 @@
1
+ class Dir
2
+
3
+ def self.walk(start_dir, &blk)
4
+ Dir["#{start_dir}/{*,.*}"].each do |item|
5
+ blk.call item
6
+ if File.directory?(item) && !(item =~ /\/\.$/) && !(item =~ /\/\.\.$/)
7
+ walk(item, &blk)
8
+ end
9
+ end
10
+ end
11
+
12
+ end
13
+
14
+ module Calatrava
15
+
16
+ class Template
17
+
18
+ def initialize(directory)
19
+ @directory = directory
20
+ end
21
+
22
+ def target_name(item)
23
+ item.sub("#{@directory}/", "")
24
+ end
25
+
26
+ def walk_directories(&blk)
27
+ Dir.walk(@directory) do |item|
28
+ if File.directory?(item)
29
+ blk.call target_name(item)
30
+ end
31
+ end
32
+ end
33
+
34
+ def walk_files(&blk)
35
+ Dir.walk(@directory) do |item|
36
+ if File.file? item
37
+ blk.call(:path => item, :name => target_name(item))
38
+ end
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,2 @@
1
+ rvm_install_on_use_flag=1
2
+ rvm --create use ruby-1.9.3-p0@{{ project_slug }}
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gem "rake"
4
+ gem "calatrava"{{#dev?}}, :path => '../'{{/dev?}}
@@ -0,0 +1 @@
1
+ require 'calatrava/tasks'