lib/cuker/helpers/formatters/jira_model.rb in cuker-0.4.5 vs lib/cuker/helpers/formatters/jira_model.rb in cuker-0.4.9
- old
+ new
@@ -1,10 +1,13 @@
require_relative '../writers/abstract_writer'
module Cuker
class JiraModel < AbstractModel
include LoggerSetup
+ include StringHelper
+ TITLE_MAX_LEN = 40
+
JIRA_BLANK = ' '
JIRA_TITLE_SEP = '||'
JIRA_ROW_SEP = '|'
JIRA_EMPTY_LINE = '(empty line)'
JIRA_NEW_LINE = '\\\\'
@@ -72,11 +75,11 @@
if type == :Background or type == :Feature
@feat_printed = true
title_str = ''
# feat handle
title_str += jira_title 'Feature', feat_title
- title_str += jira_title('Background', title) if title
+ title_str += jira_title('Background', title) if type == :Background
row_hsh = {
:s_num => "#{feat_counter}",
:s_title => surround_panel(title_str),
:s_content => surround_panel(content_ary.join("\n")),
:item => simple_surround(JIRA_ICONS[:empty], '|'),
@@ -222,11 +225,11 @@
def in_step_args arg
if arg[:type] == :DataTable
res = []
arg[:rows].each_with_index do |row, i|
sep = i == 0 ? '||' : '|'
- res << surround(row[:cells].map {|hsh| hsh[:value]}, sep)
+ res << surround(row[:cells].map {|hsh| jira_blank_pad hsh[:value]}, sep)
end
return res
elsif arg[:type] == :DocString
# todo: handle if needed
@log.warn "Docstrings found in '#{arg}' found in file @ #{@file_path}"
@@ -234,10 +237,18 @@
@log.warn "Unknown type '#{arg[:type]}' found in file @ #{@file_path}"
end
[]
end
+ def name_merge hsh, max_len = TITLE_MAX_LEN
+ str = ""
+ @log.debug "name merge for #{hsh} with max_len (#{max_len})"
+ str += add_newlines!(hsh[:name].strip.force_encoding("UTF-8"), max_len) if hsh[:name]
+ str += add_newlines!("\n#{hsh[:description].strip.force_encoding("UTF-8")}", max_len) if hsh[:description]
+ str
+ end
+
def surround_panel str, title = nil
if title
"{panel:title = #{title}} #{str} {panel}"
else
"{panel} #{str} {panel}"
@@ -251,11 +262,11 @@
"{color} #{str} {color}"
end
end
def jira_title keyword, title
- "#{jira_bold "#{keyword}:"} #{title}\n "
+ "#{jira_bold "#{keyword}:"}\n #{title}\n "
end
def jira_arg_hilight(str)
str.gsub(/<(.*)>/, jira_bold_italics('<\1>'))
end
@@ -272,8 +283,13 @@
jira_bold(jira_italics(str))
end
def jira_italics(str)
simple_surround(str, '_')
+ end
+
+ def jira_blank_pad str
+ s = str.strip
+ s.empty? ? JIRA_BLANK : s
end
end
end
\ No newline at end of file