lib/glman/commands/base.rb in glman-0.0.8 vs lib/glman/commands/base.rb in glman-0.0.9
- old
+ new
@@ -1,8 +1,9 @@
require "glman/version"
require 'executable'
require 'awesome_print'
+require "irc-notify"
module Glman
module Commands
class Base
include Executable
@@ -29,11 +30,11 @@
opts = projects_repo.create_merge_request(repository_name, params)
assignee = opts['assignee'] || {}
author = opts['author'] || {}
info = {
- url: "#{configuration.load[:gitlab_url]}/resfinity/resfinity_profile/merge_requests/#{opts['iid']}",
+ url: "#{configuration.load[:gitlab_url]}/#{repository_name}/merge_requests/#{opts['iid']}",
assignee: {
username: assignee['username'],
email: assignee['email'],
name: assignee['name']
},
@@ -167,15 +168,33 @@
def git_repo
@git_repo ||= Repos::GitRepo.new
end
+ def notify(msg)
+ nick = configuration.load[:irc][:channel] || 'glman'
+ irc_client.register(nick)
+ irc_client.notify(configuration.load[:irc][:channel], msg)
+ client.quit
+ end
+
+ def irc_client
+ @irc_client ||= (
+ irc_config = configuration.load[:irc]
+ server = irc_config[:server] || "irc.freenode.net"
+ port = (irc_config[:port] || 6697).to_i
+ ssl = irc_config[:ssl] == true ? true : false
+ IrcNotify::Client.build(server, port, ssl: ssl)
+ )
+ end
+
def help_page
%{
commands:
config # display current configuration
config <gitlab_url> <private_token> --init # init configuration
+notify_config <server:port> <channel> <ssl> # setup irc configuration for notifications
alias # display aliases
alias <user_email> <alias> # make alias for user email
alias --clear # clear all aliases
\ No newline at end of file