module Hitch
Constants
- VERSION
Public Class Methods
current_pair()
click to toggle source
# File lib/hitch.rb, line 49 def self.current_pair config[:current_pair] ||= [] end
current_pair=(pairs)
click to toggle source
# File lib/hitch.rb, line 53 def self.current_pair=(pairs) config[:current_pair] = [] pairs.each do |author| if Hitch::Author.find(author) config[:current_pair] << author else if Hitch::UI.prompt_for_pair(author) config[:current_pair] << author end end end write_file end
expire_command(time)
click to toggle source
# File lib/hitch.rb, line 23 def self.expire_command(time) %Q(sleep #{to_seconds(time)} && #{Hitch.bin_path} --unhitch&) end
export(pairs)
click to toggle source
# File lib/hitch.rb, line 17 def self.export(pairs) Hitch.current_pair = pairs write_export_file print_info end
group_domain()
click to toggle source
# File lib/hitch.rb, line 85 def self.group_domain group_email.split('@').last end
group_email()
click to toggle source
# File lib/hitch.rb, line 40 def self.group_email config[:group_email] ||= Hitch::UI.prompt_for_group_email end
group_email=(email)
click to toggle source
# File lib/hitch.rb, line 44 def self.group_email=(email) config[:group_email] = email write_file end
group_prefix()
click to toggle source
# File lib/hitch.rb, line 81 def self.group_prefix group_email.split('@').first end
print_info()
click to toggle source
# File lib/hitch.rb, line 11 def self.print_info if Hitch.pairing? && STDOUT.tty? Hitch::UI.highline.say("#{Hitch.git_author_name} <#{Hitch.git_author_email}>") end end
print_setup_path()
click to toggle source
# File lib/hitch.rb, line 93 def self.print_setup_path puts setup_path end
setup()
click to toggle source
# File lib/hitch.rb, line 97 def self.setup Hitch::UI.highline.say(File.read(setup_path)) end
setup_path()
click to toggle source
# File lib/hitch.rb, line 89 def self.setup_path File.join(File.dirname(__FILE__), 'hitch', 'hitch.sh') end
unhitch()
click to toggle source
# File lib/hitch.rb, line 27 def self.unhitch Hitch.current_pair = [] write_export_file end
write_file()
click to toggle source
# File lib/hitch.rb, line 101 def self.write_file File.open(hitchrc, File::CREAT|File::TRUNC|File::RDWR, 0644) do |out| YAML.dump(config, out) end end
Private Class Methods
bin_path()
click to toggle source
# File lib/hitch.rb, line 129 def self.bin_path %x[which hitch].chomp end
config()
click to toggle source
# File lib/hitch.rb, line 109 def self.config @config ||= get_config end
get_config()
click to toggle source
# File lib/hitch.rb, line 113 def self.get_config if File.exists?(hitchrc) yamlized = YAML::load_file(hitchrc) return yamlized if yamlized.kind_of?(Hash) end return {} end
hitchrc()
click to toggle source
# File lib/hitch.rb, line 121 def self.hitchrc File.expand_path('~/.hitchrc') end
pairing?()
click to toggle source
# File lib/hitch.rb, line 133 def self.pairing? current_pair.any? end
to_seconds(value)
click to toggle source
# File lib/hitch.rb, line 137 def self.to_seconds(value) value = value.to_s.gsub(/[^\d]/, '').to_i unless value.zero? value * 60 * 60 else raise StandardError end end
write_export_file()
click to toggle source
# File lib/hitch.rb, line 146 def self.write_export_file File.open(hitch_export_authors, 'w'){|f| f.write(author_command) } end