Module: Hitch
- Defined in:
- lib/hitch.rb,
lib/hitch/ui.rb,
lib/hitch/author.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
'1.1.0'
Class Method Summary collapse
- .author_command ⇒ Object
- .current_pair ⇒ Object
- .current_pair=(pairs) ⇒ Object
- .expire_command(time) ⇒ Object
- .export(pairs) ⇒ Object
- .git_author_email ⇒ Object
- .git_author_name ⇒ Object
- .group_domain ⇒ Object
- .group_email ⇒ Object
- .group_email=(email) ⇒ Object
- .group_prefix ⇒ Object
- .print_info ⇒ Object
- .print_setup_path ⇒ Object
- .setup ⇒ Object
- .setup_path ⇒ Object
- .unhitch ⇒ Object
- .write_file ⇒ Object
Class Method Details
.author_command ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/hitch.rb', line 32 def self. if Hitch.pairing? %Q{export GIT_AUTHOR_NAME="#{Hitch.}" GIT_AUTHOR_EMAIL="#{Hitch.}"} else "unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL" end end |
.current_pair ⇒ Object
49 50 51 |
# File 'lib/hitch.rb', line 49 def self.current_pair config[:current_pair] ||= [] end |
.current_pair=(pairs) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/hitch.rb', line 53 def self.current_pair=(pairs) config[:current_pair] = [] pairs.each do || if Hitch::Author.find() config[:current_pair] << else if Hitch::UI.prompt_for_pair() config[:current_pair] << end end end write_file end |
.expire_command(time) ⇒ Object
23 24 25 |
# File 'lib/hitch.rb', line 23 def self.expire_command(time) %Q(sleep #{to_seconds(time)} && #{Hitch.bin_path} --unhitch&) end |
.export(pairs) ⇒ Object
17 18 19 20 21 |
# File 'lib/hitch.rb', line 17 def self.export(pairs) Hitch.current_pair = pairs write_export_file print_info end |
.git_author_email ⇒ Object
77 78 79 |
# File 'lib/hitch.rb', line 77 def self. "#{group_prefix}+#{current_pair.sort.join('+')}@#{group_domain}" end |
.git_author_name ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/hitch.rb', line 67 def self. devs = current_pair.sort.map {|pair| Hitch::Author.find(pair)} case devs.length when 1, 2 devs.join(" and ") else "#{devs[0...-1].join(', ')}, and #{devs[-1]}" end end |
.group_domain ⇒ Object
85 86 87 |
# File 'lib/hitch.rb', line 85 def self.group_domain group_email.split('@').last end |
.group_email ⇒ Object
40 41 42 |
# File 'lib/hitch.rb', line 40 def self.group_email config[:group_email] ||= Hitch::UI.prompt_for_group_email end |
.group_email=(email) ⇒ Object
44 45 46 47 |
# File 'lib/hitch.rb', line 44 def self.group_email=(email) config[:group_email] = email write_file end |
.group_prefix ⇒ Object
81 82 83 |
# File 'lib/hitch.rb', line 81 def self.group_prefix group_email.split('@').first end |
.print_info ⇒ Object
11 12 13 14 15 |
# File 'lib/hitch.rb', line 11 def self.print_info if Hitch.pairing? && STDOUT.tty? Hitch::UI.highline.say("#{Hitch.} <#{Hitch.}>") end end |
.print_setup_path ⇒ Object
93 94 95 |
# File 'lib/hitch.rb', line 93 def self.print_setup_path puts setup_path end |
.setup ⇒ Object
97 98 99 |
# File 'lib/hitch.rb', line 97 def self.setup Hitch::UI.highline.say(File.read(setup_path)) end |
.setup_path ⇒ Object
89 90 91 |
# File 'lib/hitch.rb', line 89 def self.setup_path File.join(File.dirname(__FILE__), 'hitch', 'hitch.sh') end |
.unhitch ⇒ Object
27 28 29 30 |
# File 'lib/hitch.rb', line 27 def self.unhitch Hitch.current_pair = [] write_export_file end |
.write_file ⇒ Object
101 102 103 104 105 |
# 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 |