cuker 0.3.17 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6b1d180c3c6993a9369242cbb2f1f8f5d445b99e9ea053b0b23a1c8b2afa015
4
- data.tar.gz: 44f6f7ec50da9849b81c3f12b7149087073781d0bd802dcec5f6f05381a8df66
3
+ metadata.gz: 0bdf1f98d5596286d2b3f14b542c400255e1a45db25832550b1bfff6ba33ae66
4
+ data.tar.gz: c14d46c7af705d2f90ab86b32e84c0f6a2875e6db66f7a3bc52d05eb5aba5fc7
5
5
  SHA512:
6
- metadata.gz: 4242e860043fc50f7321d3dd157d372a12ea7f3b97187d07ddbb6645a71101de9b32ac3acbf2670355e803f3bda2395a388b14e52fa19b9fb24c86dddfb8092f
7
- data.tar.gz: 37782b63570653d0115514017671247af1220e777ac54dca1b7940e6adbc0f8223b73cf8f66eb0c3583db2dfb5174b5ea388cc32b073c724105d37dbc9ab4efb
6
+ metadata.gz: 6bb47ac4ec1d74ff23c6ad8cfe6980e273231c1e9e6c949f6f77ee7f08c84fdf4df5a591bfd8438c0e4686f60d7415f5378da95c90b09cc4a74f7581146ad83d
7
+ data.tar.gz: 4edf5dde8c2b961809ba439cab9f426d4dcd7879f053bd30b08d8b6acfd390c14657e22a11b9518d1f46888a7d58e35ab3b676b386a9722d460392e21b0632b5
@@ -22,12 +22,13 @@ module Cuker
22
22
  PRESETS = {
23
23
  :simple_csv => [CsvModel, CsvWriter],
24
24
  :simple_jira => [JiraModel, JiraWriter],
25
+ :monospaced_jira => [JiraMonoModel, JiraWriter],
25
26
  }
26
27
 
27
28
  # desc "report PRESET_KEY [FEATURE_PATH [REPORT_PATH [REPORT_FILE_NAME [LOG_LEVEL]]]]",
28
29
  # "reports parsed results into \nREPORT_PATH/REPORT_FILE_NAME \nfor all '*.feature' files in the given FEATURE_PATH\nSTDIO LOG_LEVEL adjustable\n"
29
30
 
30
- def report preset_key, report_file_name = 'sample_report', feat_path = "../", report_path = ".", log_level = :error
31
+ def report preset_key, feat_path = "../", report_file_name = 'sample_report', report_path = ".", log_level = :error
31
32
  init_logger log_level
32
33
  report_path = File.join report_path, 'reports', LOG_TIME_TODAY
33
34
 
@@ -43,7 +44,7 @@ module Cuker
43
44
  preset_model = model.new ast_map
44
45
  preset_writer = writer.new
45
46
  grr = GherkinReporter.new preset_writer, preset_model, report_path, report_file_name
46
- grr.write
47
+ File.expand_path grr.write
47
48
  end
48
49
 
49
50
  private
@@ -21,10 +21,10 @@ class GherkinReporter
21
21
  end
22
22
 
23
23
  def write
24
- @writer.make_file @file_path
24
+ file_name = @writer.make_new_file @file_path
25
25
  @writer.write_title @model.title
26
26
  @model.data.each {|row| @writer.write_new_row row}
27
- @file_path
27
+ file_name
28
28
  end
29
29
 
30
30
  private
data/lib/cuker/high.rb CHANGED
@@ -5,34 +5,38 @@
5
5
  # CLI = HighLine.new
6
6
  #
7
7
  # DEFAULT_REPORT_FILE_NAME = 'DEFAULT_REPORT_NAME'
8
- # # DEFAULT_FEATURES_PATH = "../../features/uat/gcm/jira_stories/"
8
+ # # DEFAULT_FEATURES_PATH = "../../features/"
9
9
  # DEFAULT_FEATURES_PATH = "."
10
10
  # # DEFAULT_REPORT_PATH = './reports'
11
11
  #
