/
specification.rb
128 lines (100 loc) · 4 KB
/
specification.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
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
require 'rubygems'
require 'rubygems/specification'
require 'rake'
module Heel
# Add some additional items to Gem::Specification
# A Heel::Specification adds additional pieces of information the
# typical gem specification
class Specification
RUBYFORGE_ROOT = "/var/www/gforge-projects/"
# user that accesses remote site
attr_accessor :remote_user
# remote host, default 'rubyforge.org'
attr_accessor :remote_host
# name the rdoc main
attr_accessor :rdoc_main
# local directory in development holding the generated rdoc
# default 'doc'
attr_accessor :local_rdoc_dir
# remote directory for storing rdoc, default 'doc'
attr_accessor :remote_rdoc_dir
# local directory for coverage report
attr_accessor :local_coverage_dir
# remote directory for storing coverage reports
# This defaults to 'coverage'
attr_accessor :remote_coverage_dir
# local directory for generated website, default +site/public+
attr_accessor :local_site_dir
# remote directory relative to +remote_root+ for the website.
# website.
attr_accessor :remote_site_dir
# is a .tgz to be created?, default 'true'
attr_accessor :need_tar
# is a .zip to be created, default 'true'
attr_accessor :need_zip
def initialize
@remote_user = nil
@remote_host = "rubyforge.org"
@rdoc_main = "README"
@local_rdoc_dir = "doc"
@remote_rdoc_dir = "doc"
@local_coverage_dir = "coverage"
@remote_coverage_dir = "coverage"
@local_site_dir = "site/public"
@remote_site_dir = "."
@need_tar = true
@need_zip = true
@spec = Gem::Specification.new
yield self if block_given?
# update rdoc options to take care of the rdoc_main if it is
# there, and add a default title if one is not given
if not @spec.rdoc_options.include?("--main") then
@spec.rdoc_options.concat(["--main", rdoc_main])
end
if not @spec.rdoc_options.include?("--title") then
@spec.rdoc_options.concat(["--title","'#{name} -- #{summary}'"])
end
end
# if this gets set then it overwrites what would be the
# rubyforge default. If rubyforge project is not set then use
# name. If rubyforge project and name are set, but they are
# different then assume that name is a subproject of the
# rubyforge project
def remote_root
if rubyforge_project.nil? or
rubyforge_project == name then
return RUBYFORGE_ROOT + "#{name}/"
else
return RUBYFORGE_ROOT + "#{rubyforge_project}/#{name}/"
end
end
# rdoc files is the same as what would be generated during gem
# installation. That is, everything in the require paths plus
# the extra_rdoc_files
#
def rdoc_files
flist = extra_rdoc_files.dup
@spec.require_paths.each do |rp|
flist << FileList["#{rp}/**/*.rb"]
end
flist.flatten.uniq
end
# calculate the remote directories
def remote_root_location
"#{remote_user}@#{remote_host}:#{remote_root}"
end
def remote_rdoc_location
remote_root_location + @remote_rdoc_dir
end
def remote_coverage_location
remote_root_loation + @remote_coverage_dir
end
def remote_site_location
remote_root_location + @remote_site_dir
end
# we delegate any other calls to spec
def method_missing(method_id,*params,&block)
@spec.send method_id, *params, &block
end
end
end