summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/hashie/extensions/parsers/yaml_erb_parser.rb12
-rw-r--r--lib/hashie/mash.rb2
-rw-r--r--lib/hashie/version.rb2
3 files changed, 10 insertions, 6 deletions
diff --git a/lib/hashie/extensions/parsers/yaml_erb_parser.rb b/lib/hashie/extensions/parsers/yaml_erb_parser.rb
index d3b5c80..05edc40 100644
--- a/lib/hashie/extensions/parsers/yaml_erb_parser.rb
+++ b/lib/hashie/extensions/parsers/yaml_erb_parser.rb
@@ -6,19 +6,23 @@ module Hashie
module Extensions
module Parsers
class YamlErbParser
- def initialize(file_path)
+ def initialize(file_path, options = {})
@content = File.read(file_path)
@file_path = file_path.is_a?(Pathname) ? file_path.to_s : file_path
+ @options = options
end
def perform
template = ERB.new(@content)
template.filename = @file_path
- YAML.safe_load template.result, [], [], true
+ whitelist_classes = @options.fetch(:whitelist_classes) { [] }
+ whitelist_symbols = @options.fetch(:whitelist_symbols) { [] }
+ aliases = @options.fetch(:aliases) { true }
+ YAML.safe_load template.result, whitelist_classes, whitelist_symbols, aliases
end
- def self.perform(file_path)
- new(file_path).perform
+ def self.perform(file_path, options = {})
+ new(file_path, options).perform
end
end
end
diff --git a/lib/hashie/mash.rb b/lib/hashie/mash.rb
index f41d745..650a269 100644
--- a/lib/hashie/mash.rb
+++ b/lib/hashie/mash.rb
@@ -107,7 +107,7 @@ module Hashie
raise ArgumentError, "The following file doesn't exist: #{path}" unless File.file?(path)
parser = options.fetch(:parser) { Hashie::Extensions::Parsers::YamlErbParser }
- @_mashes[path] = new(parser.perform(path)).freeze
+ @_mashes[path] = new(parser.perform(path, options.except(:parser))).freeze
end
def to_module(mash_method_name = :settings)
diff --git a/lib/hashie/version.rb b/lib/hashie/version.rb
index 1206e92..22480fb 100644
--- a/lib/hashie/version.rb
+++ b/lib/hashie/version.rb
@@ -1,3 +1,3 @@
module Hashie
- VERSION = '3.6.1'.freeze
+ VERSION = '3.7.0'.freeze
end