12
12
  # def ask_for_input_location
13
13
  # loc = CLI.ask "\nType your JIRA number:\n"
14
- # File.join DEFAULT_FEATURES_PATH, '**', loc
14
+ # [File.join(DEFAULT_FEATURES_PATH, '**', loc), loc]
15
15
  # end
16
16
  #
17
- # def ask_for_output_file_name
18
- # name = CLI.ask "\nType your report file name: \n[hit enter to use default name => '#{DEFAULT_REPORT_FILE_NAME}']\n"
19
- # name.empty? ? DEFAULT_REPORT_FILE_NAME : name
17
+ # def ask_for_output_file_name default = DEFAULT_REPORT_FILE_NAME
18
+ # # name = CLI.ask "\nType your report file name: \n[hit enter to use this default name => '#{default}']\n"
19
+ # name = CLI.ask "\nHit enter to use this default name for your output file => '#{default}'\n[if not, please type in the name you want]\n"
20
+ # name.empty? ? default : name
20
21
  # end
21
22
  #
22
23
  # def handle_call preset
23
24
  # begin
24
- # feat_path = ask_for_input_location
25
- # report_name = ask_for_output_file_name
26
- # file_name = CCC.report preset, report_name, feat_path
27
- # CLI.say("\n\nCreated '#{preset}' @ '#{file_name}' ... Enjoy!\n") if file_name
25
+ # feat_path, default_file_name = ask_for_input_location
26
+ # report_name = ask_for_output_file_name("#{preset}_#{default_file_name.empty? ? DEFAULT_REPORT_FILE_NAME : default_file_name}")
27
+ # file_name = CCC.report preset, feat_path, report_name
28
+ # CLI.say("\n\nCreated '#{preset}' @ \n'#{file_name}' ... Enjoy!\n") if file_name
28
29
  # rescue Exception
29
- # puts "An Error occured\nplease contact NarenSS (v675166) for more details\n"
30
+ # puts "An Error occured while \nplease contact NarenSS (v675166) for more details\n"
30
31
  # puts e
31
32
  # end
32
33
  # end
33
34
  #
34
35
  # def exit_message
35
- # CLI.say("Thank you for using Cuker :)\nFeel free to reach out to NarenSS (v675166) for any feature request\nHave a very good day!")
36
+ # CLI.say("\nThank you for using Cuker (a Gherkin Reporting Tool) :)\n
37
+ # Have Feature requests or Usage questions?
38
+ # Feel free to reach out to NarenSS (v675166)\n
39
+ # Have a very good day!")
36
40
  # exit
37
41
  # end
38
42
  #
@@ -50,13 +54,13 @@
50
54
  # end
51
55
  # end
52
56
  #
53
- # menu.choice(:quit) {exit_message}
57
+ # menu.choice(:quit) { exit_message }
54
58
  # menu.default = :quit
55
59
  # end
56
60
  #
57
- # answer = CLI.ask "\nWant to rerun? \n[ type anything and hit enter to rerun\nor just hit enter to quit this program ]\n"
58
- # break if answer.empty?
61
+ # answer = CLI.agree "\nWant to rerun? \n y [n]\n"
62
+ # break unless answer
59
63
  # puts "\n... rebooting ...\n\n"
60
64
  # end
61
65
  #
62
- # exit_message
66
+ # exit_message
data/lib/cuker/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cuker
2
- VERSION = "0.3.17"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -4,7 +4,7 @@ module IModel
4
4
  method :write_title
5
5
  method :write_new_row
6
6
 
7
- method :make_file
7
+ method :make_new_file
8
8
  method :write_new_sheet
9
9
  end
10
10
 
@@ -34,18 +34,17 @@ class AbstractModel
34
34
  ary_of_hshs.map(&:keys).flatten
35
35
  end
36
36
 
37
- # utility methods
38
- # used by any model
37
+ # utility methods
38
+ # used by any model
39
39
 
40
40
  def name_merge hsh
41
41
  str = ""
42
42
  @log.warn "name merge for #{hsh}"
43
43
  str += hsh[:name].strip.force_encoding("UTF-8") if hsh[:name]
