class Flashee::Builders
Public Class Methods
file_builder(file_path, file_contents)
click to toggle source
Called by install generators to create a file inside of the apps file structure
Parameters:¶ ↑
- file_path
-
Path to file including filename and extension
- file_contents
-
Contents to print into the file_path
Returns:¶ ↑
A file inside file_path containing file_contents
# File lib/flashee/builders.rb, line 57 def self.file_builder file_path, file_contents @out_file = File.new(file_path, 'w') @out_file.puts(file_contents) @out_file.close end
helper_builder(flashee_helper_mode)
click to toggle source
Called by install generators to build the appropriate helper file
Parameters:¶ ↑
- flashee_helper_mode
-
A string to define what mode to render the templates in
Returns:¶ ↑
A string of the template contents
# File lib/flashee/builders.rb, line 13 def self.helper_builder flashee_helper_mode @mode = flashee_helper_mode @template = File.read(File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "flashee_helper.rb.erb")) return ERB.new(@template).result(binding) end
view_builder(flashee_helper_mode)
click to toggle source
Called by install generators to build the appropriate view partial
Parameters:¶ ↑
- flashee_helper_mode
-
if flashee_helper_mode is set to “foundation” it will copy the foundation template. Otherwise it will copy the standard template that fits everything else.
Returns:¶ ↑
A string of the template contents
# File lib/flashee/builders.rb, line 30 def self.view_builder flashee_helper_mode @mode = flashee_helper_mode if @mode == "foundation" view_partial_source = File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "_flash_messages_foundation.html.erb") view_partial_target = File.join(Rails.root, "app", "views", "partials", "_flash_messages.html.erb") FileUtils::mkdir_p File.join(Rails.root, "app", "views", "partials") FileUtils.cp_r view_partial_source, view_partial_target else view_partial_source = File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "_flash_messages.html.erb") view_partial_target = File.join(Rails.root, "app", "views", "partials", "_flash_messages.html.erb") FileUtils::mkdir_p File.join(Rails.root, "app", "views", "partials") FileUtils.cp_r view_partial_source, view_partial_target end end