Sha256: 9a4dc5ce3855b6c98634e262458f18ff81bd969d369168d10275957f8c558097

Contents?: true

Size: 853 Bytes

Versions: 12

Compression:

Stored size: 853 Bytes

Contents

# frozen_string_literal: true

module Byebug
  module Helpers
    #
    # Utilities for interaction with strings
    #
    module StringHelper
      #
      # Converts +str+ from an_underscored-or-dasherized_string to
      # ACamelizedString.
      #
      def camelize(str)
        str.dup.split(/[_-]/).map(&:capitalize).join("")
      end

      #
      # Improves indentation and spacing in +str+ for readability in Byebug's
      # command prompt.
      #
      def prettify(str)
        "\n" + deindent(str) + "\n"
      end

      #
      # Removes a number of leading whitespace for each input line.
      #
      # @note Might be unnecessary when Ruby 2.2 support is dropped and we can
      # use squiggly heredoc's.
      #
      def deindent(str, leading_spaces: 6)
        str.gsub(/^ {#{leading_spaces}}/, "")
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 5 rubygems

Version Path
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/byebug-10.0.2/lib/byebug/helpers/string.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/byebug-10.0.2/lib/byebug/helpers/string.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/byebug-10.0.2/lib/byebug/helpers/string.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/byebug-10.0.2/lib/byebug/helpers/string.rb
jets-0.5.5 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/helpers/string.rb
jets-0.5.4 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/helpers/string.rb
jets-0.5.3 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/helpers/string.rb
jets-0.5.2 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/helpers/string.rb
jets-0.5.1 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/helpers/string.rb
byebug-10.0.2 lib/byebug/helpers/string.rb
byebug-10.0.1 lib/byebug/helpers/string.rb
byebug-10.0.0 lib/byebug/helpers/string.rb