Sha256: 96e86f3019847b7de648836bf6cb8ebdf98691f411d243042d734cf253a786e6

Contents?: true

Size: 907 Bytes

Versions: 21

Compression:

Stored size: 907 Bytes

Contents

module CfnDsl
  # Plural names for lists of content objects
  module Plurals
    @plurals = {
      'Metadata' => 'Metadata',
      'Property' => 'Properties',
      'Policy' => 'Policies',
      'PolicyDocument' => 'PolicyDocument',
      'AssumeRolePolicyDocument' => 'AssumeRolePolicyDocument',
      'SecurityGroupIngress' => 'SecurityGroupIngress',
      'SecurityGroupEgress' => 'SecurityGroupEgress',
      'DBSecurityGroupIngress' => 'DBSecurityGroupIngress',
      'UpdatePolicy' => 'UpdatePolicy',
      'CreationPolicy' => 'CreationPolicy'
    }

    @singles = {}
    @plurals.each_pair { |key, val| @singles[val] = key }

    def self.pluralize(name)
      name = name.to_s
      return @plurals[name] if @plurals.key?(name)

      "#{name}s"
    end

    def self.singularize(name)
      name = name.to_s
      return @singles[name] if @singles.key?(name)

      name[0..-2]
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
cfndsl-0.9.2 lib/cfndsl/plurals.rb
cfndsl-0.9.1 lib/cfndsl/plurals.rb
cfndsl-0.9.0 lib/cfndsl/plurals.rb
cfndsl-0.8.9 lib/cfndsl/plurals.rb
cfndsl-0.8.8 lib/cfndsl/plurals.rb
cfndsl-0.8.7 lib/cfndsl/plurals.rb
cfndsl-0.8.6 lib/cfndsl/plurals.rb
cfndsl-0.8.5 lib/cfndsl/plurals.rb
cfndsl-0.8.4 lib/cfndsl/plurals.rb
cfndsl-0.8.3 lib/cfndsl/plurals.rb
cfndsl-0.8.2 lib/cfndsl/plurals.rb
cfndsl-0.8.1 lib/cfndsl/plurals.rb
cfndsl-0.7.0 lib/cfndsl/plurals.rb
cfndsl-0.6.2 lib/cfndsl/plurals.rb
cfndsl-0.6.1 lib/cfndsl/plurals.rb
cfndsl-0.6.0 lib/cfndsl/plurals.rb
cfndsl-0.5.2 lib/cfndsl/plurals.rb
cfndsl-0.5.1 lib/cfndsl/plurals.rb
cfndsl-0.5.0 lib/cfndsl/plurals.rb
cfndsl-0.5.1.pre lib/cfndsl/plurals.rb