Module: Sentry::Cron::Slug

Defined in:
lib/sentry/cron/slug.rb

Class Method Summary collapse

Class Method Details

.from(name) ⇒ Object

Returns nil when nothing usable is left.



9
10
11
12
13
14
15
# File 'lib/sentry/cron/slug.rb', line 9

def from(name)
  slug = name.to_s.downcase.gsub(/[^a-z0-9_-]+/, "-").sub(/\A-+/, "")
  slug = slug[0, MonitorCheckIns::MAX_SLUG_LENGTH]
  # rindex instead of /-+\z/, which backtracks on long runs of dashes.
  last = slug.rindex(/[^-]/)
  last && slug[0..last]
end