Sha256: 4c5c78cdf3ae70aa33cf29d4514059c0f7e3ccda87cc58b5a08e1c057f0751aa

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

require_relative('./environment.rb')
require_relative('./artifacts.rb')

class Publish < Array

  def initialize
    if(Environment.scm=='git')
	  artifacts=Artifacts.new
	  artifacts.each {|artifact|
	    dest_dir = Environment.dev_root + "/dep/" + Environment.relative_directory + '/' + Environment.branch 
	    dest = dest_dir + "/" + artifact
		dest_dir=File.dirname(dest)
		self.add "<%FileUtils.mkdir_p('#{dest_dir}')%>" if (!Dir.exists?(dest_dir))
		self.add "<%FileUtils.cp('#{artifact}','#{dest}')%>"
	  }
	end
  end

  def update
    puts "Publish.update"
    if(defined?(DEV_TASKS))
	  if(DEV_TASKS).has_key?(:publish_path)
	    if(DEV_TASKS[:publish_path].include?('svn://'))
		  latestRev=Environment.svn_latest_revision 
		  svn_publish_uri="#{DEV_TASKS[:publish_path]}/#{DEV_TASKS[:relative_directory]}-#{latestRev}"
		  local_dir="#{Environment.dev_root}/tmp/#{DEV_TASKS[:relative_directory]}@#{latestRev}"
		  FileUtils.mkdir_p(File.dirname(local_dir)) if(!File.exists?(File.dirname(local_dir)))
		  dep_dir="#{Environment.dev_root}/dep/#{DEV_TASKS[:relative_directory]}@#{latestRev}@"
		  puts "Publish.update, `svn info #{svn_publish_uri}`"
		  svn_info=`svn info #{svn_publish_uri} 2>&1`
		  #puts "svn_info: #{svn_info}"
		  if(svn_info.include?('URL:'))
		    puts "#{svn_publish_uri} already exists."
		  else
		    puts "adding publish commands.."
		    add "svn mkdir #{svn_publish_uri} --parents -m\"publish\""
			add "svn checkout #{svn_publish_uri} #{local_dir}@"
			DEV_TASKS[:artifacts].each{|a|
			  f="#{Environment.dev_root}/tmp/#{a}"
			  add "<%File.cp('#{dep_dir}/#{a}','#{local_dir}/#{a}'%>"
			  add "svn add #{local_dir}/#{a} --parents"
			}
			add "svn commit #{local_dir} -m\"publish\""
		  end
		end
	  end
	end
  end

  def add command
    self << command if(!include?(command))
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dev_tasks-0.0.129 lib/publish.rb