Sha256: 9ab14b01b43479a7cd2e2af0ba7030c672db13916f19601e645cb0def20028a9

Contents?: true

Size: 989 Bytes

Versions: 37

Compression:

Stored size: 989 Bytes

Contents

module Nexmo
  module OAS
    module Renderer
      module Helpers
        module Summary
          def normalize_summary_title(summary, operation_id)
            # return summary early if provided
            return summary unless summary.nil?

            # If the operation ID is camelCase,
            if operation_id.match?(/^[a-zA-Z]\w+(?:[A-Z]\w+){1,}/x)
              # Use the rails `.underscore` method to convert someString to some_string
              operation_id = operation_id.underscore
            end

            # Replace snake_case and kebab-case with spaces and titelize the string
            operation_id = operation_id.gsub(/(_|-)/, ' ').titleize

            # Some terms need to be capitalised all the time
            uppercase_array = ['SMS', 'DTMF']
            operation_id.split(' ').map do |c|
              next c.upcase if uppercase_array.include?(c.upcase)
              c
            end.join(' ')
          end
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
nexmo-oas-renderer-0.11.3 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.11.2 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.11.1 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.11.0 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.10.0 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.9.0 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.8.0 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.7.1 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.7.0 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.6.6 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.6.5 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.6.4 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.6.3 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.6.2 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.6.1 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.5.6 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.5.5 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.5.4 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.5.2 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-0.5.1 lib/nexmo/oas/renderer/helpers/summary.rb