44
- str += " - #{hsh[:description].strip.force_encoding("UTF-8")}" if hsh[:description]
44
+ str += "\n#{hsh[:description].strip.force_encoding("UTF-8")}" if hsh[:description]
45
45
  str
46
46
  end
47
47
 
48
-
49
48
  def union feat_tags, tags
50
49
  (feat_tags.to_set | tags.to_set).to_a # union
51
50
  end
@@ -56,8 +55,8 @@ class AbstractModel
56
55
  simple_surround ary.join(sep), sep
57
56
  end
58
57
 
59
- def simple_surround item, sep
60
- "#{sep}#{item}#{sep}"
58
+ def simple_surround item, sep, r_sep = nil
59
+ "#{sep}#{item}#{r_sep || sep}"
61
60
  end
62
61
 
63
62
  # def padded_surround item, sep, pad
@@ -4,7 +4,7 @@ module IWriter
4
4
  method :write_title
5
5
  method :write_new_row
6
6
 
7
- method :make_file
7
+ method :make_new_file
8
8
  method :write_new_sheet
9
9
  end
10
10
 
@@ -14,7 +14,12 @@ class AbstractWriter
14
14
 
15
15
  NoNewFileMadeError = Class.new IOError
16
16
 
17
+ # File Extension
17
18
  attr_accessor :ext
19
+
20
+ # Active file name
21
+ attr_accessor :active_file_name
22
+
18
23
  attr_accessor :sheets, :active_sheet
19
24
  attr_reader :out_dir
20
25
 
@@ -36,18 +41,28 @@ class AbstractWriter
36
41
  end
37
42
 
38
43
  def raise_unless_active_loc data
39
- raise NoNewFileMadeError.new "Please run 'make_file' before trying to write: '#{data}'" if @active_sheet.nil?
44
+ raise NoNewFileMadeError.new "Please run 'make_new_file' before trying to write: '#{data}'" if @active_sheet.nil?
40
45
  end
41
46
 
42
47
  def make_new_sheet name = nil
43
- file_name = name.nil? ? "Sheet_#{@sheets.size + 1}" : name
44
- @log.debug "make a new abstract sheet: #{file_name}"
45
- file_name
46
- # todo: file name collision handle
48
+ sheet = new_name name
49
+ @log.debug "make a new abstract sheet: #{sheet}"
50
+ sheet
51
+ # todo: file name collision handle!!
52
+ end
53
+
54
+ def make_new_file name
55
+ @log.debug "make a new abstract file: #{name}#{@ext}"
56
+ make_name name
47
57
  end
48
58
 
49
- def make_file name
50
- @log.debug "make a new abstract file: #{name}"
59
+ # @return [String] name with ext path added
60
+ def make_name name
61
+ "#{new_name name}#{@ext}"
62
+ end
63
+
64
+ def new_name name
65
+ name.nil? ? "Sheet_#{@sheets.size + 1}" : name
51
66
  end
52
67
  end
53
68
 
@@ -68,6 +83,7 @@ class AbstractSheet
68
83
  def add_row ary
69
84
  @rows << ary
70
85
  end
86
+
71
87
  alias :add_line :add_row
72
88
 
73
89
  # @return ary of rows
@@ -21,13 +21,15 @@ class CsvWriter < AbstractWriter
21
21
 
22
22
  def make_new_sheet name
23
23
  @log.debug "csv make new sheet"
24
- path = super name
25
- @sheets[path] = CsvSheet.new path, @ext
26
- @active_sheet = @sheets[path]
24
+ #todo: dangit! handling this path naming properly
25
+ file_name = "#{name.nil? ? super(name) : name}#{ext}"
26
+ @sheets[file_name] = CsvSheet.new file_name
27
+ @active_sheet = @sheets[file_name]
28
+ file_name
27
29
  end
28
30
 
29
- def make_file name
30
- super name
31
+ def make_new_file name
32
+ path = super name
31
33
  make_new_sheet name
32
34
  end
33
35
  end
