rtomayko / wink

NO LONGER MAINTAINED

This URL has Read+Write access

wink / Rakefile
100644 139 lines (103 sloc) 2.998 kb
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
require 'rake/clean'
 
task :default => :test
 
desc 'Run tests'
task :test do
  sh "testrb test/*_test.rb"
end
 
desc 'Run specs'
task :spec do
  sh "specrb -s test/*_test.rb"
end
 
desc 'Start a development server'
task :start do
  command = "ruby wink -e #{wink_environment}"
  STDERR.puts(command) if verbose
  exec(command)
end
 
 
# Environment Configuration ==================================================
 
def wink_environment
  if ENV['WINK_ENV']
    ENV['WINK_ENV'].to_sym
  elsif defined?(Sinatra)
    Sinatra.application.options.env
  else
    :development
  end
end
 
task :environment do
  $:.unshift 'sinatra/lib' if File.exist?('sinatra')
  $:.unshift 'lib'
  $:.unshift '.'
  require 'wink'
  Wink.configure 'wink.conf' do
    set :env, wink_environment
  end
end
 
 
# Database Related Tasks ====================================================
 
namespace :db do
 
  desc 'Create all database tables'
  task :init => [ :environment ] do
    Database.create! :welcome => true
  end
 
  desc 'Drop all database tables'
  task :drop => [ :environment ] do
    Database.drop!
  end
 
  task :reset => [ :drop, :init ]
 
end
 
 
# Documentation Tasks ========================================================
 
desc 'Generate documentation and website (doc/)'
task 'doc' => [ 'doc:todo', 'doc:api' ]
 
desc 'Generate Ditz HTML reports (doc/todo)'
task 'doc:todo' => ['doc/todo/index.html']
 
directory 'doc/todo'
 
file 'doc/todo/index.html' => ['doc/todo'] + FileList['bugs/*'] do |f|
  sh 'rm -rf doc/todo && ditz html doc/todo'
end
 
CLEAN.include 'doc/todo'
 
desc 'Generate API documentation'
task 'doc:api' => 'doc/api/index.html'
 
file 'doc/api/index.html' => FileList['lib/**/*.rb','README'] do |f|
  sh((<<-end).gsub(/\s+/, ' '))
hanna --charset utf8 \
--fmt html \
--inline-source \
--line-numbers \
--main Wink \
--op doc/api \
--title 'Wink API Documentation' \
#{f.prerequisites.join(' ')}
end
end
 
CLEAN.include 'doc/api'
 
 
# Release Management/Maintenance Tasks =========================================
 
namespace 'release' do
 
  desc 'Update the ChangeLog with the current release'
  task :log => [ :environment ] do
    sh((<<-end).gsub(/^\s+/, ''))
ditz changelog #{Wink::VERSION} > ChangeLog.new &&
echo >> ChangeLog.new &&
cat ChangeLog >> ChangeLog.new &&
mv ChangeLog.new ChangeLog
end
  end
 
  desc 'Publish docs to Rubyforge'
  task :docs => [ :doc ] do |t|
    sh 'scp -rp doc/* rubyforge.org:/var/www/gforge-projects/wink/'
  end
 
end
 
# Git Submodule Tasks =========================================================
 
namespace 'submodule' do
  desc 'Init the sinatra submodule'
  task :init do |t|
    unless File.exist? 'sinatra/lib/sinatra.rb'
      rm_rf 'sinatra'
      sh 'git submodule init sinatra'
    end
  end
 
  desc 'Update the sinatra submodule'
  task :update => :init do
    sh 'git submodule update sinatra'
  end
end
 
task :submodule => 'submodule:update'