Sha256: 95b2b072faf61064b47fde13b966d7a1cb588e1689a2ebe0f35640483c0d0e9e

Contents?: true

Size: 837 Bytes

Versions: 3

Compression:

Stored size: 837 Bytes

Contents

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

      def initialize(file)
        @data = YAML.load_file(file)
      end

      def instance_settings(instance)
        ::EacLauncher::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

3 entries across 3 versions & 1 rubygems

Version Path
eac_launcher-0.5.1 lib/eac_launcher/context/settings.rb
eac_launcher-0.5.0 lib/eac_launcher/context/settings.rb
eac_launcher-0.4.0 lib/eac_launcher/context/settings.rb