Skip to content

Commit

Permalink
Merge pull request #4 from ShiftForward/deal-correctly-with-nonexisti…
Browse files Browse the repository at this point in the history
…ng-schemas

Deal correctly with non-existing schemas
  • Loading branch information
andresilva authored Aug 17, 2017
2 parents abe2691 + a00c883 commit 015dbce
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/frise/defaults_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ def merge_defaults_obj_at(config, at_path, defaults)
end

def merge_defaults(config, defaults_file, symbol_table = config)
defaults = Parser.parse(defaults_file, symbol_table)
defaults = Parser.parse(defaults_file, symbol_table) || {}
merge_defaults_obj(config, defaults)
end

def merge_defaults_at(config, at_path, defaults_file, symbol_table = config)
defaults = Parser.parse(defaults_file, symbol_table)
defaults = Parser.parse(defaults_file, symbol_table) || {}
merge_defaults_obj_at(config, at_path, defaults)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/frise/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(schema_load_paths: [], defaults_load_paths: [], pre_loaders: [],
end

def load(config_file, exit_on_fail = true, symbol_table = {})
config = Parser.parse(config_file, symbol_table)
config = Parser.parse(config_file, symbol_table) || {}
config_name = File.basename(config_file)

@pre_loaders.each do |pre_loader|
Expand Down
2 changes: 1 addition & 1 deletion lib/frise/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Frise
module Parser
class << self
def parse(file, symbol_table = nil)
return {} unless File.file? file
return nil unless File.file? file
content = File.open(file).read
content = Liquid::Template.parse(content).render symbol_table if symbol_table
YAML.safe_load(content, [], [], true) || {}
Expand Down
4 changes: 2 additions & 2 deletions lib/frise/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ def self.validate_obj(config, schema, options = {})
end

def self.validate(config, schema_file, options = {})
schema = parse_symbols(Parser.parse(schema_file))
schema = parse_symbols(Parser.parse(schema_file) || { allow_unknown_keys: true })
validate_obj(config, schema, options)
end

def self.validate_at(config, at_path, schema_file, options = {})
schema = parse_symbols(Parser.parse(schema_file))
schema = parse_symbols(Parser.parse(schema_file) || { allow_unknown_keys: true })
at_path.reverse.each { |key| schema = { key => schema, :allow_unknown_keys => true } }
validate_obj(config, schema, options)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/frise/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Frise
VERSION = '0.1.0'.freeze
VERSION = '0.2.0.pre'.freeze
end

0 comments on commit 015dbce

Please sign in to comment.