class Policial::ConfigLoader
Public: Load and parse config files from GitHub repo.
Public Class Methods
new(commit)
click to toggle source
# File lib/policial/config_loader.rb, line 6 def initialize(commit) @commit = commit end
Public Instance Methods
json(filename)
click to toggle source
# File lib/policial/config_loader.rb, line 14 def json(filename) JSON.parse(raw(filename)) rescue JSON::ParserError {} end
raw(filename)
click to toggle source
# File lib/policial/config_loader.rb, line 10 def raw(filename) blank?(filename) ? '' : @commit.file_content(filename) end
yaml(filename)
click to toggle source
# File lib/policial/config_loader.rb, line 20 def yaml(filename) YAML.load(raw(filename)) || {} rescue Psych::SyntaxError {} end
Private Instance Methods
blank?(string)
click to toggle source
# File lib/policial/config_loader.rb, line 28 def blank?(string) string.to_s.strip.empty? end