Class: HtmlEmailCreator::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/html_email_creator/settings.rb

Instance Method Summary collapse

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.expand_path('~')
  @config = create_configuration
end

Instance Method Details

#built_in_extensionsObject



54
55
56
# File 'lib/html_email_creator/settings.rb', line 54

def built_in_extensions
  (@config["extensions"] || {})["built_in"] || []
end

#cdn_urlObject



31
32
33
# File 'lib/html_email_creator/settings.rb', line 31

def cdn_url
  @config["cdn_url"]
end

#emails_pathObject



23
24
25
# File 'lib/html_email_creator/settings.rb', line 23

def emails_path
  @config["emails_path"]
end

#extension_dataObject



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_pathObject



27
28
29
# File 'lib/html_email_creator/settings.rb', line 27

def includes_path
  @config["includes_path"]
end

#layouts_pathObject



15
16
17
# File 'lib/html_email_creator/settings.rb', line 15

def layouts_path
  @config["layouts_path"]
end

#output_pathObject



19
20
21
# File 'lib/html_email_creator/settings.rb', line 19

def output_path
  @config["output_path"]
end