class EasyYAML::YAMLLoader
Public Class Methods
new(path, allow_aliases: true, allow_erb: true, relative_to_rails_root: true)
click to toggle source
# File lib/easy_yaml/yaml_loader.rb, line 7 def initialize path, allow_aliases: true, allow_erb: true, relative_to_rails_root: true @path = path @allow_aliases = allow_aliases @allow_erb = allow_erb @relative_to_rails_root = relative_to_rails_root end
Public Instance Methods
to_h()
click to toggle source
# File lib/easy_yaml/yaml_loader.rb, line 14 def to_h safe_load end
Private Instance Methods
erb_parsed_yaml()
click to toggle source
# File lib/easy_yaml/yaml_loader.rb, line 40 def erb_parsed_yaml return yaml_file unless @allow_erb ERB.new(yaml_file).result end
file_path()
click to toggle source
# File lib/easy_yaml/yaml_loader.rb, line 32 def file_path Pathname.new File.expand_path(yaml_file_path, Dir.pwd) end
normalized_path()
click to toggle source
# File lib/easy_yaml/yaml_loader.rb, line 20 def normalized_path @path.tr('\\', '/').split('/') end
prefix_path()
click to toggle source
# File lib/easy_yaml/yaml_loader.rb, line 24 def prefix_path ::Rails.root if @relative_to_rails_root && defined?(::Rails) end
safe_load()
click to toggle source
# File lib/easy_yaml/yaml_loader.rb, line 46 def safe_load YAML.safe_load(erb_parsed_yaml, aliases: @allow_aliases) end
yaml_file()
click to toggle source
# File lib/easy_yaml/yaml_loader.rb, line 36 def yaml_file File.read file_path end
yaml_file_path()
click to toggle source
# File lib/easy_yaml/yaml_loader.rb, line 28 def yaml_file_path File.join [prefix_path, normalized_path].compact end