lib/utils.rb in jekyll-ramler-0.0.7 vs lib/utils.rb in jekyll-ramler-0.0.8
- old
+ new
@@ -1,18 +1,22 @@
require 'json'
+require 'deep_clone'
module Jekyll
def self.get_dir(page_type, config)
config.fetch('ramler_generated_sub_dirs', {}).fetch(page_type, page_type)
end
def self.sanatize_json_string(s)
- strip_newlines(s)
+ # This use to do something. Hopefully someday it will do something again
+ # See strip_newlines
+ s
end
def self.strip_newlines(s)
# Assuming Markdown, so do NOT remove consecutive newlines
+ # TODO Also do not remove newlines at end of list items
regex = /([^\n])\n([^\n])/
s.gsub(regex, '\1 \2').strip
end
# Utility class for creating schema (current JSON, perhaps XML someday) based
@@ -67,10 +71,10 @@
schema_hash['title'] = @title if @title
schema_hash['description'] = Jekyll::sanatize_json_string(obj['description']) if obj.include?('description')
schema_hash['type'] = 'object'
required_properties = []
- schema_hash['properties'] = obj['body']['application/x-www-form-urlencoded']['formParameters'].dup
+ schema_hash['properties'] = DeepClone.clone obj['body']['application/x-www-form-urlencoded']['formParameters']
schema_hash['properties'].each do |name, param|
if param.include?('required')
required_properties << name if param['required'] == true
param.delete('required')
end