Sha256: 448515246e560218afb8e38869fa61dde9ee6da4a04ac69de2a3fffb3470ea3a

Contents?: true

Size: 1.09 KB

Versions: 52

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require 'avm/launcher/instances/settings'
require 'eac_ruby_utils/simple_cache'
require 'yaml'

module EacLauncher
  class Context
    class Settings
      include ::EacRubyUtils::SimpleCache

      def initialize(file)
        unless ::File.exist?(file)
          ::FileUtils.mkdir_p(::File.dirname(file))
          ::File.write(file, {}.to_yaml)
        end
        @data = YAML.load_file(file)
      end

      def instance_settings(instance)
        ::Avm::Launcher::Instances::Settings.new(value(['Instances', instance.name]))
      end

      private

      def excluded_projects_uncached
        enum_value(%w[Projects Exclude])
      end

      def excluded_paths_uncached
        enum_value(%w[Paths Exclude])
      end

      def enum_value(path)
        r = value(path)
        r.is_a?(Enumerable) ? r : []
      end

      def value(path)
        node_value(@data, path)
      end

      def node_value(data, path)
        return data if path.empty?
        return nil unless data.is_a?(Hash)

        node_value(data[path.first], path.drop(1))
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
avm-tools-0.99.0 lib/eac_launcher/context/settings.rb
avm-tools-0.98.0 lib/eac_launcher/context/settings.rb
avm-tools-0.97.0 lib/eac_launcher/context/settings.rb
avm-tools-0.96.0 lib/eac_launcher/context/settings.rb
avm-tools-0.95.0 lib/eac_launcher/context/settings.rb
avm-tools-0.94.3 lib/eac_launcher/context/settings.rb
avm-tools-0.94.2 lib/eac_launcher/context/settings.rb
avm-tools-0.94.1 lib/eac_launcher/context/settings.rb
avm-tools-0.94.0 lib/eac_launcher/context/settings.rb
avm-tools-0.93.0 lib/eac_launcher/context/settings.rb
avm-tools-0.92.0 lib/eac_launcher/context/settings.rb
avm-tools-0.91.0 lib/eac_launcher/context/settings.rb
avm-tools-0.90.0 lib/eac_launcher/context/settings.rb
avm-tools-0.89.0 lib/eac_launcher/context/settings.rb
avm-tools-0.88.0 lib/eac_launcher/context/settings.rb
avm-tools-0.87.1 lib/eac_launcher/context/settings.rb
avm-tools-0.87.0 lib/eac_launcher/context/settings.rb
avm-tools-0.86.0 lib/eac_launcher/context/settings.rb
avm-tools-0.85.1 lib/eac_launcher/context/settings.rb
avm-tools-0.85.0 lib/eac_launcher/context/settings.rb