Module: FsTemplate

Defined in:
lib/fs_template.rb,
lib/fs_template/files.rb,
lib/fs_template/project.rb,
lib/fs_template/from_command.rb,
lib/fs_template/template_file.rb

Defined Under Namespace

Classes: BasicFile, Files, FromCommand, Project, ProjectConfig, TemplateFile

Class Method Summary collapse

Class Method Details

.ec(cmd, ops = {}) ⇒ Object



34
35
36
# File 'lib/fs_template.rb', line 34

def ec(cmd,ops={})
  `#{cmd}`
end

.with_local_path(overlay_path, &b) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/fs_template.rb', line 19

def with_local_path(overlay_path,&b)
  if overlay_path =~ /git/
    with_repo_path(overlay_path) do |dir|
      b[dir]
    end
  else
    yield overlay_path
  end
end

.with_repo_path(url) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/fs_template.rb', line 9

def with_repo_path(url)
  dir = "/tmp/#{rand(100000000000000000000)}"
  `mkdir #{dir}`
  Dir.chdir(dir) do
    `git clone #{url} .`
  end
  yield dir
ensure
  `rm -rf #{dir}`
end

.write_project(overlay_path, output_path) ⇒ Object



28
29
30
31
32
# File 'lib/fs_template.rb', line 28

def write_project(overlay_path,output_path)
  with_local_path(overlay_path) do |dir|
    FsTemplate::Project.new(:path => dir).write_to!(output_path)
  end
end