Module: Convection::DSL::Helpers
- Extended by:
- Forwardable
- Includes:
- IntrinsicFunctions
- Included in:
- Cloudfile, Template, Model::Mixin::Policy, Model::Mixin::Policy::Statement, Model::Template::Condition, Model::Template::Mapping, Model::Template::Output, Model::Template::Parameter, Model::Template::Resource, Model::Template::ResourceProperty
- Defined in:
- lib/convection/dsl/helpers.rb
Overview
Helper methods for creating templates
Class Method Summary collapse
Instance Method Summary collapse
-
#camel_case(str) ⇒ Object
Convert various casings to CamelCase.
-
#screaming_snake_case(str) ⇒ Object
Convert various casings to SCREAMING_SNAKE_CASE.
-
#snake_case(str) ⇒ Object
Convert various casings to snake_case.
Methods included from IntrinsicFunctions
#base64, #find_in_map, #fn_and, #fn_equals, #fn_if, #fn_not, #fn_or, #fn_ref, #get_att, #get_azs, #join, #select
Class Method Details
.included(mod) ⇒ Object
37 38 39 |
# File 'lib/convection/dsl/helpers.rb', line 37 def included(mod) mod.extend(DSL::ClassHelpers) end |
.method_name(cf_type) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/convection/dsl/helpers.rb', line 41 def method_name(cf_type) nodes = cf_type.split('::') nodes.shift # Remove AWS:: ## Cammel-case to snake-case nodes.map! do |n| n.split(/([A-Z0-9])(?![A-Z0-9])(?<!$)/) .reject(&:empty?) .reduce('') { |a, e| (e.length == 1 && !a.empty?) ? a + "_#{e}" : a + e } .downcase end nodes.join('_').downcase end |
Instance Method Details
#camel_case(str) ⇒ Object
Convert various casings to CamelCase
58 59 60 |
# File 'lib/convection/dsl/helpers.rb', line 58 def camel_case(str) str.downcase.split(/[\.\-_]/).map(&:capitalize).join end |
#screaming_snake_case(str) ⇒ Object
Convert various casings to SCREAMING_SNAKE_CASE
68 69 70 |
# File 'lib/convection/dsl/helpers.rb', line 68 def screaming_snake_case(str) str.upcase.split(/[\.\-_]/).join('_') end |
#snake_case(str) ⇒ Object
Convert various casings to snake_case
63 64 65 |
# File 'lib/convection/dsl/helpers.rb', line 63 def snake_case(str) str.downcase.split(/[\.\-_]/).join('_') end |