Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions service/lib/agama/product_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ def initialize(logger: nil)
@logger = logger || ::Logger.new($stdout)
end

# Loads products definitions
#
# It supports a product per file or multiple products in a single file.
def load_products
glob = File.join(default_path, "*.{yaml,yml}")
Dir.glob(glob).each_with_object([]) do |path, result|
# support also single product file
products = load_file(path)
products = YAML.safe_load_file(path)
products = [products] unless products.is_a?(Array)
result.concat(products)
end
Expand All @@ -58,9 +60,5 @@ def load_products
def default_path
Dir.exist?(GIT_DIR) ? GIT_PATH : SYSTEM_PATH
end

def load_file(path)
YAML.safe_load(File.read(path.to_s))
end
end
end