Class: Project
Instance Attribute Summary collapse
-
#abs_path ⇒ Object
Returns the value of attribute abs_path.
-
#cmd_exec ⇒ Object
Returns the value of attribute cmd_exec.
-
#dst ⇒ Object
Returns the value of attribute dst.
-
#links ⇒ Object
Returns the value of attribute links.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pkg_mgr ⇒ Object
Returns the value of attribute pkg_mgr.
-
#repos ⇒ Object
Returns the value of attribute repos.
-
#yaml ⇒ Object
Returns the value of attribute yaml.
Instance Method Summary collapse
- #goto_dst ⇒ Object
- #init ⇒ Object
- #init_links ⇒ Object
- #init_project ⇒ Object
- #init_repos ⇒ Object
- #init_runs ⇒ Object
-
#initialize(name, yaml, dst) ⇒ Project
constructor
A new instance of Project.
Methods included from Logging
configure_logger_for, #logger, logger_for
Constructor Details
#initialize(name, yaml, dst) ⇒ Project
Returns a new instance of Project.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/clenver/project.rb', line 8 def initialize(name, yaml, dst) @name = name @yaml = yaml @repos = [] @pkg_mgr = [] @links = [] @cmd_exec = [] @dst = dst @abs_path = Dir::pwd + "/" + @name end |
Instance Attribute Details
#abs_path ⇒ Object
Returns the value of attribute abs_path.
7 8 9 |
# File 'lib/clenver/project.rb', line 7 def abs_path @abs_path end |
#cmd_exec ⇒ Object
Returns the value of attribute cmd_exec.
7 8 9 |
# File 'lib/clenver/project.rb', line 7 def cmd_exec @cmd_exec end |
#dst ⇒ Object
Returns the value of attribute dst.
7 8 9 |
# File 'lib/clenver/project.rb', line 7 def dst @dst end |
#links ⇒ Object
Returns the value of attribute links.
7 8 9 |
# File 'lib/clenver/project.rb', line 7 def links @links end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/clenver/project.rb', line 7 def name @name end |
#pkg_mgr ⇒ Object
Returns the value of attribute pkg_mgr.
7 8 9 |
# File 'lib/clenver/project.rb', line 7 def pkg_mgr @pkg_mgr end |
#repos ⇒ Object
Returns the value of attribute repos.
7 8 9 |
# File 'lib/clenver/project.rb', line 7 def repos @repos end |
#yaml ⇒ Object
Returns the value of attribute yaml.
7 8 9 |
# File 'lib/clenver/project.rb', line 7 def yaml @yaml end |
Instance Method Details
#goto_dst ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/clenver/project.rb', line 19 def goto_dst if @dst path = @abs_path + "/../" + @dst + "/" + @name FileUtils.mkdir_p(path) else path = @abs_path Dir::mkdir(path) end Dir::chdir(path) end |
#init ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/clenver/project.rb', line 30 def init for r in repos do logger.debug("clone repo:#{r.repo_uri}") r.clone r.add_remotes end for p in pkg_mgr do logger.debug("install packages: #{p.pkgs}") p.install end for l in links do logger.debug("create link src: #{l.src} dst:#{l.dst}") l.create end for c in cmd_exec do logger.debug("execute: #{c.cmd}") c.execute end end |
#init_links ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/clenver/project.rb', line 70 def init_links logger.debug("init_links") @yaml.each do |uri, content| if content.is_a?(Hash) #links unless content['links'].nil? content['links'].each do |s,d| #TODO: this is ugly and should be fixed buf = Array.new().push(s) s_path = Link.new(s,d).(buf)[0] Link.new(s_path,d).create end end end end end |
#init_project ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/clenver/project.rb', line 50 def init_project logger.debug("init_project:") case @yaml when Hash init_links init_repos init_runs when String begin unless @yaml.nil? @yaml['links'].each do |s,d| Link.new(s,d).create end end rescue Exception => msg puts msg end end end |
#init_repos ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/clenver/project.rb', line 87 def init_repos logger.debug("init_yaml") repos.each do |r| logger.debug("r:#{r}") if r.content.is_a?(Hash) #remotes logger.debug("content:#{r.content}") unless r.content['remotes'].nil? logger.debug("r.content:#{r.content['remotes']}") r.content['remotes'].each do |name, uri| r.add_remote(name, uri) end end end end end |
#init_runs ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/clenver/project.rb', line 104 def init_runs logger.debug("init_runs") @yaml.each do |uri, content| if content.is_a?(Hash) #run unless content['run'].nil? content['run'].each do |cmd| puts %x[#{cmd}] end end end end end |