<commit_before>= Stringex

Some [hopefully] useful extensions to Ruby's String class. It is made up of three libraries: ActsAsUrl, Unidecoder, and StringExtensions.

== ActsAsUrl

This library is designed to create URI-friendly representations of an attribute, for use in generating urls from your attributes. Basic usage is just calling the method:

  # Inside your model
  acts_as_url :title

which will populate the <tt>url</tt> attribute on the object with the converted contents of the <tt>title</tt> attribute. This behavior can be customized by adding the following options to the arguments of the <tt>acts_as_url</tt> method:

<tt>:url_attribute</tt>:: The name of the attribute to use for storing the generated url string.
                          Default is <tt>:url</tt>
<tt>:scope</tt>:: The name of model attribute to scope unique urls to. There is no default here.
<tt>:only_when_blank</tt>:: If set to true, the url generation will only happen when <tt>:url_attribute</tt> is
                            blank. Default is false (meaning url generation will happen always).
<tt>:sync_url</tt>:: If set to true, the url field will be updated when changes are made to the
                     attribute it is based on. Default is false.
<tt>:allow_slash</tt>:: If set to true, the url field will not convert slashes. Default is false.
<tt>:allow_duplicates</tt>:: If set to true, unique urls will not be enforced.
                             Default is false. <em>NOTE: This is strongly not recommended
                             if you are routing solely on the generated slug as you will no longer
                             be guaranteed to lookup the expected record based on a duplicate slug.</em>


In order to use the generated url attribute, you will probably want to override <tt>to_param</tt> like so, in your Model:

  # Inside your model
  def to_param
    url # or whatever you set :url_attribute to<commit_msg>more html<commit_after>= Stringex

Some [hopefully] useful extensions to Ruby's String class. It is made up of three libraries: ActsAsUrl, Unidecoder, and StringExtensions.

== ActsAsUrl

This library is designed to create URI-friendly representations of an attribute, for use in generating urls from your attributes. Basic usage is just calling the method:

  # Inside your model
  acts_as_url :title

which will populate the <tt>url</tt> attribute on the object with the converted contents of the <tt>title</tt> attribute. This behavior can be customized by adding the following options to the arguments of the <tt>acts_as_url</tt> method:

<tt>:url_attribute</tt>:: The name of the attribute to use for storing the generated url string.
                          Default is <tt>:url</tt>
<tt>:scope</tt>:: The name of model attribute to scope unique urls to. There is no default here.
<tt>:only_when_blank</tt>:: If set to true, the url generation will only happen when <tt>:url_attribute</tt> is
                            blank. Default is false (meaning url generation will happen always).
<tt>:sync_url</tt>:: If set to true, the url field will be updated when changes are made to the
                     attribute it is based on. Default is false.
<tt>:allow_slash</tt>:: If set to true, the url field will not convert slashes. Default is false.
<tt>:allow_duplicates</tt>:: If set to true, unique urls will not be enforced.
                             Default is false. <em>*NOTE: This is strongly not recommended
                             if you are routing solely on the generated slug as you will no longer
                             be guaranteed to lookup the expected record based on a duplicate slug.*</em>


In order to use the generated url attribute, you will probably want to override <tt>to_param</tt> like so, in your Model:

  # Inside your model
  def to_param
    url # or whatever you set :url_attribute to
{'fraction_non_alphanumeric': 0.06852138073158166, 'fraction_numerical': 0.0, 'mean_word_length': 3.0532359081419624, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4644406', 'n_tokens_mistral': 990, 'n_tokens_neox': 955, 'n_words': 524}