Sha256: d7b6cf59e18119dcb7a9eb9065bbb1a20ace168770f6867504e193ff53fe0823
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
require 'singleton' require 'singleton' require 'json' class SolaraSettingsManager include Singleton attr_accessor :root, :project_root def platform settings['platform'] end def platform=(new_platform) json = settings json['platform'] = new_platform save(json) end def value(key) settings[key] end def add(key, value) json = settings json[key] = value save(json) end private def settings path = FilePath.solara_settings FileManager.create_file_if_not_exist(path) JSON.parse(File.read(path)) rescue JSON::ParserError => e {} end def save(json) File.write(FilePath.solara_settings, JSON.pretty_generate(json)) end end module Platform Flutter = 'flutter' Android = 'android' IOS = 'ios' Unknown = 'unknown' def self.all [Flutter, Android, IOS] end def self.is_ios SolaraSettingsManager.instance.platform.downcase == IOS.downcase end def self.is_android SolaraSettingsManager.instance.platform.downcase == Android.downcase end def self.is_flutter SolaraSettingsManager.instance.platform.downcase == Flutter.downcase end end def init(platform) unless Platform.all.include?(platform) raise ArgumentError, "Invalid platform. Please use one of: #{Platform.all.join(', ')}" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
solara-0.2.0 | solara/lib/core/scripts/solara_settings_manager.rb |
solara-0.1.0 | solara/lib/core/scripts/solara_settings_manager.rb |