class Lita::Handlers::VersionCheck

Public Instance Methods

check_version(message) click to toggle source

START:handler

# File lib/lita/handlers/version_check.rb, line 46
def check_version(message)
  message.reply [
    "My git revision is [#{git_sha}].",
    "My repository URL is [#{git_repository_url}].",
    '<<<>>>',
    "Brought to you by [#{gemspec_version}]."
  ].join(' ')
end
gemspec_version() click to toggle source

START:gemspec_version Asks the bundle command which version of lita-version-check you're

running.

e.g. lita-version-check 0.1.0
# File lib/lita/handlers/version_check.rb, line 22
def gemspec_version
  # list all installed gems in this context and filter for the one named
  #   version check
  `bundle list | grep lita-version-check`
  # strip out all characters other than alphanumerics and . - and space.
  .gsub(/[^A-Za-z0-9\.\- ]/i, '')
  # trim leading and trailing whitespace
  .strip
  # split on whitespace
  .split
  # join the split tokens back together with a uniform single space
  .join(" ")
end
git_repository_url() click to toggle source

START:repo_url Fetch the short-form repository URL of this git repo e.g.

git@github.com:dpritchett/ruby-bookbot.git
# File lib/lita/handlers/version_check.rb, line 40
def git_repository_url
  `git config --get remote.origin.url`.strip
end
git_sha() click to toggle source

START:commit_hash Fetch the SHA representing the current git commit in this repository:

e.g. fc648e78f54a74ca92a82d0ff77a9151fcf8e373
# File lib/lita/handlers/version_check.rb, line 11
def git_sha
  `git rev-parse HEAD`.strip
end