Class: Ufo::Names
Instance Attribute Summary collapse
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Instance Method Summary collapse
- #app ⇒ Object
- #aws ⇒ Object
- #cluster ⇒ Object
- #env ⇒ Object (also: #ufo_env)
- #expansion(string, options = {}) ⇒ Object
-
#initialize ⇒ Names
constructor
A new instance of Names.
- #stack ⇒ Object
- #strip(string) ⇒ Object
- #task_definition ⇒ Object
- #var_value(unexpanded) ⇒ Object
Constructor Details
Instance Attribute Details
#role ⇒ Object (readonly)
Returns the value of attribute role.
5 6 7 |
# File 'lib/ufo/names.rb', line 5 def role @role end |
Instance Method Details
#aws ⇒ Object
64 65 66 |
# File 'lib/ufo/names.rb', line 64 def aws AwsData.new end |
#cluster ⇒ Object
10 11 12 |
# File 'lib/ufo/names.rb', line 10 def cluster expansion(Ufo.config.ecs.cluster) # IE: :ENV => dev end |
#env ⇒ Object Also known as: ufo_env
58 59 60 |
# File 'lib/ufo/names.rb', line 58 def env Ufo.env end |
#expansion(string, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ufo/names.rb', line 26 def expansion(string, ={}) return string unless string.is_a?(String) # in case of nil string = string.dup vars = string.scan(/:\w+/) # => [":APP", ":ROLE", :ENV"] 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
15 16 17 18 |
# File 'lib/ufo/names.rb', line 15 def stack name = expansion(Ufo.config.names.stack) # IE: :APP-:ROLE-:ENV => demo-web-dev [name, Ufo.extra].compact.join('-') end |
#strip(string) ⇒ Object
49 50 51 52 |
# File 'lib/ufo/names.rb', line 49 def strip(string) string.sub(/^-+/,'').sub(/-+$/,'') # remove leading and trailing - .gsub(%r{-+},'-') # remove double dashes are more. IE: -- => - end |
#task_definition ⇒ Object
21 22 23 |
# File 'lib/ufo/names.rb', line 21 def task_definition expansion(Ufo.config.names.task_definition) # IE: :APP-:ROLE-:ENV => demo-web-dev end |
#var_value(unexpanded) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/ufo/names.rb', line 40 def var_value() name = .sub(':','').downcase if respond_to?(name) send(name).to_s # pass value straight through else end end |