Sha256: 3e4973fd24e71e7c2ea82b5b39cc20d0e2658dd0d9a5d5434cd487dfd1888095

Contents?: true

Size: 921 Bytes

Versions: 14

Compression:

Stored size: 921 Bytes

Contents

# frozen_string_literal: true

require 'avm/applications/base'
require 'eac_config/entry_path'
require 'eac_ruby_utils/core_ext'

module Avm
  module Sources
    class Base
      module Application
        APPLICATION_NAME_KEY = 'application'

        # @return [Avm::Applications::Base]
        def application
          @application ||= ::Avm::Applications::Base.new(application_id)
        end

        # @return [String]
        def application_id
          application_id_by_configuration || application_id_by_directory
        end

        # @return [String, nil]
        def application_id_by_configuration
          configuration.entry(APPLICATION_NAME_KEY).value
        end

        # @return [String]
        def application_id_by_directory
          path.basename.to_path.gsub(::EacConfig::EntryPath::PART_SEPARATOR, '-')
            .gsub(/\A-+/, '').gsub(/-+\z/, '')
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
avm-0.94.1 lib/avm/sources/base/application.rb
eac_tools-0.98.0 sub/avm/lib/avm/sources/base/application.rb
avm-0.94.0 lib/avm/sources/base/application.rb
eac_tools-0.94.0 sub/avm/lib/avm/sources/base/application.rb
avm-0.93.0 lib/avm/sources/base/application.rb
eac_tools-0.92.0 sub/avm/lib/avm/sources/base/application.rb
avm-0.92.0 lib/avm/sources/base/application.rb
eac_tools-0.91.0 sub/avm/lib/avm/sources/base/application.rb
avm-0.90.1 lib/avm/sources/base/application.rb
eac_tools-0.87.1 sub/avm/lib/avm/sources/base/application.rb
avm-0.90.0 lib/avm/sources/base/application.rb
eac_tools-0.87.0 sub/avm/lib/avm/sources/base/application.rb
avm-0.89.0 lib/avm/sources/base/application.rb
eac_tools-0.86.12 sub/avm/lib/avm/sources/base/application.rb