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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
|
# -*- ruby -*-
#
# $Id$
#
# webgen: template based static website generator
# Copyright (C) 2004 Thomas Leitner
#
# This program is free software; you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program; if not,
# write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
begin
require 'rubygems'
require 'rake/gempackagetask'
rescue Exception
end
require 'rake/clean'
require 'rake/packagetask'
require 'rake/rdoctask'
require 'rake/testtask'
# General actions ##############################################################
$:.push 'lib'
require 'webgen/plugins/coreplugins/configuration'
PKG_NAME = "webgen"
PKG_VERSION = Webgen::VERSION.join( '.' )
PKG_FULLNAME = PKG_NAME + "-" + PKG_VERSION
PKG_SUMMARY = Webgen::SUMMARY
PKG_DESCRIPTION = Webgen::DESCRIPTION
SRC_RB = FileList['lib/**/*.rb']
# The default task is run if rake is given no explicit arguments.
desc "Default Task"
task :default => :test
# End user tasks ################################################################
desc "Prepares for installation"
task :prepare do
ruby "setup.rb config"
ruby "setup.rb setup"
end
desc "Installs the package #{PKG_NAME}"
task :install => [:prepare] do
ruby "setup.rb install"
end
task :clean do
ruby "setup.rb clean"
end
CLOBBER << "doc/output"
desc "Builds the documentation"
task :doc => [:rdoc] do
chdir 'doc' do
puts "\nGenerating online documentation..."
ruby %{-I../lib ../bin/webgen -V 2 }
end
end
rd = Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'doc/output/rdoc'
rdoc.title = PKG_NAME
rdoc.options << '--line-numbers' << '--inline-source' << '-m README'
rdoc.rdoc_files.include( 'README' )
rdoc.rdoc_files.include( 'lib/**/*.rb' )
end
CLOBBER << "test/webgen.log"
task :test do |t|
chdir 'test' do
ruby "-I../lib -I. runtests.rb"
end
end
# Developer tasks ##############################################################
PKG_FILES = FileList.new( [
'setup.rb',
'TODO',
'COPYING',
'README',
'Rakefile',
'ChangeLog',
'VERSION',
'install.rb',
'bin/**/*',
'lib/**/*.rb',
'data/**/*',
'testsite/**/*',
'tests/**/*',
'doc/**/*'
]) do |fl|
fl.exclude( /\bsvn\b/ )
fl.exclude( 'testsite/output' )
fl.exclude( 'testsite/coverage' )
fl.exclude( 'doc/output' )
end
task :package => [:gen_files, :create_gal_layout_pics] do
chdir 'pkg' do
sh "rpaadmin packport #{PKG_NAME}-#{PKG_VERSION}"
end
end
CLOBBER << "otherdata/web-for-gallery-pics/output"
task :create_gal_layout_pics do
chdir 'otherdata/web-for-gallery-pics' do
ruby "-I../../lib create_pictures.rb"
end
end
task :gen_changelog do
sh "svn log -r HEAD:1 -v > ChangeLog"
end
task :gen_version do
puts "Generating VERSION file"
File.open( 'VERSION', 'w+' ) do |file| file.write( PKG_VERSION + "\n" ) end
end
task :gen_installrb do
puts "Generating install.rb file"
File.open( 'install.rb', 'w+' ) do |file|
file.write "
require 'rpa/install'
class Install_#{PKG_NAME} < RPA::Install::FullInstaller
name '#{PKG_NAME}'
version '#{PKG_VERSION}-1'
classification Application
build do
installdocs %w[COPYING ChangeLog TODO]
installdocs 'docs'
installrdoc %w[README] + Dir['lib/**/*.rb']
installdata
end
description <<-EOF
#{PKG_SUMMARY}
#{PKG_DESCRIPTION}
EOF
end
"
end
end
task :gen_files => [:gen_changelog, :gen_version, :gen_installrb]
CLOBBER << "ChangeLog" << "VERSION" << "install.rb"
Rake::PackageTask.new( PKG_NAME, PKG_VERSION ) do |p|
p.need_tar = true
p.need_zip = true
p.package_files = PKG_FILES
end
if !defined? Gem
puts "Package Target requires RubyGEMs"
else
spec = Gem::Specification.new do |s|
#### Basic information
s.name = PKG_NAME
s.version = PKG_VERSION
s.summary = PKG_SUMMARY
s.description = PKG_DESCRIPTION
#### Dependencies, requirements and files
s.files = PKG_FILES.to_a
s.add_dependency( 'cmdparse', '~> 2.0.0' )
s.require_path = 'lib'
s.autorequire = nil
s.executables = ['webgen']
s.default_executable = 'webgen'
#### Documentation
s.has_rdoc = true
s.extra_rdoc_files = rd.rdoc_files.reject do |fn| fn =~ /\.rb$/ end.to_a
s.rdoc_options = ['--line-numbers', '-m', 'README']
#### Author and project details
s.author = "Thomas Leitner"
s.email = "t_leitner@gmx.at"
s.homepage = "http://webgen.rubyforge.org"
s.rubyforge_project = "webgen"
end
Rake::GemPackageTask.new( spec ) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end
end
=begin
desc "Creates a tag in the repository"
task :tag do
repositoryPath = File.dirname( $1 ) if `svn info` =~ /^URL: (.*)$/
fail "Tag already created in repository " if /#{PKG_NAME}/ =~ `svn ls #{repositoryPath}/versions`
sh "svn cp -m 'Created version #{PKG_NAME}' #{repositoryPath}/trunk #{repositoryPath}/versions/#{PKG_NAME}"
end
=end
desc "Upload documentation to homepage"
task :uploaddoc => [:doc] do
Dir.chdir('doc/output')
sh "scp -r * gettalong@rubyforge.org:/var/www/gforge-projects/#{PKG_NAME}/"
end
# Misc tasks ###################################################################
def count_lines( filename )
lines = 0
codelines = 0
open( filename ) do |f|
f.each do |line|
lines += 1
next if line =~ /^\s*$/
next if line =~ /^\s*#/
codelines += 1
end
end
[lines, codelines]
end
def show_line( msg, lines, loc )
printf "%6s %6s %s\n", lines.to_s, loc.to_s, msg
end
desc "Show statistics"
task :statistics do
total_lines = 0
total_code = 0
show_line( "File Name", "Lines", "LOC" )
SRC_RB.each do |fn|
lines, codelines = count_lines fn
show_line( fn, lines, codelines )
total_lines += lines
total_code += codelines
end
show_line( "Total", total_lines, total_code )
end
|