Sha256: 067362a9c8ab683acade3a6a43fe5db6a58e712eaf76d2439de49846ab5234ca

Contents?: true

Size: 1.43 KB

Versions: 97

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module Avm
  module Launcher
    module Instances
      class Settings
        DEFAULT_CURRENT_REVISION = 'origin/master'
        DEFAULT_PUBLISH_REMOTE = 'publish'
        PUBLISHABLE_KEY = :publishable

        common_constructor :data do
          self.data = (data.is_a?(Hash) ? data : {}).with_indifferent_access
        end

        def git_current_revision
          data[__method__] || DEFAULT_CURRENT_REVISION
        end

        def git_publish_remote
          data[__method__] || DEFAULT_PUBLISH_REMOTE
        end

        def publishable?
          publishable_value ? true : false
        end

        def stereotype_publishable?(stereotype)
          return publishable? unless publishable_value.is_a?(::Hash)

          parse_publishable_value(publishable_value[stereotype.stereotype_name], true)
        end

        private

        def publishable_value
          parse_publishable_value(data[PUBLISHABLE_KEY], false)
        end

        def parse_publishable_value(value, hash_to_true)
          return value.with_indifferent_access if parse_publishable_value_hash?(value, hash_to_true)
          return true if value.nil? || value == true
          return false if value == false

          value ? true : false
        end

        def parse_publishable_value_hash?(value, hash_to_true)
          !hash_to_true && value.is_a?(::Hash)
        end
      end
    end
  end
end

Version data entries

97 entries across 97 versions & 3 rubygems

Version Path
eac_tools-0.44.0 sub/avm/lib/avm/launcher/instances/settings.rb
eac_tools-0.43.0 sub/avm/lib/avm/launcher/instances/settings.rb
avm-0.55.0 lib/avm/launcher/instances/settings.rb
eac_tools-0.42.0 sub/avm/lib/avm/launcher/instances/settings.rb
eac_tools-0.41.0 sub/avm/lib/avm/launcher/instances/settings.rb
avm-0.54.0 lib/avm/launcher/instances/settings.rb
eac_tools-0.40.0 sub/avm/lib/avm/launcher/instances/settings.rb
avm-0.53.0 lib/avm/launcher/instances/settings.rb
eac_tools-0.39.0 sub/avm/lib/avm/launcher/instances/settings.rb
avm-0.52.0 lib/avm/launcher/instances/settings.rb
eac_tools-0.38.0 sub/avm/lib/avm/launcher/instances/settings.rb
avm-0.51.0 lib/avm/launcher/instances/settings.rb
eac_tools-0.37.2 sub/avm/lib/avm/launcher/instances/settings.rb
avm-0.50.0 lib/avm/launcher/instances/settings.rb
eac_tools-0.37.1 sub/avm/lib/avm/launcher/instances/settings.rb
avm-0.49.0 lib/avm/launcher/instances/settings.rb
eac_tools-0.37.0 sub/avm/lib/avm/launcher/instances/settings.rb
avm-0.48.0 lib/avm/launcher/instances/settings.rb
eac_tools-0.36.1 sub/avm/lib/avm/launcher/instances/settings.rb
avm-0.47.0 lib/avm/launcher/instances/settings.rb