html_email_creator 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -90,12 +90,7 @@ module HtmlEmailCreator
90
90
  filled_layout.gsub!(/\{\{\s*#{key}\s*\}\}/, value)
91
91
  end
92
92
 
93
- # fill also global settings content to layout
94
- @settings.extension_data.each_pair do |key, value|
95
- filled_layout.gsub!(/\{\{\s*#{key}\s*\}\}/, value)
96
- end
97
-
98
- filled_layout
93
+ @settings.fill_extension_data(filled_layout)
99
94
  end
100
95
 
101
96
  end
@@ -2,13 +2,13 @@ module HtmlEmailCreator
2
2
  class Settings
3
3
 
4
4
  # Create settings configuration file.
5
- #
5
+ #
6
6
  # If the root is not set, the configuration is not searched from the file system
7
7
  # but instead the defaults are used.
8
8
  def initialize(root = nil)
9
9
  @root = root
10
10
  @root ||= File.expand_path('~')
11
- @config = create_configuration
11
+ @config = create_configuration
12
12
  end
13
13
 
14
14
  def layouts_path
@@ -22,7 +22,7 @@ module HtmlEmailCreator
22
22
  def emails_path
23
23
  @config["emails_path"]
24
24
  end
25
-
25
+
26
26
  def includes_path
27
27
  @config["includes_path"]
28
28
  end
@@ -31,6 +31,16 @@ module HtmlEmailCreator
31
31
  @config["cdn_url"]
32
32
  end
33
33
 
34
+ def fill_extension_data(source)
35
+ filled = source.dup
36
+
37
+ extension_data.each_pair do |key, value|
38
+ filled.gsub!(/\{\{\s*#{key}\s*\}\}/, value)
39
+ end
40
+
41
+ filled
42
+ end
43
+
34
44
  def extension_data
35
45
  return @extension_data if @extension_data
36
46
  extensions = HtmlEmailCreator::Extensions.new(self)
@@ -43,7 +53,7 @@ module HtmlEmailCreator
43
53
  def built_in_extensions
44
54
  (@config["extensions"] || {})["built_in"] || []
45
55
  end
46
-
56
+
47
57
  private
48
58
 
49
59
  def custom_extensions
@@ -56,23 +66,23 @@ module HtmlEmailCreator
56
66
  config_root_dir = File.dirname(config_file)
57
67
  loaded_config = YAML.load_file(config_file)
58
68
  # fill missing values with defaults if missing
59
- default_config.each_pair do |key, value|
69
+ default_config.each_pair do |key, value|
60
70
  loaded_config[key] = value unless loaded_config[key]
61
71
  end
62
-
72
+
63
73
  # make absolute paths if is relative for all _path ending keys
64
74
  loaded_config.each_pair do |key, value|
65
75
  if key.match(/_path$/) && !value.match(/^\//)
66
76
  loaded_config[key] = File.join(config_root_dir, value)
67
77
  end
68
78
  end
69
-
79
+
70
80
  loaded_config
71
81
  else
72
82
  default_config
73
83
  end
74
84
  end
75
-
85
+
76
86
  def default_config
77
87
  {
78
88
  "layouts_path" => find_dir("Layouts"),
@@ -83,11 +93,11 @@ module HtmlEmailCreator
83
93
  "extensions" => {}
84
94
  }
85
95
  end
86
-
96
+
87
97
  def find_dir(dir)
88
98
  HtmlEmailCreator::Helper.find_recursively(@root, dir, File.join(@root, dir))
89
99
  end
90
-
100
+
91
101
  def find_config_file
92
102
  HtmlEmailCreator::Helper.find_recursively(@root, ".html_config.yaml")
93
103
  end
@@ -60,7 +60,7 @@ module HtmlEmailCreator
60
60
  if File.exists?(template)
61
61
  # run through a formatter
62
62
  formatter = HtmlEmailCreator::Formatter.new(IO.read(template), settings)
63
- formatter.find_by_filename(template).format
63
+ settings.fill_extension_data(formatter.find_by_filename(template).format)
64
64
  else
65
65
  "Included file '#{template}' not found."
66
66
  end
@@ -1,3 +1,3 @@
1
1
  module HtmlEmailCreator
2
- VERSION = "1.0.8" unless defined?(::HtmlEmailCreator::VERSION)
2
+ VERSION = "1.0.9" unless defined?(::HtmlEmailCreator::VERSION)
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 8
9
- version: 1.0.8
8
+ - 9
9
+ version: 1.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Pekka Mattila
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-11-06 00:00:00 +02:00
17
+ date: 2011-11-21 00:00:00 +02:00
18
18
  default_executable: html_email_creator
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency