Skip to content

Commit

Permalink
[ruby] Fix Psych Usage
Browse files Browse the repository at this point in the history
  • Loading branch information
captn3m0 committed Oct 8, 2022
1 parent 4bb80fd commit b01fead
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 10 additions & 2 deletions _plugins/create-json-files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@
require 'fileutils'
require 'json'
require 'yaml'
import 'date'
require 'date'

API_DIR = 'api'.freeze

def load_yaml(file)
if YAML.respond_to?(:unsafe_load)
YAML.unsafe_load_file(file)
else
YAML.load_file(self[:encoded_value])
end
end

class Product
attr_reader :hash

def initialize(markdown_file)
@hash = YAML.load_file(markdown_file, permitted_classes: [Date])
@hash = load_yaml(markdown_file)
end

def permalink
Expand Down
10 changes: 9 additions & 1 deletion _plugins/validate-releases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@
# read as strings instead.
STRING_KEYS = ['latest', 'releaseCycle']

def load_yaml(file)
if YAML.respond_to?(:unsafe_load)
YAML.unsafe_load_file(file)
else
YAML.load_file(self[:encoded_value])
end
end

def process_files
success = true
Dir['products/*.md'].each do |markdown_file|
hash = YAML.load_file(markdown_file, permitted_classes: [Date])
hash = @hash = load_yaml(markdown_file)
hash['releases'].each do |r|
STRING_KEYS.each do |k|
if r.key? k
Expand Down

0 comments on commit b01fead

Please sign in to comment.