Sha256: ff574d1d6e9a22924d4525696b4a1d81239ceb3106900d8e847109883c48f489

Contents?: true

Size: 762 Bytes

Versions: 15

Compression:

Stored size: 762 Bytes

Contents

require 'singleton'

require 'singleton'
require 'json'

require 'singleton'
require 'json'

class ProjectSettingsManager
    include Singleton

    attr_accessor :root, :project_root

    def value(key, platform)
        settings.dig(platform.to_s, key)
    end

    def add(key, value, platform)
        json = settings
        json[platform.to_s] ||= {}
        json[platform.to_s][key] = value
        save(json)
    end

    private

    def settings
        path = FilePath.project_settings
        FileManager.create_file_if_not_exist(path)
        JSON.parse(File.read(path))
    rescue JSON::ParserError => e
        {}
    end

    def save(json)
        path = FilePath.project_settings
        File.write(path, JSON.pretty_generate(json))
    end
end

Version data entries

15 entries across 15 versions & 1 rubygems

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