-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rakefile.local
63 lines (48 loc) · 1.54 KB
/
Rakefile.local
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
#!rake
#
# Project-local tasks for Ruby-WordNet
# $Id$
#
# Authors:
# * Michael Granger <[email protected]>
#
unless defined?( BASEDIR )
fail "This is meant to be loaded from the main Rakefile, not run directly."
end
require 'wordnet'
require 'rake'
CONVERT_UTIL = BASEDIR + 'convertdb.rb'
DATA_BUILD_DIR = BASEDIR + File.basename( WordNet::Lexicon::DEFAULT_DB_ENV )
DATA_DATABASE_FILE = DATA_BUILD_DIR + 'data'
### Tasks
# Add 'convert' to the default task, and the testing tasks
task :local => :convert
task :spec => :convert
### Task: convert
desc "Convert WordNet dict files to a database"
task :convert => DATA_DATABASE_FILE
# Conversion utility
file CONVERT_UTIL.to_s
# Build directory for the database files
directory DATA_BUILD_DIR.to_s
CLOBBER.include( DATA_BUILD_DIR.to_s )
# BerkeleyDB main database file
file DATA_DATABASE_FILE.to_s
task DATA_DATABASE_FILE.to_s => CONVERT_UTIL do
load CONVERT_UTIL
WordNetConverter.new( DATA_BUILD_DIR ).convertdb
end
task :install => DATA_DATABASE_FILE do
datadir = Pathname.new( CONFIG['datadir'] )
log "Installing converted WordNet files in #{CONFIG['datadir']}"
datafiles = Pathname.glob( DATA_BUILD_DIR + '**/*' ).select {|pn| pn.file? }
datafiles.each do |file|
trace " installing #{file}"
relpath = file.expand_path.relative_path_from( Pathname.pwd )
target = datadir + relpath
FileUtils.mkpath target.dirname,
:mode => 0755, :verbose => true, :noop => $dryrun unless target.dirname.directory?
FileUtils.install relpath, target,
:mode => 0644, :verbose => true, :noop => $dryrun
end
end