Sha256: 0f9aca13fea71f473b12a9afb04162ba1d22cd714a263e1529986e95e5ae7ce6

Contents?: true

Size: 1.08 KB

Versions: 13

Compression:

Stored size: 1.08 KB

Contents

require 'json'
require 'fileutils'

class BrandExporter

    def start(brand_keys, path)
        if !path.nil? && !path.strip.empty? && !File.directory?(path)
            Solara.logger.failure("#{path} is not a directory. Please specify a valid directory.")
            return
        end

        directory = path || FilePath.project_root

        brand_keys.each do |brand_key|
            export(brand_key, directory)
        end
    end

    private

    def export(brand_key, directory)
        unless BrandsManager.instance.exists(brand_key)
            Solara.logger.failure("#{brand_key} doesn't exist!")
            return
        end
        
        brand = BrandsManager.instance.brand_with_configurations(brand_key)
        json = JSON.pretty_generate(brand)
        json_file_path = File.join(directory, "#{brand_key}-solara-configurations.json")

        # Create the file if it does not exist
        File.open(json_file_path, 'w') do |file|
            file.write(json)
        end

        Solara.logger.success("Successfully exported brand #{brand_key} to: #{json_file_path}")
    end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
solara-0.7.4 solara/lib/core/scripts/brand_exporter.rb
solara-0.7.3 solara/lib/core/scripts/brand_exporter.rb
solara-0.7.2 solara/lib/core/scripts/brand_exporter.rb
solara-0.7.1 solara/lib/core/scripts/brand_exporter.rb
solara-0.7.0 solara/lib/core/scripts/brand_exporter.rb
solara-0.6.0 solara/lib/core/scripts/brand_exporter.rb
solara-0.5.0 solara/lib/core/scripts/brand_exporter.rb
solara-0.4.0 solara/lib/core/scripts/brand_exporter.rb
solara-0.3.0 solara/lib/core/scripts/brand_exporter.rb
solara-0.2.4 solara/lib/core/scripts/brand_exporter.rb
solara-0.2.3 solara/lib/core/scripts/brand_exporter.rb
solara-0.2.2 solara/lib/core/scripts/brand_exporter.rb
solara-0.2.1 solara/lib/core/scripts/brand_exporter.rb