Class: Project

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

Overview

require ‘dev_commands’

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.



13
14
15
16
17
18
19
20
# File 'lib/dev_projects.rb', line 13

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.



12
13
14
# File 'lib/dev_projects.rb', line 12

def filename
  @filename
end

Instance Method Details

#checkoutObject



50
51
52
53
54
55
# File 'lib/dev_projects.rb', line 50

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



43
44
45
46
47
48
# File 'lib/dev_projects.rb', line 43

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



26
27
28
# File 'lib/dev_projects.rb', line 26

def get_latest_unique_id 
  '51ed9c9d45ba3979c808740d75ba1831c85aff5d'
end

#nameObject



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

def name
  self[:name]
end

#pullObject



34
35
36
37
38
39
40
41
# File 'lib/dev_projects.rb', line 34

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



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/dev_projects.rb', line 57

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



30
31
32
# File 'lib/dev_projects.rb', line 30

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