Sha256: 6f4eb539759608b761793498ff4eff82c3fb1842c6b0cc5318e40f245d348055

Contents?: true

Size: 1018 Bytes

Versions: 15

Compression:

Stored size: 1018 Bytes

Contents

# frozen_string_literal: true

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 = %w[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

15 entries across 15 versions & 1 rubygems

Version Path
nexmo-oas-renderer-2.7.2 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.7.1 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.7.0 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.6.0 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.5.0 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.4.1 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.4.0 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.3.0 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.2.0 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.1.3 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.1.2 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.1.1 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.1.0 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.0.1 lib/nexmo/oas/renderer/helpers/summary.rb
nexmo-oas-renderer-2.0.0 lib/nexmo/oas/renderer/helpers/summary.rb