https://svn.lrde.epita.fr/svn/lrdetools/trunk
Index: ChangeLog
from Nicolas Pouillard <ertai(a)lrde.epita.fr>
Some renaming.
* vcs/lib/vcs/form.rb: Rename instanciate_form to mk_iform.
Handles better dots in title, subject and ChangeLog entry.
* vcs/lib/vcs/common_commit.rb: Rename message to mk_message.
* vcs/lib/vcs/mail.rb: More class variables.
* vcs/lib/vcs/news.rb: Prevent for warnings on double loading.
common_commit.rb | 2 +-
form.rb | 10 +++++-----
mail.rb | 21 ++++++++++-----------
news.rb | 2 +-
4 files changed, 17 insertions(+), 18 deletions(-)
Index: vcs/lib/vcs/mail.rb
--- vcs/lib/vcs/mail.rb (revision 258)
+++ vcs/lib/vcs/mail.rb (working copy)
@@ -8,16 +8,16 @@
class Vcs
- MAIL = Sendmail::MAIL_FILE
- MAILER = Sendmail.new
- DEFAULT_OPTIONS = { :confirm => true, :mime => true,
+ MAIL = Sendmail::MAIL_FILE unless defined? MAIL
+ @@mailer ||= Sendmail.new
+ @@default_options ||= { :confirm => true, :mime => true,
:header => "X-Mailer: Vcs.mail (#{Vcs.version})" }
#
# Mail.
#
# FIXME handle options properly.
- # Delegata the option parsing to Sendmail.
+ # Delegate the option parsing to Sendmail.
def mail! ( files=[], options={} )
# Backward compatiblity
@@ -25,19 +25,18 @@
error_handling :mail_failed
unless MAIL.exist?
- options = DEFAULT_OPTIONS.merge(options)
+ options = @@default_options.merge(options)
options[:signed] = Vcs.user_conf.sign
- print_body(MAIL, MAILER.parse_mail_options(options), files)
+ print_body(MAIL, @@mailer.parse_mail_options(options), files)
end
- MAILER.sendmail
- MAIL.delete
+ @@mailer.sendmail
puts 'Mail: Sent.'
end
def mail_failed
- if defined? MAIL and MAIL.exist?
- logger.info "#{MAIL}: Contains the generated mail " +
- "(generated from #{Message})"
+ if defined? @@mail and @@mail.exist?
+ logger.info { "#{MAIL}: Contains the generated mail" }
+ logger.info { " AND information to send it (smtpserver, port...)"
}
end
end
Index: vcs/lib/vcs/news.rb
--- vcs/lib/vcs/news.rb (revision 258)
+++ vcs/lib/vcs/news.rb (working copy)
@@ -9,7 +9,7 @@
class Vcs
- NEWS = Pathname.new(',news')
+ NEWS = ',news'.to_path unless defined? NEWS
def parse_news_options ( *args )
require 'optparse'
Index: vcs/lib/vcs/form.rb
--- vcs/lib/vcs/form.rb (revision 258)
+++ vcs/lib/vcs/form.rb (working copy)
@@ -11,13 +11,13 @@
if Form.read =~ /\A---/
raise Failure, "You must fill this file: `#{Form}' (and remove the first
line)"
else
- instanciate_form(*args)
+ mk_iform(*args)
return YAML.load(IForm.read)['commited']
end
end
- def instanciate_form! ( *args )
+ def mk_iform! ( *args )
with_cache! IForm, 'instanciated form (title, subject, ChangeLog entry,
diff)' do
cl = mk_form(*args).read
ls = []
@@ -30,7 +30,7 @@
if header['title'].nil? or header['title'].blank?
raise Failure, "No title found. Reopen `#{Form}' and add it"
end
- header['title'].sub!(/\.$/, '')
+ header['title'] += '.' unless header['title'] =~ /[.?!]$/
b = getBinding(header.merge(:rev => rev))
input = ERB.new(input, nil, '<-%->', '$erbout_').result(b)
LogEntry.open('w') { |f| f.print input }
@@ -48,10 +48,10 @@
puts "
|--- | ########## Fill this file correctly and remove this line ########## | ---
|title:
- |subject: #{@@subject_format}.
+ |subject: #{@@subject_format}
|
|--- | ###################### Your ChangeLog entry ############### 80c| # | ---
- |<%= title %>.
+ |<%= title %>
|
|".head_cut!
Index: vcs/lib/vcs/common_commit.rb
--- vcs/lib/vcs/common_commit.rb (revision 258)
+++ vcs/lib/vcs/common_commit.rb (working copy)
@@ -50,7 +50,7 @@
Vcs.commited = edit_form!(files)
- message(files)
+ mk_message(files)
edit! Message
iform = nil