Class: Calatrava::MobileWebApp
- Inherits:
-
Object
- Object
- Calatrava::MobileWebApp
- Includes:
- Rake::DSL
- Defined in:
- lib/calatrava/mobile_web_app.rb
Instance Method Summary collapse
- #build_dir ⇒ Object
- #coffee_files ⇒ Object
- #haml_files ⇒ Object
-
#initialize(path, manifest) ⇒ MobileWebApp
constructor
A new instance of MobileWebApp.
- #install_tasks ⇒ Object
- #scripts ⇒ Object
- #scripts_build_dir ⇒ Object
- #styles_build_dir ⇒ Object
Constructor Details
#initialize(path, manifest) ⇒ MobileWebApp
Returns a new instance of MobileWebApp.
6 7 8 9 |
# File 'lib/calatrava/mobile_web_app.rb', line 6 def initialize(path, manifest) @path, @manifest = path, manifest @apache = Apache.new end |
Instance Method Details
#build_dir ⇒ Object
11 |
# File 'lib/calatrava/mobile_web_app.rb', line 11 def build_dir ; "#{@path}/web/public" ; end |
#coffee_files ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/calatrava/mobile_web_app.rb', line 15 def coffee_files Dir.chdir @path do core_coffee = ['bridge', 'init'].collect { |l| "web/app/source/#{l}.coffee" } core_coffee += @manifest.coffee_files.select { |cf| cf =~ /calatrava.coffee$/ } web_coffee = Dir['web/app/source/*.coffee'] - core_coffee mf_coffee = @manifest.coffee_files.reject { |cf| cf =~ /calatrava.coffee$/ } core_coffee + web_coffee + [Calatrava::Project.current.config.path('env.coffee')] + mf_coffee end end |
#haml_files ⇒ Object
25 26 27 |
# File 'lib/calatrava/mobile_web_app.rb', line 25 def haml_files Dir.chdir(@path) { @manifest.haml_files } end |
#install_tasks ⇒ Object
33 34 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 65 66 67 68 69 70 71 |
# File 'lib/calatrava/mobile_web_app.rb', line 33 def install_tasks directory build_dir directory scripts_build_dir app_files = coffee_files.collect do |cf| file "#{scripts_build_dir}/#{File.basename(cf, '.coffee')}.js" => [scripts_build_dir, cf] do coffee cf, scripts_build_dir end end app_files << file("#{build_dir}/index.html" => ["web/app/views/index.haml"] + haml_files) do HamlSupport::compile "web/app/views/index.haml", build_dir end app_files += @manifest.css_tasks(styles_build_dir) task :shared do cp_ne "assets/images/*", File.join(build_dir, 'images') cp_ne "assets/lib/*.js", scripts_build_dir end desc "Build the web app" task :build => app_files + [:shared] desc "Publishes the built web app as an artifact" task :publish => :build do artifact_dir(build_dir, 'web/public') end desc "Clean web app" task :clean => 'apache:clean' do rm_rf build_dir end namespace :apache do @apache.install_tasks end end |
#scripts ⇒ Object
29 30 31 |
# File 'lib/calatrava/mobile_web_app.rb', line 29 def scripts coffee_files.collect { |cf| "scripts/#{File.basename(cf, '.coffee')}.js" } end |
#scripts_build_dir ⇒ Object
12 |
# File 'lib/calatrava/mobile_web_app.rb', line 12 def scripts_build_dir ; "#{build_dir}/scripts" ; end |
#styles_build_dir ⇒ Object
13 |
# File 'lib/calatrava/mobile_web_app.rb', line 13 def styles_build_dir ; "#{build_dir}/styles" ; end |