On Thu, Jun 23, 2005 at 09:00:36AM +0900, Jeremy Hinegardner wrote:
> On Thu, Jun 23, 2005 at 08:31:35AM +0900, Ara.T.Howard wrote:
> > On Thu, 23 Jun 2005, James Britt wrote:
> > 
> > >Ara.T.Howard wrote:
> > >>
> > >>i wasn't drinking enough coffee while coding the 0.3.0 release.  this is a
> > >>remedy release.
> > >
> > >Very very cool.
> > >
> > >Is there a gem for this?
> > 
> > not yet.  i'm having gem issues ;-)
> > 
> > i keep codeforpeople.com in sync like like
> > 
> >   scp -r ruby/ codeforpeople.com/lib/
> > 
> > and all my ruby projects are updated.  with rubyforge and gems i have to do
> > each one individually and this tends to take me a while to get to... how are
> > others dealing with this?
> 
> Rakefile's are your friend.  Check out:

And I really mean it this time.  See the attached Rakefile as an
example one for traits.   I haven't yet tried recursive Rakefiles.
Executing 'rake publish' in your top level ruby directory and watching
it build gems and sync everything up, that could be nice.

There is a rake task for publishing to rubyforge, but I haven't played
with it yet.


enjoy,

-jeremy

-- 
========================================================================
 Jeremy Hinegardner                              jeremy / hinegardner.org 


require 'rake'
require 'rake/clean'
require 'rake/contrib/sshpublisher'
require 'rake/gempackagetask'

PKG_VERSION = IO::read 'VERSION'
PKG_VERSION.strip!
PKG_NAME = "traits"
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"

#-----------------------------------------------------------------------
desc "Default Task"
task :default => :package

#-----------------------------------------------------------------------
# cleanup
#-----------------------------------------------------------------------
CLOBBER.include(
    "pkg/**",
    "README"
    )
#-----------------------------------------------------------------------
# generate README
#
# - maybe make a task lib out of the gen_readme.rb code ?
#
#-----------------------------------------------------------------------
desc "Generate README"
task :readme => [:clobber] do
    File.open('README','w') do |f|
        $stdout = f
        tmpl = IO::read 'gen_readme.rb'
        eval tmpl
        $stdout = STDOUT
    end
end


#-----------------------------------------------------------------------
# Publish to website
#-----------------------------------------------------------------------
desc "Publish the gem on codeforpeople.com"

PUBLISH_HOST = "codeforpeople.com"
PUBLISH_ROOT = "/lib/ruby"
task :publish => [:package] do
    `ssh #{PUBLISH_HOST} 'mkdir -p #{PUBLISH_ROOT}/#{PKG_NAME}/#{PKG_FILE_NAME}'`
    `scp -rq ./ #{PUBLISH_HOST}:#{PUBLISH_ROOT}/#{PKG_NAME}/#{PKG_FILE_NAME}`

    # if packages should go somewhere else
  Rake::SshFilePublisher.new(PUBLISH_HOST, "#{PUBLISH_ROOT}/pkg", "pkg", "#{PKG_FILE_NAME}.zip").upload
  Rake::SshFilePublisher.new(PUBLISH_HOST, "#{PUBLISH_ROOT}/pkg", "pkg", "#{PKG_FILE_NAME}.tgz").upload
  Rake::SshFilePublisher.new(PUBLISH_HOST, "#{PUBLISH_ROOT}/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload

end

#-----------------------------------------------------------------------
# install
#-----------------------------------------------------------------------
task :install => [:package] do
  `gem install pkg/#{PKG_FILE_NAME}.gem`
end

#-----------------------------------------------------------------------
# gem specification for :package
#-----------------------------------------------------------------------
task :package => [:clobber, :readme]

spec = Gem::Specification.new do |s|
  s.name = PKG_NAME
  s.version = PKG_VERSION
  s.platform = Gem::Platform::RUBY
  s.summary = "better living through metaprogramming:"
  s.description = <<DESC
  traits.rb aims to be a better set of attr_* methods and encourages
  better living through meta-programming and uniform access priciples.
  traits.rb supercedes attributes.rb.  why?  the name is shorter ;-)
DESC
  
  s.has_rdoc = false

  # no dependencies
  # s.add_dependency('gem', '>= version')

  s.files = %w(README VERSION) + Dir['lib/**/*'] + Dir['sample/**/*']
  s.require_path = '.'

  s.author = "Ara T. Howard"
  s.email = "ara [dot] t [dot] howard [at] noaa [dot] gov"

end

Rake::GemPackageTask.new(spec) do |p|
  p.gem_spec = spec
  p.need_tar = true
  p.need_zip = true
end