Module: Hoe::Deveiate
- Defined in:
- lib/hoe/deveiate.rb
Overview
A collection of Rake tasks and utility functions I use to maintain my Open Source projects.
Constant Summary collapse
- VERSION =
Library version constant
'0.0.7'
- REVISION =
Version-control revision constant
%q$Revision: 989a77b09844 $
Instance Attribute Summary collapse
-
#email_from ⇒ Object
Who to send announcement emails as.
-
#email_to ⇒ Object
readonly
Where to send announcement emails.
Class Method Summary collapse
-
.extended(mod) ⇒ Object
Extension callback.
Instance Method Summary collapse
-
#define_deveiate_tasks ⇒ Object
Add tasks.
-
#initialize_deveiate ⇒ Object
Set up defaults.
Instance Attribute Details
#email_from ⇒ Object
Who to send announcement emails as
56 57 58 |
# File 'lib/hoe/deveiate.rb', line 56 def email_from @email_from end |
#email_to ⇒ Object (readonly)
Where to send announcement emails
53 54 55 |
# File 'lib/hoe/deveiate.rb', line 53 def email_to @email_to end |
Class Method Details
.extended(mod) ⇒ Object
Extension callback
26 27 28 29 30 |
# File 'lib/hoe/deveiate.rb', line 26 def self::extended( mod ) mod.extend( Hoe::Mercurial ) mod.extend( Hoe::Highline ) super end |
Instance Method Details
#define_deveiate_tasks ⇒ Object
Add tasks
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/hoe/deveiate.rb', line 60 def define_deveiate_tasks task 'hg:precheckin' => [:spec] if File.directory?( 'spec' ) # Rebuild the ChangeLog immediately before release task :prerelease => 'ChangeLog' ### Task: prerelease unless Rake::Task.task_defined?( :pre ) desc "Append the package build number to package versions" task :pre do rev = get_numeric_rev() trace "Current rev is: %p" % [ rev ] $hoespec.spec.version.version << "pre#{rev}" Rake::Task[:gem].clear Gem::PackageTask.new( $hoespec.spec ) do |pkg| pkg.need_zip = true pkg.need_tar = true end end end ### Make the ChangeLog update if the repo has changed since it was last built file '.hg/branch' file 'ChangeLog' => '.hg/branch' do |task| $stderr.puts "Updating the changelog..." content = make_changelog() File.open( task.name, 'w', 0644 ) do |fh| fh.print( content ) end end # Announcement tasks, mostly stolen from hoe-seattlerb task :announce => :send_email desc "Send a release announcement to: %p" % [ @email_to ] task :send_email do abort "no email config in your ~/.hoerc" unless defined?( @email_config ) @email_from = @email_config['from'] ||= "%s <%s>" % self.developer.first smtp_host = @email_config['host'] || ask( "Email host: " ) smtp_port = @email_config['port'] || 'smtp' smtp_port = Socket.getservbyname( smtp_port.to_s ) smtp_user = @email_config['user'] = generate_email( :full ) say "<%= color 'About to send this email:', :subheader %>" say( ) if agree( "\n<%= color 'Okay to send it?', :warning %> " ) require 'socket' require 'net/smtp' require 'etc' username = smtp_user || ask( "Email username: " ) do |q| q.default = Etc.getlogin # default to the current user end password = ask( "Email password for #{username}: " ) do |q| q.echo = color( '*', :yellow ) # Hide the password end say "Creating SMTP connection to #{smtp_host}:#{smtp_port}" smtp = Net::SMTP.new( smtp_host, smtp_port ) smtp.set_debug_output( $stdout ) smtp.esmtp = true # Don't verify the server cert, as my server's cert is self-signed ssl_context = OpenSSL::SSL::SSLContext.new ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE smtp.enable_ssl( ssl_context ) helo = Socket.gethostname smtp.start( helo, username, password, :plain ) do |smtp| smtp.( , self.email_from, *self.email_to ) end else abort "Okay, aborting." end end end |
#initialize_deveiate ⇒ Object
Set up defaults
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/hoe/deveiate.rb', line 34 def initialize_deveiate $hoespec = self @email_to ||= [] @email_from = nil unless defined?( @email_from ) self. = true with_config do |config, _| self.spec_extras[:signing_key] = config['signing_key_file'] or abort "no signing key ('signing_key_file') configured." @email_config = config['email'] @email_to = Array( @email_config['to'] ) end $stderr.puts "Done initializing hoe-deveiate" if Rake.application..trace end |