Class: Rails::TemplateRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/bard/template/helper.rb

Instance Method Summary collapse

Instance Method Details

#bard_load_template(template_file) ⇒ Object



24
25
26
# File 'lib/bard/template/helper.rb', line 24

def bard_load_template(template_file)
  load_template Gem.required_location "bard", "bard/template/#{template_file}.rb"
end

#file_append(file, data) ⇒ Object



8
9
10
11
# File 'lib/bard/template/helper.rb', line 8

def file_append(file, data)
  log 'file_append', file
  append_file(file, "\n#{data}")
end

#file_inject(file_name, sentinel, string, before_after = :after) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/bard/template/helper.rb', line 13

def file_inject(file_name, sentinel, string, before_after=:after)
  log 'file_inject', file_name
  gsub_file file_name, /(#{Regexp.escape(sentinel)})/mi do |match|
    if :after == before_after
      "#{match}\n#{string}"
    else
      "#{string}\n#{match}"
    end
  end
end

#project_nameObject



4
5
6
# File 'lib/bard/template/helper.rb', line 4

def project_name
  @root.split("/").last
end