forked from olliemuh/nbdn_store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rakefile.rb
91 lines (71 loc) · 2.65 KB
/
rakefile.rb
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
require 'rake'
require 'rake/clean'
require 'fileutils'
['build/tools/Rake','build'].each do|pattern|
Dir.glob(File.join(File.dirname(__FILE__),pattern,"*.rb")).each do|item|
puts item
require item
end
end
#load settings that differ by machine
local_settings = LocalSettings.new
COMPILE_TARGET = 'debug'
CLEAN.include(File.join('artifacts',"*.*"),'**/*.sql')
def create_sql_fileset(folder)
FileList.new(File.join('product','sql',folder,'**/*.sql'))
end
template_files = TemplateFileList.new('**/*.template')
template_code_dir = File.join('product','templated_code')
#configuration files
config_files = FileList.new(File.join('product','config','*.template')).select{|fn| ! fn.include?('app.config')}
app_config = TemplateFile.new(File.join('product','config',local_settings[:app_config_template]))
#target folders that can be run from VS
solution_file = "solution#{local_settings[:use_vs2010] ? ".vs2010":""}.sln"
task :default => ["specs:run"]
task :init => :clean do
cp_r "thirdparty/machine.specifications/.","artifacts"
[Project.specs_dir,Project.report_folder].each{|folder| mkdir folder if ! File.exists?(folder)}
end
desc 'expands all of the template files in the project'
task :expand_all_template_files do
template_files.generate_all_output_files(local_settings.settings)
end
desc 'builds the database'
task :build_db => :expand_all_template_files do
sql_runner.process_sql_files(create_sql_fileset('ddl'))
end
desc 'load the database'
task :load_data => :build_db do
sql_runner.process_sql_files(create_sql_fileset('data'))
end
desc 'compiles the project'
task :compile => :expand_all_template_files do
MSBuildRunner.compile :compile_target => COMPILE_TARGET, :solution_file => solution_file
end
task :from_ide do
app_config.generate_to(File.join(Project.startup_dir,"#{Project.startup_config}"),local_settings.settings)
Project.spec_assemblies.each do |assembly|
app_config.generate_to(File.join('artifacts',"#{File.basename(assembly)}.config"),local_settings.settings)
end
config_files.each do |file|
TemplateFile.new(file).generate_to_directories([Project.startup_dir,'artifacts'],local_settings.settings)
end
end
namespace :specs do
desc 'view the spec report'
task :view do
puts Project.report_folder
system "start #{Project.report_folder}/#{Project.name}.specs.html"
end
desc 'run the specs for the project'
task :run => [:init,:compile] do
sh "artifacts/mspec.exe", "--html", "#{Project.report_folder}/#{Project.name}.specs.html", "-x", "example", *([] + Project.spec_assemblies)
end
end
desc "open the solution"
task :sln do
path = "devenv #{solution_file}"
Thread.new do
system path
end
end