Class: Calatrava::AppBuilder
- Inherits:
-
Object
- Object
- Calatrava::AppBuilder
- Includes:
- Rake::DSL
- Defined in:
- lib/calatrava/app_builder.rb
Instance Method Summary collapse
- #build_dir ⇒ Object
- #build_html_dir ⇒ Object
- #build_images_dir ⇒ Object
- #build_scripts_dir ⇒ Object
- #build_styles_dir ⇒ Object
- #builder_task ⇒ Object
- #coffee_files ⇒ Object
- #haml_files ⇒ Object
-
#initialize(output_dir, manifest) ⇒ AppBuilder
constructor
A new instance of AppBuilder.
- #js_file(cf) ⇒ Object
- #load_instructions ⇒ Object
Constructor Details
#initialize(output_dir, manifest) ⇒ AppBuilder
Returns a new instance of AppBuilder.
6 7 8 |
# File 'lib/calatrava/app_builder.rb', line 6 def initialize(output_dir, manifest) @output_dir, @manifest = output_dir, manifest end |
Instance Method Details
#build_dir ⇒ Object
10 |
# File 'lib/calatrava/app_builder.rb', line 10 def build_dir ; @output_dir ; end |
#build_html_dir ⇒ Object
11 |
# File 'lib/calatrava/app_builder.rb', line 11 def build_html_dir ; "#{build_dir}/views" ; end |
#build_images_dir ⇒ Object
13 |
# File 'lib/calatrava/app_builder.rb', line 13 def build_images_dir ; "#{build_dir}/images" ; end |
#build_scripts_dir ⇒ Object
12 |
# File 'lib/calatrava/app_builder.rb', line 12 def build_scripts_dir ; "#{build_dir}/scripts" ; end |
#build_styles_dir ⇒ Object
14 |
# File 'lib/calatrava/app_builder.rb', line 14 def build_styles_dir ; "#{build_dir}/styles" ; end |
#builder_task ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/calatrava/app_builder.rb', line 35 def builder_task directory build_html_dir directory build_images_dir directory build_scripts_dir app_files = haml_files.collect do |hf| file "#{build_html_dir}/#{File.basename(hf, '.haml')}.html" => [build_html_dir, hf] do HamlSupport::compile_hybrid_page hf, build_html_dir, :platform => 'ios' end end app_files += coffee_files.collect do |cf| file js_file(cf) => [build_scripts_dir, cf] do coffee cf, build_scripts_dir end end app_files += @manifest.css_tasks(build_styles_dir) app_files << file("#{build_dir}/load_file.txt" => build_dir) do |t| File.open(t.name, "w+") { |f| f.puts load_instructions } end task :shared => [build_images_dir, build_scripts_dir] do cp_ne "assets/images/*", build_images_dir cp_ne "assets/lib/*.js", build_scripts_dir cp_ne "ios/res/js/*.js", build_scripts_dir end task :app => [:shared] + app_files end |
#coffee_files ⇒ Object
16 17 18 |
# File 'lib/calatrava/app_builder.rb', line 16 def coffee_files @manifest.coffee_files + [Calatrava::Project.current.config.path('env.coffee')] end |
#haml_files ⇒ Object
31 32 33 |
# File 'lib/calatrava/app_builder.rb', line 31 def haml_files @manifest.haml_files end |
#js_file(cf) ⇒ Object
20 21 22 |
# File 'lib/calatrava/app_builder.rb', line 20 def js_file(cf) "#{build_scripts_dir}/#{File.basename(cf, '.coffee')}.js" end |
#load_instructions ⇒ Object
24 25 26 27 28 29 |
# File 'lib/calatrava/app_builder.rb', line 24 def load_instructions build_path = Pathname.new(File.dirname(build_dir)) @manifest.kernel_bootstrap.collect do |cf| Pathname.new(js_file(cf)).relative_path_from(build_path).to_s end.join($/) end |