cuker 0.4.5 → 0.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02035bad58d8e020d683213c6417d2b81d9fcd3c2c35ea6feff3234b38adbf9f
4
- data.tar.gz: f1c2ea9f35d297a3e7d37f70f953c637302f1493eda2cfd3e69067a0b691997b
3
+ metadata.gz: ea9e7c78907f9ffa3783fa4e6e657db008bbc27304f095f770c44977ad1587d1
4
+ data.tar.gz: 65890c29fbf590e0679ce8f05800a8ee2ff44c9a1656eccfc9908bbfa2a7f0e4
5
5
  SHA512:
6
- metadata.gz: 1cfc0fb18e1b799eceffe2a3ec7f26822b27805682586dea9100bf573aac0bc15e9a28e3201fea8c950cb08be01ac07bfc476de0642e4f5331e121065a04d3f7
7
- data.tar.gz: f347f0a0d79ea91bef37387c3a8531375bfd3ab8a49ed557eb3bdc3e9f715490f6a7f97c48cc83f044f00f6f068f87fb7aa0758e18a17298c2a1637dde2bc093
6
+ metadata.gz: 89e61d4e64248a0ce2ed460afe48a7f0980031a74f4ca3e0ec0d2d724e1d434307a12096d9152b38d55d9bc0dafc97235c08ef562ef7b05bf6b2e3e2e957cc11
7
+ data.tar.gz: 3e65628c004451840294afe37f07584b67f1173ed2a6a221e620023e29cc130266372edee34a4022c74fc8bb85b18013a8ef4406f8472634f3583b4f86b91d71
@@ -3,6 +3,7 @@ require 'thor'
3
3
  require 'require_all'
4
4
  # require_all 'lib/cuker/**/*.rb'
5
5
  # require_all 'lib/cuker/*.rb'
6
+ require_rel '**/helpers/*.rb'
6
7
  require_rel '**/*.rb'
7
8
  require_rel '*.rb'
8
9
 
@@ -40,7 +40,7 @@ module Cuker
40
40
 
41
41
  def name_merge hsh
42
42
  str = ""
43
- @log.warn "name merge for #{hsh}"
43
+ @log.debug "name merge for #{hsh}"
44
44
  str += hsh[:name].strip.force_encoding("UTF-8") if hsh[:name]
45
45
  str += "\n#{hsh[:description].strip.force_encoding("UTF-8")}" if hsh[:description]
46
46
  str
@@ -3,6 +3,9 @@ module Cuker
3
3
  class JiraModel < AbstractModel
4
4
  include LoggerSetup
5
5
 
6
+ include StringHelper
7
+ TITLE_MAX_LEN = 40
8
+
6
9
  JIRA_BLANK = ' '
7
10
  JIRA_TITLE_SEP = '||'
8
11
  JIRA_ROW_SEP = '|'
@@ -74,7 +77,7 @@ module Cuker
74
77
  title_str = ''
75
78
  # feat handle
76
79
  title_str += jira_title 'Feature', feat_title
