Sha256: 643cd650d9fea3ec471a48a3e4a8389e9c58d8b59501e45ccaa9be5f9aa823f0

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

require 'json'
require 'dev_commands'

class Project < Hash
attr_accessor :filename
	def initialize value=''
		@filename=''
		self[:url]=''
		self[:url] = value if value.is_a?(String)
		if(value.is_a?(Hash))
			value.each{|k,v|self[k]=v}
		end
	end

    def name
    	self[:name]
    end
    
	def get_latest_unique_id 
		'51ed9c9d45ba3979c808740d75ba1831c85aff5d'
	end

	def wrk_dir
		"#{Environment.dev_root}/wrk/#{self.name}"
	end

	def pull
		if(File.exists?(wrk_dir) && File.exists?("#{wrk_dir}/.git"))
			Dir.chdir(wrk_dir) do
				puts "git pull (#{wrk_dir})"
				puts `git pull`
			end
		end
	end

	def clone
		if(!File.exists?(wrk_dir) && self[:url].include?('.git'))
			puts "cloning #{self[:url]} to #{self.wrk_dir}"
			puts `git clone #{self[:url]} #{self.wrk_dir}`
		end
	end

	def checkout
		if(!File.exists?(wrk_dir) && self[:url].include?('svn'))
			puts "checkout #{self.url} to #{self.wrk_dir}"
			puts `svn checkout #{self.url} #{self.wrk_dir}`
		end
	end

	def rake
		if(!File.exists?(self.wrk_dir))
			clone
			checkout
		end
		if(File.exists?(self.wrk_dir))
			Dir.chdir(self.wrk_dir) do
				rake = Command.new({ :input => 'rake', :timeout => 300, :ignore_failure => true })
				#puts "rake (#{self.wrk_dir})"
				#puts `rake`
				rake.execute
				puts rake.summary
			end
		end
	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dev_projects-0.0.26 lib/project.rb
dev_projects-0.0.25 lib/project.rb
dev_projects-0.0.24 lib/project.rb
dev_projects-0.0.23 lib/project.rb
dev_projects-0.0.22 lib/project.rb