cuker 0.4.0 → 0.4.5
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/lib/cuker/gherkin_ripper.rb +1 -1
- data/lib/cuker/helpers/_interfact.rb +9 -0
- data/lib/cuker/helpers/formatters/abstract_model.rb +79 -0
- data/lib/cuker/{writer_helper → helpers/formatters}/csv_model.rb +1 -1
- data/lib/cuker/{writer_helper → helpers/formatters}/jira_model.rb +1 -1
- data/lib/cuker/{writer_helper → helpers/formatters}/jira_mono_model.rb +1 -1
- data/lib/cuker/helpers/writers/abstract_writer.rb +95 -0
- data/lib/cuker/helpers/writers/csv_writer.rb +62 -0
- data/lib/cuker/helpers/writers/jira_writer.rb +57 -0
- data/lib/cuker/helpers/writers/ruby_x_l_writer.rb +34 -0
- data/lib/cuker/version.rb +1 -1
- metadata +14 -27
- data/lib/cuker/gherkin_lexer.rb +0 -33
- data/lib/cuker/gherkin_parser.rb +0 -23
- data/lib/cuker/models/model_try.rb +0 -30
- data/lib/cuker/models/models_forming.rb +0 -65
- data/lib/cuker/models/models_ready.rb +0 -132
- data/lib/cuker/models/state.rb +0 -3
- data/lib/cuker/state/in_background.rb +0 -0
- data/lib/cuker/state/in_comment.rb +0 -3
- data/lib/cuker/state/in_feature.rb +0 -0
- data/lib/cuker/state/in_scenario.rb +0 -0
- data/lib/cuker/state/in_scenario_outline.rb +0 -0
- data/lib/cuker/state/in_table.rb +0 -0
- data/lib/cuker/state/in_tag.rb +0 -0
- data/lib/cuker/writer_helper/_interfact.rb +0 -7
- data/lib/cuker/writer_helper/abstract_model.rb +0 -75
- data/lib/cuker/writer_helper/abstract_writer.rb +0 -93
- data/lib/cuker/writer_helper/csv_writer.rb +0 -60
- data/lib/cuker/writer_helper/jira_writer.rb +0 -55
- data/lib/cuker/writer_helper/ruby_x_l_writer.rb +0 -32
- /data/lib/cuker/{helper → helpers}/file_helper.rb +0 -0
- /data/lib/cuker/{writer_helper → helpers/formatters}/title.rb +0 -0
- /data/lib/cuker/{helper → helpers}/gherkin_helper.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02035bad58d8e020d683213c6417d2b81d9fcd3c2c35ea6feff3234b38adbf9f
|
4
|
+
data.tar.gz: f1c2ea9f35d297a3e7d37f70f953c637302f1493eda2cfd3e69067a0b691997b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cfc0fb18e1b799eceffe2a3ec7f26822b27805682586dea9100bf573aac0bc15e9a28e3201fea8c950cb08be01ac07bfc476de0642e4f5331e121065a04d3f7
|
7
|
+
data.tar.gz: f347f0a0d79ea91bef37387c3a8531375bfd3ab8a49ed557eb3bdc3e9f715490f6a7f97c48cc83f044f00f6f068f87fb7aa0758e18a17298c2a1637dde2bc093
|
data/lib/cuker/gherkin_ripper.rb
CHANGED
@@ -0,0 +1,79 @@
|
|
1
|
+
module Cuker
|
2
|
+
module IModel
|
3
|
+
extend Interface
|
4
|
+
method :initialize
|
5
|
+
method :write_title
|
6
|
+
method :write_new_row
|
7
|
+
|
8
|
+
method :make_new_file
|
9
|
+
method :write_new_sheet
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
class AbstractModel
|
14
|
+
include LoggerSetup
|
15
|
+
|
16
|
+
# @return [Array] writable rows of title
|
17
|
+
# Defaults to []
|
18
|
+
attr_accessor :title
|
19
|
+
|
20
|
+
# @return [Array] writable array of rows of data
|
21
|
+
# Defaults to []
|
22
|
+
attr_accessor :data
|
23
|
+
|
24
|
+
def initialize _model_input = []
|
25
|
+
init_logger
|
26
|
+
@title = []
|
27
|
+
@data = []
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_values_ary ary_of_hshs
|
31
|
+
ary_of_hshs.map(&:values).flatten
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_keys_ary ary_of_hshs
|
35
|
+
ary_of_hshs.map(&:keys).flatten
|
36
|
+
end
|
37
|
+
|
38
|
+
# utility methods
|
39
|
+
# used by any model
|
40
|
+
|
41
|
+
def name_merge hsh
|
42
|
+
str = ""
|
43
|
+
@log.warn "name merge for #{hsh}"
|
44
|
+
str += hsh[:name].strip.force_encoding("UTF-8") if hsh[:name]
|
45
|
+
str += "\n#{hsh[:description].strip.force_encoding("UTF-8")}" if hsh[:description]
|
46
|
+
str
|
47
|
+
end
|
48
|
+
|
49
|
+
def union feat_tags, tags
|
50
|
+
(feat_tags.to_set | tags.to_set).to_a # union
|
51
|
+
end
|
52
|
+
|
53
|
+
# @param sep [String] seperator around the array objects
|
54
|
+
# @return [String] with an array surrounded by the sep
|
55
|
+
def surround ary, sep
|
56
|
+
# "#{sep}#{ary.is_a?(Array)? ary.join(sep) : ary}#{sep}"
|
57
|
+
# "#{sep}#{ary.join(sep)}#{sep}"
|
58
|
+
simple_surround ary.join(sep), sep
|
59
|
+
end
|
60
|
+
|
61
|
+
def simple_surround item, sep, r_sep = nil
|
62
|
+
"#{sep}#{item}#{r_sep || sep}"
|
63
|
+
end
|
64
|
+
|
65
|
+
# def padded_surround item, sep, pad
|
66
|
+
# "#{sep}#{pad}#{item}#{pad}#{sep}"
|
67
|
+
# end
|
68
|
+
|
69
|
+
def get_tags(hsh)
|
70
|
+
if hsh[:tags] and hsh[:tags].any?
|
71
|
+
hsh[:tags].map {|tag| tag[:name]}
|
72
|
+
else
|
73
|
+
@log.warn "No Tags found in #{hsh[:keyword]} @ #{@file_path}"
|
74
|
+
[]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Cuker
|
2
|
+
module IWriter
|
3
|
+
extend Interface
|
4
|
+
method :initialize
|
5
|
+
method :write_title
|
6
|
+
method :write_new_row
|
7
|
+
|
8
|
+
method :make_new_file
|
9
|
+
method :write_new_sheet
|
10
|
+
end
|
11
|
+
|
12
|
+
class AbstractWriter
|
13
|
+
include IWriter
|
14
|
+
include LoggerSetup
|
15
|
+
|
16
|
+
NoNewFileMadeError = Class.new IOError
|
17
|
+
|
18
|
+
# File Extension
|
19
|
+
attr_accessor :ext
|
20
|
+
|
21
|
+
# Active file name
|
22
|
+
attr_accessor :active_file_name
|
23
|
+
|
24
|
+
attr_accessor :sheets, :active_sheet
|
25
|
+
attr_reader :out_dir
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
init_logger
|
29
|
+
# @out_dir = output_path
|
30
|
+
# FileUtils.mkdir_p(output_path) unless Dir.exist? output_path
|
31
|
+
@log.debug "initing AbstractWriter"
|
32
|
+
@active_sheet = nil
|
33
|
+
@sheets = {}
|
34
|
+
end
|
35
|
+
|
36
|
+
def write_title data
|
37
|
+
raise_unless_active_loc data
|
38
|
+
end
|
39
|
+
|
40
|
+
def write_new_row data
|
41
|
+
raise_unless_active_loc data
|
42
|
+
end
|
43
|
+
|
44
|
+
def raise_unless_active_loc data
|
45
|
+
raise NoNewFileMadeError.new "Please run 'make_new_file' before trying to write: '#{data}'" if @active_sheet.nil?
|
46
|
+
end
|
47
|
+
|
48
|
+
def make_new_sheet name = nil
|
49
|
+
sheet = new_name name
|
50
|
+
@log.debug "make a new abstract sheet: #{sheet}"
|
51
|
+
sheet
|
52
|
+
# todo: file name collision handle!!
|
53
|
+
end
|
54
|
+
|
55
|
+
def make_new_file name
|
56
|
+
@log.debug "make a new abstract file: #{name}#{@ext}"
|
57
|
+
make_name name
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [String] name with ext path added
|
61
|
+
def make_name name
|
62
|
+
"#{new_name name}#{@ext}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def new_name name
|
66
|
+
name.nil? ? "Sheet_#{@sheets.size + 1}" : name
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class AbstractSheet
|
71
|
+
include LoggerSetup
|
72
|
+
attr_accessor :name, :rows
|
73
|
+
|
74
|
+
def initialize name
|
75
|
+
init_logger
|
76
|
+
@name = name
|
77
|
+
@rows = []
|
78
|
+
end
|
79
|
+
|
80
|
+
def current_row
|
81
|
+
@rows.size + 1
|
82
|
+
end
|
83
|
+
|
84
|
+
def add_row ary
|
85
|
+
@rows << ary
|
86
|
+
end
|
87
|
+
|
88
|
+
alias :add_line :add_row
|
89
|
+
|
90
|
+
# @return ary of rows
|
91
|
+
def read_rows
|
92
|
+
@rows
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative 'abstract_writer'
|
2
|
+
|
3
|
+
module Cuker
|
4
|
+
class CsvWriter < AbstractWriter
|
5
|
+
def initialize
|
6
|
+
@ext = '.csv'
|
7
|
+
super
|
8
|
+
@log.debug "initing #{self.class}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def write_title title_ary
|
12
|
+
super title_ary
|
13
|
+
@log.debug "csv write title"
|
14
|
+
@active_sheet.add_row title_ary
|
15
|
+
end
|
16
|
+
|
17
|
+
def write_new_row row_ary
|
18
|
+
super row_ary
|
19
|
+
@log.debug "csv write row: #{row_ary}"
|
20
|
+
@active_sheet.add_row row_ary
|
21
|
+
end
|
22
|
+
|
23
|
+
def make_new_sheet name
|
24
|
+
@log.debug "csv make new sheet"
|
25
|
+
#todo: dangit! handling this path naming properly
|
26
|
+
file_name = "#{name.nil? ? super(name) : name}#{ext}"
|
27
|
+
@sheets[file_name] = CsvSheet.new file_name
|
28
|
+
@active_sheet = @sheets[file_name]
|
29
|
+
file_name
|
30
|
+
end
|
31
|
+
|
32
|
+
def make_new_file name
|
33
|
+
path = super name
|
34
|
+
make_new_sheet name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
require 'csv'
|
39
|
+
# == CSV Sheet
|
40
|
+
# extends sheet to give csv read/write-ability
|
41
|
+
# {file:https://docs.ruby-lang.org/en/2.1.0/CSV.html CSV usage documentation}
|
42
|
+
|
43
|
+
class CsvSheet < AbstractSheet
|
44
|
+
def initialize file_name
|
45
|
+
super file_name
|
46
|
+
@csv_sheet = CSV.open(file_name, "wb")
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_row row_ary
|
50
|
+
super row_ary
|
51
|
+
@log.warn "argument not an array.. instead is a '#{row_ary.class}' -> '#{row_ary}'" unless row_ary.is_a? Array
|
52
|
+
CSV.open(@name, "ab") do |csv|
|
53
|
+
csv << row_ary
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return ary of rows
|
58
|
+
def read_rows
|
59
|
+
@rows = CSV.read(@name)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# require_relative 'abstract_writer'
|
2
|
+
|
3
|
+
module Cuker
|
4
|
+
class JiraWriter < AbstractWriter
|
5
|
+
def initialize
|
6
|
+
@ext = '.txt'
|
7
|
+
super
|
8
|
+
@log.debug "initing #{self.class}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def write_title title_line
|
12
|
+
super title_line
|
13
|
+
@log.debug "JW write title: #{title_line}"
|
14
|
+
@active_sheet.add_line title_line
|
15
|
+
end
|
16
|
+
|
17
|
+
def write_new_row row_line
|
18
|
+
super row_line
|
19
|
+
@log.debug "JW write row: #{row_line}"
|
20
|
+
@active_sheet.add_line row_line
|
21
|
+
end
|
22
|
+
|
23
|
+
def make_new_sheet name = nil
|
24
|
+
@log.debug "JW make new sheet"
|
25
|
+
path = super name
|
26
|
+
path
|
27
|
+
end
|
28
|
+
|
29
|
+
def make_new_file name
|
30
|
+
path = super name
|
31
|
+
@sheets[path] = JiraFile.new path
|
32
|
+
@active_sheet = @sheets[path]
|
33
|
+
path
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class JiraFile < AbstractSheet
|
38
|
+
def initialize file_name
|
39
|
+
super file_name
|
40
|
+
@jira_file = File.open(file_name, "wb")
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_line line
|
44
|
+
super line
|
45
|
+
@log.error "argument not a String.. instead is a '#{line.class}' -> '#{line}'" unless line.is_a? String
|
46
|
+
File.open(@name, "ab") do |file|
|
47
|
+
file << "#{line}\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return ary of rows
|
52
|
+
def read_rows
|
53
|
+
@rows = File.read(@name)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative 'abstract_writer'
|
2
|
+
|
3
|
+
module Cuker
|
4
|
+
class RubyXLWriter < AbstractWriter
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@log.debug "initing #{self.class}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def write_title title_ary
|
11
|
+
@log.debug "Rxl write title"
|
12
|
+
@active_sheet.add_row title_ary
|
13
|
+
end
|
14
|
+
|
15
|
+
def write_new_row row_ary
|
16
|
+
@log.debug "Rxl write row"
|
17
|
+
@active_sheet.add_row row_ary
|
18
|
+
end
|
19
|
+
|
20
|
+
def make_new_sheet name = nil
|
21
|
+
@log.debug "Rxl make new sheet"
|
22
|
+
path = super name
|
23
|
+
@sheets[name] = RubyXLSheet.new path
|
24
|
+
end
|
25
|
+
|
26
|
+
def make_new_file name
|
27
|
+
super name
|
28
|
+
end
|
29
|
+
|
30
|
+
class RubyXLSheet < AbstractSheet
|
31
|
+
#todo: finish class
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
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.4.
|
4
|
+
version: 0.4.5
|
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-
|
11
|
+
date: 2019-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -157,36 +157,23 @@ files:
|
|
157
157
|
- cuker.gemspec
|
158
158
|
- lib/cuker.rb
|
159
159
|
- lib/cuker/cuker_cmd.rb
|
160
|
-
- lib/cuker/gherkin_lexer.rb
|
161
|
-
- lib/cuker/gherkin_parser.rb
|
162
160
|
- lib/cuker/gherkin_reporter.rb
|
163
161
|
- lib/cuker/gherkin_ripper.rb
|
164
|
-
- lib/cuker/
|
165
|
-
- lib/cuker/
|
162
|
+
- lib/cuker/helpers/_interfact.rb
|
163
|
+
- lib/cuker/helpers/file_helper.rb
|
164
|
+
- lib/cuker/helpers/formatters/abstract_model.rb
|
165
|
+
- lib/cuker/helpers/formatters/csv_model.rb
|
166
|
+
- lib/cuker/helpers/formatters/jira_model.rb
|
167
|
+
- lib/cuker/helpers/formatters/jira_mono_model.rb
|
168
|
+
- lib/cuker/helpers/formatters/title.rb
|
169
|
+
- lib/cuker/helpers/gherkin_helper.rb
|
170
|
+
- lib/cuker/helpers/writers/abstract_writer.rb
|
171
|
+
- lib/cuker/helpers/writers/csv_writer.rb
|
172
|
+
- lib/cuker/helpers/writers/jira_writer.rb
|
173
|
+
- lib/cuker/helpers/writers/ruby_x_l_writer.rb
|
166
174
|
- lib/cuker/high.rb
|
167
175
|
- lib/cuker/log_utils.rb
|
168
|
-
- lib/cuker/models/model_try.rb
|
169
|
-
- lib/cuker/models/models_forming.rb
|
170
|
-
- lib/cuker/models/models_ready.rb
|
171
|
-
- lib/cuker/models/state.rb
|
172
|
-
- lib/cuker/state/in_background.rb
|
173
|
-
- lib/cuker/state/in_comment.rb
|
174
|
-
- lib/cuker/state/in_feature.rb
|
175
|
-
- lib/cuker/state/in_scenario.rb
|
176
|
-
- lib/cuker/state/in_scenario_outline.rb
|
177
|
-
- lib/cuker/state/in_table.rb
|
178
|
-
- lib/cuker/state/in_tag.rb
|
179
176
|
- lib/cuker/version.rb
|
180
|
-
- lib/cuker/writer_helper/_interfact.rb
|
181
|
-
- lib/cuker/writer_helper/abstract_model.rb
|
182
|
-
- lib/cuker/writer_helper/abstract_writer.rb
|
183
|
-
- lib/cuker/writer_helper/csv_model.rb
|
184
|
-
- lib/cuker/writer_helper/csv_writer.rb
|
185
|
-
- lib/cuker/writer_helper/jira_model.rb
|
186
|
-
- lib/cuker/writer_helper/jira_mono_model.rb
|
187
|
-
- lib/cuker/writer_helper/jira_writer.rb
|
188
|
-
- lib/cuker/writer_helper/ruby_x_l_writer.rb
|
189
|
-
- lib/cuker/writer_helper/title.rb
|
190
177
|
- reports/.gitignore
|
191
178
|
homepage: https://github.com/ufo2mstar/cuker
|
192
179
|
licenses:
|
data/lib/cuker/gherkin_lexer.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
module Cuker
|
2
|
-
class GherkinLexer
|
3
|
-
NonLexicalError = Class.new NotImplementedError
|
4
|
-
|
5
|
-
attr_reader :lexed_ary
|
6
|
-
attr :file_name
|
7
|
-
|
8
|
-
def initialize raw_str_ary, file_name = nil
|
9
|
-
@raw_strs_ary = raw_str_ary
|
10
|
-
@file_name = file_name
|
11
|
-
@lexed_ary = []
|
12
|
-
end
|
13
|
-
|
14
|
-
def lex
|
15
|
-
# temp = nil
|
16
|
-
@raw_strs_ary.each_with_index do |raw_str, line_num|
|
17
|
-
res = case raw_str
|
18
|
-
when /^\s*#/
|
19
|
-
Comment.new raw_str
|
20
|
-
else
|
21
|
-
raise NonLexicalError.new "unable to lex line: #{line_num} :'#{raw_str}' #{"in file #{@file_name}" if @file_name}"
|
22
|
-
end
|
23
|
-
# if temp
|
24
|
-
# temp.items << Comment.new raw_str
|
25
|
-
# else
|
26
|
-
# temp = nil
|
27
|
-
# end
|
28
|
-
@lexed_ary << res
|
29
|
-
end
|
30
|
-
@lexed_ary
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/cuker/gherkin_parser.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require_relative 'log_utils'
|
2
|
-
|
3
|
-
# = Parse Gherkins into my mental models
|
4
|
-
#
|
5
|
-
# Init Parser and get to action on a given location
|
6
|
-
# @
|
7
|
-
module Cuker
|
8
|
-
class GherkinParser
|
9
|
-
include LoggerSetup
|
10
|
-
|
11
|
-
attr_accessor :lex_ary
|
12
|
-
|
13
|
-
def initialize lex = []
|
14
|
-
init_logger
|
15
|
-
@lex_ary = lex
|
16
|
-
@log.trace "init parser for lexer with items: "
|
17
|
-
end
|
18
|
-
|
19
|
-
def parse
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# class Item
|
2
|
-
#
|
3
|
-
# end
|
4
|
-
#
|
5
|
-
# class Collection
|
6
|
-
# attr_accessor :tags
|
7
|
-
# attr_accessor :title, :comments
|
8
|
-
# attr_accessor :items
|
9
|
-
# end
|
10
|
-
#
|
11
|
-
# class Feature < Collection
|
12
|
-
# attr_accessor :background
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# class Background < Collection
|
16
|
-
#
|
17
|
-
# end
|
18
|
-
#
|
19
|
-
# class Scenario < Collection
|
20
|
-
#
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
# class ScenarioOutline < Scenario
|
24
|
-
# attr_accessor :examples
|
25
|
-
# end
|
26
|
-
#
|
27
|
-
# class Step < Item
|
28
|
-
# attr_accessor :keyword, :line
|
29
|
-
# attr_accessor :table # optional
|
30
|
-
# end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# class Item
|
2
|
-
# attr_accessor :content
|
3
|
-
# end
|
4
|
-
#
|
5
|
-
# class Step < Item
|
6
|
-
# attr_accessor :keyword, :line
|
7
|
-
# attr_accessor :table # optional
|
8
|
-
# end
|
9
|
-
#
|
10
|
-
# class Comment < Item
|
11
|
-
#
|
12
|
-
# end
|
13
|
-
#
|
14
|
-
# class InlineComment < Comment
|
15
|
-
#
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# class Tag < Item
|
19
|
-
#
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# class Row < Item
|
23
|
-
#
|
24
|
-
# end
|
25
|
-
#
|
26
|
-
# class Collection < Item
|
27
|
-
# attr_accessor :items
|
28
|
-
# end
|
29
|
-
#
|
30
|
-
# class Tags < Collection
|
31
|
-
#
|
32
|
-
# end
|
33
|
-
#
|
34
|
-
# class Table < Collection
|
35
|
-
#
|
36
|
-
# end
|
37
|
-
#
|
38
|
-
# class Example < Table
|
39
|
-
#
|
40
|
-
# end
|
41
|
-
#
|
42
|
-
# class SimpleGherkinCollection < Collection
|
43
|
-
# attr_accessor :title, :comments
|
44
|
-
# end
|
45
|
-
#
|
46
|
-
# class Background < SimpleGherkinCollection
|
47
|
-
#
|
48
|
-
# end
|
49
|
-
#
|
50
|
-
# class TaggedGherkinCollection < SimpleGherkinCollection
|
51
|
-
# attr_accessor :tags
|
52
|
-
# end
|
53
|
-
#
|
54
|
-
# class Feature < TaggedGherkinCollection
|
55
|
-
# attr_accessor :background
|
56
|
-
# # attr_accessor :collections
|
57
|
-
# end
|
58
|
-
#
|
59
|
-
# class Scenario < TaggedGherkinCollection
|
60
|
-
#
|
61
|
-
# end
|
62
|
-
#
|
63
|
-
# class ScenarioOutline < Scenario
|
64
|
-
# attr_accessor :examples
|
65
|
-
# end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
class Item
|
2
|
-
attr_accessor :content
|
3
|
-
|
4
|
-
def initialize content_str
|
5
|
-
@content = content_str
|
6
|
-
end
|
7
|
-
|
8
|
-
def to_s
|
9
|
-
@content
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Step < Item
|
14
|
-
attr_accessor :keyword, :line
|
15
|
-
attr_accessor :table # optional
|
16
|
-
end
|
17
|
-
|
18
|
-
class Comment < Item
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
class InlineComment < Comment
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
class Tag < Item
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
class TableRow < Item
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
class Collection < Item
|
35
|
-
attr_accessor :items
|
36
|
-
attr_reader :keyword
|
37
|
-
|
38
|
-
def initialize content_str
|
39
|
-
super content_str
|
40
|
-
@items = []
|
41
|
-
end
|
42
|
-
|
43
|
-
def to_s
|
44
|
-
([super] + items.map(&:to_s)).join "\n"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class Tags < Collection
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
class Table < Collection
|
53
|
-
attr_accessor :title_row, :table_rows
|
54
|
-
def initialize content_str
|
55
|
-
super content_str
|
56
|
-
@table_rows = []
|
57
|
-
@title_row = @items[0]
|
58
|
-
@table_rows = @items[1..-1]
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
class Examples < Table
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
class SimpleGherkinCollection < Collection
|
68
|
-
attr_accessor :title, :comments
|
69
|
-
|
70
|
-
def initialize content_str, keyword
|
71
|
-
super content_str
|
72
|
-
@title = parse_title content_str, keyword
|
73
|
-
end
|
74
|
-
|
75
|
-
def parse_title content, keyword
|
76
|
-
match = content[/^\s*#{keyword}(.*)$/, 1]
|
77
|
-
warn "no matches for '#{keyword}' in '#{content}'" unless match
|
78
|
-
match
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
class Background < SimpleGherkinCollection
|
83
|
-
def initialize content_str
|
84
|
-
@keyword = "Background:"
|
85
|
-
super content_str, keyword
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
class TaggedGherkinCollection < SimpleGherkinCollection
|
90
|
-
attr_accessor :tags
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
class Feature < TaggedGherkinCollection
|
95
|
-
attr_accessor :background
|
96
|
-
|
97
|
-
def initialize content_str
|
98
|
-
@keyword = "Feature:"
|
99
|
-
super content_str, keyword
|
100
|
-
#todo: think about item ordering
|
101
|
-
end
|
102
|
-
|
103
|
-
def comments= content
|
104
|
-
@items << content
|
105
|
-
@comments = content
|
106
|
-
end
|
107
|
-
|
108
|
-
def tags= content
|
109
|
-
@items << content
|
110
|
-
@tags = content
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
class Scenario < TaggedGherkinCollection
|
116
|
-
attr_accessor :steps
|
117
|
-
|
118
|
-
def initialize content_str, keyword = "Scenario:"
|
119
|
-
@steps = []
|
120
|
-
@keyword = keyword
|
121
|
-
super content_str, @keyword
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
class ScenarioOutline < Scenario
|
126
|
-
attr_accessor :examples
|
127
|
-
|
128
|
-
def initialize content_str, keyword = "Scenario Outline:"
|
129
|
-
@keyword = keyword
|
130
|
-
super content_str, @keyword
|
131
|
-
end
|
132
|
-
end
|
data/lib/cuker/models/state.rb
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/cuker/state/in_table.rb
DELETED
File without changes
|
data/lib/cuker/state/in_tag.rb
DELETED
File without changes
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module IModel
|
2
|
-
extend Interface
|
3
|
-
method :initialize
|
4
|
-
method :write_title
|
5
|
-
method :write_new_row
|
6
|
-
|
7
|
-
method :make_new_file
|
8
|
-
method :write_new_sheet
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
class AbstractModel
|
13
|
-
include LoggerSetup
|
14
|
-
|
15
|
-
# @return [Array] writable rows of title
|
16
|
-
# Defaults to []
|
17
|
-
attr_accessor :title
|
18
|
-
|
19
|
-
# @return [Array] writable array of rows of data
|
20
|
-
# Defaults to []
|
21
|
-
attr_accessor :data
|
22
|
-
|
23
|
-
def initialize _model_input = []
|
24
|
-
init_logger
|
25
|
-
@title = []
|
26
|
-
@data = []
|
27
|
-
end
|
28
|
-
|
29
|
-
def get_values_ary ary_of_hshs
|
30
|
-
ary_of_hshs.map(&:values).flatten
|
31
|
-
end
|
32
|
-
|
33
|
-
def get_keys_ary ary_of_hshs
|
34
|
-
ary_of_hshs.map(&:keys).flatten
|
35
|
-
end
|
36
|
-
|
37
|
-
# utility methods
|
38
|
-
# used by any model
|
39
|
-
|
40
|
-
def name_merge hsh
|
41
|
-
str = ""
|
42
|
-
@log.warn "name merge for #{hsh}"
|
43
|
-
str += hsh[:name].strip.force_encoding("UTF-8") if hsh[:name]
|
44
|
-
str += "\n#{hsh[:description].strip.force_encoding("UTF-8")}" if hsh[:description]
|
45
|
-
str
|
46
|
-
end
|
47
|
-
|
48
|
-
def union feat_tags, tags
|
49
|
-
(feat_tags.to_set | tags.to_set).to_a # union
|
50
|
-
end
|
51
|
-
|
52
|
-
def surround ary, sep
|
53
|
-
# "#{sep}#{ary.is_a?(Array)? ary.join(sep) : ary}#{sep}"
|
54
|
-
# "#{sep}#{ary.join(sep)}#{sep}"
|
55
|
-
simple_surround ary.join(sep), sep
|
56
|
-
end
|
57
|
-
|
58
|
-
def simple_surround item, sep, r_sep = nil
|
59
|
-
"#{sep}#{item}#{r_sep || sep}"
|
60
|
-
end
|
61
|
-
|
62
|
-
# def padded_surround item, sep, pad
|
63
|
-
# "#{sep}#{pad}#{item}#{pad}#{sep}"
|
64
|
-
# end
|
65
|
-
|
66
|
-
def get_tags(hsh)
|
67
|
-
if hsh[:tags] and hsh[:tags].any?
|
68
|
-
hsh[:tags].map {|tag| tag[:name]}
|
69
|
-
else
|
70
|
-
@log.warn "No Tags found in #{hsh[:keyword]} @ #{@file_path}"
|
71
|
-
[]
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
module IWriter
|
2
|
-
extend Interface
|
3
|
-
method :initialize
|
4
|
-
method :write_title
|
5
|
-
method :write_new_row
|
6
|
-
|
7
|
-
method :make_new_file
|
8
|
-
method :write_new_sheet
|
9
|
-
end
|
10
|
-
|
11
|
-
class AbstractWriter
|
12
|
-
include IWriter
|
13
|
-
include LoggerSetup
|
14
|
-
|
15
|
-
NoNewFileMadeError = Class.new IOError
|
16
|
-
|
17
|
-
# File Extension
|
18
|
-
attr_accessor :ext
|
19
|
-
|
20
|
-
# Active file name
|
21
|
-
attr_accessor :active_file_name
|
22
|
-
|
23
|
-
attr_accessor :sheets, :active_sheet
|
24
|
-
attr_reader :out_dir
|
25
|
-
|
26
|
-
def initialize
|
27
|
-
init_logger
|
28
|
-
# @out_dir = output_path
|
29
|
-
# FileUtils.mkdir_p(output_path) unless Dir.exist? output_path
|
30
|
-
@log.debug "initing AbstractWriter"
|
31
|
-
@active_sheet = nil
|
32
|
-
@sheets = {}
|
33
|
-
end
|
34
|
-
|
35
|
-
def write_title data
|
36
|
-
raise_unless_active_loc data
|
37
|
-
end
|
38
|
-
|
39
|
-
def write_new_row data
|
40
|
-
raise_unless_active_loc data
|
41
|
-
end
|
42
|
-
|
43
|
-
def raise_unless_active_loc data
|
44
|
-
raise NoNewFileMadeError.new "Please run 'make_new_file' before trying to write: '#{data}'" if @active_sheet.nil?
|
45
|
-
end
|
46
|
-
|
47
|
-
def make_new_sheet name = nil
|
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
|
57
|
-
end
|
58
|
-
|
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
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
class AbstractSheet
|
70
|
-
include LoggerSetup
|
71
|
-
attr_accessor :name, :rows
|
72
|
-
|
73
|
-
def initialize name
|
74
|
-
init_logger
|
75
|
-
@name = name
|
76
|
-
@rows = []
|
77
|
-
end
|
78
|
-
|
79
|
-
def current_row
|
80
|
-
@rows.size + 1
|
81
|
-
end
|
82
|
-
|
83
|
-
def add_row ary
|
84
|
-
@rows << ary
|
85
|
-
end
|
86
|
-
|
87
|
-
alias :add_line :add_row
|
88
|
-
|
89
|
-
# @return ary of rows
|
90
|
-
def read_rows
|
91
|
-
@rows
|
92
|
-
end
|
93
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require_relative 'abstract_writer'
|
2
|
-
|
3
|
-
class CsvWriter < AbstractWriter
|
4
|
-
def initialize
|
5
|
-
@ext = '.csv'
|
6
|
-
super
|
7
|
-
@log.debug "initing #{self.class}"
|
8
|
-
end
|
9
|
-
|
10
|
-
def write_title title_ary
|
11
|
-
super title_ary
|
12
|
-
@log.debug "csv write title"
|
13
|
-
@active_sheet.add_row title_ary
|
14
|
-
end
|
15
|
-
|
16
|
-
def write_new_row row_ary
|
17
|
-
super row_ary
|
18
|
-
@log.debug "csv write row: #{row_ary}"
|
19
|
-
@active_sheet.add_row row_ary
|
20
|
-
end
|
21
|
-
|
22
|
-
def make_new_sheet name
|
23
|
-
@log.debug "csv make new sheet"
|
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
|
29
|
-
end
|
30
|
-
|
31
|
-
def make_new_file name
|
32
|
-
path = super name
|
33
|
-
make_new_sheet name
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
require 'csv'
|
38
|
-
# == CSV Sheet
|
39
|
-
# extends sheet to give csv read/write-ability
|
40
|
-
# {file:https://docs.ruby-lang.org/en/2.1.0/CSV.html CSV usage documentation}
|
41
|
-
|
42
|
-
class CsvSheet < AbstractSheet
|
43
|
-
def initialize file_name
|
44
|
-
super file_name
|
45
|
-
@csv_sheet = CSV.open(file_name, "wb")
|
46
|
-
end
|
47
|
-
|
48
|
-
def add_row row_ary
|
49
|
-
super row_ary
|
50
|
-
@log.warn "argument not an array.. instead is a '#{row_ary.class}' -> '#{row_ary}'" unless row_ary.is_a? Array
|
51
|
-
CSV.open(@name, "ab") do |csv|
|
52
|
-
csv << row_ary
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# @return ary of rows
|
57
|
-
def read_rows
|
58
|
-
@rows = CSV.read(@name)
|
59
|
-
end
|
60
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require_relative 'abstract_writer'
|
2
|
-
|
3
|
-
class JiraWriter < AbstractWriter
|
4
|
-
def initialize
|
5
|
-
@ext = '.txt'
|
6
|
-
super
|
7
|
-
@log.debug "initing #{self.class}"
|
8
|
-
end
|
9
|
-
|
10
|
-
def write_title title_line
|
11
|
-
super title_line
|
12
|
-
@log.debug "JW write title"
|
13
|
-
@active_sheet.add_line title_line
|
14
|
-
end
|
15
|
-
|
16
|
-
def write_new_row row_line
|
17
|
-
super row_line
|
18
|
-
@log.debug "JW write row"
|
19
|
-
@active_sheet.add_line row_line
|
20
|
-
end
|
21
|
-
|
22
|
-
def make_new_sheet name = nil
|
23
|
-
@log.debug "JW make new sheet"
|
24
|
-
path = super name
|
25
|
-
path
|
26
|
-
end
|
27
|
-
|
28
|
-
def make_new_file name
|
29
|
-
path = super name
|
30
|
-
@sheets[path] = JiraFile.new path
|
31
|
-
@active_sheet = @sheets[path]
|
32
|
-
path
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class JiraFile < AbstractSheet
|
37
|
-
def initialize file_name
|
38
|
-
super file_name
|
39
|
-
@jira_file = File.open(file_name, "wb")
|
40
|
-
end
|
41
|
-
|
42
|
-
def add_line line
|
43
|
-
super line
|
44
|
-
@log.error "argument not a String.. instead is a '#{line.class}' -> '#{line}'" unless line.is_a? String
|
45
|
-
File.open(@name, "ab") do |file|
|
46
|
-
file << "#{line}\n"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# @return ary of rows
|
51
|
-
def read_rows
|
52
|
-
@rows = File.read(@name)
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require_relative 'abstract_writer'
|
2
|
-
|
3
|
-
class RubyXLWriter < AbstractWriter
|
4
|
-
def initialize
|
5
|
-
super
|
6
|
-
@log.debug "initing #{self.class}"
|
7
|
-
end
|
8
|
-
|
9
|
-
def write_title title_ary
|
10
|
-
@log.debug "Rxl write title"
|
11
|
-
@active_sheet.add_row title_ary
|
12
|
-
end
|
13
|
-
|
14
|
-
def write_new_row row_ary
|
15
|
-
@log.debug "Rxl write row"
|
16
|
-
@active_sheet.add_row row_ary
|
17
|
-
end
|
18
|
-
|
19
|
-
def make_new_sheet name = nil
|
20
|
-
@log.debug "Rxl make new sheet"
|
21
|
-
path = super name
|
22
|
-
@sheets[name] = RubyXLSheet.new path
|
23
|
-
end
|
24
|
-
|
25
|
-
def make_new_file name
|
26
|
-
super name
|
27
|
-
end
|
28
|
-
|
29
|
-
class RubyXLSheet < AbstractSheet
|
30
|
-
#todo: finish class
|
31
|
-
end
|
32
|
-
end
|
File without changes
|
File without changes
|
File without changes
|