Class: Project

Inherits:
Hash
  • Object
show all
Defined in:
lib/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Hash

#execute, #to_html

Constructor Details

#initialize(value = '') ⇒ Project

Returns a new instance of Project.



5
6
7
8
9
10
11
12
# File 'lib/project.rb', line 5

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

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



4
5
6
# File 'lib/project.rb', line 4

def filename
  @filename
end

Instance Method Details

#checkoutObject



42
43
44
45
46
47
# File 'lib/project.rb', line 42

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

#cloneObject



35
36
37
38
39
40
# File 'lib/project.rb', line 35

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

#get_latest_unique_idObject



18
19
20
# File 'lib/project.rb', line 18

def get_latest_unique_id 
	'51ed9c9d45ba3979c808740d75ba1831c85aff5d'
end

#nameObject



14
15
16
# File 'lib/project.rb', line 14

def name
	self[:name]
end

#pullObject



26
27
28
29
30
31
32
33
# File 'lib/project.rb', line 26

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

#rakeObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/project.rb', line 49

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 })
			rake.execute
			puts rake.summary
		end
	end
end

#wrk_dirObject



22
23
24
# File 'lib/project.rb', line 22

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