structured-acceptance-test 0.0.6 → 0.0.7

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
- SHA1:
3
- metadata.gz: 0f581dbe460ec7e6c654bc3181df2fd8711a1b1a
4
- data.tar.gz: 9bc1dc9372d8b0752531469be9ac83150d778750
2
+ SHA256:
3
+ metadata.gz: 7eb89a8fd641e832bc16239d0d22c2e95e0614f04eafb5052ebf75ab73838eee
4
+ data.tar.gz: c75f33f0763a6be1bfa4c81d62e97438dcc94702fe1d745b619b4c6de9ebd9bd
5
5
  SHA512:
6
- metadata.gz: 4b7826e641a54264490b0d6e985992cbb50b1d5c599c4b13835ae4e6ca42b48af15d26733fe8a5867ce2ef740b87212eb110f409a85159c20545bbdcda5c8ab0
7
- data.tar.gz: 441400ecf15de90f27f44cf85512b47386bb65790e0f412f24990a2eec548954a737e6e86ac307327181962ced129e75148830b1b45ff033e648dcf94834a4d5
6
+ metadata.gz: cefb90c13ab6e0e616df7e5b520032798cd98b3833b2f61901044a47da7b5517155cf067d6019775bfbccbb6b26ebf24c4a9d776ddd13f43d8f4f231060781e5
7
+ data.tar.gz: 4040066d402612c070542ee6e3ccfd79f5db6810ce9984c7e4c58d719fe95dd0eff445cb4ad290c6e4788ca9f39704aa9a94b1ae82054cd1926b00897489eb7f
data/lib/JSONable.rb CHANGED
@@ -9,6 +9,11 @@ module StatModule
9
9
  FORMATTING_BALL = '⚫'
10
10
  FORMATTING_WARNING = '⚠'
11
11
 
12
+ ##
13
+ # Initialize object extending JSONable
14
+ #
15
+ # Params:
16
+ # +hash+:: Hash
12
17
  def initialize(hash)
13
18
  if hash.is_a? Hash
14
19
  hash.each do |k, v|
@@ -46,6 +51,11 @@ module StatModule
46
51
  end
47
52
  end
48
53
 
54
+ ##
55
+ # Get object in pretty json format
56
+ #
57
+ # Params:
58
+ # +excluded_fields+:: array of String - attributes to exclude
49
59
  def to_json(excluded_fields = [])
50
60
  hash = {}
51
61
  self.instance_variables.each do |var|
@@ -54,7 +64,9 @@ module StatModule
54
64
  JSON.pretty_generate(hash)
55
65
  end
56
66
 
57
- def self.from_json! string
67
+ ##
68
+ # Generate Hash from json string
69
+ def self.from_json!(string)
58
70
  JSON.load(string).each do |var, val|
59
71
  self.instance_variable_set '@' + var, val
60
72
  end
data/lib/category.rb CHANGED
@@ -1,6 +1,16 @@
1
1
  module StatModule
2
2
  require 'enum'
3
3
 
4
+ ##
5
+ # Category can be:
6
+ # * Bug Risk — the meaning is likely to not be what the author intended
7
+ # * Clarity — the meaning is unclear
8
+ # * Compatibility — the meaning has changed and is no longer valid
9
+ # * Complexity — the meaning should be broken into smaller pieces
10
+ # * Duplication — unnecessary duplication was found
11
+ # * Performance — an inefficient approach was used
12
+ # * Security — a situation may allow access to something that should be allowed
13
+ # * Style — the style could be improved
4
14
  class Category < Enum::Base
5
15
  values 'Bug Risk', 'Clarity', 'Associative', 'Compatibility', 'Complexity', 'Duplication', 'Performance', 'Security', 'Style'
6
16
  end
data/lib/detail.rb CHANGED
@@ -3,24 +3,43 @@ module StatModule
3
3
 
4
4
  class Detail < JSONable
5
5
 
