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::ResourceCollection, 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_import_value, #fn_not, #fn_or, #fn_ref, #fn_sub, #get_att, #get_azs, #join, mixers, #select
Class Method Details
.included(mod) ⇒ Object
37 38 39 40 41 |
# File 'lib/convection/dsl/helpers.rb', line 37 def included(mod) DSL::IntrinsicFunctions.mixers << mod mod.extend(DSL::ClassHelpers) end |
.method_name(cf_type) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/convection/dsl/helpers.rb', line 43 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
60 61 62 |
# File 'lib/convection/dsl/helpers.rb', line 60 def camel_case(str) str.downcase.split(/[\.\-_]/).map(&:capitalize).join end |
#screaming_snake_case(str) ⇒ Object
Convert various casings to SCREAMING_SNAKE_CASE
70 71 72 |
# File 'lib/convection/dsl/helpers.rb', line 70 def screaming_snake_case(str) str.upcase.split(/[\.\-_]/).join('_') end |
#snake_case(str) ⇒ Object
Convert various casings to snake_case
65 66 67 |
# File 'lib/convection/dsl/helpers.rb', line 65 def snake_case(str) str.downcase.split(/[\.\-_]/).join('_') end |