Module: Lipsiadmin::Generator::Commands::Create

Includes:
Base
Defined in:
lib/generator.rb

Overview

Module Create

Constant Summary

Constants included from Base

Base::PROTECTED_DIRS

Instance Method Summary collapse

Methods included from Base

#create_all, #with_source_in

Instance Method Details

#append(relative_destination, text, sentinel = nil) ⇒ Object



96
97
98
99
100
101
102
103
104
# File 'lib/generator.rb', line 96

def append(relative_destination, text, sentinel=nil)
  path = destination_path(relative_destination)
  logger.append relative_destination
  content = File.read(path)
  unless content.include?(text)
    text = sentinel.blank? ? (content + "\n" + text + "\n") : content.gsub(sentinel, sentinel+"\n"+text)
    File.open(path, 'wb') {|f| f.write(text) }
  end
end