cuker 0.5.7 → 0.5.15
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 +4 -4
- data/Gemfile +2 -1
- data/cuker.gemspec +2 -1
- data/lib/cuker/gherkin_reporter.rb +2 -0
- data/lib/cuker/helpers/formatters/jira_model.rb +2 -2
- data/lib/cuker/helpers/formatters/ruby_x_l_model.rb +47 -71
- data/lib/cuker/helpers/writers/abstract_writer.rb +15 -6
- data/lib/cuker/helpers/writers/csv_writer.rb +5 -5
- data/lib/cuker/helpers/writers/jira_writer.rb +5 -5
- data/lib/cuker/helpers/writers/ruby_x_l_writer.rb +111 -25
- data/lib/cuker/helpers/writers/simple_macro_template.xlsm +0 -0
- data/lib/cuker/test/book1.rb +25 -0
- data/lib/cuker/test/ruby_xl.rb +2 -0
- data/lib/cuker/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53ee9df71c45ebfe470bc55fac4b042237a53a5bbc13b54f0626d0aa79f157f2
|
4
|
+
data.tar.gz: 9dbb308de7cade288292180fec03a0eeaa5e7cd1d615b1ba05eb574d988da6a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2eff443de2f3ae8d757c8b15abb6ef286dd70561fc0f07e0e16460d5b425772a99533fe9b5e9f8fa62da81ce49e047e975e16c38ace3866128d00b893261cd3
|
7
|
+
data.tar.gz: 2379c423926e94ea62c6fa07da8e1dbf2fc80da5bae39989ba76a9323b1d7bae1a1484cb6a7390969136f3b9f9bde6785cf9b963150c0b1268c4d547a20e2dad
|
data/Gemfile
CHANGED
data/cuker.gemspec
CHANGED
@@ -21,9 +21,11 @@ class GherkinReporter
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def write
|
24
|
+
# todo: why don't we just give the writer the model?
|
24
25
|
file_name = @writer.make_new_file @file_path
|
25
26
|
@writer.write_title @model.title
|
26
27
|
@model.data.each {|row| @writer.write_new_row row}
|
28
|
+
@writer.finishup
|
27
29
|
file_name
|
28
30
|
end
|
29
31
|
|
@@ -169,8 +169,8 @@ module Cuker
|
|
169
169
|
eg_header = surround(in_table_row(example[:tableHeader]), '||')
|
170
170
|
res << eg_header
|
171
171
|
|
172
|
-
|
173
|
-
|
172
|
+
eg_body = example[:tableBody]
|
173
|
+
eg_body.map {|row_hsh| res << surround(in_table_row(row_hsh), '|')}
|
174
174
|
|
175
175
|
else
|
176
176
|
@log.warn "Unknown type '#{item[:type]}' found in file @ #{@file_path}"
|
@@ -2,6 +2,7 @@ require_relative '../writers/abstract_writer'
|
|
2
2
|
|
3
3
|
module Cuker
|
4
4
|
module ExcelSupport
|
5
|
+
EXCEL_BLANK = ''
|
5
6
|
|
6
7
|
def surround_panel str, title = nil
|
7
8
|
if title
|
@@ -19,8 +20,13 @@ module Cuker
|
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
|
-
def
|
23
|
-
|
23
|
+
def excel_content_format ary
|
24
|
+
ary.join "\n"
|
25
|
+
end
|
26
|
+
|
27
|
+
def excel_title keyword, title_ary
|
28
|
+
# "#{excel_bold "#{keyword}:"}\n #{title}\n "
|
29
|
+
[excel_bold("#{keyword}:")] + title_ary
|
24
30
|
end
|
25
31
|
|
26
32
|
def excel_arg_hilight(str)
|
@@ -86,14 +92,6 @@ module Cuker
|
|
86
92
|
|
87
93
|
def make_order
|
88
94
|
[
|
89
|
-
# {:counter => "Sl.No"},
|
90
|
-
# {:feature_title => "Feature"},
|
91
|
-
# {:s_type => "Type"},
|
92
|
-
# {:s_title => "Title"},
|
93
|
-
# {:tags => special_tag_titles},
|
94
|
-
# {:file_s_num => "S.no"},
|
95
|
-
# {:file_name => "File"},
|
96
|
-
# {:other_tags => "Tags"},
|
97
95
|
{:counter => "Sl.No"},
|
98
96
|
{:feature => "Feature"},
|
99
97
|
{:background => "Background"},
|
@@ -102,8 +100,8 @@ module Cuker
|
|
102
100
|
{:result => "Result"},
|
103
101
|
{:tested_by => "Tested By"},
|
104
102
|
{:test_designer => "Test Designer"},
|
103
|
+
{:comments => "Comments"},
|
105
104
|
]
|
106
|
-
|
107
105
|
# todo: make title order reorderable
|
108
106
|
# todo: tag based reordering
|
109
107
|
end
|
@@ -134,68 +132,47 @@ module Cuker
|
|
134
132
|
end
|
135
133
|
|
136
134
|
feat_counter = 1
|
137
|
-
|
138
135
|
feat_content = ''
|
139
136
|
bg_content = ''
|
140
137
|
|
141
138
|
res = []
|
142
139
|
@asts.each do |file_path, ast|
|
143
|
-
|
144
140
|
@file_path = file_path
|
145
141
|
in_feat_counter = 0
|
146
|
-
# @feat_printed = false
|
147
142
|
|
148
143
|
if ast[:type] == :GherkinDocument
|
149
144
|
in_feature(ast) do |feat_tags_ary, feat_title, feat_item|
|
150
|
-
in_item(feat_item) do |tags_ary,
|
151
|
-
|
145
|
+
in_item(feat_item) do |tags_ary, type, item_title, content_ary, example_ary|
|
152
146
|
row_hsh = {}
|
153
|
-
|
154
147
|
if type == :Background or type == :Feature
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
title_str += excel_title 'Feature', feat_title
|
161
|
-
# title_str += excel_title('Background', title) if type == :Background
|
162
|
-
row_hsh = {
|
163
|
-
# :s_num => "#{feat_counter}",
|
164
|
-
# :s_title => surround_panel(title_str),
|
165
|
-
# :s_content => surround_panel(content_ary.join("\n")),
|
166
|
-
# :item => simple_surround(EXCEL_ICONS[:empty], '|'),
|
167
|
-
}
|
168
|
-
feat_content = "Feature:\n#{title_str}"
|
169
|
-
bg_content = content_ary.join("\n")
|
170
|
-
elsif type == :Scenario or type == :ScenarioOutline
|
171
|
-
# row_hsh = {
|
172
|
-
# :s_num => "#{feat_counter}.#{in_feat_counter += 1}",
|
173
|
-
# :s_title => surround_panel(excel_title(type, title)),
|
174
|
-
# :s_content => surround_panel(content_ary.join("\n")),
|
175
|
-
# # :item => simple_surround(EXCEL_ICONS[type == :ScenarioOutline ? :info : :exclam], '|'),
|
176
|
-
# :item => simple_surround(EXCEL_ICONS[:info], '|'),
|
148
|
+
feat_content = excel_title FEATURE, feat_title
|
149
|
+
bg_content = [excel_title(BACKGROUND, item_title)] + content_ary
|
150
|
+
else
|
151
|
+
# if type == :Scenario or type == :ScenarioOutline
|
152
|
+
scen_content = [excel_title(type.to_s, item_title)] + content_ary
|
177
153
|
|
178
154
|
row_hsh[:counter] = "#{feat_counter}.#{in_feat_counter += 1}"
|
179
|
-
row_hsh[:feature] =
|
180
|
-
row_hsh[:background] = bg_content
|
181
|
-
row_hsh[:scenario] =
|
182
|
-
|
183
|
-
row_hsh[:result] = ""
|
155
|
+
row_hsh[:feature] = excel_content_format feat_content
|
156
|
+
row_hsh[:background] = excel_content_format bg_content
|
157
|
+
row_hsh[:scenario] = excel_content_format scen_content
|
158
|
+
row_hsh[:result] = EXCEL_CONSTS::RESULT::PENDING
|
184
159
|
row_hsh[:tested_by] = ""
|
185
160
|
row_hsh[:test_designer] = ""
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
161
|
+
row_hsh[:comments] = ""
|
162
|
+
|
163
|
+
if type == :ScenarioOutline
|
164
|
+
row_hsh[:examples] = excel_content_format example_ary
|
165
|
+
end
|
166
|
+
row_ary = []
|
167
|
+
get_keys_ary(@order).each {|k| row_ary << (row_hsh[k])}
|
168
|
+
# get_keys_ary(@order).each {|k| row_ary << excel_arg_hilight(row_hsh[k])}
|
169
|
+
res << row_ary
|
190
170
|
end
|
191
|
-
row_ary = []
|
192
|
-
# get_keys_ary(@order).each {|k| row_ary << excel_arg_hilight(row_hsh[k])}
|
193
|
-
res << row_ary
|
194
171
|
end
|
195
172
|
end
|
196
173
|
end
|
197
174
|
feat_counter += 1
|
198
|
-
|
175
|
+
feat_title = ''
|
199
176
|
bg_content = ''
|
200
177
|
end
|
201
178
|
@file_path = nil
|
@@ -207,7 +184,7 @@ module Cuker
|
|
207
184
|
feat = hsh[:feature]
|
208
185
|
|
209
186
|
feat_tags = get_tags feat
|
210
|
-
feat_title =
|
187
|
+
feat_title = get_title_ary feat
|
211
188
|
|
212
189
|
children = feat[:children]
|
213
190
|
children.each {|child| yield feat_tags, feat_title, child}
|
@@ -217,17 +194,17 @@ module Cuker
|
|
217
194
|
end
|
218
195
|
|
219
196
|
def in_item(child)
|
220
|
-
item_title =
|
197
|
+
item_title = get_title_ary child
|
221
198
|
tags = get_tags child
|
222
199
|
if child[:type] == :Background
|
223
|
-
yield tags,
|
200
|
+
yield tags, child[:type], item_title, get_steps(child), []
|
224
201
|
# elsif !@feat_printed
|
225
202
|
# yield [], EXCEL_BLANK, :Feature, [EXCEL_BLANK]
|
226
|
-
# yield tags,
|
203
|
+
# yield tags, child[:type], item_title, get_steps(child), []
|
227
204
|
elsif child[:type] == :Scenario
|
228
|
-
yield tags,
|
205
|
+
yield tags, child[:type], item_title, get_steps(child), []
|
229
206
|
elsif child[:type] == :ScenarioOutline
|
230
|
-
yield tags,
|
207
|
+
yield tags, child[:type], item_title, get_steps(child), get_examples(child[:examples])
|
231
208
|
# todo: think about new examples in new lines
|
232
209
|
else
|
233
210
|
@log.warn "Unknown type '#{child[:type]}' found in file @ #{@file_path}"
|
@@ -239,7 +216,7 @@ module Cuker
|
|
239
216
|
if step[:type] == :Step
|
240
217
|
step_ary = []
|
241
218
|
step_str = [
|
242
|
-
((excel_bold(step[:keyword].strip)).rjust(
|
219
|
+
((excel_bold(step[:keyword].strip)).rjust(6)), # bolding the keywords
|
243
220
|
(step[:text].strip)
|
244
221
|
].join(' ')
|
245
222
|
|
@@ -261,8 +238,8 @@ module Cuker
|
|
261
238
|
if arg[:type] == :DataTable
|
262
239
|
res = []
|
263
240
|
arg[:rows].each_with_index do |row, i|
|
264
|
-
|
265
|
-
|
241
|
+
sep = i == 0 ? EXCEL_TITLE_SEP : EXCEL_ROW_SEP
|
242
|
+
res << surround(row[:cells].map {|hsh| excel_blank_pad hsh[:value]}, sep)
|
266
243
|
end
|
267
244
|
return res
|
268
245
|
elsif arg[:type] == :DocString
|
@@ -292,14 +269,14 @@ module Cuker
|
|
292
269
|
if example[:type] == :Examples
|
293
270
|
# res << EXCEL_HORIZ_RULER
|
294
271
|
|
295
|
-
eg_title = excel_title
|
272
|
+
eg_title = excel_title EXAMPLES, get_title_ary(example)
|
296
273
|
res << eg_title
|
297
274
|
|
298
275
|
eg_header = surround(get_table_row(example[:tableHeader]), EXCEL_TITLE_SEP)
|
299
276
|
res << eg_header
|
300
277
|
|
301
|
-
|
302
|
-
|
278
|
+
eg_body = example[:tableBody]
|
279
|
+
eg_body.map {|row_hsh| res << surround(get_table_row(row_hsh), EXCEL_ROW_SEP)}
|
303
280
|
|
304
281
|
else
|
305
282
|
@log.warn "Unknown type '#{example[:type]}' found in file @ #{@file_path}"
|
@@ -327,12 +304,11 @@ module Cuker
|
|
327
304
|
end
|
328
305
|
end
|
329
306
|
|
330
|
-
def
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
str
|
307
|
+
def get_title_ary hsh, max_len = TITLE_MAX_LEN
|
308
|
+
title_ary = []
|
309
|
+
title_ary << hsh[:name].strip.force_encoding("UTF-8") if hsh[:name]
|
310
|
+
title_ary << hsh[:description].strip.force_encoding("UTF-8") if hsh[:description]
|
311
|
+
title_ary
|
336
312
|
end
|
337
313
|
|
338
314
|
|
@@ -340,7 +316,7 @@ module Cuker
|
|
340
316
|
attr_accessor :name, :title, :pattern
|
341
317
|
end
|
342
318
|
|
343
|
-
module
|
319
|
+
module EXCEL_CONSTS
|
344
320
|
module RESULT
|
345
321
|
PENDING = "Pending"
|
346
322
|
PASS = "Pass"
|
@@ -7,6 +7,7 @@ module Cuker
|
|
7
7
|
|
8
8
|
method :make_new_file
|
9
9
|
method :write_new_sheet
|
10
|
+
method :finishup
|
10
11
|
end
|
11
12
|
|
12
13
|
class AbstractWriter
|
@@ -21,7 +22,7 @@ module Cuker
|
|
21
22
|
# Active file name
|
22
23
|
attr_accessor :active_file_name
|
23
24
|
|
24
|
-
attr_accessor :
|
25
|
+
attr_accessor :book, :active_file
|
25
26
|
attr_reader :out_dir
|
26
27
|
|
27
28
|
def initialize
|
@@ -29,8 +30,8 @@ module Cuker
|
|
29
30
|
# @out_dir = output_path
|
30
31
|
# FileUtils.mkdir_p(output_path) unless Dir.exist? output_path
|
31
32
|
@log.debug "initing AbstractWriter"
|
32
|
-
@
|
33
|
-
@
|
33
|
+
@active_file = nil
|
34
|
+
@book = {}
|
34
35
|
end
|
35
36
|
|
36
37
|
def write_title data
|
@@ -42,7 +43,7 @@ module Cuker
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def raise_unless_active_loc data
|
45
|
-
raise NoNewFileMadeError.new "Please run 'make_new_file' before trying to write: '#{data}'" if @
|
46
|
+
raise NoNewFileMadeError.new "Please run 'make_new_file' before trying to write: '#{data}'" if @active_file.nil?
|
46
47
|
end
|
47
48
|
|
48
49
|
def make_new_sheet name = nil
|
@@ -52,6 +53,10 @@ module Cuker
|
|
52
53
|
# todo: file name collision handle!!
|
53
54
|
end
|
54
55
|
|
56
|
+
def finishup
|
57
|
+
@log.debug "closing up #{@name} file if needed"
|
58
|
+
end
|
59
|
+
|
55
60
|
def make_new_file name
|
56
61
|
@log.debug "make a new abstract file: #{name}#{@ext}"
|
57
62
|
make_name name
|
@@ -63,11 +68,11 @@ module Cuker
|
|
63
68
|
end
|
64
69
|
|
65
70
|
def new_name name
|
66
|
-
name.nil? ? "Sheet_#{@
|
71
|
+
name.nil? ? "Sheet_#{@book.size + 1}" : name
|
67
72
|
end
|
68
73
|
end
|
69
74
|
|
70
|
-
class
|
75
|
+
class AbstractFile
|
71
76
|
include LoggerSetup
|
72
77
|
attr_accessor :name, :rows
|
73
78
|
|
@@ -91,6 +96,10 @@ module Cuker
|
|
91
96
|
def read_rows
|
92
97
|
@rows
|
93
98
|
end
|
99
|
+
|
100
|
+
def finishup
|
101
|
+
@log.debug "closing up #{@name} file if needed"
|
102
|
+
end
|
94
103
|
end
|
95
104
|
|
96
105
|
end
|
@@ -11,21 +11,21 @@ module Cuker
|
|
11
11
|
def write_title title_ary
|
12
12
|
super title_ary
|
13
13
|
@log.debug "csv write title"
|
14
|
-
@
|
14
|
+
@active_file.add_row title_ary
|
15
15
|
end
|
16
16
|
|
17
17
|
def write_new_row row_ary
|
18
18
|
super row_ary
|
19
19
|
@log.debug "csv write row: #{row_ary}"
|
20
|
-
@
|
20
|
+
@active_file.add_row row_ary
|
21
21
|
end
|
22
22
|
|
23
23
|
def make_new_sheet name
|
24
24
|
@log.debug "csv make new sheet"
|
25
25
|
#todo: dangit! handling this path naming properly
|
26
26
|
file_name = "#{name.nil? ? super(name) : name}#{ext}"
|
27
|
-
@
|
28
|
-
@
|
27
|
+
@book[file_name] = CsvFile.new file_name
|
28
|
+
@active_file = @book[file_name]
|
29
29
|
file_name
|
30
30
|
end
|
31
31
|
|
@@ -40,7 +40,7 @@ module Cuker
|
|
40
40
|
# extends sheet to give csv read/write-ability
|
41
41
|
# {file:https://docs.ruby-lang.org/en/2.1.0/CSV.html CSV usage documentation}
|
42
42
|
|
43
|
-
class
|
43
|
+
class CsvFile < AbstractFile
|
44
44
|
def initialize file_name
|
45
45
|
super file_name
|
46
46
|
@log.info "Making new #{self.class} => #{file_name}"
|
@@ -11,13 +11,13 @@ module Cuker
|
|
11
11
|
def write_title title_line
|
12
12
|
super title_line
|
13
13
|
@log.debug "JW write title: #{title_line}"
|
14
|
-
@
|
14
|
+
@active_file.add_line title_line
|
15
15
|
end
|
16
16
|
|
17
17
|
def write_new_row row_line
|
18
18
|
super row_line
|
19
19
|
@log.debug "JW write row: #{row_line}"
|
20
|
-
@
|
20
|
+
@active_file.add_line row_line
|
21
21
|
end
|
22
22
|
|
23
23
|
def make_new_sheet name = nil
|
@@ -28,13 +28,13 @@ module Cuker
|
|
28
28
|
|
29
29
|
def make_new_file name
|
30
30
|
path = super name
|
31
|
-
@
|
32
|
-
@
|
31
|
+
@book[path] = JiraFile.new path
|
32
|
+
@active_file = @book[path]
|
33
33
|
path
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
class JiraFile <
|
37
|
+
class JiraFile < AbstractFile
|
38
38
|
def initialize file_name
|
39
39
|
super file_name
|
40
40
|
@log.info "Making new #{self.class} => #{file_name}"
|
@@ -1,55 +1,141 @@
|
|
1
1
|
require_relative 'abstract_writer'
|
2
|
+
require 'rubyXL'
|
3
|
+
require 'rubyXL/convenience_methods'
|
2
4
|
|
3
5
|
module Cuker
|
4
6
|
class RubyXLWriter < AbstractWriter
|
5
7
|
def initialize
|
8
|
+
@ext = '.xlsm'
|
6
9
|
super
|
7
10
|
@log.debug "initing #{self.class}"
|
8
11
|
end
|
9
12
|
|
10
13
|
def write_title title_ary
|
11
|
-
|
12
|
-
@
|
14
|
+
super title_ary
|
15
|
+
@log.debug "rxl write title"
|
16
|
+
@active_file.add_row title_ary
|
13
17
|
end
|
14
18
|
|
15
19
|
def write_new_row row_ary
|
16
|
-
|
17
|
-
@
|
20
|
+
super row_ary
|
21
|
+
@log.debug "rxl write row: #{row_ary}"
|
22
|
+
@active_file.add_row row_ary
|
18
23
|
end
|
19
24
|
|
20
|
-
def
|
21
|
-
@log.debug "
|
22
|
-
path
|
23
|
-
|
25
|
+
def make_new_book name
|
26
|
+
@log.debug "rxl make new sheet"
|
27
|
+
#todo: dangit! handling this path naming properly
|
28
|
+
file_name = "#{name.nil? ? super(name) : name}#{ext}"
|
29
|
+
@book[file_name] = RubyXLFile.new file_name
|
30
|
+
@active_file = @book[file_name]
|
31
|
+
file_name
|
24
32
|
end
|
25
33
|
|
26
34
|
def make_new_file name
|
27
|
-
super name
|
35
|
+
path = super name
|
36
|
+
finishup
|
37
|
+
make_new_book name
|
38
|
+
end
|
39
|
+
|
40
|
+
def finishup
|
41
|
+
@active_file.finishup if @active_file
|
28
42
|
end
|
43
|
+
end
|
29
44
|
|
30
|
-
|
31
|
-
|
32
|
-
super file_name
|
33
|
-
@log.info "Making new #{self.class} => #{file_name}"
|
34
|
-
# @jira_file = File.open(file_name, "wb")
|
45
|
+
class RubyXLFile < AbstractFile
|
46
|
+
attr_accessor :workbook, :worksheets, :worksheet
|
35
47
|
|
36
|
-
|
37
|
-
end
|
48
|
+
def initialize file_name
|
38
49
|
|
39
|
-
|
40
|
-
|
41
|
-
|
50
|
+
premade = File.basename(file_name) =~ /xlsm/
|
51
|
+
# premade = true
|
52
|
+
# premade = false
|
53
|
+
template_file_name = './lib/cuker/helpers/writers/simple_macro_template.xlsm'
|
54
|
+
# template_file_name = './lib/cuker/helpers/writers/demo_file2.xlsm'
|
55
|
+
@file_name = premade ? template_file_name : file_name
|
56
|
+
|
57
|
+
super @file_name
|
58
|
+
@log.info "Making new #{self.class} => #{@file_name}"
|
59
|
+
|
60
|
+
@workbook = premade ? RubyXL::Parser.parse(@file_name) : RubyXL::Workbook.new
|
61
|
+
# @workbook.add_worksheet('Acceptance Tests')
|
62
|
+
# @workbook[0].sheet_name = 'Acceptance Tests'
|
63
|
+
|
64
|
+
@worksheets = @workbook.worksheets
|
65
|
+
|
66
|
+
# todo: delete sheet convenienve method
|
67
|
+
# @workbook['test_id'].delete
|
68
|
+
|
69
|
+
# delete_sheet 'null'
|
70
|
+
locate_sheet 'test_id'
|
71
|
+
|
72
|
+
# @worksheet = @workbook[0]
|
73
|
+
@worksheet = @workbook['Acceptance Tests']
|
74
|
+
|
75
|
+
|
76
|
+
@rows = sheet_rows.dup # starting Row
|
77
|
+
@offset = 0 # starting Col
|
42
78
|
|
43
|
-
|
44
|
-
|
79
|
+
# inserting a blank cell to make sure title format is not being copied
|
80
|
+
@worksheet.add_cell(@rows.size, @offset, ' ')
|
81
|
+
|
82
|
+
@file_name = file_name
|
83
|
+
end
|
84
|
+
|
85
|
+
def locate_sheet sheet_name
|
86
|
+
sheet_index = @workbook.worksheets.index {|x| x.sheet_name == sheet_name}
|
87
|
+
@link_sheet = @workbook.worksheets[sheet_index]
|
88
|
+
if sheet_index
|
89
|
+
@log.debug "located sheet #{sheet_name} @location #{sheet_index}"
|
90
|
+
# @workbook.worksheets.delete_at(sheet_index)
|
91
|
+
sheet_index
|
92
|
+
else
|
93
|
+
@log.error "no sheet named '#{sheet_name}' found.. available sheets []"
|
94
|
+
nil
|
45
95
|
end
|
96
|
+
end
|
46
97
|
|
47
|
-
|
98
|
+
def current_row
|
99
|
+
rows.size - 1
|
100
|
+
end
|
101
|
+
|
102
|
+
def current_col
|
103
|
+
@offset
|
104
|
+
end
|
48
105
|
|
49
|
-
|
50
|
-
|
51
|
-
|
106
|
+
def add_row ary
|
107
|
+
super ary
|
108
|
+
row, col = current_row, current_col
|
109
|
+
worksheet.insert_row(row)
|
110
|
+
ary.each do |val|
|
111
|
+
worksheet.insert_cell(row, col, val.to_s)
|
112
|
+
col += 1
|
52
113
|
end
|
114
|
+
|
115
|
+
link_sheet_name = "#{ary[0]} results"
|
116
|
+
workbook.add_worksheet(link_sheet_name)
|
117
|
+
back_link_value = @link_sheet[0][0].value
|
118
|
+
back_link_formula = @link_sheet[0][0].formula
|
119
|
+
@workbook[link_sheet_name].add_cell(0, 0, back_link_value, back_link_formula)
|
120
|
+
# workbook.worksheets <<
|
121
|
+
# (link_sheet_name)
|
122
|
+
|
123
|
+
@log.info workbook.worksheets.map(&:sheet_name)
|
124
|
+
@log.info sheet_rows
|
125
|
+
# @log.debug worksheet.rows
|
126
|
+
end
|
127
|
+
|
128
|
+
alias :add_line :add_row
|
129
|
+
|
130
|
+
# @return ary of rows
|
131
|
+
def sheet_rows
|
132
|
+
@worksheet.sheet_data.rows
|
133
|
+
end
|
134
|
+
|
135
|
+
def finishup
|
136
|
+
# @workbook.write("#{@name}")
|
137
|
+
@workbook.worksheets.delete_at(locate_sheet 'test_id') if locate_sheet 'test_id'
|
138
|
+
@workbook.write("#{@file_name}") if @workbook
|
53
139
|
end
|
54
140
|
end
|
55
141
|
end
|
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# require 'rubyXL'
|
2
|
+
# require 'rubyXL/convenience_methods/cell'
|
3
|
+
#
|
4
|
+
# workbook = RubyXL::Parser.parse './Book1.xlsx'
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# worksheets = workbook.worksheets
|
8
|
+
#
|
9
|
+
# worksheets.each do |worksheet|
|
10
|
+
# puts "Reading: #{worksheet.sheet_name}"
|
11
|
+
# num_rows = 0
|
12
|
+
#
|
13
|
+
# worksheet.each do |row|
|
14
|
+
# row_cells = row.cells.map(&:value)
|
15
|
+
# num_rows += 1
|
16
|
+
#
|
17
|
+
# # uncomment to print out row values
|
18
|
+
# puts row_cells.join ' '
|
19
|
+
# end
|
20
|
+
# puts "Read #{num_rows} rows"
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# workbook.write("res.xlsx")
|
24
|
+
#
|
25
|
+
# puts 'Done'
|
data/lib/cuker/test/ruby_xl.rb
CHANGED
data/lib/cuker/version.rb
CHANGED
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.5.
|
4
|
+
version: 0.5.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ufo2mstar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: text-table
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description: generates reports and gives some customizable formatting options
|
126
140
|
email:
|
127
141
|
- ufo2mstar@gmail.com
|
@@ -162,6 +176,7 @@ files:
|
|
162
176
|
- lib/cuker/helpers/writers/simple_macro_template.xlsm
|
163
177
|
- lib/cuker/high.rb
|
164
178
|
- lib/cuker/log_utils.rb
|
179
|
+
- lib/cuker/test/book1.rb
|
165
180
|
- lib/cuker/test/ruby_xl.rb
|
166
181
|
- lib/cuker/test/sablon-try.rb
|
167
182
|
- lib/cuker/test/template.docx
|