# File lib/bones/plugins/ann.rb, line 92
92: def define_tasks
93: config = ::Bones.config
94: namespace :ann do
95:
96: # A prerequisites task that all other tasks depend upon
97: task :prereqs
98:
99: file config.ann.file do
100: ann = config.ann
101: puts "Generating #{ann.file}"
102: File.open(ann.file,'w') do |fd|
103: fd.puts("#{config.name} version #{config.version}")
104: fd.puts(" by #{Array(config.authors).first}") if config.authors
105: fd.puts(" #{config.url}") if config.url.valid?
106: fd.puts(" (the \"#{config.release_name}\" release)") if config.release_name
107: fd.puts
108: fd.puts("== DESCRIPTION")
109: fd.puts
110: fd.puts(config.description)
111: fd.puts
112: fd.puts(config.changes.sub(/^.*$/, '== CHANGES'))
113: fd.puts
114: ann.paragraphs.each do |p|
115: fd.puts "== #{p.upcase}"
116: fd.puts
117: fd.puts paragraphs_of(config.readme_file, p).join("\n\n")
118: fd.puts
119: end
120: fd.puts ann.text if ann.text
121: end
122: end
123:
124: desc "Create an announcement file"
125: task :announcement => ['ann:prereqs', config.ann.file]
126:
127: desc "Send an email announcement"
128: task :email => ['ann:prereqs', config.ann.file] do
129: ann = config.ann
130: email = config.ann.email
131:
132: from = email.from
133: to = Array(email.to)
134:
135: ### build a mail header for RFC 822
136: rfc822msg = "From: #{from}\n"
137: rfc822msg << "To: #{to.join(',')}\n"
138: rfc822msg << "Subject: [ANN] #{config.name} #{config.version}"
139: rfc822msg << " (#{config.release_name})" if config.release_name
140: rfc822msg << "\n"
141: rfc822msg << "Date: #{Time.new.rfc822}\n"
142: rfc822msg << "Message-Id: "
143: rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{email.domain}>\n\n"
144: rfc822msg << File.read(ann.file)
145:
146: params = [:server, :port, :domain, :username, :password, :authtype].map { |key| email[key] }
147:
148: if params[4].nil?
149: STDOUT.write "Please enter your e-mail password (#{params[3]}): "
150: params[4] = STDIN.gets.chomp
151: end
152:
153: ### send email
154: Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
155: end
156: end # namespace :ann
157:
158: desc 'Alias to ann:announcement'
159: task :ann => 'ann:announcement'
160:
161: CLOBBER << config.ann.file
162: end
# File lib/bones/plugins/ann.rb, line 18
18: def initialize_ann
19: ::Bones.config {
20: desc 'Configuration for creating and mailing an announcement message.'
21: ann {
22: file 'announcement.txt', :desc => When announcing a release of your project the announcement text will be written to this file.
23:
24: text nil, :desc => 'Extra text to be appended to the announcement.'
25:
26: paragraphs Array.new, :desc => Array of paragraphs from the README file to include in the announcement. The paragraphs are identified by their heading name in the README, but when listed here they can be given as lowercase or uppercase.
27:
28: desc Configuration for e-mailing the announcement. A convenience method is provided for configuring Mr Bones to use gmail for sending project announcements. The project's e-mail address isused by default if a gmail username is not supplied. | | use_gmail | use_gmail 'username' | Use the latter form of the method is your gmail username is different then the project's e-mail address.
29: email {
30: from nil, :desc => The name to show on the 'from' line of the annoucement e-mail. This will default to the author name or the project e-mail if an author is not specified.
31:
32: to %(ruby-talk@ruby-lang.org), :desc => 'An array of e-mail recipients.'
33:
34: server 'localhost', :desc => 'The server used to send the announcement e-mail.'
35:
36: port 25, :desc => 'The server port number to connect to.'
37:
38: domain ENV['HOSTNAME'], :desc => The originating domain of the e-mail. This safely deafaults to the local hostname.
39:
40: username nil, :desc => 'The e-mail account name used to log into the e-mail server.'
41:
42: password nil, :desc => 'The e-mail password used to log into the e-mail server.'
43:
44: authtype :plain, :desc => The authentication type used by the e-mail server. This should be one of :plain, :login, or :cram_md5. See the documentation on the Net::SMTP class for more information.
45: }
46: }
47: }
48:
49: have?(:ann) { true }
50: end
# File lib/bones/plugins/ann.rb, line 83
83: def post_load
84: config = ::Bones.config
85:
86: config.exclude << "^#{Regexp.escape(config.ann.file)}$"
87: config.ann.email.from ||= Array(config.authors).first || config.email
88: config.ann.email.username ||= config.email
89: config.ann.email.domain ||= 'localhost'
90: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.