Class: LambdaWrap::Environment
- Inherits:
-
Object
- Object
- LambdaWrap::Environment
- Defined in:
- lib/lambda_wrap/environment.rb
Overview
Environment class to pass to the deploy and teardown
Instance Attribute Summary collapse
-
#description ⇒ String
readonly
The description of the environment.
-
#name ⇒ String
readonly
The descriptive name of the environment.
-
#variables ⇒ Hash
readonly
The Hash of environment variables to deploy with the environment.
Instance Method Summary collapse
-
#initialize(name, variables = {}, description = 'Managed by LambdaWrap') ⇒ Environment
constructor
Constructor.
- #to_s ⇒ Object
Constructor Details
#initialize(name, variables = {}, description = 'Managed by LambdaWrap') ⇒ Environment
Constructor
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/lambda_wrap/environment.rb', line 28 def initialize(name, variables = {}, description = 'Managed by LambdaWrap') raise ArgumentError, 'name must be provided (String)!' unless name && name.is_a?(String) # Max Alias Name length is 20 characters. raise ArgumentError, "Invalid name format: #{name}" unless /^[a-zA-Z0-9\-\_]{3,20}$/ =~ name @name = name raise ArgumentError, 'Variables must be a Hash!' unless variables.is_a?(Hash) variables.each do |key, value| next if /^[0-9a-zA-Z\_]{1,64}$/ =~ key && /^[A-Za-z0-9\-.\_~:\/?#&=,]{1,512}$/ =~ value && value.is_a?(String) raise ArgumentError, "Invalid Format of variables hash: #{key} => #{value}" end variables[:environment] = name unless variables[:environment] @variables = variables raise ArgumentError, 'Description must be a String!' unless description.is_a?(String) raise ArgumentError, 'Description too long (Max 256)' unless description.length < 256 @description = description end |
Instance Attribute Details
#description ⇒ String (readonly)
Returns The description of the environment.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lambda_wrap/environment.rb', line 14 class Environment attr_reader :name attr_reader :description attr_reader :variables # Constructor # # @param name [String] Name of the environment. Corresponds to the Lambda Alias and API Gateway Stage. # Must be at least 3 characters, and no more than 20 characters. # @param variables [Hash] Environment variables to pass to the API Gateway stage. Must be a flat hash. # Each key must be Alphanumeric (underscores allowed) and no more than 64 characters. Values can have # most special characters, and no more than 512 characters. # @param description [String] Description of the environment for Stage & Alias descriptions. Must not # exceed 256 characters. def initialize(name, variables = {}, description = 'Managed by LambdaWrap') raise ArgumentError, 'name must be provided (String)!' unless name && name.is_a?(String) # Max Alias Name length is 20 characters. raise ArgumentError, "Invalid name format: #{name}" unless /^[a-zA-Z0-9\-\_]{3,20}$/ =~ name @name = name raise ArgumentError, 'Variables must be a Hash!' unless variables.is_a?(Hash) variables.each do |key, value| next if /^[0-9a-zA-Z\_]{1,64}$/ =~ key && /^[A-Za-z0-9\-.\_~:\/?#&=,]{1,512}$/ =~ value && value.is_a?(String) raise ArgumentError, "Invalid Format of variables hash: #{key} => #{value}" end variables[:environment] = name unless variables[:environment] @variables = variables raise ArgumentError, 'Description must be a String!' unless description.is_a?(String) raise ArgumentError, 'Description too long (Max 256)' unless description.length < 256 @description = description end def to_s return @name if @name && @name.is_a?(String) super end end |
#name ⇒ String (readonly)
Returns The descriptive name of the environment.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lambda_wrap/environment.rb', line 14 class Environment attr_reader :name attr_reader :description attr_reader :variables # Constructor # # @param name [String] Name of the environment. Corresponds to the Lambda Alias and API Gateway Stage. # Must be at least 3 characters, and no more than 20 characters. # @param variables [Hash] Environment variables to pass to the API Gateway stage. Must be a flat hash. # Each key must be Alphanumeric (underscores allowed) and no more than 64 characters. Values can have # most special characters, and no more than 512 characters. # @param description [String] Description of the environment for Stage & Alias descriptions. Must not # exceed 256 characters. def initialize(name, variables = {}, description = 'Managed by LambdaWrap') raise ArgumentError, 'name must be provided (String)!' unless name && name.is_a?(String) # Max Alias Name length is 20 characters. raise ArgumentError, "Invalid name format: #{name}" unless /^[a-zA-Z0-9\-\_]{3,20}$/ =~ name @name = name raise ArgumentError, 'Variables must be a Hash!' unless variables.is_a?(Hash) variables.each do |key, value| next if /^[0-9a-zA-Z\_]{1,64}$/ =~ key && /^[A-Za-z0-9\-.\_~:\/?#&=,]{1,512}$/ =~ value && value.is_a?(String) raise ArgumentError, "Invalid Format of variables hash: #{key} => #{value}" end variables[:environment] = name unless variables[:environment] @variables = variables raise ArgumentError, 'Description must be a String!' unless description.is_a?(String) raise ArgumentError, 'Description too long (Max 256)' unless description.length < 256 @description = description end def to_s return @name if @name && @name.is_a?(String) super end end |
#variables ⇒ Hash (readonly)
Returns The Hash of environment variables to deploy with the environment.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lambda_wrap/environment.rb', line 14 class Environment attr_reader :name attr_reader :description attr_reader :variables # Constructor # # @param name [String] Name of the environment. Corresponds to the Lambda Alias and API Gateway Stage. # Must be at least 3 characters, and no more than 20 characters. # @param variables [Hash] Environment variables to pass to the API Gateway stage. Must be a flat hash. # Each key must be Alphanumeric (underscores allowed) and no more than 64 characters. Values can have # most special characters, and no more than 512 characters. # @param description [String] Description of the environment for Stage & Alias descriptions. Must not # exceed 256 characters. def initialize(name, variables = {}, description = 'Managed by LambdaWrap') raise ArgumentError, 'name must be provided (String)!' unless name && name.is_a?(String) # Max Alias Name length is 20 characters. raise ArgumentError, "Invalid name format: #{name}" unless /^[a-zA-Z0-9\-\_]{3,20}$/ =~ name @name = name raise ArgumentError, 'Variables must be a Hash!' unless variables.is_a?(Hash) variables.each do |key, value| next if /^[0-9a-zA-Z\_]{1,64}$/ =~ key && /^[A-Za-z0-9\-.\_~:\/?#&=,]{1,512}$/ =~ value && value.is_a?(String) raise ArgumentError, "Invalid Format of variables hash: #{key} => #{value}" end variables[:environment] = name unless variables[:environment] @variables = variables raise ArgumentError, 'Description must be a String!' unless description.is_a?(String) raise ArgumentError, 'Description too long (Max 256)' unless description.length < 256 @description = description end def to_s return @name if @name && @name.is_a?(String) super end end |
Instance Method Details
#to_s ⇒ Object
48 49 50 51 |
# File 'lib/lambda_wrap/environment.rb', line 48 def to_s return @name if @name && @name.is_a?(String) super end |