6
+ ##
7
+ # Initialize new Detail object
8
+ #
9
+ # Params:
10
+ # +body+:: String, required
11
+ # +hash+:: Hash, can be null
6
12
  def initialize(body, hash = nil)
7
13
  if hash.is_a? Hash
8
14
  super(hash)
9
15
  return
10
16
  end
11
17
 
18
+ raise TypeException unless body.is_a?(String)
12
19
  @body = body
13
20
  end
14
21
 
22
+ ##
23
+ # Set body
24
+ #
25
+ # Params:
26
+ # +body+:: String
15
27
  def body=(body)
16
28
  raise TypeException unless body.is_a?(String)
17
29
  @body = body
18
30
  end
19
31
 
32
+ ##
33
+ # Get body
20
34
  def body
21
35
  @body
22
36
  end
23
37
 
38
+ ##
39
+ # Set trace
40
+ #
41
+ # Params:
42
+ # +trace+:: array of StatModule::Location objects
24
43
  def trace=(trace)
25
44
  raise TypeException unless trace.is_a?(Array)
26
45
  trace.each { |item|
@@ -30,6 +49,8 @@ module StatModule
30
49
  }
31
50
  end
32
51
 
52
+ ##
53
+ # Get trace
33
54
  def trace
34
55
  @trace
35
56
  end
@@ -1,4 +1,6 @@
1
1
  module StatModule
2
+ ##
3
+ # Duplicated element in array exception
2
4
  class DuplicateElementException < Exception
3
5
  end
4
6
  end
data/lib/finding.rb CHANGED
@@ -3,6 +3,14 @@ module StatModule
3
3
 
4
4
  class Finding < JSONable
5
5
 
6
+ ##
7
+ # Initialize new Finding object
8
+ #
9
+ # Params:
10
+ # +failure+:: boolean, required
11
+ # +rule+:: String, required
12
+ # +description+:: String, required
13
+ # +hash+:: Hash, can be null
6
14
  def initialize(failure, rule, description, hash = nil)
7
15
  if hash.is_a? Hash
8
16
  super(hash)
@@ -15,32 +23,58 @@ module StatModule
15
23
  @description = description
16
24
  end
17
25
 
26
+ ##
27
+ # Set failure
28
+ #
29
+ # Params:
30
+ # +failure+:: boolean
18
31
  def failure=(failure)
19
32
  @failure = failure
20
33
  end
21
34
 
35
+ ##
36
+ # Get failure
22
37
  def failure
23
38
  @failure
24
39
  end
25
40
 
41
+ ##
42
+ # Set rule
43
+ #
44
+ # Params:
45
+ # +rule+:: String
26
46
  def rule=(rule)
27
47
  raise TypeException unless rule.is_a?(String)
28
48
  @rule = rule
29
49
  end
30
50
 
51
+ ##
52
+ # Get rule
31
53
  def rule
32
54
  @rule
33
55
  end
34
56
 
57
+ ##
58
+ # Set description
59
+ #
60
+ # Params:
61
+ # +description+:: String
35
62
  def description=(description)
36
63
  raise TypeException unless description.is_a?(String)
37
64
  @description = description
38
65
  end
39
66
 
67
+ ##
68
+ # Get description
40
69
  def description
41
70
  @description
42
71
  end
43
72
 
73
+ ##
74
+ # Set detail
75
+ #
76
+ # Params:
77
+ # +detail+:: StatModule::Detail
44
78
  def detail=(detail)
45
79
  raise TypeException unless detail.is_a?(StatModule::Detail)
46
80
  @detail = detail
@@ -50,6 +84,11 @@ module StatModule
50
84
  @detail
51
85
  end
52
86
 
87
+ ##
88
+ # Set array of categories
89
+ #
90
+ # Params:
91
+ # +categories+:: array of StatModule::Category
53
92
  def categories=(categories)
54
93
  raise TypeException unless categories.is_a?(Array)
55
94
  categories.each { |item|
@@ -59,37 +98,65 @@ module StatModule
59
98
  }
