From 5b2480c8ba093f550f46dd3aa3eecbb624f4e5c3 Mon Sep 17 00:00:00 2001 From: Aidan Feldman Date: Thu, 19 Dec 2013 01:58:46 -0500 Subject: [PATCH] refactor file+matter creation in cucumber steps --- features/step_definitions/jekyll_steps.rb | 42 +++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 43c7e31d..e3e3945d 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -1,3 +1,25 @@ +def file_content_from_hash(input_hash) + matter_hash = {} + %w(title layout tag tags category categories published author path date permalink).each do |key| + matter_hash[key] = input_hash[key] if input_hash[key] + end + matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp + + content = if input_hash['input'] && input_hash['filter'] + "{{ #{input_hash['input']} | #{input_hash['filter']} }}" + else + input_hash['content'] + end + + <