-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile.rb
88 lines (77 loc) · 2.73 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
require 'rdoc'
verbose(true)
rule(/_(dlg|widget)\.rb\Z/ => proc{|f| f.sub(/\.rb\Z/,'.ui')}) do |t|
cmd = "rbuic4 -o #{t.name} #{t.source}"
sh cmd
end
UI_FILES = Dir.glob('**/*.ui').map{|f| f.sub(/\.ui\Z/, '.rb')}
RB_FILES = Dir.glob('**/*.rb')-UI_FILES
# This is needed because rbuic4 produces KEditListBox::Remove instead of
# KDE::EditListBox::Remove. So we have to correct it by hand
file 'plugins/custom_actions/ui/config_widget.rb' => 'plugins/custom_actions/ui/config_widget.ui' do |f|
cmd = "rbuic4 -o #{f.name} #{f.prerequisites[0]}"
sh cmd
contents = File.read f.name
contents.sub! 'KEditListBox', 'KDE::EditListBox'
File.open(f.name, 'w'){|of| of.write contents}
end
desc 'Creates all the files needed to run Ruber'
file :ruber => UI_FILES
task :default => :ruber
require 'rdoc/task'
Rake::RDocTask.new do |t|
output_dir= File.expand_path(ENV['OUTPUT_DIR']) rescue 'rdoc'
t.rdoc_dir = output_dir
t.rdoc_files.include( 'lib/ruber/**/*.rb', 'plugins/**/*.rb', 'TODO', 'INSTALL', 'LICENSE')
t.options << '-a' << '-S' << '-w' << '2' << '-x' << 'lib/ruber/ui' << '-x' << 'plugins/.*/ui'
t.title = "Ruber"
rdoc_warning = <<-EOS
WARNING: the documentation for this project is written for YARD (http://www.yardoc.org)
If you use rdoc, you'll obtain documentation which is incomplete and hard to read.
If possible, consider installing and using YARD instead
EOS
t.before_running_rdoc {puts rdoc_warning}
end
desc 'Removes documentation and intermediate files'
task :clean do
sh "rm -f #{UI_FILES.join(' ')}"
rm_rf 'doc'
rm_rf 'rdoc'
end
begin
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new do |t|
t.fail_on_error = false
end
rescue LoadError
require 'rspec/rake/spectask'
rspec_rake_task_cls.new do |t|
t.fail_on_error = false
t.libs << 'lib'
t.spec_opts += %w[-L m -R]
end
end
rescue LoadError
end
begin
require 'yard'
desc 'generates the documentation using YARD'
cache = ENV['YARD_NO_CACHE'] ? '' : '-c'
YARD::Rake::YardocTask.new(:doc) do |t|
output_dir= File.expand_path(ENV['OUTPUT_DIR']) rescue 'doc'
t.files = ['lib/**/*.rb', 'lib/ruber/**/*.rb', 'plugins/**/*.rb', '-', 'TODO', 'manual/**/*', 'INSTALL', 'CHANGES', 'LICENSE']
t.options = ['-r', 'doc/_index.html', cache, '--protected', '--private', '--backtrace', '-e', './yard/extensions.rb', '--title', 'Ruber API', '--private', '-o', output_dir, '-m', 'textile', '--exclude', '/ui/[\w\d]+\.rb$']
end
rescue LoadError
end
desc 'Builds the ruber gem'
task :gem => [:ruber] do
require 'rubygems'
spec = Gem::Specification.load 'ruber.gemspec'
begin require 'rubygems/package'
rescue LoadError
Gem::Builder.new(spec).build
end
Gem::Package.build(spec)
end