inspec-reporter-flex 0.1.1 → 0.1.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
  SHA256:
3
- metadata.gz: 4a3a407e8d18f6b3322ae80be9966b218b3e7c74afe5ba7cebf50b2888f2121a
4
- data.tar.gz: 272924c807526f524a99805f2d6ffc2999d1fd8f6cfe138ee63baa56efaf4a20
3
+ metadata.gz: a70f1ad5110657323aa557b7876f254052aa80e5e82d0dc2d1bd1fa62e5ee097
4
+ data.tar.gz: af696adb163985a265cc85fb0d6da9213f316ad33cc377d3211814abf7d62f25
5
5
  SHA512:
6
- metadata.gz: b59accab7656b4a910ad433b862d822d0bd7cb518f965c808ed93fed7288f54c8d8b7716cebca723afe9c7bb49df4a4eb30634b5dcc6c7f4f7691bb9c9a37cff
7
- data.tar.gz: 77667735300b220f165cc89aa14835d3f2ace950c6801d8674e3f25e2cc96413a28634a3c643f7c998e5825aafdf88670e123fb190807ffa6d80b25a624fa6dc
6
+ metadata.gz: 309b3ee73a2884b4155de09cf5708f62d1fe98241d3a34c41ab051394a42391385af2dbf0acbd899707a3c6cf165967409bd8462d92dba4261de3f0c4503876c
7
+ data.tar.gz: 056d903d087b8ca2ac21204d766a0c72547b563dac3d9908ae515ed8b369c7fdadcbd1467cc177e723d112ca09c85d5f54278f1c39c4019f67829492e5d0e3c8
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.1.2
4
+
5
+ - Fix lookup of `scan_time` ERB helper
6
+ - Refactor template handling
7
+
3
8
  ## v0.1.1
4
9
 
5
10
  - Add configurability via environment variable
@@ -1,10 +1,12 @@
1
1
  module InspecPlugins::FlexReporter
2
2
  module ErbHelpers
3
- # Return latest start time of the scan
3
+ # Return approximate time of the scan
4
4
  #
5
- # @return [DateTime] Timestamp of the last scan in the profile
5
+ # @return [DateTime] Timestamp of the first scan in the profile
6
6
  def scan_time
7
- DateTime.strptime(report[:profiles].last[:controls].last[:results].last[:start_time])
7
+ scan_time = report[:profiles].detect { |p| p[:controls].detect { |c| c[:results].detect { |r| !r.empty? } } }.dig(:controls, 0, :results, 0, :start_time)
8
+
9
+ DateTime.strptime(scan_time)
8
10
  end
9
11
 
10
12
  # Execute a remote command.
@@ -1,11 +1,11 @@
1
1
  module InspecPlugins::FlexReporter
2
2
  module FileResolver
3
- # Resolve the absolute path for a file in order absolute path/gem bundled file/relative.
3
+ # Resolve the full path for a file in order absolute path/gem bundled file/relative.
4
4
  #
5
5
  # @param [String] name Name or path of a file to resolve
6
6
  # @return [String] Absolute path to the file, if any
7
7
  # @raise [IOError] if file not found
8
- def resolve_path(name)
8
+ def full_path(name)
9
9
  if absolute_path?(name)
10
10
  name
11
11
  elsif relative_path?(name)
@@ -10,12 +10,11 @@ module InspecPlugins::FlexReporter
10
10
 
11
11
  ENV_PREFIX = "INSPEC_REPORTER_FLEX_".freeze
12
12
 
13
- attr_writer :config, :env, :inspec_config, :logger
13
+ attr_writer :config, :env, :inspec_config, :logger, :template_contents
14
14
 
15
15
  # Render report
16
16
  def render
17
- template_file = resolve_path(config["template_file"])
18
- template = ERB.new(File.read(template_file))
17
+ template = ERB.new(template_contents)
19
18
 
20
19
  # Use JSON Reporter base's `report` to have pre-processed data
21
20
  mushy_report = Hashie::Mash.new(report)
@@ -54,6 +53,14 @@ module InspecPlugins::FlexReporter
54
53
 
55
54
  private
56
55
 
56
+ # Read contents of requested template.
57
+ #
58
+ # @return [String] ERB Template
59
+ # @raise [IOError]
60
+ def template_contents
61
+ @template_contents ||= File.read full_path(config["template_file"])
62
+ end
63
+
57
64
  # Initialize configuration with defaults and Plugin config.
58
65
  #
59
66
  # @return [Hash] Configuration data after merge
@@ -1,5 +1,5 @@
1
1
  module InspecPlugins
2
2
  module FlexReporter
3
- VERSION = "0.1.1".freeze
3
+ VERSION = "0.1.2".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec-reporter-flex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Heinen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-03 00:00:00.000000000 Z
11
+ date: 2020-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bump