class ModuleSync::Hook
Attributes
args[R]
branch[R]
hook_file[R]
namespace[R]
Public Class Methods
new(hook_file, options = [])
click to toggle source
# File lib/modulesync/hook.rb, line 7 def initialize(hook_file, options = []) @hook_file = hook_file @namespace = options[:namespace] @branch = options[:branch] @args = options[:hook_args] end
Public Instance Methods
activate()
click to toggle source
# File lib/modulesync/hook.rb, line 25 def activate hook_args = [] hook_args << "-n #{namespace}" if namespace hook_args << "-b #{branch}" if branch hook_args << args if args File.write(hook_file, content(hook_args.join(' '))) end
content(arguments)
click to toggle source
# File lib/modulesync/hook.rb, line 14 def content(arguments) <<~CONTENT #!/usr/bin/env bash current_branch=`git symbolic-ref HEAD | sed -e 's,.*/(.*),\1,'` git_dir=`git rev-parse --show-toplevel` message=`git log -1 --format=%B` msync -m "$message" #{arguments} CONTENT end
deactivate()
click to toggle source
# File lib/modulesync/hook.rb, line 34 def deactivate FileUtils.rm_f(hook_file) end