-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
62 lines (50 loc) · 1.85 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
57
58
59
60
61
62
#!/usr/bin/env rake
# coding: utf-8
require 'sprockets'
require 'rake/sprocketstask'
require './src/helper'
# This deals with the javascript and css
Rake::SprocketsTask.new do |t|
environment = Sprockets::Environment.new
environment.append_path 'src/javascripts'
environment.append_path 'src/stylesheets'
environment.append_path 'contrib/js'
environment.append_path 'contrib/css'
environment.append_path 'contrib/img'
environment.context_class.class_eval do
include Helper
end
t.environment = environment
t.output = "./public/assets"
t.assets = %w( application.js application.css )
end
require 'haml'
require 'json'
require 'decc_2050_model'
require_relative 'src/helper'
manifest = './public/assets/manifest.json'
file manifest => ['assets']
desc "Compiles changes to src/*.haml into public/ and adds links it to the latest versions of application.cs and application.js, then sets so that the pow server will operate in production mode"
task 'production' => [manifest] do
class Context
include Helper
end
context = Context.new
# We need to figure out the filename of the latest javascript and css
context.assets = JSON.parse(IO.readlines(manifest).join)['assets']
haml_files = Dir.glob("./src/**/*.haml")
haml_files.each do |name|
p "Compiling #{name}"
input = IO.readlines(name).join
File.open("./public/"+name[/\.\/src\/(.*)\.haml/,1],'w') do |f|
f.puts Haml::Engine.new(input).render(context)
end
end
File.open('./.powenv','w') { |f| f.puts "export RAILS_ENV=production" }
end
desc "Cleans out the html from the public folder and sets so that a pow server will operate in development mode"
task 'development' do
File.delete(*Dir.glob("./public/*.html"))
File.delete(*Dir.glob("./public/questions/*.html"))
File.open('./.powenv','w') { |f| f.puts "export RAILS_ENV=development" }
end