Top Level Namespace
Defined Under Namespace
Classes: ApplicationController, Hash, UserSessionsController, UsersController, WelcomeController
Instance Method Summary collapse
- #add_in_file(path, match, content) ⇒ Object
-
#gsub_file(path, regexp, *args, &block) ⇒ Object
Helpers #####.
Instance Method Details
#add_in_file(path, match, content) ⇒ Object
7 8 9 10 11 |
# File 'lib/base_template.rb', line 7 def add_in_file(path, match, content) gsub_file path, /(#{Regexp.escape(match)})/mi do |match| "#{match}\n#{content}" end end |
#gsub_file(path, regexp, *args, &block) ⇒ Object
Helpers #####
2 3 4 5 |
# File 'lib/base_template.rb', line 2 def gsub_file(path, regexp, *args, &block) content = File.read(path).gsub(regexp, *args, &block) File.open(path, 'wb') { |file| file.write(content) } end |