lib/pinpress.rb in pinpress-1.4.0 vs lib/pinpress.rb in pinpress-1.4.1

- old
+ new

@@ -43,13 +43,13 @@ # @param [Fixnum] template_type The template type # @return [Hash] def get_template(template_name, template_type) case template_type when PinPress::Template::TYPE_PIN - configuration.pin_templates[template_name.to_sym] + configuration.pin_templates.find { |t| t.keys[0] == template_name.to_sym}.values[0] when PinPress::Template::TYPE_TAG - configuration.tag_templates[template_name.to_sym] + configuration.tag_templates.find { |t| t.keys[0] == template_name.to_sym}.values[0] end end # "Initializes" a passed template: # 1. If the template exists, returns it. @@ -130,23 +130,25 @@ when PinPress::Template::TYPE_PIN templates = configuration.pin_templates when PinPress::Template::TYPE_TAG templates = configuration.tag_templates end - !templates[template_name.to_sym].nil? + !templates.find { |t| t.keys[0] == template_name.to_sym }.nil? end # Present a list of installed templates to the user # @return [void] def list_templates pin_templates = configuration.pin_templates tag_templates = configuration.tag_templates messenger.section('AVAILABLE PIN TEMPLATES:') if pin_templates + # pin_templates.each_with_index do |template, index| pin_templates.each_with_index do |template, index| - puts "#{ index + 1 }.\tName: ".blue + "#{ template[:name] }" + template_name, template = template.first + puts "#{ index + 1 }.\tName: ".blue + "#{ template_name }" puts "Opener:".blue.rjust(22) + "\t#{ template[:opener] }".truncate(80) puts "Item:".blue.rjust(22) + "\t#{ template[:item] }".truncate(80) puts "Closer:".blue.rjust(22) + "\t#{ template[:closer] }".truncate(80) end else @@ -154,10 +156,11 @@ end messenger.section('AVAILABLE TAG TEMPLATES:') if tag_templates tag_templates.each_with_index do |template, index| - puts "#{ index + 1 }.\tName: ".blue + "#{ template[:name] }" + template_name, template = template.first + puts "#{ index + 1 }.\tName: ".blue + "#{ template_name }" puts "Opener:".blue.rjust(22) + "\t#{ template[:opener] }".truncate(80) puts "Item:".blue.rjust(22) + "\t#{ template[:item] }".truncate(80) puts "Closer:".blue.rjust(22) + "\t#{ template[:closer] }".truncate(80) end else