calatrava 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/.gitignore +1 -1
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +4 -0
  5. data/CHANGES.markdown +67 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +100 -0
  8. data/README.md +39 -3
  9. data/Rakefile +4 -0
  10. data/Vagrantfile +106 -0
  11. data/calatrava.gemspec +9 -4
  12. data/features/cli.feature +9 -0
  13. data/features/project.feature +15 -3
  14. data/features/sample_app.feature +5 -1
  15. data/features/support/calatrava_app.rb +1 -1
  16. data/features/support/env.rb +1 -1
  17. data/lib/calatrava/apache.rb +10 -31
  18. data/lib/calatrava/app.rb +7 -3
  19. data/lib/calatrava/app_builder.rb +11 -12
  20. data/lib/calatrava/configuration.rb +23 -6
  21. data/lib/calatrava/droid_app.rb +11 -2
  22. data/lib/calatrava/ios_app.rb +8 -1
  23. data/lib/calatrava/manifest.rb +0 -20
  24. data/lib/calatrava/mobile_web_app.rb +13 -9
  25. data/lib/calatrava/output_file.rb +53 -0
  26. data/lib/calatrava/platform.rb +12 -0
  27. data/lib/calatrava/project.rb +31 -3
  28. data/lib/calatrava/project_script.rb +15 -6
  29. data/lib/calatrava/tasks/assets.rb +2 -1
  30. data/lib/calatrava/tasks/bootstrap.rb +2 -3
  31. data/lib/calatrava/tasks/rake.rb +24 -0
  32. data/lib/calatrava/tasks.rb +1 -9
  33. data/lib/calatrava/templates/.ruby-gemset.calatrava +1 -0
  34. data/lib/calatrava/templates/.ruby-version +1 -0
  35. data/lib/calatrava/templates/droid/app/bridge.coffee +1 -1
  36. data/lib/calatrava/templates/droid/calatrava/CALATRAVA_TMPL/AndroidManifest.xml.calatrava +3 -4
  37. data/lib/calatrava/templates/droid/calatrava/CALATRAVA_TMPL/build.xml.calatrava +0 -4
  38. data/lib/calatrava/templates/droid/calatrava/ant/calatrava.xml +7 -3
  39. data/lib/calatrava/templates/droid/calatrava/{ivy.xml → ivy/ivy.xml} +0 -0
  40. data/lib/calatrava/templates/droid/calatrava/{ivysettings.xml → ivy/ivysettings.xml} +0 -0
  41. data/lib/calatrava/templates/droid/calatrava/src/com/CALATRAVA_TMPL/Bootstrap.java.calatrava +21 -0
  42. data/lib/calatrava/templates/droid/calatrava/src/com/CALATRAVA_TMPL/Title.java.calatrava +8 -15
  43. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/CalatravaApplication.java +87 -0
  44. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PageRegistry.java +12 -9
  45. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PluginRegistry.java +11 -5
  46. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RegisteredActivity.java +6 -15
  47. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RegisteredPlugin.java +1 -1
  48. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RhinoService.java +27 -41
  49. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/shell/WebViewActivity.java +7 -8
  50. data/lib/calatrava/templates/ios/Podfile.calatrava +1 -1
  51. data/lib/calatrava/templates/ios/src/AppDelegate.h +6 -1
  52. data/lib/calatrava/templates/ios/src/AppDelegate.m +20 -0
  53. data/lib/calatrava/templates/kernel/app/calatrava.coffee +13 -5
  54. data/lib/calatrava/templates/kernel/plugins/alert.coffee +4 -1
  55. data/lib/calatrava/templates/kernel/spec/converter/controller.converter.spec.coffee +1 -1
  56. data/lib/calatrava/templates/kernel/spec/stubView.coffee +17 -3
  57. data/lib/calatrava/templates/package.json +0 -1
  58. data/lib/calatrava/templates/shell/pages/converter/page.conversionForm.coffee +7 -2
  59. data/lib/calatrava/templates/web/app/source/bridge.coffee +7 -7
  60. data/lib/calatrava/templates/web/app/source/init.coffee +1 -1
  61. data/lib/calatrava/version.rb +1 -1
  62. data/lib/calatrava.rb +4 -0
  63. data/spec/app_builder_spec.rb +2 -2
  64. data/spec/mobile_web_app_spec.rb +1 -1
  65. data/spec/output_file_spec.rb +33 -0
  66. metadata +104 -35
  67. data/.rvmrc +0 -2
  68. data/lib/calatrava/templates/.rvmrc.calatrava +0 -2
  69. data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/Launcher.java +0 -86
  70. data/lib/calatrava/templates/ios/res/xibs/ProgressViewController.xib +0 -334
  71. data/lib/calatrava/templates/ios/res/xibs/WebViewController.xib +0 -173
  72. data/lib/calatrava/templates/web/deploy/instance.sh +0 -10