60
99
  end
61
100
 
101
+ ##
102
+ # Get array of StatModule::Category objects
62
103
  def categories
63
104
  @categories
64
105
  end
65
106
 
107
+ ##
108
+ # Set location
109
+ #
110
+ # Params:
111
+ # +location+:: StatModule::Location
66
112
  def location=(location)
67
113
  raise TypeException unless location.is_a?(Location)
68
114
  @location = location
69
115
  end
70
116
 
117
+ ##
118
+ # Get location
71
119
  def location
72
120
  @location
73
121
  end
74
122
 
123
+ ##
124
+ # Set time to fix
125
+ #
126
+ # Params:
127
+ # +time_to_fix+:: Integer
75
128
  def time_to_fix=(time_to_fix)
76
129
  raise TypeException unless time_to_fix.is_a?(Integer)
77
130
  @timeToFix = time_to_fix
78
131
  end
79
132
 
133
+ ##
134
+ # Get time to fix
80
135
  def time_to_fix
81
136
  @timeToFix
82
137
  end
83
138
 
139
+ ##
140
+ # Set recommendation
141
+ #
142
+ # Params:
143
+ # +recommendation+:: String
84
144
  def recommendation=(recommendation)
85
145
  raise TypeException unless recommendation.is_a?(String)
86
146
  @recommendation = recommendation
87
147
  end
88
148
 
149
+ ##
150
+ # Get recommendation
89
151
  def recommendation
90
152
  @recommendation
91
153
  end
92
154
 
155
+ ##
156
+ # Set fixes
157
+ #
158
+ # Params:
159
+ # +fixes+:: array of StatModule::Fix
93
160
  def fixes=(fixes)
94
161
  raise TypeException unless fixes.is_a?(Array)
95
162
  fixes.each { |item|
@@ -99,10 +166,18 @@ module StatModule
99
166
  }
100
167
  end
101
168
 
169
+ ##
170
+ # Get array of StatModule::Fix objects
102
171
  def fixes
103
172
  @fixes
104
173
  end
105
174
 
175
+ ##
176
+ # Get formatted information about findings
177
+ #
178
+ # Params:
179
+ #
180
+ # +formatted+:: indicate weather print boring or pretty colorful finding
106
181
  def print(formatted = false)
107
182
  result = "#{rule}, #{description}"
108
183
  if formatted
data/lib/fix.rb CHANGED
@@ -3,6 +3,12 @@ module StatModule
3
3
 
4
4
  class Fix < JSONable
5
5
 
6
+ ##
7
+ # Initialize new Fix object
8
+ #
9
+ # Params:
10
+ # +location+:: StatModule::Location, required
11
+ # +hash+:: Hash, can be null
6
12
  def initialize(location, hash = nil)
7
13
  if hash.is_a? Hash
8
14
  super(hash)
@@ -11,20 +17,34 @@ module StatModule
11
17
  @location = location
12
18
  end
13
19
 
20
+ ##
21
+ # Set location
22
+ #
23
+ # Params:
24
+ # +location+:: StatModule::Location
14
25
  def location=(location)
15
26
  raise TypeException unless location.is_a?(StatModule::Location)
16
27
  @location = location
17
28
  end
18
29
 
30
+ ##
31
+ # Get location
19
32
  def location
20
33
  @location
21
34
  end
22
35
 
36
+ ##
37
+ # Set new text
38
+ #
39
+ # Params:
40
+ # +new_text+:: String
23
41
  def new_text=(new_text)
24
42
  raise TypeException unless new_text.is_a?(String)
25
43
  @newText = new_text
26
44
  end
27
45
 
46
+ ##
47
+ # Get new text
28
48
  def new_text
29
49
  @newText
30
50
  end
@@ -1,4 +1,6 @@
1
1
  module StatModule
2
+ ##
3
+ # Index out of array bound exception
2
4
  class IndexOutOfBoundException < Exception
3
5
  end
4
6
  end
