* Update erb_lint to track newer Rubocop versions * Update rubocop-rspec to 2.1 * Fix Rails/WhereEquals and Style/RedundantParentheses * Upgrade rubocop to 1.1.0 * Enable Rubocop 1.1 cops * Upgrade rubocop to 1.2.0 * Enable Rubocop 1.2 cops * Upgrade rubocop to 1.3.0 * Enable Rubocop 1.3 cops * Enable Rubocop 1.4 cops * Enable Rubocop 1.5 cops * Upgrade rubocop to 1.6.x * Restore previous .reject * Fork the PR to make sure we don't inject unwanted code accidentally
29 lines
640 B
Ruby
29 lines
640 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ERBLint
|
|
# Loads file from disk
|
|
class FileLoader
|
|
attr_reader :base_path
|
|
|
|
def initialize(base_path)
|
|
@base_path = base_path
|
|
end
|
|
|
|
if RUBY_VERSION >= "2.6"
|
|
def yaml(filename)
|
|
YAML.safe_load(read_content(filename), permitted_classes: [Regexp, Symbol], filename: filename) || {}
|
|
end
|
|
else
|
|
def yaml(filename)
|
|
YAML.safe_load(read_content(filename), [Regexp, Symbol], [], false, filename) || {}
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def read_content(filename)
|
|
path = File.expand_path(filename, base_path)
|
|
File.read(path)
|
|
end
|
|
end
|
|
end
|