-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
54 lines (42 loc) · 1.29 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
VENDINGMACHINE_ROOT = "vendingmachine"
MACHINEDIR='/home/pi/vendingmachine'
PI = ENV["PI"] || "pi@raspberrypi"
def remote_run(command)
sh "ssh #{PI} #{command}"
end
desc "start vendingmachine service"
task :start => :init_d do
remote_run "sudo /etc/init.d/vendingmachine restart"
end
desc "stop vendingmachine service on pi"
task :stop do
remote_run "sudo /etc/init.d/vendingmachine stop"
end
desc "vendingmachine service status on pi"
task :status do
remote_run "sudo /etc/init.d/vendingmachine status"
end
desc "run integration tests"
task :integration => :deploy do
remote_run "cd #{MACHINEDIR} && rake test"
end
task :init_d => :deploy do
#install init.d script
remote_run "sudo 'rsync -av --delete /home/pi/vendingmachine/init.d/vendingmachine /etc/init.d/vendingmachine && sudo chmod +x /etc/init.d/vendingmachine'"
#start on boot
remote_run "sudo update-rc.d vendingmachine defaults"
end
require 'rake/testtask'
desc 'run unit tests'
task :default => :test
Rake::TestTask.new(:test) do |t|
t.test_files = FileList['test/**/*test.rb', 'test/*test.rb']
end
desc "deploy to pi"
task :deploy => :test do
sh "rsync -avz --delete * #{PI}:#{VENDINGMACHINE_ROOT}/"
end
desc "render documentation"
task :doc do
sh "cd .. && pandoc --standalone -o doc/html/README.html -i README.md"
end