Module: Roda::Project::Helpers::Template

Included in:
CLI
Defined in:
lib/roda/project/helpers/template.rb

Instance Method Summary collapse

Instance Method Details

#cp(type, path) ⇒ Object



28
29
30
31
32
33
# File 'lib/roda/project/helpers/template.rb', line 28

def cp(type, path)
  File.write(
    "#{@dir}#{@context.project_name}/#{path}",
    File.read(File.expand_path("../../templates/#{type}/#{path}", __dir__))
  )
end

#cp_r(type, path) ⇒ Object



21
22
23
24
25
26
# File 'lib/roda/project/helpers/template.rb', line 21

def cp_r(type, path)
  FileUtils.cp_r(
    File.expand_path("../../templates/#{type}/#{path}", __dir__),
    "#{@dir}#{@context.project_name}/#{path}"
  )
end

#tty_cp(type, path) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/roda/project/helpers/template.rb', line 13

def tty_cp(type, path)
  TTY::File.copy_file(
    File.expand_path("../../templates/#{type}/#{path}", __dir__),
    "#{@dir}#{@context.project_name}/#{path}",
    context: @context
  )
end

#tty_cp_r(type, path) ⇒ Object



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

def tty_cp_r(type, path)
  TTY::File.copy_directory(
    File.expand_path("../../templates/#{type}/#{path}", __dir__),
    "#{@dir}#{@context.project_name}/#{path}",
    context: @context
  )
end