Module: Wicked::Pipeline::Generators::Helpers
- Included in:
- Erb::Wicked::Pipeline::ControllerGenerator, ControllerGenerator, StepGenerator, Wicked::PipelineGenerator
- Defined in:
- lib/generators/wicked/pipeline/helpers.rb
Instance Method Summary collapse
- #available_locales ⇒ Object
- #hashify_locale_keypath(keypath) ⇒ Object
- #indented(indentation = 2, &block) ⇒ Object
- #options_as_switches ⇒ Object
- #remove_possible_suffix(name, *suffixes) ⇒ Object
Instance Method Details
#available_locales ⇒ Object
7 8 9 |
# File 'lib/generators/wicked/pipeline/helpers.rb', line 7 def available_locales @_available_locales ||= I18n.available_locales.presence || [I18n.default_locale.presence || :en] end |
#hashify_locale_keypath(keypath) ⇒ Object
11 12 13 |
# File 'lib/generators/wicked/pipeline/helpers.rb', line 11 def hashify_locale_keypath(keypath) keypath.split(".").reverse.inject(nil) { |assigned_value, key| {key.to_s => assigned_value} } end |
#indented(indentation = 2, &block) ⇒ Object
15 16 17 |
# File 'lib/generators/wicked/pipeline/helpers.rb', line 15 def indented(indentation = 2, &block) concat(indent(capture(&block), indentation)) end |
#options_as_switches ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/generators/wicked/pipeline/helpers.rb', line 30 def @options_as_switches ||= .compact_blank.each_with_object([]) do |(option, value), obj| next unless value obj << "--#{option.to_s.dasherize}" obj << value.presence unless value == true end end |
#remove_possible_suffix(name, *suffixes) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/generators/wicked/pipeline/helpers.rb', line 19 def remove_possible_suffix(name, *suffixes) regex = if suffixes.empty? /_?(?:(:?steps_?)?controller|pipeline|step)\z/i else /_?(?:#{Regexp.union(*suffixes)})\z/i end name.sub(regex, "") end |