@@ -38,8 +40,7 @@ require 'csv'
38
40
  # {file:https://docs.ruby-lang.org/en/2.1.0/CSV.html CSV usage documentation}
39
41
 
40
42
  class CsvSheet < AbstractSheet
41
- def initialize path, ext
42
- file_name = "#{path}#{ext}"
43
+ def initialize file_name
43
44
  super file_name
44
45
  @csv_sheet = CSV.open(file_name, "wb")
45
46
  end
@@ -3,14 +3,23 @@ module Cuker
3
3
  class JiraModel < AbstractModel
4
4
  include LoggerSetup
5
5
 
6
+ JIRA_BLANK = ' '
7
+ JIRA_TITLE_SEP = '||'
8
+ JIRA_ROW_SEP = '|'
9
+ JIRA_EMPTY_LINE = '(empty line)'
10
+ JIRA_NEW_LINE = '\\\\'
11
+ JIRA_HORIZ_RULER = '----'
12
+
6
13
  JIRA_ICONS = {
7
14
  info: "(i)",
8
15
  pass: "(/)",
9
16
  fail: "(x)",
10
17
  exclam: "(!)",
11
18
  question: "(?)",
19
+ empty: JIRA_BLANK
12
20
  }
13
21
 
22
+
14
23
  def initialize ast_map
15
24
  super
16
25
  @log.trace "initing #{self.class}"
@@ -55,34 +64,41 @@ module Cuker
55
64
  @asts.each do |file_path, ast|
56
65
  @file_path = file_path
57
66
  in_feat_counter = 0
67
+ @feat_printed = false
58
68
  if ast[:type] == :GherkinDocument
59
69
  in_feature(ast) do |feat_tags_ary, feat_title, feat_item|
60
70
  in_item(feat_item) do |tags_ary, title, type, content_ary|
61
71
  row_hsh = {}
62
- if type == :Background
72
+ if type == :Background or type == :Feature
73
+ @feat_printed = true
74
+ title_str = ''
75
+ # feat handle
76
+ title_str += jira_title 'Feature', feat_title
77
+ title_str += jira_title('Background', title) if title
63
78
  row_hsh = {
64
79
  :s_num => "#{feat_counter}",
65
- :s_title => "Feature: #{feat_title}\nBackground: #{title}",
80
+ :s_title => surround_panel(title_str),
66
81
  :s_content => surround_panel(content_ary.join("\n")),
67
82
  :item => simple_surround(JIRA_ICONS[:empty], '|'),
68
83
  }
69
84
  elsif type == :Scenario or type == :ScenarioOutline
70
85
  row_hsh = {
71
86
  :s_num => "#{feat_counter}.#{in_feat_counter += 1}",
72
- :s_title => title,
87
+ :s_title => surround_panel(jira_title(type, title)),
73
88
  :s_content => surround_panel(content_ary.join("\n")),
74
- :item => simple_surround(JIRA_ICONS[type == :ScenarioOutline ? :info : :exclam], '|'),
89
+ # :item => simple_surround(JIRA_ICONS[type == :ScenarioOutline ? :info : :exclam], '|'),
90
+ :item => simple_surround(JIRA_ICONS[:info], '|'),
75
91
  }
76
92
  elsif type == :Examples
77
93
  row_hsh = {
78
94
  :s_num => "#{feat_counter}.#{in_feat_counter}.x",
79
- :s_title => title, # example title
95
+ :s_title => surround_panel(jira_title(type, title)), # example title
80
96
  :s_content => surround_panel(content_ary.join("\n")),
81
97
  :item => simple_surround(JIRA_ICONS[:info], '|'),
82
98
  }
83
99
  end
84
100
  row_ary = []
85
- get_keys_ary(@order).each {|k| row_ary << row_hsh[k]}
101
+ get_keys_ary(@order).each {|k| row_ary << jira_arg_hilight(row_hsh[k])}
86
102
  res << surround(row_ary, '|')
87
103
  end
88
104
  end
@@ -112,6 +128,9 @@ module Cuker
112
128
  tags = get_tags child
