Module: Hound::Tools::Template

Included in:
HoundDefaults, HoundOverrides, HoundYml, MergedYml, RubocopYml
Defined in:
lib/hound/tools/template.rb

Defined Under Namespace

Classes: InvalidTemplate

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



7
8
9
# File 'lib/hound/tools/template.rb', line 7

def filename
  @filename
end

Instance Method Details

#generateObject



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

def generate
  _validate(IO.read(@filename))
  $stdout.puts "#{@filename} (seems ok - skipped)"
  true
rescue Errno::ENOENT
  Pathname.new(@filename).dirname.mkpath
  IO.write(@filename, _template_for(@filename))
  $stdout.puts "#{@filename} created"
rescue InvalidTemplate => e
  $stderr.puts "Error: #{@filename} is invalid! (#{e.message})"
end

#initialize(filename) ⇒ Object



9
10
11
# File 'lib/hound/tools/template.rb', line 9

def initialize(filename)
  @filename = filename
end