@@ -3,8 +3,8 @@ module Calatrava
3
3
  class AppBuilder
4
4
  include Rake::DSL
5
5
 
6
- def initialize(output_dir, manifest)
7
- @output_dir, @manifest = output_dir, manifest
6
+ def initialize(platform, output_dir, manifest)
7
+ @platform, @output_dir, @manifest = platform, output_dir, manifest
8
8
  end
9
9
 
10
10
  def build_dir ; @output_dir ; end
@@ -14,7 +14,8 @@ module Calatrava
14
14
  def build_styles_dir ; "#{build_dir}/styles" ; end
15
15
 
16
16
  def coffee_files
17
- @manifest.coffee_files + [Calatrava::Project.current.config.path('env.coffee')]
17
+ env_file = OutputFile.new(build_scripts_dir, Calatrava::Project.current.config.path('env.coffee'), ['configure:calatrava_env'])
18
+ @manifest.coffee_files.collect { |cf| OutputFile.new(build_scripts_dir, cf) } + [env_file]
18
19
  end
19
20
 
20
21
  def js_file(cf)
@@ -40,25 +41,23 @@ module Calatrava
40
41
 
41
42
  app_files = haml_files.collect do |hf|
42
43
  file "#{build_html_dir}/#{File.basename(hf, '.haml')}.html" => [build_html_dir, hf] do
43
- HamlSupport::compile_hybrid_page hf, build_html_dir, :platform => 'ios'
44
- end
45
- end
46
-
47
- app_files += coffee_files.collect do |cf|
48
- file js_file(cf) => [build_scripts_dir, cf] do
49
- coffee cf, build_scripts_dir
44
+ HamlSupport::compile_hybrid_page hf, build_html_dir, :platform => @platform
50
45
  end
51
46
  end
52
47
 
48
+ app_files += coffee_files.collect { |cf| cf.to_task }
53
49
  app_files += @manifest.css_tasks(build_styles_dir)
54
- app_files << file("#{build_dir}/load_file.txt" => [build_dir, @manifest.src_file]) do |t|
50
+ app_files << file("#{build_dir}/load_file.txt" => [build_dir,
51
+ @manifest.src_file,
52
+ transient("#{@platform}_coffee", @manifest.kernel_bootstrap)
53
+ ]) do |t|
55
54
  File.open(t.name, "w+") { |f| f.puts load_instructions }
56
55
  end
57
56
 
58
57
  task :shared => [build_images_dir, build_scripts_dir] do
59
58
  cp_ne "assets/images/*", build_images_dir
60
59
  cp_ne "assets/lib/*.js", build_scripts_dir
61
- cp_ne "ios/res/js/*.js", build_scripts_dir
60
+ cp_ne "#{@platform}/res/js/*.js", build_scripts_dir
62
61
  end
63
62
 
64
63
  task :app => [:shared] + app_files
@@ -6,10 +6,16 @@ module Calatrava
6
6
  include Rake::DSL
