Sha256: dc63fa659b4c33b04f321a23499f8698e9956dc88182b3de16c8a4245be075d3

Contents?: true

Size: 1.58 KB

Versions: 19

Compression:

Stored size: 1.58 KB

Contents

#
# Copyright:: Copyright 2016, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require "license_scout/exporter/csv"

module LicenseScout
  class Exporter

    attr_reader :json_file
    attr_reader :export_format
    attr_reader :exporter

    def initialize(json_file, export_format)
      @json_file = json_file
      @export_format = export_format

      @exporter = case export_format
                  when "csv"
                    LicenseScout::Exporter::CSV.new(json_file)
                  else
                    # We shouldn't ever hit this, because the CLI filters out unsupported formats. But just in case...
                    raise LicenseScout::Exceptions::UnsupportedExporter.new("'#{export_format}' is not a supported format. Please use one of the following: #{supported_formats.join(", ")}")
                  end
    end

    def self.supported_formats
      [
        "csv",
      ]
    end

    def export
      LicenseScout::Log.info("[exporter] Exporting #{json_file} to '#{export_format}'")
      exporter.export
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
license_scout-2.6.10 lib/license_scout/exporter.rb
license_scout-2.6.7 lib/license_scout/exporter.rb
license_scout-2.6.3 lib/license_scout/exporter.rb
license_scout-2.6.2 lib/license_scout/exporter.rb
license_scout-2.5.1 lib/license_scout/exporter.rb
license_scout-2.5.0 lib/license_scout/exporter.rb
license_scout-2.4.0 lib/license_scout/exporter.rb
license_scout-2.2.0 lib/license_scout/exporter.rb
license_scout-2.1.5 lib/license_scout/exporter.rb
license_scout-2.1.4 lib/license_scout/exporter.rb
license_scout-2.1.3 lib/license_scout/exporter.rb
license_scout-2.1.2 lib/license_scout/exporter.rb
license_scout-2.1.1 lib/license_scout/exporter.rb
license_scout-2.1.0 lib/license_scout/exporter.rb
license_scout-2.0.14 lib/license_scout/exporter.rb
license_scout-2.0.13 lib/license_scout/exporter.rb
license_scout-2.0.12 lib/license_scout/exporter.rb
license_scout-2.0.11 lib/license_scout/exporter.rb
license_scout-2.0.9 lib/license_scout/exporter.rb