data/lib/location.rb CHANGED
@@ -3,59 +3,103 @@ module StatModule
3
3
 
4
4
  class Location < JSONable
5
5
 
6
+ ##
7
+ # Initialize new Location object
8
+ #
9
+ # Params:
10
+ # +process+:: String, required
11
+ # +hash+:: Hash, can be null
6
12
  def initialize(path, hash = nil)
7
13
  if hash.is_a? Hash
8
14
  super(hash)
9
15
  return
10
16
  end
17
+ raise TypeException unless path.is_a?(String)
11
18
  @path = path
12
19
  end
13
20
 
21
+ ##
22
+ # Set path
23
+ #
24
+ # Params:
25
+ # +path+:: String
14
26
  def path=(path)
15
27
  raise TypeException unless path.is_a?(String)
16
28
  @path = path
17
29
  end
18
30
 
31
+ ##
32
+ # Get path
19
33
  def path
20
34
  @path
21
35
  end
22
36
 
37
+ ##
38
+ # Set begin line
39
+ #
40
+ # Params:
41
+ # +begin_line+:: Integer
23
42
  def begin_line=(begin_line)
24
43
  raise TypeException unless begin_line.is_a?(Integer)
25
44
  @beginLine = begin_line
26
45
  end
27
46
 
47
+ ##
48
+ # Get begin line number
28
49
  def begin_line
29
50
  @beginLine
30
51
  end
31
52
 
53
+ ##
54
+ # Set begin column
55
+ #
56
+ # Params:
57
+ # +begin_column+:: Integer
32
58
  def begin_column=(begin_column)
33
59
  raise TypeException unless begin_column.is_a?(Integer)
34
60
  @beginColumn = begin_column
35
61
  end
36
62
 
63
+ ##
64
+ # Get begin column number
37
65
  def begin_column
38
66
  @beginColumn
39
67
  end
40
68
 
69
+ ##
70
+ # Set end line
71
+ #
72
+ # Params:
73
+ # +end_line+:: Integer
41
74
  def end_line=(end_line)
42
75
  raise TypeException unless end_line.is_a?(Integer)
43
76
  @endLine = end_line
44
77
  end
45
78
 
79
+ ##
80
+ # Get end line number
46
81
  def end_line
47
82
  @endLine
48
83
  end
49
84
 
85
+ ##
86
+ # Set end column
87
+ #
88
+ # Params:
89
+ # +end_column+:: Integer
50
90
  def end_column=(end_column)
51
91
  raise TypeException unless end_column.is_a?(Integer)
52
92
  @endColumn = end_column
53
93
  end
54
94
 
95
+ ##
96
+ # Get end column number
55
97
  def end_column
56
98
  @endColumn
57
99
  end
58
100
 
101
+ ##
102
+ # Get formatted information about location
59
103
  def print
60
104
  result = "in #{path}"
61
105
  if !begin_line.nil? && !end_line.nil?
data/lib/process.rb CHANGED
@@ -4,6 +4,12 @@ module StatModule
4
4
 
5
5
  class Process < JSONable
6
6
 
7
+ ##
8
+ # Initialize new Process object
9
+ #
10
+ # Params:
11
+ # +name+:: String, name of the process, required
12
+ # +hash+:: Hash, can be null
7
13
  def initialize(name, hash = nil)
8
14
  if hash.is_a? Hash
9
15
  super(hash)
@@ -14,69 +20,124 @@ module StatModule
14
20
  @name = name
15
21
  end
16
22
 
23
+ ##
24
+ # Set name of the process
25
+ #
26
+ # Params:
27
+ # +name+:: String, name of the process, required
17
28
  def name=(name)
18
29
  raise TypeException unless name.is_a?(String)
19
30
  @name = name
20
31
  end
21
32
 
33
+ ##
34
+ # Get name of the process
22
35
  def name
23
36
  @name
24
37
  end
25
38
 