7
7
 
8
8
  @@extras = []
9
+ @@env = ENV['CALATRAVA_ENV'] || 'development'
10
+
9
11
  def self.extra(&configurator)
10
12
  @@extras << configurator
11
13
  end
12
14
 
15
+ def self.env
16
+ @@env
17
+ end
18
+
13
19
  def initialize
14
20
  @runtime = {}
15
21
  end
@@ -17,19 +23,30 @@ module Calatrava
17
23
  def config_result_dir
18
24
  "config/result"
19
25
  end
26
+
20
27
  def config_yaml
21
28
  "config/environments.yml"
22
29
  end
30
+
23
31
  def config_template_dir
24
32
  "config/templates"
25
33
  end
34
+
26
35
  def templates
27
36
  Rake::FileList["#{config_template_dir}/*.erb"]
28
37
  end
29
38
 
30
39
  def config_for(environment)
31
40
  @@extras.each { |e| e.call(self) }
32
- @runtime.merge(YAML::load(File.open(config_yaml))[environment])
41
+ @runtime.merge(environments_yml[environment])
42
+ end
43
+
44
+ def environment_names
45
+ environments_yml.keys
46
+ end
47
+
48
+ def environments_yml
49
+ @environments_yml ||= YAML::load(File.open(config_yaml))
33
50
  end
34
51
 
35
52
  def runtime(key, value)
@@ -44,16 +61,16 @@ module Calatrava
44
61
  end
45
62
 
46
63
  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
64
+ artifact_path(File.join(Configuration.env, file))
51
65
  end
52
66
 
53
67
  def install_tasks
54
68
  directory config_result_dir
55
69
 
56
- %w{local development test automation production}.each do |environment|
70
+ puts "CALATRAVA_ENV = '#{Configuration.env}'"
71
+ transient :calatrava_env, Configuration.env
72
+
73
+ environment_names.each do |environment|
57
74
  desc "Create config files for #{environment} environment"
58
75
  task environment.to_sym => [:clean, config_result_dir] do
59
76
  configuration = config_for(environment)
@@ -5,7 +5,7 @@ module Calatrava
5
5
 
6
6
  def initialize(path, proj_name, manifest)
7
7
  @path, @proj_name, @manifest = path, proj_name, manifest
8
- @app_builder = AppBuilder.new("droid/#{@proj_name}/assets/calatrava", @manifest)
8
+ @app_builder = AppBuilder.new('droid', "droid/#{@proj_name}/assets/calatrava", @manifest)
9
9
  end
10
10
 
11
11
  def install_tasks
@@ -15,8 +15,17 @@ module Calatrava
15
15
  coffee 'droid/app/bridge.coffee', @app_builder.build_scripts_dir
16
16
  end
17
17
 
18
+ task :resolve => "droid/#{@proj_name}/ivy/ivy.xml" do
19
+ cd "droid/#{@proj_name}" do
20
+ sh "ant -f ant/calatrava.xml resolve"
21
+ end
22
+ end
23
+
24
+ desc "Bootstraps the Droid app"
25
+ task :bootstrap => :resolve
26
+
18
27
  desc "Builds the Android app"
19
- task :build => app_task do
28
+ task :build => [:resolve, app_task] do
20
29
  cd "droid/#{@proj_name}" do
21
30
  sh "ant clean debug"
22
31
  end
@@ -5,7 +5,7 @@ module Calatrava
5
5
 
6
6
  def initialize(path, manifest)
7
7
  @path, @manifest = path, manifest
8
- @app_builder = AppBuilder.new('ios/public', @manifest)
8
+ @app_builder = AppBuilder.new('ios', 'ios/public', @manifest)
9
9
  end
10
10
 
11
11
  def install_tasks
@@ -20,6 +20,13 @@ module Calatrava
20
20
  end
21
21
  end
22
22
 
