Class: Ufo::Names
Instance Attribute Summary collapse
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Instance Method Summary collapse
- #app ⇒ Object
- #cluster ⇒ Object
- #env ⇒ Object (also: #ufo_env)
- #expansion(string, options = {}) ⇒ Object
- #extra ⇒ Object
-
#initialize ⇒ Names
constructor
A new instance of Names.
-
#stack ⇒ Object
Examples: When UFO_EXTRA not set: :APP-:ROLE-:ENV-:EXTRA => demo-web-dev When UFO_EXTRA=1: :APP-:ROLE-:ENV-:EXTRA => demo-web-dev-2.
- #strip(string) ⇒ Object
-
#task_definition ⇒ Object
Examples: When UFO_EXTRA not set: :APP-:ROLE-:ENV-:EXTRA => demo-web-dev When UFO_EXTRA=1: :APP-:ROLE-:ENV-:EXTRA => demo-web-dev-2.
- #var_value(unexpanded) ⇒ Object
Methods included from Config::CallableOption::Concern
Methods included from TaskDefinition::Helpers::AwsHelper
Constructor Details
Instance Attribute Details
#role ⇒ Object (readonly)
Returns the value of attribute role.
7 8 9 |
# File 'lib/ufo/names.rb', line 7 def role @role end |
Instance Method Details
#cluster ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/ufo/names.rb', line 12 def cluster string = callable_option( config_name: "ecs.cluster", # Ufo.ecs.cluster => :ENV => dev passed_args: [self], ) expansion(string) # IE: :ENV => dev end |
#env ⇒ Object Also known as: ufo_env
77 78 79 |
# File 'lib/ufo/names.rb', line 77 def env Ufo.env end |
#expansion(string, options = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ufo/names.rb', line 45 def expansion(string, ={}) return string unless string.is_a?(String) # in case of nil string = string.dup vars = string.scan(/:\w+/) # => [":APP", ":ROLE", :ENV", ":EXTRA"] vars.each do |var| string.gsub!(var, var_value(var)) end string = strip(string) dashes = [:dasherize].nil? ? true : [:dasherize] string = string.dasherize if dashes string end |
#stack ⇒ Object
Examples: When UFO_EXTRA not set: :APP-:ROLE-:ENV-:EXTRA => demo-web-dev When UFO_EXTRA=1: :APP-:ROLE-:ENV-:EXTRA => demo-web-dev-2
24 25 26 27 28 29 30 |
# File 'lib/ufo/names.rb', line 24 def stack string = callable_option( config_name: "names.stack", # Ufo.config.names.stack => :APP-:ROLE-:ENV => demo-web-dev passed_args: [self], ) expansion(string) # IE: :APP-:ROLE-:ENV => demo-web-dev end |
#strip(string) ⇒ Object
68 69 70 71 |
# File 'lib/ufo/names.rb', line 68 def strip(string) string.sub(/^-+/,'').sub(/-+$/,'') # remove leading and trailing - .gsub(%r{-+},'-') # remove double dashes are more. IE: -- => - end |
#task_definition ⇒ Object
Examples: When UFO_EXTRA not set: :APP-:ROLE-:ENV-:EXTRA => demo-web-dev When UFO_EXTRA=1: :APP-:ROLE-:ENV-:EXTRA => demo-web-dev-2
36 37 38 39 40 41 42 |
# File 'lib/ufo/names.rb', line 36 def task_definition string = callable_option( config_name: "names.task_definition", # Ufo.config.names.task_definition => :APP-:ROLE-:ENV => demo-web-dev passed_args: [self], ) expansion(string) # IE: :APP-:ROLE-:ENV => demo-web-dev end |
#var_value(unexpanded) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/ufo/names.rb', line 59 def var_value() name = .sub(':','').downcase if respond_to?(name) send(name).to_s # pass value straight through else end end |