lib/reap/manager/announce.rb in reap-9.2.0 vs lib/reap/manager/announce.rb in reap-9.2.1

- old
+ new

@@ -51,37 +51,41 @@ domain = options.domain # User domain (not sure why SMTP requires this?) login = options.login # Login type (plain, login) secure = options.secure # Use TLS/SSL true or false? password = options.password || ENV['EMAIL_PASSWORD'] - title = options.title || metadata.title - version = options.versoin || metadata.version + title = options.title || metadata.title + version = options.versoin || metadata.version # defaults - subject ||= "ANN: #{title}, v#{version}" + subject ||= "%s, v%s released" account ||= mail_from subject = subject % [title, version] - puts "\n#{message}\n\n" - - if mail_to and !dryrun? - ans = ask("Would you like to email this announcement?", "yN") - case ans.downcase - when 'y', 'yes' - email(message, - :to => mail_to, - :from => mail_from, - :subject => subject, - :server => server, - :port => port, - :domain => domain, - :account => account, - :login => login, - :secure => secure, - :password => password - ) + if dryrun? + puts "[DRYRUN] Email '#{subject}'" + puts "\n#{message}\n\n" if verbose? + else + puts "\n#{message}\n\n" + if mail_to + ans = ask("Would you like to email this announcement?", "yN") + case ans.downcase + when 'y', 'yes' + email(message, + :to => mail_to, + :from => mail_from, + :subject => subject, + :server => server, + :port => port, + :domain => domain, + :account => account, + :login => login, + :secure => secure, + :password => password + ) + end end end end # Make a release announcement. Generates and can email a release @@ -138,11 +142,11 @@ message.sub!(/^\s*please\ see(\ the)?\ notes(.*?)$/i, "\n" + notelog) if notelog message.sub!(/^\s*please\ see(\ the)?\ change(.*?)$/i, "\n" + changelog) if changelog template = message.dup - template.scan(/[$](.*?)[$]/m) do |key| + template.scan(/\$(\w+?)\$/m) do |key| #key = key.strip name = $1.strip #key[1..-1] if metadata.respond_to?(name.downcase) value = metadata.send(name.downcase) message.gsub!("$#{name}$", value.to_s.strip) @@ -150,10 +154,10 @@ puts "Warning: Unknown project field -- #{name}." end end message.gsub!(/(^|[ ])[$].*?(?=[ ]|$)/,'') # remove unused vars - message.gsub!(/\n\s*\n\s*\n/m,"\n\n") # remove any triple blank lines + message.gsub!(/\n\s*\n\s*\n/m,"\n\n") # remove any triple blank lines message.rstrip! return message end