113
129
  if child[:type] == :Background
114
130
  yield tags, item_title, child[:type], get_steps(child)
131
+ elsif !@feat_printed
132
+ yield [], JIRA_BLANK, :Feature, [JIRA_BLANK]
133
+ yield tags, item_title, child[:type], get_steps(child)
115
134
  elsif child[:type] == :Scenario
116
135
  yield tags, item_title, child[:type], get_steps(child)
117
136
  elsif child[:type] == :ScenarioOutline
@@ -141,9 +160,9 @@ module Cuker
141
160
  res = []
142
161
  examples.each do |example|
143
162
  if example[:type] == :Examples
144
- res << " "
163
+ res << JIRA_HORIZ_RULER
145
164
 
146
- eg_title = "Examples: #{name_merge(example)}"
165
+ eg_title = jira_title 'Examples', name_merge(example)
147
166
  res << eg_title
148
167
 
149
168
  eg_header = surround(in_table_row(example[:tableHeader]), '||')
@@ -170,9 +189,11 @@ module Cuker
170
189
 
171
190
  def in_table_cell cell_hsh
172
191
  if cell_hsh[:type] == :TableCell
173
- cell_hsh[:value]
192
+ val = cell_hsh[:value].strip
193
+ val.empty? ? JIRA_BLANK : val
174
194
  else
175
195
  @log.warn "Expected :TableCell in #{cell_hsh} @ #{@file_path}"
196
+ JIRA_BLANK
176
197
  end
177
198
  end
178
199
 
@@ -180,10 +201,14 @@ module Cuker
180
201
  steps.each do |step|
181
202
  if step[:type] == :Step
182
203
  step_ary = []
183
- step_ary << [
184
- "*#{step[:keyword].strip}*", # bolding the keywords
185
- step[:text].strip
186
- ].join(" ")
204
+ step_str = [
205
+ ((jira_bold(step[:keyword].strip)).rjust(7)), # bolding the keywords
206
+ (step[:text].strip)
207
+ ].join(' ')
208
+
209
+ # step_ary << jira_monospace(step_str)
210
+ step_ary << (step_str)
211
+
187
212
  step_ary += in_step_args(step[:argument]) if step[:argument]
188
213
  # todo: padding as needed
189
214
  yield step_ary
@@ -193,6 +218,7 @@ module Cuker
193
218
  end
194
219
  end
195
220
 
221
+ # helps handle tables for now
196
222
  def in_step_args arg
197
223
  if arg[:type] == :DataTable
198
224
  res = []
@@ -218,5 +244,36 @@ module Cuker
218
244
  end
219
245
  end
220
246
 
247
+ def surround_color str, color = nil
248
+ if title
249
+ "{color:#{color}} #{str} {color}"
250
+ else
251
+ "{color} #{str} {color}"
252
+ end
253
+ end
254
+
255
+ def jira_title keyword, title
256
+ "#{jira_bold "#{keyword}:"} #{title}\n "
257
+ end
258
+
259
+ def jira_arg_hilight(str)
260
+ str.gsub(/<(.*)>/, jira_bold_italics('<\1>'))
261
+ end
262
+
263
+ def jira_bold str
264
+ simple_surround str, '*'
265
+ end
266
+
267
+ def jira_monospace str
268
+ simple_surround str, '{{', '}}'
269
+ end
270
+
271
+ def jira_bold_italics(str)
272
+ jira_bold(jira_italics(str))
273
+ end
274
+
275
+ def jira_italics(str)
276
+ simple_surround(str, '_')
277
+ end
221
278
  end
222
279
  end