77
- title_str += jira_title('Background', title) if title
80
+ title_str += jira_title('Background', title) if type == :Background
78
81
  row_hsh = {
79
82
  :s_num => "#{feat_counter}",
80
83
  :s_title => surround_panel(title_str),
@@ -224,7 +227,7 @@ module Cuker
224
227
  res = []
225
228
  arg[:rows].each_with_index do |row, i|
226
229
  sep = i == 0 ? '||' : '|'
227
- res << surround(row[:cells].map {|hsh| hsh[:value]}, sep)
230
+ res << surround(row[:cells].map {|hsh| jira_blank_pad hsh[:value]}, sep)
228
231
  end
229
232
  return res
230
233
  elsif arg[:type] == :DocString
@@ -236,6 +239,14 @@ module Cuker
236
239
  []
237
240
  end
238
241
 
242
+ def name_merge hsh, max_len = TITLE_MAX_LEN
243
+ str = ""
244
+ @log.debug "name merge for #{hsh} with max_len (#{max_len})"
245
+ str += add_newlines!(hsh[:name].strip.force_encoding("UTF-8"), max_len) if hsh[:name]
246
+ str += add_newlines!("\n#{hsh[:description].strip.force_encoding("UTF-8")}", max_len) if hsh[:description]
247
+ str
248
+ end
249
+
239
250
  def surround_panel str, title = nil
240
251
  if title
241
252
  "{panel:title = #{title}} #{str} {panel}"
@@ -253,7 +264,7 @@ module Cuker
253
264
  end
254
265
 
255
266
  def jira_title keyword, title
256
- "#{jira_bold "#{keyword}:"} #{title}\n "
267
+ "#{jira_bold "#{keyword}:"}\n #{title}\n "
257
268
  end
258
269
 
259
270
  def jira_arg_hilight(str)
@@ -275,5 +286,10 @@ module Cuker
275
286
  def jira_italics(str)
276
287
  simple_surround(str, '_')
277
288
  end
289
+
290
+ def jira_blank_pad str
291
+ s = str.strip
292
+ s.empty? ? JIRA_BLANK : s
293
+ end
278
294
  end
279
295
  end
@@ -40,7 +40,7 @@ module Cuker
40
40
  res = []
41
41
  arg[:rows].each_with_index do |row, i|
42
42
  sep = i == 0 ? '||' : '|'
43
- res << surround(row[:cells].map {|hsh| jira_monospace(hsh[:value])}, sep)
43
+ res << surround(row[:cells].map {|hsh| jira_monospace(jira_blank_pad hsh[:value])}, sep)
44
44
  end
45
45
  return res
46
46
  elsif arg[:type] == :DocString
@@ -0,0 +1,39 @@
1
+ module StringHelper
2
+
3
+ def add_newlines_regex(str, max_len)
4
+ str.scan(/.{1,#{max_len}}.*?(?:\b|$)/).join "\n"
5
+ end
6
+
7
+ def add_newlines!(str, max_len)
8
+ index = max_len - 1
9
+ until index >= str.length
10
+ if str[index] == ' '
11
+ str[index] = "\n"
12
+ index += max_len
13
+ else
14
+ index += 1
15
+ end
16
+ end
17
+ str
18
+ end
19
+
20
+ def add_newlines(str, max_len)
21
+ words = str.split(' ')
22
+ lines = []
23
+ current_line = []
24
+ current_len = 0
25
+ until words.empty?
26
+ next_word = words.shift
27
+ current_line << next_word
28
+ current_len += next_word.length + 1
29
+ if current_len >= max_len
30
+ lines << current_line.join(' ')
31
+ current_line = []
32
+ current_len = 0
33
+ end
34
+ end
35
+ lines << current_line.join(' ') unless current_line.empty?
36
+ lines.join("\n")
37
+ end
38
+
39
+ end
@@ -43,6 +43,7 @@ module Cuker
43
43
  class CsvSheet < AbstractSheet
44
44
  def initialize file_name
45
45
  super file_name
46
+ @log.info "Making new #{self.class} => #{file_name}"
46
47
  @csv_sheet = CSV.open(file_name, "wb")
47
48
  end
48
49
 
@@ -37,6 +37,7 @@ module Cuker
37
37
  class JiraFile < AbstractSheet
38
38
  def initialize file_name
39
39
  super file_name
40
+ @log.info "Making new #{self.class} => #{file_name}"
40
41
  @jira_file = File.open(file_name, "wb")
41
42
  end
42
43
 
@@ -28,7 +28,12 @@ module Cuker
28
28
  end
29
29
 
30
30
  class RubyXLSheet < AbstractSheet
31
- #todo: finish class
31
+ def initialize file_name
32
+ super file_name
33
+ @log.info "Making new #{self.class} => #{file_name}"
34
+ # @jira_file = File.open(file_name, "wb")
35
+ end
36
+
32
37
  end
33
38
  end
34
39
  end
data/lib/cuker/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cuker
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ufo2mstar
@@ -167,6 +167,7 @@ files:
167
167
  - lib/cuker/helpers/formatters/jira_mono_model.rb
168
168
  - lib/cuker/helpers/formatters/title.rb
169
169
  - lib/cuker/helpers/gherkin_helper.rb
170
+ - lib/cuker/helpers/string_helper.rb
170
171
  - lib/cuker/helpers/writers/abstract_writer.rb
171
172
  - lib/cuker/helpers/writers/csv_writer.rb
172
173
  - lib/cuker/helpers/writers/jira_writer.rb