Module: Projectr

Defined in:
lib/projectr.rb,
lib/projectr/version.rb

Constant Summary collapse

PROJECT_PATH =
"#{Dir.home}/.projectr"
VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.listObject



9
10
11
12
13
14
# File 'lib/projectr.rb', line 9

def self.list
  dirs = Dir.glob("#{PROJECT_PATH}/*")
    .select { |f|File.directory? f }
    .map { |p| p.split('/').last }
  dirs.each { |dir| puts dir }
end

.load(name, dest_path = Dir.pwd) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/projectr.rb', line 15

def self.load(name, dest_path = Dir.pwd)
  src_path = "#{PROJECT_PATH}/#{name}"
  raise "#{name} is not a valid project" if !File.exist?(src_path)
  FileUtils.cp_r(Dir.glob("#{src_path}/*"), dest_path)
  projectrfile_path = "#{dest_path}/Projectrfile"
  if File.exist?(projectrfile_path)
    FileUtils.chmod('+x', projectrfile_path)
    exec "#{projectrfile_path}"
    FileUtils.rm(projectrfile_path)
  end
end