Sha256: a3d666755892c0fba04e6dcf2c451b987314fbeebc08cc79f631588018919196

Contents?: true

Size: 825 Bytes

Versions: 21

Compression:

Stored size: 825 Bytes

Contents

# frozen_string_literal: true

module Aws
  module Partitions
    # @api private
    module Metadata
      class << self

        # aws.partition(region: string) Option<Partition>
        def partition(region)
          partition =
            partitions.find { |p| p['regions']&.fetch(region, nil) } ||
            partitions.find { |p| region.match(p['regionRegex']) } ||
            partitions.find { |p| p['id'] == 'aws' }

          return nil unless partition

          partition['outputs']
        end

        def partitions
          @partitions ||= default_partition_metadata
        end

        def default_partition_metadata
          path = File.expand_path('../../../partitions-metadata.json', __FILE__)
          JSON.parse(File.read(path), freeze: true)['partitions']
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
aws-partitions-1.1012.0 lib/aws-partitions/metadata.rb
aws-partitions-1.1011.0 lib/aws-partitions/metadata.rb
aws-partitions-1.1010.0 lib/aws-partitions/metadata.rb
aws-partitions-1.1009.0 lib/aws-partitions/metadata.rb
aws-partitions-1.1008.0 lib/aws-partitions/metadata.rb
aws-partitions-1.1007.0 lib/aws-partitions/metadata.rb
aws-partitions-1.1006.0 lib/aws-partitions/metadata.rb
aws-partitions-1.1005.0 lib/aws-partitions/metadata.rb
aws-partitions-1.1004.0 lib/aws-partitions/metadata.rb
aws-partitions-1.1003.0 lib/aws-partitions/metadata.rb
aws-partitions-1.1002.0 lib/aws-partitions/metadata.rb
aws-partitions-1.1001.0 lib/aws-partitions/metadata.rb
aws-partitions-1.1000.0 lib/aws-partitions/metadata.rb
aws-partitions-1.999.0 lib/aws-partitions/metadata.rb
aws-partitions-1.998.0 lib/aws-partitions/metadata.rb
aws-partitions-1.997.0 lib/aws-partitions/metadata.rb
aws-partitions-1.996.0 lib/aws-partitions/metadata.rb
aws-partitions-1.995.0 lib/aws-partitions/metadata.rb
aws-partitions-1.994.0 lib/aws-partitions/metadata.rb
aws-partitions-1.993.0 lib/aws-partitions/metadata.rb