Module: PairUp
- Defined in:
- lib/pair-up.rb,
lib/pair-up/ui.rb,
lib/pair-up/participant.rb
Defined Under Namespace
Classes: Participant, UI
Constant Summary collapse
- VERSION =
'1.0.4'
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
- .git_committer_email ⇒ Object
- .git_committer_name ⇒ Object
- .print_info ⇒ Object
- .print_setup_path ⇒ Object
- .setup ⇒ Object
- .setup_path ⇒ Object
- .switch ⇒ Object
- .unpair ⇒ Object
- .write_file ⇒ Object
Class Method Details
.author_command ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/pair-up.rb', line 44 def self. if PairUp.pairing? "export GIT_AUTHOR_NAME='#{PairUp.}' GIT_AUTHOR_EMAIL='#{PairUp.}' GIT_COMMITTER_NAME='#{PairUp.git_committer_name}' GIT_COMMITTER_EMAIL='#{PairUp.git_committer_email}'" else "unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL" end end |
.current_pair ⇒ Object
52 53 54 |
# File 'lib/pair-up.rb', line 52 def self.current_pair config[:current_pair] ||= [] end |
.current_pair=(pairs) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/pair-up.rb', line 62 def self.current_pair=(pairs) config[:current_pair] = [] pairs.each do |participant| if PairUp::Participant.find(participant) config[:current_pair] << participant else if PairUp::UI.prompt_for_pair(participant) config[:current_pair] << participant end end end write_file end |
.expire_command(time) ⇒ Object
29 30 31 |
# File 'lib/pair-up.rb', line 29 def self.expire_command(time) %Q(sleep #{to_seconds(time)} && #{PairUp.bin_path} --unpair&) end |
.export(pairs) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pair-up.rb', line 17 def self.export(pairs) PairUp.current_pair = pairs if PairUp.mac? `launchctl setenv GIT_AUTHOR_NAME '#{PairUp.}' GIT_AUTHOR_EMAIL '#{PairUp.}'` `launchctl setenv GIT_COMMITTER_NAME '#{PairUp.git_committer_name}' GIT_COMMITTER_EMAIL '#{PairUp.git_committer_email}'` end write_export_file print_info end |
.git_author_email ⇒ Object
81 82 83 84 |
# File 'lib/pair-up.rb', line 81 def self. dev = PairUp::Participant.find(current_pair[0]) dev["email"] end |
.git_author_name ⇒ Object
76 77 78 79 |
# File 'lib/pair-up.rb', line 76 def self. dev = PairUp::Participant.find(current_pair[0]) dev["name"] end |
.git_committer_email ⇒ Object
91 92 93 94 |
# File 'lib/pair-up.rb', line 91 def self.git_committer_email dev = PairUp::Participant.find(current_pair[1]) dev["email"] end |
.git_committer_name ⇒ Object
86 87 88 89 |
# File 'lib/pair-up.rb', line 86 def self.git_committer_name dev = PairUp::Participant.find(current_pair[1]) dev["name"] end |
.print_info ⇒ Object
11 12 13 14 15 |
# File 'lib/pair-up.rb', line 11 def self.print_info if PairUp.pairing? && STDOUT.tty? PairUp::UI.highline.say("Author: #{PairUp.} <#{PairUp.}>, Committer: #{PairUp.git_committer_name} <#{PairUp.git_committer_email}>") end end |
.print_setup_path ⇒ Object
100 101 102 |
# File 'lib/pair-up.rb', line 100 def self.print_setup_path puts setup_path end |
.setup ⇒ Object
104 105 106 |
# File 'lib/pair-up.rb', line 104 def self.setup PairUp::UI.highline.say(File.read(setup_path)) end |
.setup_path ⇒ Object
96 97 98 |
# File 'lib/pair-up.rb', line 96 def self.setup_path File.join(File.dirname(__FILE__), 'pair-up', 'pair-up.sh') end |
.switch ⇒ Object
56 57 58 59 60 |
# File 'lib/pair-up.rb', line 56 def self.switch if not current_pair.empty? PairUp.export current_pair.reverse end end |
.unpair ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pair-up.rb', line 33 def self.unpair PairUp.current_pair = [] if PairUp.mac? `launchctl unsetenv GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL` `launchctl unsetenv GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL` end write_export_file end |
.write_file ⇒ Object
108 109 110 111 112 |
# File 'lib/pair-up.rb', line 108 def self.write_file File.open(self.PairUprc, File::CREAT|File::TRUNC|File::RDWR, 0644) do |out| YAML.dump(config, out) end end |