require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Test the Comatose.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for Comatose.' Rake::RDocTask.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'Comatose' rdoc.options << '--line-numbers' << '--inline-source' rdoc.rdoc_files.include('README') rdoc.rdoc_files.include('lib/**/*.rb') end desc "Builds the admin costumizable layout, the embedded layout have the JS and CSS inlined" task :build do require 'erb' # Javascript script_path = File.join('resources', 'public', 'javascripts', 'comatose_admin.js') script_contents = '' # Stylesheet style_path = File.join('resources', 'public', 'stylesheets', 'comatose_admin.css') style_contents = '' # Layout Template tmpl_path = File.join('resources', 'layouts', 'comatose_admin_template.rhtml') tmpl_contents = '' # Layout Target layout_path = File.join('views', 'layouts', 'comatose_admin.rhtml') layout_contents = '' # Customizable Target customizable_path = File.join('views', 'layouts', 'comatose_admin_customize.rhtml') # Read the file contents... File.open(script_path, 'r') {|f| script_contents = "" } File.open(style_path, 'r') {|f| style_contents = "" } File.open(tmpl_path, 'r') {|f| tmpl_contents = f.read } # Create the final layout... layout_contents = ERB.new( tmpl_contents ).result(binding) # Write it out... File.open(layout_path, 'w') {|f| f.write layout_contents } # Now let's create the customizable one... style_contents = "<%= stylesheet_link_tag 'comatose_admin' %>" script_contents = "<%= javascript_include_tag 'comatose_admin' %>" # Create the final layout... layout_contents = ERB.new( tmpl_contents ).result(binding) # Write it out... File.open(customizable_path, 'w') {|f| f.write layout_contents } # That's it -- we're done. puts "Finished." end