Sha256: 5a844b6fd49b47b3376cf6f15d88c801576ead50055a5201f7125937ac507880

Contents?: true

Size: 634 Bytes

Versions: 18

Compression:

Stored size: 634 Bytes

Contents

module Fontist
  module Import
    module TextHelper
      class << self
        def cleanup(text)
          return unless text

          text.gsub("\r\n", "\n")
            .gsub("\r", "\n")
            .strip
            .lines
            .map(&:rstrip)
            .drop_while(&:empty?)
            .join("\n")
        end

        def longest_common_prefix(strs)
          return if strs.empty?

          min, max = strs.minmax
          idx = min.size.times { |i| break i if min[i] != max[i] }
          prefix = min[0...idx].strip
          return if prefix.size < 2

          prefix
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
fontist-1.21.2 lib/fontist/import/text_helper.rb
fontist-1.21.1 lib/fontist/import/text_helper.rb
fontist-1.20.0 lib/fontist/import/text_helper.rb
fontist-1.19.0 lib/fontist/import/text_helper.rb
fontist-1.18.2 lib/fontist/import/text_helper.rb
fontist-1.17.1 lib/fontist/import/text_helper.rb
fontist-1.17.0 lib/fontist/import/text_helper.rb
fontist-1.16.0 lib/fontist/import/text_helper.rb
fontist-1.15.2 lib/fontist/import/text_helper.rb
fontist-1.15.1 lib/fontist/import/text_helper.rb
fontist-1.15.0 lib/fontist/import/text_helper.rb
fontist-1.14.6 lib/fontist/import/text_helper.rb
fontist-1.14.5 lib/fontist/import/text_helper.rb
fontist-1.14.4 lib/fontist/import/text_helper.rb
fontist-1.14.3 lib/fontist/import/text_helper.rb
fontist-1.14.2 lib/fontist/import/text_helper.rb
fontist-1.14.1 lib/fontist/import/text_helper.rb
fontist-1.14.0 lib/fontist/import/text_helper.rb