23
+ desc "Bootstraps the iOS app"
24
+ task :bootstrap do
25
+ cd "ios" do
26
+ sh "pod install" if Calatrava.platform == :mac
27
+ end
28
+ end
29
+
23
30
  desc "Clean ios public directory"
24
31
  task :clean do
25
32
  sh "rm -rf #{@app_builder.build_dir}"
@@ -15,17 +15,6 @@ module Calatrava
15
15
  @feature_list
16
16
  end
17
17
 
18
- def load_file(target_dir, js_load_path, options)
19
- File.open("#{target_dir}/load_file.#{options[:type]}", "w+") do |f|
20
- @feature_list.each do |feature|
21
- coffee_files(feature, :include_pages => options[:include_pages]).each do |coffee_file|
22
- js_src = File.join(js_load_path, File.basename(coffee_file, '.coffee') + ".js")
23
- f.puts self.send(options[:type], js_src)
24
- end
25
- end
26
- end
27
- end
28
-
29
18
  def coffee_files
30
19
  [@shell, @kernel].collect do |src|
31
20
  src.coffee_files + feature_files(src, :coffee)
@@ -45,7 +34,6 @@ module Calatrava
45
34
  end
46
35
 
47
36
  def css_tasks(output_dir)
48
- mkdir_p output_dir
49
37
  css_files.collect do |style_file|
50
38
  file "#{output_dir}/#{File.basename(style_file, '.*')}.css" => [output_dir, style_file] do |t|
51
39
  if style_file =~ /\.css$/
@@ -60,14 +48,6 @@ module Calatrava
60
48
  def feature_files(source, type)
61
49
  source.features.select { |f| @feature_list.include?(f[:name]) }.collect { |f| f[type] }.flatten
62
50
  end
63
-
64
- def haml(js_src)
65
- %{%script(type="text/javascript" src="#{js_src}")}
66
- end
67
-
68
- def text(js_src)
69
- js_src
70
- end
71
51
  end
72
52
 
73
53
  end
@@ -11,6 +11,7 @@ module Calatrava
11
11
  def build_dir ; "#{@path}/web/public" ; end
12
12
  def scripts_build_dir ; "#{build_dir}/scripts" ; end
13
13
  def styles_build_dir ; "#{build_dir}/styles" ; end
14
+ def images_build_dir ; "#{build_dir}/images" ; end
14
15
 
15
16
  def coffee_files
16
17
  Dir.chdir @path do
@@ -18,7 +19,8 @@ module Calatrava
18
19
  core_coffee += @manifest.coffee_files.select { |cf| cf =~ /calatrava.coffee$/ }
19
20
  web_coffee = Dir['web/app/source/*.coffee'] - core_coffee
20
21
  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
+ env_file = OutputFile.new(scripts_build_dir, Calatrava::Project.current.config.path('env.coffee'), ['configure:calatrava_env'])
23
+ (core_coffee + web_coffee + mf_coffee).collect { |cf| OutputFile.new(scripts_build_dir, cf) } + [env_file]
22
24
  end
23
25
  end
24
26
 
@@ -27,27 +29,29 @@ module Calatrava
27
29
  end
28
30
 
29
31
  def scripts
30
- coffee_files.collect { |cf| "scripts/#{File.basename(cf, '.coffee')}.js" }
32
+ coffee_files.collect do |cf|
33
+ cf.output_path.gsub("#{build_dir}/", "")
34
+ end
31
35
  end
32
36
 
33
37
  def install_tasks
34
38
  directory build_dir
35
39
  directory scripts_build_dir
36
40
  directory styles_build_dir
41
+ directory images_build_dir
37
42
 
38
- app_files = coffee_files.collect do |cf|
39
- file "#{scripts_build_dir}/#{File.basename(cf, '.coffee')}.js" => [scripts_build_dir, cf] do
40
- coffee cf, scripts_build_dir
41
- end
42
- end
43
+ app_files = coffee_files.collect { |cf| cf.to_task }
43
44
 
