Class: LicenseScout::Exporter
- Inherits:
-
Object
- Object
- LicenseScout::Exporter
- Defined in:
- lib/license_scout/exporter.rb,
lib/license_scout/exporter/csv.rb
Defined Under Namespace
Classes: CSV
Instance Attribute Summary collapse
-
#export_format ⇒ Object
readonly
Returns the value of attribute export_format.
-
#exporter ⇒ Object
readonly
Returns the value of attribute exporter.
-
#json_file ⇒ Object
readonly
Returns the value of attribute json_file.
Class Method Summary collapse
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(json_file, export_format) ⇒ Exporter
constructor
A new instance of Exporter.
Constructor Details
#initialize(json_file, export_format) ⇒ Exporter
Returns a new instance of Exporter.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/license_scout/exporter.rb', line 27 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 |
Instance Attribute Details
#export_format ⇒ Object (readonly)
Returns the value of attribute export_format.
24 25 26 |
# File 'lib/license_scout/exporter.rb', line 24 def export_format @export_format end |
#exporter ⇒ Object (readonly)
Returns the value of attribute exporter.
25 26 27 |
# File 'lib/license_scout/exporter.rb', line 25 def exporter @exporter end |
#json_file ⇒ Object (readonly)
Returns the value of attribute json_file.
23 24 25 |
# File 'lib/license_scout/exporter.rb', line 23 def json_file @json_file end |
Class Method Details
.supported_formats ⇒ Object
40 41 42 43 44 |
# File 'lib/license_scout/exporter.rb', line 40 def self.supported_formats [ "csv", ] end |
Instance Method Details
#export ⇒ Object
46 47 48 49 |
# File 'lib/license_scout/exporter.rb', line 46 def export LicenseScout::Log.info("[exporter] Exporting #{json_file} to '#{export_format}'") exporter.export end |