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.84.0 lib/avm/instances/ids.rb
eac_tools-0.83.0 sub/avm/lib/avm/instances/ids.rb
avm-0.83.0 lib/avm/instances/ids.rb
eac_tools-0.82.0 sub/avm/lib/avm/instances/ids.rb
avm-0.82.0 lib/avm/instances/ids.rb
eac_tools-0.81.0 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.80.0 sub/avm/lib/avm/instances/ids.rb
avm-0.81.0 lib/avm/instances/ids.rb
eac_tools-0.79.0 sub/avm/lib/avm/instances/ids.rb
avm-0.80.0 lib/avm/instances/ids.rb
eac_tools-0.78.0 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.77.1 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.77.0 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.76.1 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.76.0 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.75.2 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.75.1 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.75.0 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.74.1 sub/avm/lib/avm/instances/ids.rb
eac_tools-0.74.0 sub/avm/lib/avm/instances/ids.rb