Sha256: 8d75150b3e19e429498e6971f825f7133c22acbc5a6cbde43a38639af210ab2f
Contents?: true
Size: 1.95 KB
Versions: 5
Compression:
Stored size: 1.95 KB
Contents
class Tasks::Toolbelt::Build::Tarball < Tasks::Toolbelt around_ensure :cleanup def call # checkout requested revision checkout_revision # clean directories clean # copy files into release copy_files_into_release # add revision when given append_revision_to_release_version if options.revision.present? # vendorize the bundle copy_vendored_gems # build tar package_release_into_tar end protected def checkout_revision raise "You have unstaged commits." if %x{git status} =~ /Changes not staged for commit/ sh "git checkout #{options.revision}" raise "Unable to checkout #{options.revision}" unless %x{git branch | grep '*'} =~ /#{options.revision}/ end def copy_files_into_release # for each path ['lib', 'bin', 'config', 'VERSION'].each do |path| # recursively copy into release cp_r File.join( root_path, path ), File.join( release_path, path ) end end def clean rm_rf tarball_path # create release mkdir_p release_path end def append_revision_to_release_version version_file = File.join( release_path, 'VERSION') IO.write(version_file, File.open(version_file) do |f| f.read.gsub(version, "#{version}-#{revision}") end ) end def copy_vendored_gems Bundler.with_clean_env do sh( "bundle install --without development test --path #{release_path}/vendor" ) mv File.join(release_path, "vendor/ruby/1.9.1/gems"), File.join(release_path, "vendor") rm_rf File.join(release_path, "vendor/ruby") end end def package_release_into_tar # path to tarball tarball_filename = File.basename([ release_path, revision, 'tar.gz' ].compact.join(".")) # enter tarball build directory Dir.chdir(tarball_path) do # create targz Tar.pack( 'quandl-command', File.join(tarball_path, tarball_filename) ) end end def cleanup rm_rf File.join( root_path, '.bundle') end end
Version data entries
5 entries across 5 versions & 1 rubygems