Skip to content

Commit 36b5faa

Browse files
refactored supported bom format parsing
Signed-off-by: Jeffrey Zhang <[email protected]>
1 parent daf8e00 commit 36b5faa

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/bom_builder.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
require 'active_support/core_ext/hash'
3535

3636
class Bombuilder
37+
SUPPORTED_BOM_FORMATS = %w[xml json]
38+
3739
def self.build(path)
3840
original_working_directory = Dir.pwd
3941
setup(path)
@@ -123,12 +125,12 @@ def self.setup(path)
123125
abort
124126
end
125127

126-
if @options[:bom_output_format].nil? || @options[:bom_output_format] == "xml"
128+
if @options[:bom_output_format].nil?
127129
@bom_output_format = 'xml'
128-
elsif @options[:bom_output_format] == "json"
129-
@bom_output_format = 'json'
130+
elsif SUPPORTED_BOM_FORMATS.include?(@options[:bom_output_format])
131+
@bom_output_format = @options[:bom_output_format]
130132
else
131-
@logger.error("Unrecognized cyclonedx bom output format provided: #{@options[:bom_output_format]}")
133+
@logger.error("Unrecognized cyclonedx bom output format provided. Please choose one of #{SUPPORTED_BOM_FORMATS}")
132134
abort
133135
end
134136

0 commit comments

Comments
 (0)