39
+ ##
40
+ # Set version
41
+ #
42
+ # Params:
43
+ # +version+:: String
26
44
  def version=(version)
27
45
  raise TypeException unless version.is_a?(String)
28
46
  @version = version
29
47
  end
30
48
 
49
+ ##
50
+ # Get version of the process
31
51
  def version
32
52
  @version
33
53
  end
34
54
 
55
+ ##
56
+ # Set description
57
+ #
58
+ # Params:
59
+ # +description+:: String
35
60
  def description=(description)
36
61
  raise TypeException unless description.is_a?(String)
37
62
  @description = description
38
63
  end
39
64
 
65
+ ##
66
+ # Get description
40
67
  def description
41
68
  @description
42
69
  end
43
70
 
71
+ ##
72
+ # Set maintainer
73
+ #
74
+ # Params:
75
+ # +maintainer+:: String
44
76
  def maintainer=(maintainer)
45
77
  raise TypeException unless maintainer.is_a?(String)
46
78
  @maintainer = maintainer
47
79
  end
48
80
 
81
+ ##
82
+ # Get maintainer
49
83
  def maintainer
50
84
  @maintainer
51
85
  end
52
86
 
87
+ ##
88
+ # Set email
89
+ #
90
+ # Params:
91
+ # +email+:: String
53
92
  def email=(email)
54
93
  raise TypeException unless email.is_a?(String)
55
94
  @email = email
56
95
  end
57
96
 
97
+ ##
98
+ # Get email
58
99
  def email
59
100
  @email
60
101
  end
61
102
 
103
+ ##
104
+ # Set website
105
+ #
106
+ # Params:
107
+ # +website+:: String
62
108
  def website=(website)
63
109
  raise TypeException unless website.is_a?(String)
64
110
  @website = website
65
111
  end
66
112
 
113
+ ##
114
+ # Get website
67
115
  def website
68
116
  @website
69
117
  end
70
118
 
119
+ ##
120
+ # Set repeatability
121
+ #
122
+ # Params:
123
+ # +repeatability+:: String
71
124
  def repeatability=(repeatability)
72
125
  raise TypeException unless Repeatability.all.include?(repeatability)
73
126
  @repeatability = repeatability
74
127
  end
75
128
 
129
+ ##
130
+ # Get repeatability
76
131
  def repeatability
77
132
  @repeatability
78
133
  end
79
134
 
135
+ ##
136
+ # Get formatted information about process
137
+ #
138
+ # Params:
139
+ #
140
+ # +formatted+:: indicate weather print boring or pretty colorful process
80
141
  def print(formatted = nil)
81
142
  result = name
82
143
  unless version.nil?
data/lib/repeatability.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  module StatModule
2
2
  require 'enum'
3
3
 
4
+ ##
5
+ # Repeatability can be:
6
+ # * Volatile — findings MAY change when repeating validation on the identical targets
7
+ # * Repeatable — Findings MUST be identical if the program is run again with the same inputs
8
+ # * Associative — Findings for targets [a, b] MUST equal the union of findings for [a] and [b] -- in other words, if only one file is changed, only that file need be tested
4
9
  class Repeatability < Enum::Base
5
10
  values 'Volatile', 'Repeatable', 'Associative'
6
11
  end
@@ -15,6 +15,12 @@ module StatModule
15
15
  class Stat < JSONable
16
16
  attr_reader :statVersion
17
17
 
18
+ ##
19
+ # Initialize new Stat object
20
+ #
21
+ # Params:
22
+ # +process+:: StatModule::Process, required
23
+ # +hash+:: Hash, can be null
18
24
  def initialize(process, hash = nil)
19
25
  @finding_print_index = 0
20
26
  @findings = []
@@ -29,6 +35,11 @@ module StatModule
29
35
  @process = process
30
36
  end
31
37
 
38
+ ##
39
+ # Set array of findings
40
+ #
41
+ # Params:
42
+ # +findings+:: Array of StatModule::Finding
32
43
  def findings=(findings)