44
- app_files << file("#{build_dir}/index.html" => [@manifest.src_file, "web/app/views/index.haml"] + haml_files) do
45
+ app_files << file("#{build_dir}/index.html" => [@manifest.src_file,
46
+ "web/app/views/index.haml",
47
+ transient('web_coffee', coffee_files),
48
+ transient('web_haml', haml_files)] + haml_files) do
45
49
  HamlSupport::compile "web/app/views/index.haml", build_dir
46
50
  end
47
51
 
48
52
  app_files += @manifest.css_tasks(styles_build_dir)
49
53
 
50
- task :shared do
54
+ task :shared => [images_build_dir, scripts_build_dir] do
51
55
  cp_ne "assets/images/*", File.join(build_dir, 'images')
52
56
  cp_ne "assets/lib/*.js", scripts_build_dir
53
57
  end
@@ -0,0 +1,53 @@
1
+ require 'pathname'
2
+
3
+ module Calatrava
4
+
5
+ class OutputFile
6
+ @@rules = {}
7
+
8
+ def self.rule(opts, &action)
9
+ start_ext = opts.keys[0]
10
+ @@rules[start_ext] = {:target => opts[start_ext], :action => action}
11
+ end
12
+
13
+ def self.target_file(file_name)
14
+ start_ext = file_name.extname
15
+ Pathname.new(file_name.basename(start_ext).to_s + rule_for(start_ext)[:target])
16
+ end
17
+
18
+ def self.action(file_name)
19
+ rule_for(file_name.extname)[:action]
20
+ end
21
+
22
+ def self.rule_for(ext)
23
+ @@rules[ext]
24
+ end
25
+
26
+ include Rake::DSL
27
+ attr_reader :source_file, :dependencies
28
+
29
+ def initialize(output_dir, source_file, dependencies = [])
30
+ @output_dir = Pathname.new(output_dir)
31
+ @source_file = Pathname.new(source_file)
32
+
33
+ @dependencies = [@source_file.to_s, @output_dir.to_s]
34
+ @dependencies += dependencies if dependencies
35
+ end
36
+
37
+ def output_path
38
+ (@output_dir + OutputFile.target_file(@source_file)).to_s
39
+ end
40
+ alias :to_s :output_path
41
+
42
+ def to_task
43
+ file(output_path => @dependencies) do
44
+ OutputFile.action(@source_file).call(output_path.to_s, @source_file.to_s)
45
+ end
46
+ end
47
+ end
48
+
49
+ OutputFile.rule '.coffee' => '.js' do |target, source|
50
+ coffee source, File.dirname(target)
51
+ end
52
+
53
+ end
@@ -0,0 +1,12 @@
1
+ module Calatrava
2
+ def self.platform
3
+ case RbConfig::CONFIG['host_os']
4
+ when /darwin/
5
+ :mac
6
+ when /linux/
7
+ :linux
8
+ else
9
+ raise "Unsupported OS"
10
+ end
11
+ end
12
+ end
@@ -1,6 +1,7 @@
1
1
  module Calatrava
2
2
 
3
3
  class Project
4
+ include Rake::DSL
4
5
 
5
6
  def self.here(directory)
6
7
  @@current = Project.new(directory)
@@ -27,9 +28,36 @@ module Calatrava
27
28
  @config = Configuration.new
28
29
  @kernel = Kernel.new(@path)
29
30
  @shell = Shell.new(@path)
