structured-acceptance-test 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: db1011b13e229f0bcc5b3aad85cf5b8a0ba76b88
4
- data.tar.gz: 3b70de0a60d7e732f202750c2621caa9e12101dd
3
+ metadata.gz: 2b247928af0754f0da447bf44ad19fc76265c5c0
4
+ data.tar.gz: be9c9043e42ce03211f2792e96538da84d272e93
5
5
  SHA512:
6
- metadata.gz: d664c6933b6020e761babc9a150c6f54ed11530773376b8bec829ea1b1d95240fe66b85dfbd13389393484b4fcc7467cf5c3c8bc1995d320b8c75c53cacc16fe
7
- data.tar.gz: b8efc5f4ed1f9319772807479e10a3b47e7125b919983fd6646fc4dbe955d8e61ea0d7195aae1a9cae45772ce61a44685f4bdfa56d991d1f5b9ff9db49f91321
6
+ metadata.gz: 027a533e426d3cd2363a478880ec516381e31a1d3a5eb3b4bea9aa2848d46823a291b6608d1fc75557a69a8b317f8ea727813e4e5e35995e566d22d7ba3f4025
7
+ data.tar.gz: 9f2b16309871ac643f2832e33fc0709d103197d2ae34e913b07d2ce133e9fe7389d450a77d64e93719a000d4d63661fc2c2d704c90dce7fb6942b8aa95bc7c9b
data/lib/JSONable.rb CHANGED
@@ -2,10 +2,10 @@ module StatModule
2
2
  require 'json'
3
3
 
4
4
  class JSONable
5
- def to_json(options = {})
5
+ def to_json(excluded_fields = [])
6
6
  hash = {}
7
7
  self.instance_variables.each do |var|
8
- hash[var.to_s.delete "@"] = self.instance_variable_get var
8
+ hash[var.to_s.delete "@"] = self.instance_variable_get var unless excluded_fields.is_a?(Array) && excluded_fields.include?(var.to_s.delete "@")
9
9
  end
10
10
  hash.to_json
11
11
  end
@@ -0,0 +1,4 @@
1
+ module StatModule
2
+ class IndexOutOfBoundException < Exception
3
+ end
4
+ end
data/lib/stat.rb CHANGED
@@ -9,6 +9,8 @@ module StatModule
9
9
  require_relative 'category'
10
10
  require_relative 'JSONable'
11
11
  require_relative 'type_exception'
12
+ require_relative 'duplicate_element_exception'
13
+ require_relative 'index_out_of_bound_exception'
12
14
 
13
15
  class Stat < JSONable
14
16
  attr_reader :statVersion
@@ -18,6 +20,7 @@ module StatModule
18
20
  @statVersion = '1.0.0'
19
21
  @process = process
20
22
  @findings = []
23
+ @finding_print_index = 0
21
24
  end
22
25
 
23
26
  def findings=(findings)
@@ -41,5 +44,39 @@ module StatModule
41
44
  def process
42
45
  @process
43
46
  end
47
+
48
+ def print_header
49
+ @finding_print_index = 0
50
+ hash = {}
51
+ hash['statVersion'] = @statVersion
52
+ hash['process'] = @process.to_json
53
+ hash['findings'] = []
54
+ result = hash.to_json.to_s
55
+ result = result[0..result.length - 3]
56
+ puts(result)
57
+ puts
58
+ end
59
+
60
+ def print_finding
61
+ if @finding_print_index < @findings.length
62
+ result = @findings[@finding_print_index].to_json
63
+ result += ',' unless @finding_print_index >= @findings.length - 1
64
+ puts(result)
65
+ puts
66
+ @finding_print_index += 1
67
+ else
68
+ raise IndexOutOfBoundException
69
+ end
70
+ end
71
+
72
+ def print_footer
73
+ @finding_print_index = 0
74
+ puts ']}'
75
+ puts
76
+ end
77
+
78
+ def to_json(options = {})
79
+ super(['finding_print_index'])
80
+ end
44
81
  end
45
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structured-acceptance-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Entriken
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-11 00:00:00.000000000 Z
12
+ date: 2017-02-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Structured acceptance test data structure gem
15
15
  email: github.com@phor.net
@@ -23,6 +23,7 @@ files:
23
23
  - lib/duplicate_element_exception.rb
24
24
  - lib/finding.rb
25
25
  - lib/fix.rb
26
+ - lib/index_out_of_bound_exception.rb
26
27
  - lib/location.rb
27
28
  - lib/process.rb
28
29
  - lib/repeatability.rb