Sha256: a7969406a7fa6a65cedf7f21046a7c54e75d32a4b2725282dd009e357753eece

Contents?: true

Size: 749 Bytes

Versions: 104

Compression:

Stored size: 749 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module Avm
  module Instances
    module Ids
      ID_PARTS_SEPARATOR = '_'
      ID_PATTERN = /\A([a-z0-9]+(?:\-[a-z0-9]+)*)_(.+)\z/.freeze
      ID_PARSER = ID_PATTERN.to_parser do |m|
        ::Struct.new(:application_id, :instance_suffix).new(m[1], m[2])
      end

      class << self
        # @param application_id [String]
        # @param instance_suffix [String]
        # @return [String]
        def build(application_id, instance_suffix)
          [application_id, instance_suffix].join(ID_PARTS_SEPARATOR)
        end

        # @param id [String]
        # @return [String]
        def parse!(id)
          ID_PARSER.parse!(id)
        end
      end
    end
  end
end

Version data entries

104 entries across 104 versions & 2 rubygems

Version Path
avm-0.71.0 lib/avm/instances/ids.rb
eac_tools-0.65.0 sub/avm/lib/avm/instances/ids.rb
avm-0.70.0 lib/avm/instances/ids.rb
eac_tools-0.64.0 sub/avm/lib/avm/instances/ids.rb
avm-0.69.0 lib/avm/instances/ids.rb
eac_tools-0.63.0 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.62.1 sub/avm/lib/avm/instances/ids.rb
avm-0.68.0 lib/avm/instances/ids.rb
eac_tools-0.62.0 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.61.1 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.61.0 sub/avm/lib/avm/instances/ids.rb
avm-0.67.1 lib/avm/instances/ids.rb
eac_tools-0.60.3 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.60.2 sub/avm/lib/avm/instances/ids.rb
avm-0.67.0 lib/avm/instances/ids.rb
eac_tools-0.60.1 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.60.0 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.59.0 sub/avm/lib/avm/instances/ids.rb
avm-0.66.1 lib/avm/instances/ids.rb
eac_tools-0.58.0 sub/avm/lib/avm/instances/ids.rb