30
- @mobile_web = MobileWebApp.new(@path, Manifest.new(@path, 'web', @kernel, @shell))
31
- @ios = IosApp.new(@path, Manifest.new(@path, 'ios', @kernel, @shell))
32
- @droid = DroidApp.new(@path, @name, Manifest.new(@path, 'droid', @kernel, @shell))
31
+ if platform? 'web'
32
+ @mobile_web = MobileWebApp.new(@path, Manifest.new(@path, 'web', @kernel, @shell))
33
+ end
34
+ if platform? 'ios'
35
+ @ios = IosApp.new(@path, Manifest.new(@path, 'ios', @kernel, @shell))
36
+ end
37
+ if platform? 'droid'
38
+ @droid = DroidApp.new(@path, @name, Manifest.new(@path, 'droid', @kernel, @shell))
39
+ end
40
+ end
41
+
42
+ def install_tasks
43
+ namespace(:kernel) { kernel.install_tasks }
44
+ namespace(:configure) { config.install_tasks }
45
+
46
+ namespace(:droid) { droid.install_tasks } if platform?('droid')
47
+ namespace(:ios) { ios.install_tasks } if platform?('ios')
48
+ namespace(:web) { mobile_web.install_tasks } if platform?('web')
49
+
50
+ desc "Clean all apps"
51
+ task :clean => tasks_for_platforms(:clean)
52
+ task :build => tasks_for_platforms(:build)
53
+ end
54
+
55
+ def platform?(p)
56
+ @options[:platforms].include? p
57
+ end
58
+
59
+ def tasks_for_platforms(task)
60
+ @options[:platforms].collect { |p| "#{p}:#{task}" }
33
61
  end
34
62
 
35
63
  end
@@ -1,6 +1,6 @@
1
1
  require 'mustache'
2
2
  require 'yaml'
3
- require 'xcodeproj'
3
+ require 'xcodeproj' if Calatrava.platform == :mac
4
4
 
5
5
  module Calatrava
6
6
 
@@ -13,6 +13,11 @@ module Calatrava
13
13
  @slug = name.gsub(" ", "_").downcase
14
14
  @title = @name[0..0].upcase + @name[1..-1]
15
15
  @options = overrides
16
+ puts @options
17
+
18
+ @platforms = ['ios', 'droid', 'web'].select do |platform|
19
+ !@options["no-#{platform}"]
20
+ end
16
21
  end
17
22
 
18
23
  def sh(cmd)
@@ -21,7 +26,7 @@ module Calatrava
21
26
  end
22
27
 
23
28
  def dev?
24
- @options[:is_dev]
29
+ @options.dev?
25
30
  end
26
31
 
27
32
  def create(template)
@@ -29,14 +34,18 @@ module Calatrava
29
34
  create_directory_tree(template)
30
35
  create_files(template)
31
36
 
32
- create_android_tree(template)
33
- create_ios_tree(template)
37
+ create_android_tree(template) if @platforms.include?('droid')
38
+ create_ios_tree(template) if Calatrava.platform == :mac && @platforms.include?('ios')
39
+
40
+ ['droid', 'ios', 'web'].each do |app|
41
+ FileUtils.rm_rf(File.join(@name, app)) unless @platforms.include?(app)
42
+ end
34
43
  end
35
44
 
36
45
  def create_project(template)
37
46
  FileUtils.mkdir_p @name
38
47
  File.open(File.join(@name, 'calatrava.yml'), "w+") do |f|
39
- f.print({:project_name => @name}.to_yaml)
48
+ f.print({project_name: @name, platforms: @platforms}.to_yaml)
40
49
  end
41
50
  end
42
51
 
@@ -70,7 +79,7 @@ module Calatrava
70
79
 
71
80
  def create_android_tree(template)
72
81
  Dir.chdir(File.join(@name, "droid")) do
73
- sh "android create project --name '#{@slug}' --path '#{@name}' --package com.#{@slug} --target android-10 --activity #{@title}"
82
+ sh "android create project --name '#{@slug}' --path '#{@name}' --package com.#{@slug} --target android-#{@options[:'android-api']} --activity #{@title}"
74
83
 
75
84
  Dir.walk("calatrava") do |item|
76
85
  target_item = item.sub('calatrava', @name)
@@ -5,6 +5,7 @@ end
5
5
  def coffee(in_dir_or_file, out_dir)
