Sha256: c59741b1595c16928857ec78aada0cc1c3c9e05b90e1052ad81df796e38bb673

Contents?: true

Size: 565 Bytes

Versions: 11

Compression:

Stored size: 565 Bytes

Contents

# frozen_string_literal: true

class String
  def self.clean_certificate(str)
    CGI.unescape(str).gsub(/(\n|-+(BEGIN|END)\s+CERTIFICATE-+|\s+)/, '').strip
  end

  def clean_certificate
    String.clean_certificate(self)
  end

  def clean_certificate!
    self.replace clean_certificate
  end

  def cleanup
    dup.gsub!(/\s*(\r?\n\s*|\s+)/, ' ')
  end

  def cleanup!
    gsub!(/\s*(\r?\n\s*|\s+)/, ' ')
    self
  end

  def cleanup_production
    Rails.env.production? \
      ? cleanup
      : self
  end

  alias_method :clean_cert, :clean_certificate
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
better_record-0.25.2 config/initializers/core_ext/string.rb
better_record-0.25.1 config/initializers/core_ext/string.rb
better_record-0.25.0 config/initializers/core_ext/string.rb
better_record-0.24.4 config/initializers/core_ext/string.rb
better_record-0.24.3 config/initializers/core_ext/string.rb
better_record-0.23.7 config/initializers/core_ext/string.rb
better_record-0.23.6 config/initializers/core_ext/string.rb
better_record-0.23.5 config/initializers/core_ext/string.rb
better_record-0.23.4 config/initializers/core_ext/string.rb
better_record-0.23.3 config/initializers/core_ext/string.rb
better_record-0.22.9 config/initializers/core_ext/string.rb