-
Notifications
You must be signed in to change notification settings - Fork 10
/
Rakefile
56 lines (47 loc) · 1.43 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$:.unshift File.expand_path '../lib', __FILE__
require 'nutcracker/web'
require 'rake'
require 'rubygems/package_task'
require "rake/testtask"
desc "Compile assets"
task :compile do
require 'logger'
require 'pathname'
require 'sprockets'
require 'uglifier'
require 'eco'
rm_rf 'public'
mkdir_p 'public/assets'
build_dir = Pathname(File.dirname(__FILE__)).join("public/assets")
environment = Nutcracker::Web::App.assets
environment.logger = Logger.new STDOUT
environment.js_compressor = Uglifier.new(mangle: true)
%w( javascripts/application.js stylesheets/application.css ).each do |target|
target = File.expand_path("../assets/#{target}",__FILE__)
environment.logger.info "#{'#'*10} Building #{target} #{'#'*10} "
asset = environment[target] or abort "Unknown target #{target.inspect}"
prefix, basename = asset.pathname.to_s.split('/')[-2..-1]
asset.write_to build_dir.join(basename)
end
end
desc "Build new gem"
task :build => [:compile] do
Gem::PackageTask.new(eval File.read 'nutcracker-web.gemspec') do |pkg|
pkg.need_zip = false
pkg.need_tar = false
end
Rake::Task["gem"].invoke
end
task :gem do
abort "Please use rake build instead"
end
task :install => [:build] do
sh "gem install pkg/nutcracker-web"
Rake::Task['clobber_package'].execute
end
## Tests stuff
task :default => :test
Rake::TestTask.new(:test) do |t|
t.libs << "tests"
t.pattern = "tests/**/*_test.rb"
end