6
6
  if !Dir["#{in_dir_or_file}/**/*.coffee"].empty? || File.exists?(in_dir_or_file)
7
7
  $stdout.puts "coffee #{in_dir_or_file} -> #{out_dir}"
8
- sh "node_modules/coffee-script/bin/coffee --compile --output #{out_dir} #{in_dir_or_file}"
8
+ ok = system "node_modules/coffee-script/bin/coffee --compile --output #{out_dir} #{in_dir_or_file}"
9
+ fail "Error compiling CoffeeScript: '#{in_dir_or_file}'" if !ok
9
10
  end
10
11
  end
@@ -2,9 +2,8 @@ desc "Installs all required Ruby gems and Node.js packages for your new Calatrav
2
2
  task :bootstrap do
3
3
  sh "bundle install"
4
4
  sh "npm install"
5
- cd "ios" do
6
- sh "pod install"
7
- end
5
+ Rake::Task['ios:bootstrap'].invoke if Rake::Task.task_defined? 'ios:bootstrap'
6
+ Rake::Task['droid:bootstrap'].invoke if Rake::Task.task_defined? 'droid:bootstrap'
8
7
 
9
8
  Rake::Task['configure:development'].invoke
10
9
  end
@@ -0,0 +1,24 @@
1
+ require 'digest/sha1'
2
+
3
+ module Rake
4
+ module DSL
5
+
6
+ def transient(name, value)
7
+ transients = File.join('.rake', 'transients')
8
+ FileUtils.mkdir_p transients
9
+ value_file = File.join(transients, name.to_s)
10
+ value_hash = Digest::SHA1.hexdigest(value.to_s)
11
+ if File.exists? value_file
12
+ previous_hash = IO.read(value_file)
13
+ FileUtils.rm value_file if previous_hash != value_hash
14
+ end
15
+
16
+ file value_file do
17
+ File.open(value_file, "w+") { |f| f.print value_hash }
18
+ end
19
+ task name => value_file
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -5,13 +5,5 @@ Calatrava::Project.here('.')
5
5
 
6
6
  Dir["#{File.join(File.dirname(__FILE__), 'tasks')}/*.rb"].each { |t| require t }
7
7
 
8
- namespace(:kernel) { Calatrava::Project.current.kernel.install_tasks }
9
- namespace(:configure) { Calatrava::Project.current.config.install_tasks }
10
- namespace(:droid) { Calatrava::Project.current.droid.install_tasks }
11
- namespace(:ios) { Calatrava::Project.current.ios.install_tasks }
12
- namespace(:web) { Calatrava::Project.current.mobile_web.install_tasks }
8
+ Calatrava::Project.current.install_tasks
13
9
 
14
- desc "Clean all apps"
15
- task :clean => ['web:clean', 'ios:clean', 'droid:clean']
16
-
17
- task :build => ['web:build', 'ios:build', 'droid:build']
@@ -0,0 +1 @@
1
+ {{ project_slug }}
@@ -0,0 +1 @@
1
+ ruby-1.9.3
@@ -27,7 +27,7 @@ calatrava.bridge.runtime = (() ->
27
27
  options.url,
28
28
  options.method,
29
29
  options.body,
30
- options.headers)
30
+ JSON.stringify(options.headers))
31
31
 
32
32
  callPlugin: (plugin, method, args) ->
33
33
  pluginRegistry.call(plugin, method, JSON.stringify(args))
@@ -3,8 +3,9 @@
3
3
  package="com.{{ project_slug }}"
4
4
  android:versionCode="1"
5
5
  android:versionName="1.0">
6
- <application android:label="@string/app_name" >
7
- <activity android:name="com.{{ project_slug }}.{{ project_title }}"
6
+ <application android:label="@string/app_name"
7
+ android:name="{{ project_title }}">
8
+ <activity android:name=".Bootstrap"
8
9
  android:label="@string/app_name">
9
10
  <intent-filter>
