jcraigk/story_key

View on GitHub
lib/story_key/tokenizer.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true
class StoryKey::Tokenizer < StoryKey::Base
  param :text

  def call
    token_from_text
  end

  private

  def token_from_text
    text.downcase
        .gsub(/\[.+\]/, '')
        .gsub(/[^a-z0-9\s-]/, '')
        .strip
        .gsub(/\s+/, '-')
  end
end