@@ -0,0 +1,60 @@
1
+ require_relative 'abstract_writer'
2
+ module Cuker
3
+ class JiraMonoModel < JiraModel
4
+ include LoggerSetup
5
+
6
+ def in_table_cell cell_hsh
7
+ if cell_hsh[:type] == :TableCell
8
+ val = cell_hsh[:value].strip
9
+ val.empty? ? JIRA_BLANK : jira_monospace(val)
10
+ else
11
+ @log.warn "Expected :TableCell in #{cell_hsh} @ #{@file_path}"
12
+ JIRA_BLANK
13
+ end
14
+ end
15
+
16
+ def in_step(steps)
17
+ steps.each do |step|
18
+ if step[:type] == :Step
19
+ step_ary = []
20
+ step_str = [
21
+ (jira_monospace(jira_bold(step[:keyword].strip)).rjust(11)), # bolding the keywords
22
+ jira_monospace(step[:text].strip)
23
+ ].join(' ')
24
+
25
+ # step_ary << jira_monospace(step_str)
26
+ step_ary << (step_str)
27
+
28
+ step_ary += in_step_args(step[:argument]) if step[:argument]
29
+ # todo: padding as needed
30
+ yield step_ary
31
+ else
32
+ @log.warn "Unknown type '#{item[:type]}' found in file @ #{@file_path}"
33
+ end
34
+ end
35
+ end
36
+
37
+ # helps handle tables for now
38
+ def in_step_args arg
39
+ if arg[:type] == :DataTable
40
+ res = []
41
+ arg[:rows].each_with_index do |row, i|
42
+ sep = i == 0 ? '||' : '|'
43
+ res << surround(row[:cells].map {|hsh| jira_monospace(hsh[:value])}, sep)
44
+ end
45
+ return res
46
+ elsif arg[:type] == :DocString
47
+ # todo: handle if needed
48
+ @log.warn "Docstrings found in '#{arg}' found in file @ #{@file_path}"
49
+ else
50
+ @log.warn "Unknown type '#{arg[:type]}' found in file @ #{@file_path}"
51
+ end
52
+ []
53
+ end
54
+
55
+ def jira_monospace str
56
+ simple_surround str, '{{', '}}'
57
+ end
58
+
59
+ end
60
+ end
@@ -22,26 +22,26 @@ class JiraWriter < AbstractWriter
22
22
  def make_new_sheet name = nil
23
23
  @log.debug "JW make new sheet"
24
24
  path = super name
25
- @sheets[path] = JiraFile.new path, @ext
26
- @active_sheet = @sheets[path]
25
+ path
27
26
  end
28
27
 
29
- def make_file name
30
- super name
31
- make_new_sheet name
28
+ def make_new_file name
29
+ path = super name
30
+ @sheets[path] = JiraFile.new path
31
+ @active_sheet = @sheets[path]
32
+ path
32
33
  end
33
34
  end
34
35
 
35
36
  class JiraFile < AbstractSheet
36
- def initialize path, ext
37
- file_name = "#{path}#{ext}"
37
+ def initialize file_name
38
38
  super file_name
39
- @csv_sheet = File.open(file_name, "wb")
39
+ @jira_file = File.open(file_name, "wb")
40
40
  end
41
41
 
42
42
  def add_line line
43
43
  super line
44
- @log.warn "argument not a String.. instead is a '#{line.class}' -> '#{line}'" unless line.is_a? String
44
+ @log.error "argument not a String.. instead is a '#{line.class}' -> '#{line}'" unless line.is_a? String
45
45
  File.open(@name, "ab") do |file|
46
46
  file << "#{line}\n"
47
47
  end
@@ -22,7 +22,7 @@ class RubyXLWriter < AbstractWriter
22
22
  @sheets[name] = RubyXLSheet.new path
23
23
  end
24
24
 
25
- def make_file name
25
+ def make_new_file name
26
26
  super name
27
27
  end
28
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.17
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ufo2mstar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-14 00:00:00.000000000 Z
11
+ date: 2019-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -183,6 +183,7 @@ files:
183
183
  - lib/cuker/writer_helper/csv_model.rb
184
184
  - lib/cuker/writer_helper/csv_writer.rb
185
185
  - lib/cuker/writer_helper/jira_model.rb
186
+ - lib/cuker/writer_helper/jira_mono_model.rb
186
187
  - lib/cuker/writer_helper/jira_writer.rb
187
188
  - lib/cuker/writer_helper/ruby_x_l_writer.rb
188
189
  - lib/cuker/writer_helper/title.rb