10
11
  <action android:name="android.intent.action.MAIN" />
@@ -14,7 +15,5 @@
14
15
  <activity android:name=".ConversionForm"
15
16
  android:label="@string/app_name">
16
17
  </activity>
17
- <service android:enabled="true"
18
- android:name="com.calatrava.bridge.RhinoService"/>
19
18
  </application>
20
19
  </manifest>
@@ -50,10 +50,6 @@
50
50
  <!-- Load the calatrava additions -->
51
51
  <import file="ant/calatrava.xml" />
52
52
 
53
- <!-- Calatrava configuration -->
54
- <target name="-pre-build" depends="resolve">
55
- </target>
56
-
57
53
  <!-- extension targets. Uncomment the ones where you want to do custom work
58
54
  in between standard targets -->
59
55
  <!--
@@ -3,8 +3,12 @@
3
3
  <!-- here is the version of ivy we will use. change this property to try a newer
4
4
  version if you want -->
5
5
  <property name="ivy.install.version" value="2.3.0-rc1" />
6
- <property name="ivy.jar.dir" value="${basedir}/ivy" />
7
- <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
6
+
7
+ <!-- Paths to various ivy pieces. You probably don't need to change these -->
8
+ <property name="ivy.jar.dir" value="${basedir}/../ivy" />
9
+ <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
10
+ <property name="ivy.dep.file" value="${ivy.jar.dir}/ivy.xml" />
11
+ <property name="ivy.settings.file" value="${ivy.jar.dir}/ivysettings.xml" />
8
12
 
9
13
  <property name="build.dir" value="build" />
10
14
  <property name="src.dir" value="src" />
@@ -34,7 +38,7 @@
34
38
 
35
39
  <ivy:report />
36
40
 
37
- <ivy:retrieve pattern="libs/[artifact]-[revision](-[classifier]).[ext]" conf="${ivy.configurations}" />
41
+ <ivy:retrieve pattern="../libs/[artifact]-[revision](-[classifier]).[ext]" conf="${ivy.configurations}" />
38
42
  </target>
39
43
 
40
44
  <target name="clean-ivy" description="--> clean the ivy installation">
@@ -0,0 +1,21 @@
1
+ package com.{{ project_slug }};
2
+
3
+ import android.app.Activity;
4
+ import android.os.Bundle;
5
+
6
+ import com.calatrava.bridge.CalatravaApplication;
7
+
8
+ public class Bootstrap extends Activity
9
+ {
10
+ @Override
11
+ public void onCreate(Bundle savedInstanceState)
12
+ {
13
+ super.onCreate(savedInstanceState);
14
+ setContentView(R.layout.main);
15
+
16
+ ((CalatravaApplication)getApplication()).provideActivityContext(this);
17
+
18
+ // And then start your first feature
19
+ launchFlow("example.converter.start");
20
+ }
21
+ }
@@ -3,21 +3,14 @@ package com.{{ project_slug }};
3
3
  import android.app.Activity;
4
4
  import android.os.Bundle;
5
5
 
6
- import com.calatrava.bridge.Launcher;
6
+ import com.calatrava.bridge.CalatravaApplication;
7
7
 
8
- public class {{ project_title }} extends Activity
8
+ public class {{ project_title }} extends CalatravaApplication
9
9
  {
10
- /** Called when the activity is first created. */
11
- @Override
12
- public void onCreate(Bundle savedInstanceState)
13
- {
14
- super.onCreate(savedInstanceState);
15
- setContentView(R.layout.main);
16
-
17
- Launcher.launchKernel("com.{{ project_slug }}", this, getApplication(), new Runnable() {
18
- public void run() {
19
- Launcher.launchFlow("example.converter.start");
20
- }
21
- });
22
- }
10
+ @Override
11
+ public void onCreate()
12
+ {
13
+ // Call this to start Calatrava
14
+ bootCalatrava("com.{{ project_slug }}");
15
+ }
23
16
  }