#!/usr/bin/env rake begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end begin require 'rdoc/task' rescue LoadError require 'rdoc/rdoc' require 'rake/rdoctask' RDoc::Task = Rake::RDocTask end RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'RedhatAccess' rdoc.options << '--line-numbers' rdoc.rdoc_files.include('README.rdoc') rdoc.rdoc_files.include('lib/**/*.rb') end APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) load 'rails/tasks/engine.rake' Bundler::GemHelper.install_tasks require 'rake/testtask' #----Temp lifted from https://github.com/ejholmes/sprockets-gem-paths ....# def self.rubygems_latest_specs # If newer Rubygems if ::Gem::Specification.respond_to? :latest_specs ::Gem::Specification.latest_specs else ::Gem.source_index.latest_specs end end def append_gem_paths env try_paths = [ %w{ assets }, %w{ app }, %w{ app assets }, %w{ vendor }, %w{ vendor assets }, %w{ lib }, %w{ lib assets } ].inject([]) do |sum, v| sum + [ File.join(v, 'javascripts'), File.join(v, 'stylesheets'), File.join(v, 'images'), File.join(v, 'fonts') ] end (rubygems_latest_specs.map(&:full_gem_path)).each do |root_path| try_paths.map {|p| File.join(root_path, p) }. select {|p| File.directory?(p) }. each {|path| env.append_path(path) } end end #-----end lift Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.libs << 'test' t.pattern = 'test/**/*_test.rb' t.verbose = false end desc 'Compile stand alone engine assets' task 'a:c' do #Alias for commandline execution Rake::Task['assets:precompile:engine'].invoke end task 'assets:precompile:engine' do require 'sprockets' require 'sprockets/railtie' require 'uglifier' require 'sass/rails/compressor' require 'angular-rails-templates' Sprockets::Engines #force autoloading Sprockets.register_engine '.html', AngularRailsTemplates::Template precompile = [ 'redhat_access/application.js', 'redhat_access/application.css', 'proactive_support/application.js', 'insights/application.js', 'insights/application.css' ] env = Sprockets::Environment.new(RedhatAccess::Engine.root) env.js_compressor = Uglifier.new(:mangle=>false) env.css_compressor = Sass::Rails::CssCompressor.new paths = [ 'app/assets/stylesheets', 'app/assets/javascripts', 'vendor/assets/javascripts', 'vendor/assets/stylesheets' ] paths.each do |path| env.append_path(path) end append_gem_paths(env) target = File.join(RedhatAccess::Engine.root, 'public', 'assets') rm_rf target compiler = Sprockets::StaticCompiler.new(env, target, precompile, :manifest_path => File.join(target), :digest => true, :manifest => true) puts 'Compiling assets' compiler.compile end # task 'build' do # Rake::Task['assets:precompile:engine'].invoke # gem build 'redhat_access.gemspec' # end task :default => :test