Class: HtmlEmailCreator::Settings
- Inherits:
-
Object
- Object
- HtmlEmailCreator::Settings
- Defined in:
- lib/html_email_creator/settings.rb
Instance Method Summary collapse
- #built_in_extensions ⇒ Object
- #cdn_url ⇒ Object
- #emails_path ⇒ Object
- #extension_data ⇒ Object
- #fill_extension_data(source) ⇒ Object
- #includes_path ⇒ Object
-
#initialize(root = nil) ⇒ Settings
constructor
Create settings configuration file.
- #layouts_path ⇒ Object
- #output_path ⇒ Object
Constructor Details
#initialize(root = nil) ⇒ Settings
Create settings configuration file.
If the root is not set, the configuration is not searched from the file system but instead the defaults are used.
9 10 11 12 13 |
# File 'lib/html_email_creator/settings.rb', line 9 def initialize(root = nil) @root = root @root ||= File.('~') @config = create_configuration end |
Instance Method Details
#built_in_extensions ⇒ Object
54 55 56 |
# File 'lib/html_email_creator/settings.rb', line 54 def built_in_extensions (@config["extensions"] || {})["built_in"] || [] end |
#cdn_url ⇒ Object
31 32 33 |
# File 'lib/html_email_creator/settings.rb', line 31 def cdn_url @config["cdn_url"] end |
#emails_path ⇒ Object
23 24 25 |
# File 'lib/html_email_creator/settings.rb', line 23 def emails_path @config["emails_path"] end |
#extension_data ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/html_email_creator/settings.rb', line 45 def extension_data return @extension_data if @extension_data extensions = HtmlEmailCreator::Extensions.new built_in_data = extensions.built_in(built_in_extensions) # use built in data for creating custom data custom_data = extensions.custom(built_in_data, custom_extensions) @extension_data = built_in_data.merge(custom_data) end |
#fill_extension_data(source) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/html_email_creator/settings.rb', line 35 def fill_extension_data(source) filled = source.dup extension_data.each_pair do |key, value| filled.gsub!(/\{\{\s*#{key}\s*\}\}/, value) end filled end |
#includes_path ⇒ Object
27 28 29 |
# File 'lib/html_email_creator/settings.rb', line 27 def includes_path @config["includes_path"] end |
#layouts_path ⇒ Object
15 16 17 |
# File 'lib/html_email_creator/settings.rb', line 15 def layouts_path @config["layouts_path"] end |
#output_path ⇒ Object
19 20 21 |
# File 'lib/html_email_creator/settings.rb', line 19 def output_path @config["output_path"] end |