33
44
  raise TypeException unless findings.is_a?(Array)
34
45
  findings.each { |item|
@@ -38,19 +49,31 @@ module StatModule
38
49
  }
39
50
  end
40
51
 
52
+ ##
53
+ # Get array of findings
41
54
  def findings
42
55
  @findings
43
56
  end
44
57
 
58
+ ##
59
+ # Set process
60
+ #
61
+ # Params:
62
+ # +process+:: instance of StatModule::Process
45
63
  def process=(process)
46
64
  raise TypeException unless process.is_a?(StatModule::Process)
47
65
  @process = process
48
66
  end
49
67
 
68
+ ##
69
+ # Get process
50
70
  def process
51
71
  @process
52
72
  end
53
73
 
74
+ ##
75
+ # Prints header of STAT object in json format
76
+ # Header contains statVersion, process and optional array of findings
54
77
  def print_header
55
78
  @finding_print_index = 0
56
79
  hash = {}
@@ -64,6 +87,8 @@ module StatModule
64
87
  $stdout.flush
65
88
  end
66
89
 
90
+ ##
91
+ # Prints one finding in json format.
67
92
  def print_finding
68
93
  if @finding_print_index < @findings.length
69
94
  result = @findings[@finding_print_index].to_json
@@ -77,6 +102,8 @@ module StatModule
77
102
  end
78
103
  end
79
104
 
105
+ ##
106
+ # Prints footer of STAT object in json format
80
107
  def print_footer
81
108
  @finding_print_index = 0
82
109
  puts ']}'
@@ -84,10 +111,18 @@ module StatModule
84
111
  $stdout.flush
85
112
  end
86
113
 
114
+ ##
115
+ # Get STAT object in json format
87
116
  def to_json(options = {})
88
117
  super(['finding_print_index'])
89
118
  end
90
119
 
120
+ ##
121
+ # Get statistic information about findings
122
+ #
123
+ # Params:
124
+ #
125
+ # +formatted+:: indicate weather print boring or pretty colorful statistic
91
126
  def summary_print(formatted = false)
92
127
  errors = 0
93
128
  warnings = 0
@@ -1,4 +1,6 @@
1
1
  module StatModule
2
+ ##
3
+ # Wrong type exception
2
4
  class TypeException < Exception
3
5
  end
4
6
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structured-acceptance-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Entriken
8
8
  - Ilia Grabko
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-12 00:00:00.000000000 Z
12
+ date: 2022-12-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: safe-enum
@@ -37,20 +37,14 @@ dependencies:
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.8'
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 2.8.0
40
+ version: '3.0'
44
41
  type: :runtime
45
42
  prerelease: false
46
43
  version_requirements: !ruby/object:Gem::Requirement
47
44
  requirements:
48
45
  - - "~>"
49
46
  - !ruby/object:Gem::Version
50
- version: '2.8'
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: 2.8.0
47
+ version: '3.0'
54
48
  - !ruby/object:Gem::Dependency
55
49
  name: colorize
56
50
  requirement: !ruby/object:Gem::Requirement
@@ -87,13 +81,13 @@ files:
87
81
  - lib/location.rb
88
82
  - lib/process.rb
89
83
  - lib/repeatability.rb
90
- - lib/stat.rb
84
+ - lib/structured-acceptance-test.rb
91
85
  - lib/type_exception.rb
92
86
  homepage: https://github.com/fulldecent/structured-acceptance-test
93
87
  licenses:
94
88
  - MIT
95
89
  metadata: {}
96
- post_install_message:
90
+ post_install_message:
97
91
  rdoc_options: []
98
92
  require_paths:
99
93
  - lib
@@ -108,9 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
102
  - !ruby/object:Gem::Version
109
103
  version: '0'
110
104
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.6.11
113
- signing_key:
105
+ rubygems_version: 3.3.11
106
+ signing_key:
114
107
  specification_version: 4
115
108
  summary: Structured acceptance test
116
109
  test_files: []