Skip to content
Rafael Mendonça França edited this page Jun 15, 2023 · 8 revisions

ℹ️ Events are what causes your TODO to expire and be reminded about it.

Here is the list of built-in events SmartTodo provides:

🕐 date

date will expire your TODO on a specific date and time. This event expects one String argument and needs to be a correctly formatted date (parseable by Time.parse).

Example
# TODO(on: date('2019-08-07'), to: '...')
# TODO(on: date('2019/08/02'), to: '...')
# TODO(on: date('2019-08-02 16:54:00'), to: '...')
# TODO(on: date('2019-08-02 16:54:00 +0000'), to: '...')

:octocat: pull_request_close

pull_request_close will expire your TODO when a GitHub Pull Request is closed. This event expects three arguments. In order: The organization name, the repository name, and the PR number.

⚠️ If the repository is private, you'll need to expose a GitHub token in the environment with the repo scope. The token needs to be exposed in the SMART_TODO_GITHUB_TOKEN environment variable.

Example
# TODO(on: pull_request_close('rails', 'rails', 5431), to: '...')
# TODO(on: pull_request_close('rails', 'sprockets', 2233), to: '...')

:octocat: issue_close

issue_close will expire your TODO when a GitHub issue is closed. This event expects the exact same arguments as the pull_request_close above.

⚠️ Please see the warning from the pull_request_close event above.

Example
# TODO(on: issue_close('rails', 'rails', 33521), to: '...')
# TODO(on: issue_close('rails', 'sprockets', 45678), to: '...')

💎 gem_release

gem_release will expire your TODO when a gem is released on RubyGems.org with a specific version. This event expects the name of the gem and the version(s) specifiers. The version specifier syntax are the exact same as what you are used to from the Gemfile.

Example
# Expire your TODO when Rails 6.0 is released
# TODO(on: gem_release('rails', '6.0'), to: '...')  

# Expire your TODO when Rails gets a new release in the 5.x.x series
# TODO(on: gem_release('rails', '> 5.2', '< 6'), to: '...')

# See the explanation of `~>` https://guides.rubygems.org/patterns/#pessimistic-version-constraint
# TODO(on: gem_release('rails', '~> 6.1'), to: '...')

💎 gem_bump

gem_bump will expire your TODO when a gem inside your Gemfile.lock snapshot gets updated to a specific version. This event expects the name of the gem and the version(s) specifiers. The version specifier syntax are the exact same as what you are used to from the Gemfile.

Example
# Expire your TODO when Rails 6.0 is released
# TODO(on: gem_bump('rails', '6.0'), to: '...')  

# Expire your TODO when Rails gets a new release in the 5.x.x series
# TODO(on: gem_bump('rails', '> 5.2', '< 6'), to: '...')

# See the explanation of `~>` https://guides.rubygems.org/patterns/#pessimistic-version-constraint
# TODO(on: gem_bump('rails', '~> 6.1'), to: '...')

💎 ruby_version

ruby_version will expire your TODO when the current Ruby version fulfill the requirements.

Example
# Expire your TODO when Ruby 3.3 is used
# TODO(on: ruby_version(">= 3.3.0"), to: '...')

More built-in events will be added as this gem matures and support for writing your own events will be added soon.