inspec-reporter-flex 0.1.0 → 0.1.1
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/CHANGELOG.md +5 -1
- data/README.md +4 -4
- data/lib/inspec-reporter-flex/mixin/file_resolver.rb +2 -2
- data/lib/inspec-reporter-flex/reporter.rb +41 -3
- data/lib/inspec-reporter-flex/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a3a407e8d18f6b3322ae80be9966b218b3e7c74afe5ba7cebf50b2888f2121a
|
4
|
+
data.tar.gz: 272924c807526f524a99805f2d6ffc2999d1fd8f6cfe138ee63baa56efaf4a20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b59accab7656b4a910ad433b862d822d0bd7cb518f965c808ed93fed7288f54c8d8b7716cebca723afe9c7bb49df4a4eb30634b5dcc6c7f4f7691bb9c9a37cff
|
7
|
+
data.tar.gz: 77667735300b220f165cc89aa14835d3f2ace950c6801d8674e3f25e2cc96413a28634a3c643f7c998e5825aafdf88670e123fb190807ffa6d80b25a624fa6dc
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -35,7 +35,7 @@ For example:
|
|
35
35
|
"version": "1.2",
|
36
36
|
"plugins": {
|
37
37
|
"inspec-reporter-flex": {
|
38
|
-
"template_file":"template/markdown.
|
38
|
+
"template_file": "template/markdown.erb"
|
39
39
|
}
|
40
40
|
}
|
41
41
|
}
|
@@ -43,9 +43,9 @@ For example:
|
|
43
43
|
|
44
44
|
See below all customization options available:
|
45
45
|
|
46
|
-
| Option | Default |
|
47
|
-
|
48
|
-
| `template_file` | `templates/flex.erb` |
|
46
|
+
| Option | Env Variable | Default | Description |
|
47
|
+
|------------------|:------------------------------------:|:--------------------:|---------------|
|
48
|
+
| `template_file` | `INSPEC_REPORTER_FLEX_TEMPLATE_FILE` | `templates/flex.erb` | Name of the file for templating. Will look up in order "absolute path", "relative to current directory", "relative to gem directory" |
|
49
49
|
|
50
50
|
## Writing Templates
|
51
51
|
|
@@ -4,7 +4,7 @@ module InspecPlugins::FlexReporter
|
|
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
|
-
# @raise [
|
7
|
+
# @raise [IOError] if file not found
|
8
8
|
def resolve_path(name)
|
9
9
|
if absolute_path?(name)
|
10
10
|
name
|
@@ -13,7 +13,7 @@ module InspecPlugins::FlexReporter
|
|
13
13
|
elsif gem_path?(name)
|
14
14
|
gem_path(name)
|
15
15
|
else
|
16
|
-
raise "Template file #{name} not found"
|
16
|
+
raise IOError, "Template file #{name} not found"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -8,9 +8,13 @@ module InspecPlugins::FlexReporter
|
|
8
8
|
include InspecPlugins::FlexReporter::ErbHelpers
|
9
9
|
include InspecPlugins::FlexReporter::FileResolver
|
10
10
|
|
11
|
+
ENV_PREFIX = "INSPEC_REPORTER_FLEX_".freeze
|
12
|
+
|
13
|
+
attr_writer :config, :env, :inspec_config, :logger
|
14
|
+
|
11
15
|
# Render report
|
12
16
|
def render
|
13
|
-
template_file = resolve_path(config["
|
17
|
+
template_file = resolve_path(config["template_file"])
|
14
18
|
template = ERB.new(File.read(template_file))
|
15
19
|
|
16
20
|
# Use JSON Reporter base's `report` to have pre-processed data
|
@@ -58,10 +62,44 @@ module InspecPlugins::FlexReporter
|
|
58
62
|
|
59
63
|
# Defaults
|
60
64
|
@config = {
|
61
|
-
"
|
65
|
+
"template_file" => "templates/flex.erb",
|
62
66
|
}
|
63
67
|
|
64
|
-
@config.merge!
|
68
|
+
@config.merge! inspec_config.fetch_plugin_config("inspec-reporter-flex")
|
69
|
+
@config.merge! config_environment
|
70
|
+
|
71
|
+
logger.debug format("Configuration: %<config>s", config: @config)
|
72
|
+
|
73
|
+
@config
|
74
|
+
end
|
75
|
+
|
76
|
+
# Allow (top-level) setting overrides from environment.
|
77
|
+
#
|
78
|
+
# @return [Hash] Configuration data from environment
|
79
|
+
def config_environment
|
80
|
+
env_reporter = env.select { |var, _| var.start_with?(ENV_PREFIX) }
|
81
|
+
env_reporter.transform_keys { |key| key.delete_prefix(ENV_PREFIX).downcase }
|
82
|
+
end
|
83
|
+
|
84
|
+
# Return environment variables.
|
85
|
+
#
|
86
|
+
# @return [Hash] Mapping of environment variables
|
87
|
+
def env
|
88
|
+
@env ||= ENV
|
89
|
+
end
|
90
|
+
|
91
|
+
# Return InSpec Config object.
|
92
|
+
#
|
93
|
+
# @return [Inspec::Config] The InSpec config object
|
94
|
+
def inspec_config
|
95
|
+
@inspec_config ||= Inspec::Config.cached
|
96
|
+
end
|
97
|
+
|
98
|
+
# Return InSpec logger.
|
99
|
+
#
|
100
|
+
# @return [Inspec:Log] The Logger object
|
101
|
+
def logger
|
102
|
+
@logger ||= Inspec::Log
|
65
103
|
end
|
66
104
|
|
67
105
|
# Return InSpec Runner for further inspection.
|