pair-up 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c85ff4124c27a9d99a65ba8d69c7bf7ae3b9b4a
4
- data.tar.gz: 8ea00b9f79aa675a2f1d0b001de8dda9b3289ff5
3
+ metadata.gz: 5c604bc3f4e1e46eca3ccef20b3fd13d8569c5b4
4
+ data.tar.gz: 23958e1158e2afee7d59956cb69a1f78b32161cf
5
5
  SHA512:
6
- metadata.gz: 8e2501b0b20763e21a031df15d85c681710698c0646ad1ba29c55dffb77a022f95bf3c93dcf2e98d5309a23d716b3230d64a9665204c7f05262e98849a88b1e3
7
- data.tar.gz: 3be127eb8ec810b9b1916dc8cdf0fd686d1895c012b0b1e09431cfaf9e4dc94c0fb9742ce6ac023b8d2b1d874fef4291f4eeef7fa607cfd07c7cf41557bb34e8
6
+ metadata.gz: 7015d80d29d07edc6801902a05f4257d94e7780b460f1791c01af076586bfad4620a2371473b8457d2f16e6785c16658d4fdc880b2b8446e2733817422e98e8f
7
+ data.tar.gz: fc2c7ea836fbbe197769e8c32dd8d34f2e00814691e5d93650e96d89af93cf8f12f898f61bca966b3c48b917e3e7df11ac9c3861ad9ee0a468d8a95ab8e2a059
data/README.md CHANGED
@@ -1,26 +1,26 @@
1
- Git Pair
1
+ Pair Up
2
2
  =====
3
3
  by Andre Helberg (@A-Helberg)
4
4
 
5
- [![Build Status](https://travis-ci.org/A-Helberg/git-pair.svg)](https://travis-ci.org/A-Helberg/git-pair)
5
+ [![Build Status](https://travis-ci.org/A-Helberg/pair-up.svg)](https://travis-ci.org/A-Helberg/pair-up)
6
6
 
7
7
  Description:
8
8
  -----------
9
9
 
10
- Git Pair allows developers to be jointly credited when Pair Programming and using Git.
10
+ Pair Up allows two developers to be jointly credited when Pair Programming and using Git.
11
11
 
12
12
  Features:
13
13
  --------
14
14
 
15
15
  * Persists pair between different terminal instances.
16
16
  * Can be used in OSX GUI applications ( after restarting the application )
17
- * Allows you to expire the pair information in N hours. e.g. git pair --expire 8 fry leela
17
+ * Allows you to expire the pair information in N hours. e.g. pair --expire 8 fry leela
18
18
 
19
19
  Installation & Usage:
20
20
  ----------
21
21
  Install the gem and add the setup to the end of your zshrc or bashrc file
22
22
  ```shell
23
- $ gem install git-pair
23
+ $ gem install pair-up
24
24
  ```
25
25
 
26
26
  ```shell
@@ -34,7 +34,7 @@ To pair with someone replace the following names with your github names
34
34
  $ pair A-Helberg aleciafb
35
35
  ```
36
36
 
37
- Now just commit as you usually would. If you use a gui application on OSX, remember to restart it when you setupa new pair or switch pairs for it to take effect. The first person will be used as the author and the second person as the committer.
37
+ Now just commit as you usually would. If you use a gui application on OSX, remember to restart it when you setup a new pair or switch pairs for it to take effect. The first username will be used as the author and the second username as the committer.
38
38
 
39
39
  To switch the pairs around run:
40
40
  ``` shell
@@ -55,7 +55,7 @@ Install:
55
55
  -------
56
56
 
57
57
  ``` shell
58
- gem install git-pair
58
+ gem install pair-up
59
59
  ```
60
60
 
61
61
  ``` shell
@@ -64,14 +64,14 @@ pair --setup
64
64
 
65
65
  * this prints out the necessary shell function and aliases you need to add to your ~/.bashrc or ~/.zshrc
66
66
  - eg. `pair --setup >> ~/.zshrc`
67
- * Or copy/paste [the code](lib/git-pair/git-pair.sh) into your ~/.bashrc or ~/.zshrc
68
- * As another option, copy/symlink the script to a separate file (e.g. `~/.bash/git-pair.sh` or `/etc/profile.d/git-pair.sh`) and source it. You can get the path using `pair --setup-path`.
67
+ * Or copy/paste [the code](lib/pair-up/pair-up.sh) into your ~/.bashrc or ~/.zshrc
68
+ * As another option, copy/symlink the script to a separate file (e.g. `~/.bash/pair-up.sh` or `/etc/profile.d/pair-up.sh`) and source it. You can get the path using `pair --setup-path`.
69
69
  * Restart your terminal.
70
70
 
71
71
  Development:
72
72
  -----------
73
73
 
74
- * Fork git-pair
74
+ * Fork pair-up
75
75
  * Add tests and code for your feature
76
76
  * Create a pull request
77
77
  * Double-check TravisCI to make sure all tests pass
@@ -93,4 +93,4 @@ License:
93
93
  -------
94
94
  Released under the MIT License. See the [LICENSE][license] file for further details.
95
95
 
96
- [license]: https://github.com/A-Helberg/git-pair/blob/master/LICENSE.md
96
+ [license]: https://github.com/A-Helberg/pair-up/blob/master/LICENSE.md
data/bin/pair CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib git-pair]))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib pair-up]))
4
4
 
5
5
  args = ARGV
6
6
  options = []
7
7
  opts = OptionParser.new do |opts|
8
- opts.banner = "Usage: git pair [options] first_pair_username second_pair_username"
8
+ opts.banner = "Usage: pair [options] first_pair_username second_pair_username"
9
9
  opts.separator ""
10
10
  opts.separator "General options:"
11
11
 
@@ -38,14 +38,14 @@ opts = OptionParser.new do |opts|
38
38
  end
39
39
 
40
40
  opts.on_tail("-v", "--version", "Show version") do
41
- abort "git pair v#{GitPair::VERSION}"
41
+ abort "pair-up v#{PairUp::VERSION}"
42
42
  end
43
43
  end
44
44
 
45
45
  if args.any?
46
46
  opts.parse!(args)
47
47
  if options.delete(:expire)
48
- system(GitPair.expire_command(options.pop))
48
+ system(PairUp.expire_command(options.pop))
49
49
  end
50
50
 
51
51
  options = [:export, args] if options.empty?
@@ -53,4 +53,4 @@ else
53
53
  options = [:print_info]
54
54
  end
55
55
 
56
- GitPair.send(*options)
56
+ PairUp.send(*options)
@@ -1,25 +1,25 @@
1
1
  require 'highline'
2
2
  require 'yaml'
3
3
 
4
- require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib git-pair ui]))
5
- require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib git-pair participant]))
4
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib pair-up ui]))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib pair-up participant]))
6
6
 
7
- module GitPair
7
+ module PairUp
8
8
 
9
9
  VERSION = '1.0.0'
10
10
 
11
11
  def self.print_info
12
- if GitPair.pairing? && STDOUT.tty?
13
- GitPair::UI.highline.say("Author: #{GitPair.git_author_name} <#{GitPair.git_author_email}>, Comitter: #{GitPair.git_committer_name} <#{GitPair.git_committer_email}>")
12
+ if PairUp.pairing? && STDOUT.tty?
13
+ PairUp::UI.highline.say("Author: #{PairUp.git_author_name} <#{PairUp.git_author_email}>, Comitter: #{PairUp.git_committer_name} <#{PairUp.git_committer_email}>")
14
14
  end
15
15
  end
16
16
 
17
17
  def self.export(pairs)
18
- GitPair.current_pair = pairs
18
+ PairUp.current_pair = pairs
19
19
 
20
- if GitPair.mac?
21
- `launchctl setenv GIT_AUTHOR_NAME '#{GitPair.git_author_name}' GIT_AUTHOR_EMAIL '#{GitPair.git_author_email}'`
22
- `launchctl setenv GIT_COMMITTER_NAME '#{GitPair.git_committer_name}' GIT_COMMITTER_EMAIL '#{GitPair.git_committer_email}'`
20
+ if PairUp.mac?
21
+ `launchctl setenv GIT_AUTHOR_NAME '#{PairUp.git_author_name}' GIT_AUTHOR_EMAIL '#{PairUp.git_author_email}'`
22
+ `launchctl setenv GIT_COMMITTER_NAME '#{PairUp.git_committer_name}' GIT_COMMITTER_EMAIL '#{PairUp.git_committer_email}'`
23
23
  end
24
24
 
25
25
  write_export_file
@@ -27,13 +27,13 @@ module GitPair
27
27
  end
28
28
 
29
29
  def self.expire_command(time)
30
- %Q(sleep #{to_seconds(time)} && #{GitPair.bin_path} --unpair&)
30
+ %Q(sleep #{to_seconds(time)} && #{PairUp.bin_path} --unpair&)
31
31
  end
32
32
 
33
33
  def self.unpair
34
- GitPair.current_pair = []
34
+ PairUp.current_pair = []
35
35
 
36
- if GitPair.mac?
36
+ if PairUp.mac?
37
37
  `launchctl unsetenv GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL`
38
38
  `launchctl unsetenv GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL`
39
39
  end
@@ -42,8 +42,8 @@ module GitPair
42
42
  end
43
43
 
44
44
  def self.author_command
45
- if GitPair.pairing?
46
- "export GIT_AUTHOR_NAME='#{GitPair.git_author_name}' GIT_AUTHOR_EMAIL='#{GitPair.git_author_email}' GIT_COMMITTER_NAME='#{GitPair.git_committer_name}' GIT_COMMITTER_EMAIL='#{GitPair.git_committer_email}'"
45
+ if PairUp.pairing?
46
+ "export GIT_AUTHOR_NAME='#{PairUp.git_author_name}' GIT_AUTHOR_EMAIL='#{PairUp.git_author_email}' GIT_COMMITTER_NAME='#{PairUp.git_committer_name}' GIT_COMMITTER_EMAIL='#{PairUp.git_committer_email}'"
47
47
  else
48
48
  "unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL"
49
49
  end
@@ -55,17 +55,17 @@ module GitPair
55
55
 
56
56
  def self.switch
57
57
  if not current_pair.empty?
58
- GitPair.export current_pair.reverse
58
+ PairUp.export current_pair.reverse
59
59
  end
60
60
  end
61
61
 
62
62
  def self.current_pair=(pairs)
63
63
  config[:current_pair] = []
64
64
  pairs.each do |participant|
65
- if GitPair::Participant.find(participant)
65
+ if PairUp::Participant.find(participant)
66
66
  config[:current_pair] << participant
67
67
  else
68
- if GitPair::UI.prompt_for_pair(participant)
68
+ if PairUp::UI.prompt_for_pair(participant)
69
69
  config[:current_pair] << participant
70
70
  end
71
71
  end
@@ -74,27 +74,27 @@ module GitPair
74
74
  end
75
75
 
76
76
  def self.git_author_name
77
- dev = GitPair::Participant.find(current_pair[0])
77
+ dev = PairUp::Participant.find(current_pair[0])
78
78
  dev["name"]
79
79
  end
80
80
 
81
81
  def self.git_author_email
82
- dev = GitPair::Participant.find(current_pair[0])
82
+ dev = PairUp::Participant.find(current_pair[0])
83
83
  dev["email"]
84
84
  end
85
85
 
86
86
  def self.git_committer_name
87
- dev = GitPair::Participant.find(current_pair[1])
87
+ dev = PairUp::Participant.find(current_pair[1])
88
88
  dev["name"]
89
89
  end
90
90
 
91
91
  def self.git_committer_email
92
- dev = GitPair::Participant.find(current_pair[1])
92
+ dev = PairUp::Participant.find(current_pair[1])
93
93
  dev["email"]
94
94
  end
95
95
 
96
96
  def self.setup_path
97
- File.join(File.dirname(__FILE__), 'git-pair', 'git-pair.sh')
97
+ File.join(File.dirname(__FILE__), 'pair-up', 'pair-up.sh')
98
98
  end
99
99
 
100
100
  def self.print_setup_path
@@ -102,11 +102,11 @@ module GitPair
102
102
  end
103
103
 
104
104
  def self.setup
105
- GitPair::UI.highline.say(File.read(setup_path))
105
+ PairUp::UI.highline.say(File.read(setup_path))
106
106
  end
107
107
 
108
108
  def self.write_file
109
- File.open(gitpairrc, File::CREAT|File::TRUNC|File::RDWR, 0644) do |out|
109
+ File.open(self.PairUprc, File::CREAT|File::TRUNC|File::RDWR, 0644) do |out|
110
110
  YAML.dump(config, out)
111
111
  end
112
112
  end
@@ -122,23 +122,23 @@ module GitPair
122
122
  end
123
123
 
124
124
  def self.get_config
125
- if File.exists?(gitpairrc)
126
- yamlized = YAML::load_file(gitpairrc)
125
+ if File.exists?(self.PairUprc)
126
+ yamlized = YAML::load_file(self.PairUprc)
127
127
  return yamlized if yamlized.kind_of?(Hash)
128
128
  end
129
129
  return {}
130
130
  end
131
131
 
132
- def self.gitpairrc
133
- File.expand_path('~/.git-pairrc')
132
+ def self.PairUprc
133
+ File.expand_path('~/.pair-uprc')
134
134
  end
135
135
 
136
- def self.gitpair_export_authors
137
- File.expand_path('~/.git-pair_export_authors')
136
+ def self.PairUp_export_authors
137
+ File.expand_path('~/.pair-up_export_authors')
138
138
  end
139
139
 
140
140
  def self.bin_path
141
- %x[which git-pair].chomp
141
+ %x[which pair].chomp
142
142
  end
143
143
 
144
144
  def self.pairing?
@@ -155,7 +155,7 @@ module GitPair
155
155
  end
156
156
 
157
157
  def self.write_export_file
158
- File.open(gitpair_export_authors, 'w'){|f| f.write(author_command) }
158
+ File.open(self.PairUp_export_authors, 'w'){|f| f.write(author_command) }
159
159
  end
160
160
 
161
161
  end
@@ -1,10 +1,10 @@
1
1
  # Add the following to your ~/.bashrc or ~/.zshrc
2
2
  #
3
- # Alternatively, copy/symlink this file and source in your shell. See `git pair --setup-path`.
3
+ # Alternatively, copy/symlink this file and source in your shell. See `pair --setup-path`.
4
4
 
5
5
  pair() {
6
6
  command pair "$@"
7
- if [[ -s "$HOME/.git-pair_export_authors" ]] ; then source "$HOME/.git-pair_export_authors" ; fi
7
+ if [[ -s "$HOME/.pair-up_export_authors" ]] ; then source "$HOME/.pair-up_export_authors" ; fi
8
8
  }
9
9
 
10
10
  # Uncomment to persist pair info between terminal instances
@@ -1,4 +1,4 @@
1
- module GitPair
1
+ module PairUp
2
2
  class Participant
3
3
 
4
4
  def self.add(github, email, name)
@@ -22,7 +22,7 @@ module GitPair
22
22
  private
23
23
 
24
24
  def self.pairs_file
25
- File.expand_path("~/.git-pair_pairs")
25
+ File.expand_path("~/.pair-up_pairs")
26
26
  end
27
27
 
28
28
  def self.available_pairs
@@ -1,15 +1,15 @@
1
1
  HighLine.track_eof = false
2
2
 
3
- module GitPair
3
+ module PairUp
4
4
  class UI
5
5
 
6
6
  def self.prompt_for_pair(new_participant)
7
7
  highline.say("I don't know who #{new_participant} is.")
8
- if highline.agree("Do you want to add #{new_participant} to ~/.git-pair_pairs? (yn)")
8
+ if highline.agree("Do you want to add #{new_participant} to ~/.pair-up_pairs? (yn)")
9
9
  participant_name = highline.ask("What is #{new_participant}'s full name?").to_s
10
10
  participant_email = highline.ask("What is #{new_participant}'s email?").to_s
11
- GitPair::Participant.add(new_participant, participant_email, participant_name)
12
- GitPair::Participant.write_file
11
+ PairUp::Participant.add(new_participant, participant_email, participant_name)
12
+ PairUp::Participant.write_file
13
13
  return new_participant
14
14
  else
15
15
  highline.say("Ignoring #{new_participant}.")
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
5
5
  s.rubygems_version = '1.3.5'
6
6
 
7
7
  s.name = %q{pair-up}
8
- s.version = '1.0.0'
8
+ s.version = '1.0.1'
9
9
  s.date = Time.now.strftime('%F')
10
10
  s.license = 'MIT'
11
11
 
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.summary = %q{pair-up allows developers to be properly credited when Pair Programming and using Git.}
14
14
  s.authors = [%q{Andre Helberg}]
15
15
  s.email = ["helberg.andre@gmail.com"]
16
- s.homepage = %q{http://github.com/A-Helberg/git-pair}
16
+ s.homepage = %q{http://github.com/A-Helberg/pair-up}
17
17
  s.require_paths = %w[lib]
18
18
  s.extra_rdoc_files = %w[README.md LICENSE.md]
19
19
  s.rdoc_options = [%q{--charset=UTF-8}]
@@ -33,14 +33,14 @@ Gem::Specification.new do |s|
33
33
  README.md
34
34
  Rakefile
35
35
  bin/pair
36
- git-pair.gemspec
37
- lib/git-pair.rb
38
- lib/git-pair/participant.rb
39
- lib/git-pair/git-pair.sh
40
- lib/git-pair/ui.rb
41
- spec/git-pair/participant_spec.rb
42
- spec/git-pair/ui_spec.rb
43
- spec/git-pair_spec.rb
36
+ pair-up.gemspec
37
+ lib/pair-up.rb
38
+ lib/pair-up/participant.rb
39
+ lib/pair-up/pair-up.sh
40
+ lib/pair-up/ui.rb
41
+ spec/pair-up/participant_spec.rb
42
+ spec/pair-up/ui_spec.rb
43
+ spec/pair-up_spec.rb
44
44
  spec/spec_helper.rb
45
45
  ]
46
46
  # = MANIFEST =
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe PairUp::Participant do
4
+
5
+ let(:base_pairs) do
6
+ {
7
+ 'bender' => {"email"=>"rcrichoch@fakeinbox.com", "name"=>"Rogelio J. Samour"},
8
+ 'fry' => {"email"=>"crichoch@fakeinbox.com", "name"=>"Phillip J. Fry"},
9
+ 'leela' => {"email"=>"stepriso@fakeinbox.com", "name"=>"Turanga Leela"}
10
+ }
11
+ end
12
+
13
+ describe ".write_file" do
14
+ it "writes the contents of PairUp::Participant.available_pairs to the hitch_pairs file" do
15
+ expect(YAML).to receive(:dump)
16
+ PairUp::Participant.write_file
17
+ end
18
+ end
19
+
20
+ describe ".add" do
21
+
22
+ context "when the participant is not present" do
23
+ it "adds the participant to PairUp::Participant.available_pairs" do
24
+ allow(PairUp::Participant).to receive(:get_available_pairs) { {} }
25
+ PairUp::Participant.add("therubymug", "rcrichoch@fakeinbox.com", "Rogelio J. Samour")
26
+ expect(PairUp::Participant.available_pairs).to eql({"therubymug"=>{"email"=>"rcrichoch@fakeinbox.com", "name"=>"Rogelio J. Samour"}})
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ describe ".find" do
33
+
34
+ context "when the participant is present" do
35
+ it "and_return the full name" do
36
+ expect(PairUp::Participant.find("therubymug")).to eql({"email"=>"rcrichoch@fakeinbox.com", "name"=>"Rogelio J. Samour"})
37
+ end
38
+ end
39
+
40
+ context "when the participant is not present" do
41
+ it "and_return nil" do
42
+ expect(PairUp::Participant.find("nobody")).to be_nil
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe PairUp::UI do
4
+
5
+ describe '.prompt_for_pair' do
6
+
7
+ let(:new_author) { 'leela' }
8
+ let(:new_author_name) { 'Turanga Leela' }
9
+ let(:new_author_email) { 'Turanga Leela' }
10
+
11
+
12
+ before do
13
+ allow(PairUp::UI.highline).to receive(:ask) {new_author_name}
14
+ # expect(PairUp::UI.highline).to receive(:say)
15
+ end
16
+
17
+ it 'states that the new pair is not in the pair-up_pairs file' do
18
+ expect(PairUp::UI.highline).to receive(:say).with("I don't know who #{new_author} is.")
19
+ PairUp::UI.prompt_for_pair(new_author)
20
+ end
21
+
22
+ it 'prompts for pair' do
23
+ expect(PairUp::UI.highline).to receive(:say)
24
+ expect(PairUp::UI.highline).to receive(:agree).with("Do you want to add #{new_author} to ~/.pair-up_pairs? (yn)")
25
+ expect(PairUp::UI.highline).to receive(:say)
26
+ PairUp::UI.prompt_for_pair(new_author)
27
+ end
28
+
29
+ context 'when user does not agree to add new author' do
30
+ it "states it's ignoring the author" do
31
+ allow(PairUp::UI.highline).to receive(:agree) {false}
32
+ expect(PairUp::UI.highline).to receive(:say)
33
+ expect(PairUp::UI.highline).to receive(:say).with("Ignoring #{new_author}.")
34
+ PairUp::UI.prompt_for_pair(new_author)
35
+ end
36
+ end
37
+
38
+ context 'when user agrees to add new author' do
39
+
40
+ before do
41
+ allow(PairUp::UI.highline).to receive(:agree) {true}
42
+ expect(PairUp::UI.highline).to receive(:say)
43
+ end
44
+
45
+ it "asks for the new author's name" do
46
+ expect(PairUp::UI.highline).to receive(:ask).with("What is #{new_author}'s full name?")
47
+ PairUp::UI.prompt_for_pair(new_author)
48
+ end
49
+
50
+ it "adds the new author" do
51
+ expect(PairUp::Participant).to receive(:add).with(new_author, new_author_name, new_author_email)
52
+ PairUp::UI.prompt_for_pair(new_author)
53
+ end
54
+
55
+ it "writes the ~/.hitch_pairs file" do
56
+ expect(PairUp::Participant).to receive(:write_file)
57
+ PairUp::UI.prompt_for_pair(new_author)
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,233 @@
1
+ require 'spec_helper'
2
+
3
+ describe PairUp do
4
+
5
+ let(:pairs_data) {
6
+ {
7
+ 'leela' => { 'name' => 'Turanga Leela', 'email' => 'leela@futurama.test'},
8
+ 'fry' => { 'name' => 'Philip J. Fry', 'email' => 'fry@futurama.test'},
9
+ 'zoidberg' => { 'name' => 'John A. Zoidberg', 'email' => 'zoidberg@futurama.test' }
10
+ }
11
+ }
12
+
13
+ let(:config) do
14
+ {
15
+ :current_pair => ["leela", "fry"]
16
+ }
17
+ end
18
+
19
+ before do
20
+ allow(PairUp::Participant).to receive(:config) { config }
21
+ allow(PairUp::Participant).to receive(:available_pairs) { pairs_data }
22
+ allow(PairUp).to receive(:write_file)
23
+ end
24
+
25
+ describe '.print_info' do
26
+
27
+ context 'when pairing' do
28
+ it 'returns the author and commiters names and emails' do
29
+ expect(PairUp::UI.highline).to receive(:say).with("Author: Turanga Leela <leela@futurama.test>, Comitter: Philip J. Fry <fry@futurama.test>")
30
+ PairUp.current_pair = ['leela', 'fry']
31
+ PairUp.print_info
32
+ end
33
+ end
34
+
35
+ context 'when not pairing' do
36
+ it 'returns nothing' do
37
+ PairUp.current_pair = []
38
+ expect(PairUp.print_info).to be_nil
39
+ end
40
+ end
41
+
42
+ context 'when not in an interactive shell' do
43
+ it 'returns nothing' do
44
+ allow(STDOUT).to receive(:tty?) { false }
45
+ expect(PairUp::UI.highline).to_not receive(:say)
46
+ PairUp.current_pair = ['leela', 'fry']
47
+ PairUp.print_info
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ describe '.switch' do
54
+
55
+ it "switches the author and commiter around" do
56
+ allow(PairUp::UI.highline).to receive(:say)
57
+ PairUp.current_pair= ['leela', 'fry']
58
+ expect(PairUp.current_pair).to eql(['leela', 'fry'])
59
+ PairUp.switch
60
+ expect(PairUp.current_pair).to eql(["fry", "leela"])
61
+ end
62
+ end
63
+
64
+ describe '.export' do
65
+
66
+ let(:pairs) { ['fry', 'leela'] }
67
+
68
+ before do
69
+ allow(PairUp).to receive(:print_info)
70
+ end
71
+
72
+ it 'sets the current pair' do
73
+ expect(PairUp).to receive(:current_pair=) {pairs}
74
+ PairUp.export(pairs)
75
+ end
76
+
77
+ it 'writes the export file' do
78
+ expect(PairUp).to receive(:write_export_file)
79
+ PairUp.export(pairs)
80
+ end
81
+
82
+ it 'prints out pair info' do
83
+ expect(PairUp).to receive(:print_info)
84
+ PairUp.export(pairs)
85
+ end
86
+
87
+ end
88
+
89
+ describe '.expire_command' do
90
+ before do
91
+ allow(PairUp).to receive(:bin_path) {'/usr/local/bin/pair'}
92
+ end
93
+
94
+ context 'with a valid string' do
95
+ let(:time_string) { '8' }
96
+ it 'returns the system command to call' do
97
+ expect(PairUp.expire_command(time_string)).to eql('sleep 28800 && /usr/local/bin/pair --unpair&')
98
+ end
99
+ end
100
+
101
+ context 'with a valid integer' do
102
+ let(:time_string) { 8 }
103
+ it 'returns the system command to call' do
104
+ expect(PairUp.expire_command(time_string)).to eql('sleep 28800 && /usr/local/bin/pair --unpair&')
105
+ end
106
+ end
107
+
108
+ context 'with an invalid string' do
109
+ let(:time_string) { 'BAR' }
110
+ it 'raises an error' do
111
+ expect {PairUp.expire_command(time_string)}.to raise_error(StandardError)
112
+ end
113
+ end
114
+
115
+ end
116
+
117
+ describe '.unpair' do
118
+
119
+ let(:pairs) { ['fry', 'leela'] }
120
+
121
+ it 'sets the current pair to an empty array' do
122
+ allow(PairUp).to receive(:current_pair=)
123
+ PairUp.unpair
124
+ end
125
+
126
+ it 'writes the export file' do
127
+ allow(PairUp).to receive(:write_export_file)
128
+ PairUp.unpair
129
+ end
130
+
131
+ end
132
+
133
+ describe '.author_command' do
134
+
135
+ context 'when pairing' do
136
+ it 'returns the export shell command for GIT_AUTHOR_* and GIT_COMMITTER_*' do
137
+ PairUp.current_pair = ['leela', 'fry']
138
+ expect(PairUp.author_command).to eql("export GIT_AUTHOR_NAME='Turanga Leela' GIT_AUTHOR_EMAIL='leela@futurama.test' GIT_COMMITTER_NAME='Philip J. Fry' GIT_COMMITTER_EMAIL='fry@futurama.test'")
139
+ end
140
+
141
+ it 'uses the first pair as author and the second as commiter' do
142
+ PairUp.current_pair = ['fry', 'leela']
143
+ expect(PairUp.author_command).to eql("export GIT_AUTHOR_NAME='Philip J. Fry' GIT_AUTHOR_EMAIL='fry@futurama.test' GIT_COMMITTER_NAME='Turanga Leela' GIT_COMMITTER_EMAIL='leela@futurama.test'")
144
+ end
145
+ end
146
+
147
+ context 'when not pairing' do
148
+ it 'returns the unset shell command for GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL' do
149
+ PairUp.current_pair = []
150
+ expect(PairUp.author_command).to eql("unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL")
151
+ end
152
+ end
153
+
154
+ context 'with more than 2 developers' do
155
+ it "ignores everyone but the first two" do
156
+ PairUp.current_pair = ['leela', 'fry', 'zoidberg']
157
+ expect(PairUp.author_command).to eql("export GIT_AUTHOR_NAME='Turanga Leela' GIT_AUTHOR_EMAIL='leela@futurama.test' GIT_COMMITTER_NAME='Philip J. Fry' GIT_COMMITTER_EMAIL='fry@futurama.test'")
158
+ end
159
+ end
160
+
161
+ end
162
+
163
+ describe '.current_pair' do
164
+ it 'returns an array of Github usernames' do
165
+ allow(PairUp).to receive(:config) {config}
166
+ expect(PairUp.current_pair).to eql(['leela', 'fry'])
167
+ end
168
+ end
169
+
170
+ describe '.current_pair=' do
171
+
172
+ before { allow(PairUp).to receive(:write_file) }
173
+
174
+ it 'writes the pair-uprc file' do
175
+ expect(PairUp).to receive(:write_file)
176
+ PairUp.current_pair = ['leela', 'fry']
177
+ end
178
+
179
+ context 'when there are no new participants' do
180
+ it 'sets the current pair with the participants given' do
181
+ PairUp.current_pair = ['leela', 'fry']
182
+ expect(PairUp.current_pair).to eql(['leela', 'fry'])
183
+ end
184
+ end
185
+
186
+ context 'when there are new participants' do
187
+
188
+ let(:new_participant) { 'therubymug' }
189
+
190
+ it "prompts for the new participant's info" do
191
+ expect(PairUp::UI).to receive(:prompt_for_pair).with(new_participant)
192
+ PairUp.current_pair = [new_participant, 'fry']
193
+ end
194
+
195
+ it 'adds the new participant to current pair' do
196
+ allow(PairUp::UI).to receive(:prompt_for_pair) {new_participant}
197
+ PairUp.current_pair = [new_participant, 'fry']
198
+ expect(PairUp.current_pair).to eql([new_participant, 'fry'])
199
+ end
200
+
201
+ end
202
+ end
203
+
204
+ describe '.git_author_name' do
205
+ it "returns the first participant's name" do
206
+ allow(PairUp).to receive(:config) { config }
207
+ expect(PairUp.git_author_name).to eql('Turanga Leela')
208
+ end
209
+ end
210
+
211
+ describe '.git_author_email' do
212
+ it "returns the first participant's email" do
213
+ allow(PairUp).to receive(:config) { config }
214
+ expect(PairUp.git_author_email).to eql('leela@futurama.test')
215
+ end
216
+ end
217
+
218
+ describe '.git_committer_name' do
219
+ it "returns the second participant's name" do
220
+ allow(PairUp).to receive(:config) { config }
221
+ expect(PairUp.git_committer_name).to eql('Philip J. Fry')
222
+ end
223
+ end
224
+
225
+ describe '.git_committer_email' do
226
+ it "returns the second participant's email" do
227
+ allow(PairUp).to receive(:config) { config }
228
+ expect(PairUp.git_committer_email).to eql('fry@futurama.test')
229
+ end
230
+ end
231
+
232
+
233
+ end
data/spec/spec_helper.rb CHANGED
@@ -3,7 +3,7 @@ require 'fileutils'
3
3
  require 'tempfile'
4
4
  require 'pry'
5
5
 
6
- require File.join(File.dirname(__FILE__), '..', 'lib', 'git-pair')
6
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'pair-up')
7
7
 
8
8
  RSpec.configure do |config|
9
9
  config.color = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pair-up
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andre Helberg
@@ -54,16 +54,16 @@ files:
54
54
  - README.md
55
55
  - Rakefile
56
56
  - bin/pair
57
- - git-pair.gemspec
58
- - lib/git-pair.rb
59
- - lib/git-pair/git-pair.sh
60
- - lib/git-pair/participant.rb
61
- - lib/git-pair/ui.rb
62
- - spec/git-pair/participant_spec.rb
63
- - spec/git-pair/ui_spec.rb
64
- - spec/git-pair_spec.rb
57
+ - lib/pair-up.rb
58
+ - lib/pair-up/pair-up.sh
59
+ - lib/pair-up/participant.rb
60
+ - lib/pair-up/ui.rb
61
+ - pair-up.gemspec
62
+ - spec/pair-up/participant_spec.rb
63
+ - spec/pair-up/ui_spec.rb
64
+ - spec/pair-up_spec.rb
65
65
  - spec/spec_helper.rb
66
- homepage: http://github.com/A-Helberg/git-pair
66
+ homepage: http://github.com/A-Helberg/pair-up
67
67
  licenses:
68
68
  - MIT
69
69
  metadata: {}
@@ -90,7 +90,7 @@ specification_version: 2
90
90
  summary: pair-up allows developers to be properly credited when Pair Programming and
91
91
  using Git.
92
92
  test_files:
93
- - spec/git-pair/participant_spec.rb
94
- - spec/git-pair/ui_spec.rb
95
- - spec/git-pair_spec.rb
93
+ - spec/pair-up/participant_spec.rb
94
+ - spec/pair-up/ui_spec.rb
95
+ - spec/pair-up_spec.rb
96
96
  - spec/spec_helper.rb
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GitPair::Participant do
4
-
5
- let(:base_pairs) do
6
- {
7
- 'bender' => {"email"=>"rcrichoch@fakeinbox.com", "name"=>"Rogelio J. Samour"},
8
- 'fry' => {"email"=>"crichoch@fakeinbox.com", "name"=>"Phillip J. Fry"},
9
- 'leela' => {"email"=>"stepriso@fakeinbox.com", "name"=>"Turanga Leela"}
10
- }
11
- end
12
-
13
- describe ".write_file" do
14
- it "writes the contents of GitPair::Participant.available_pairs to the hitch_pairs file" do
15
- expect(YAML).to receive(:dump)
16
- GitPair::Participant.write_file
17
- end
18
- end
19
-
20
- describe ".add" do
21
-
22
- context "when the participant is not present" do
23
- it "adds the participant to GitPair::Participant.available_pairs" do
24
- allow(GitPair::Participant).to receive(:get_available_pairs) { {} }
25
- GitPair::Participant.add("therubymug", "rcrichoch@fakeinbox.com", "Rogelio J. Samour")
26
- expect(GitPair::Participant.available_pairs).to eql({"therubymug"=>{"email"=>"rcrichoch@fakeinbox.com", "name"=>"Rogelio J. Samour"}})
27
- end
28
- end
29
-
30
- end
31
-
32
- describe ".find" do
33
-
34
- context "when the participant is present" do
35
- it "and_return the full name" do
36
- expect(GitPair::Participant.find("therubymug")).to eql({"email"=>"rcrichoch@fakeinbox.com", "name"=>"Rogelio J. Samour"})
37
- end
38
- end
39
-
40
- context "when the participant is not present" do
41
- it "and_return nil" do
42
- expect(GitPair::Participant.find("nobody")).to be_nil
43
- end
44
- end
45
-
46
- end
47
-
48
- end
@@ -1,64 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GitPair::UI do
4
-
5
- describe '.prompt_for_pair' do
6
-
7
- let(:new_author) { 'leela' }
8
- let(:new_author_name) { 'Turanga Leela' }
9
- let(:new_author_email) { 'Turanga Leela' }
10
-
11
-
12
- before do
13
- allow(GitPair::UI.highline).to receive(:ask) {new_author_name}
14
- # expect(GitPair::UI.highline).to receive(:say)
15
- end
16
-
17
- it 'states that the new pair is not in the git-pair_pairs file' do
18
- expect(GitPair::UI.highline).to receive(:say).with("I don't know who #{new_author} is.")
19
- GitPair::UI.prompt_for_pair(new_author)
20
- end
21
-
22
- it 'prompts for pair' do
23
- expect(GitPair::UI.highline).to receive(:say)
24
- expect(GitPair::UI.highline).to receive(:agree).with("Do you want to add #{new_author} to ~/.git-pair_pairs? (yn)")
25
- expect(GitPair::UI.highline).to receive(:say)
26
- GitPair::UI.prompt_for_pair(new_author)
27
- end
28
-
29
- context 'when user does not agree to add new author' do
30
- it "states it's ignoring the author" do
31
- allow(GitPair::UI.highline).to receive(:agree) {false}
32
- expect(GitPair::UI.highline).to receive(:say)
33
- expect(GitPair::UI.highline).to receive(:say).with("Ignoring #{new_author}.")
34
- GitPair::UI.prompt_for_pair(new_author)
35
- end
36
- end
37
-
38
- context 'when user agrees to add new author' do
39
-
40
- before do
41
- allow(GitPair::UI.highline).to receive(:agree) {true}
42
- expect(GitPair::UI.highline).to receive(:say)
43
- end
44
-
45
- it "asks for the new author's name" do
46
- expect(GitPair::UI.highline).to receive(:ask).with("What is #{new_author}'s full name?")
47
- GitPair::UI.prompt_for_pair(new_author)
48
- end
49
-
50
- it "adds the new author" do
51
- expect(GitPair::Participant).to receive(:add).with(new_author, new_author_name, new_author_email)
52
- GitPair::UI.prompt_for_pair(new_author)
53
- end
54
-
55
- it "writes the ~/.hitch_pairs file" do
56
- expect(GitPair::Participant).to receive(:write_file)
57
- GitPair::UI.prompt_for_pair(new_author)
58
- end
59
-
60
- end
61
-
62
- end
63
-
64
- end
@@ -1,233 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GitPair do
4
-
5
- let(:pairs_data) {
6
- {
7
- 'leela' => { 'name' => 'Turanga Leela', 'email' => 'leela@futurama.test'},
8
- 'fry' => { 'name' => 'Philip J. Fry', 'email' => 'fry@futurama.test'},
9
- 'zoidberg' => { 'name' => 'John A. Zoidberg', 'email' => 'zoidberg@futurama.test' }
10
- }
11
- }
12
-
13
- let(:gitpair_config) do
14
- {
15
- :current_pair => ["leela", "fry"]
16
- }
17
- end
18
-
19
- before do
20
- allow(GitPair::Participant).to receive(:config) { gitpair_config }
21
- allow(GitPair::Participant).to receive(:available_pairs) { pairs_data }
22
- allow(GitPair).to receive(:write_file)
23
- end
24
-
25
- describe '.print_info' do
26
-
27
- context 'when pairing' do
28
- it 'returns the author and commiters names and emails' do
29
- expect(GitPair::UI.highline).to receive(:say).with("Author: Turanga Leela <leela@futurama.test>, Comitter: Philip J. Fry <fry@futurama.test>")
30
- GitPair.current_pair = ['leela', 'fry']
31
- GitPair.print_info
32
- end
33
- end
34
-
35
- context 'when not pairing' do
36
- it 'returns nothing' do
37
- GitPair.current_pair = []
38
- expect(GitPair.print_info).to be_nil
39
- end
40
- end
41
-
42
- context 'when not in an interactive shell' do
43
- it 'returns nothing' do
44
- allow(STDOUT).to receive(:tty?) { false }
45
- expect(GitPair::UI.highline).to_not receive(:say)
46
- GitPair.current_pair = ['leela', 'fry']
47
- GitPair.print_info
48
- end
49
- end
50
-
51
- end
52
-
53
- describe '.switch' do
54
-
55
- it "switches the author and commiter around" do
56
- allow(GitPair::UI.highline).to receive(:say)
57
- GitPair.current_pair= ['leela', 'fry']
58
- expect(GitPair.current_pair).to eql(['leela', 'fry'])
59
- GitPair.switch
60
- expect(GitPair.current_pair).to eql(["fry", "leela"])
61
- end
62
- end
63
-
64
- describe '.export' do
65
-
66
- let(:pairs) { ['fry', 'leela'] }
67
-
68
- before do
69
- allow(GitPair).to receive(:print_info)
70
- end
71
-
72
- it 'sets the current pair' do
73
- expect(GitPair).to receive(:current_pair=) {pairs}
74
- GitPair.export(pairs)
75
- end
76
-
77
- it 'writes the export file' do
78
- expect(GitPair).to receive(:write_export_file)
79
- GitPair.export(pairs)
80
- end
81
-
82
- it 'prints out pair info' do
83
- expect(GitPair).to receive(:print_info)
84
- GitPair.export(pairs)
85
- end
86
-
87
- end
88
-
89
- describe '.expire_command' do
90
- before do
91
- allow(GitPair).to receive(:bin_path) {'/usr/local/bin/git-pair'}
92
- end
93
-
94
- context 'with a valid string' do
95
- let(:time_string) { '8' }
96
- it 'returns the system command to call' do
97
- expect(GitPair.expire_command(time_string)).to eql('sleep 28800 && /usr/local/bin/git-pair --unpair&')
98
- end
99
- end
100
-
101
- context 'with a valid integer' do
102
- let(:time_string) { 8 }
103
- it 'returns the system command to call' do
104
- expect(GitPair.expire_command(time_string)).to eql('sleep 28800 && /usr/local/bin/git-pair --unpair&')
105
- end
106
- end
107
-
108
- context 'with an invalid string' do
109
- let(:time_string) { 'BAR' }
110
- it 'raises an error' do
111
- expect {GitPair.expire_command(time_string)}.to raise_error(StandardError)
112
- end
113
- end
114
-
115
- end
116
-
117
- describe '.unpair' do
118
-
119
- let(:pairs) { ['fry', 'leela'] }
120
-
121
- it 'sets the current pair to an empty array' do
122
- allow(GitPair).to receive(:current_pair=)
123
- GitPair.unpair
124
- end
125
-
126
- it 'writes the export file' do
127
- allow(GitPair).to receive(:write_export_file)
128
- GitPair.unpair
129
- end
130
-
131
- end
132
-
133
- describe '.author_command' do
134
-
135
- context 'when pairing' do
136
- it 'returns the export shell command for GIT_AUTHOR_* and GIT_COMMITTER_*' do
137
- GitPair.current_pair = ['leela', 'fry']
138
- expect(GitPair.author_command).to eql("export GIT_AUTHOR_NAME='Turanga Leela' GIT_AUTHOR_EMAIL='leela@futurama.test' GIT_COMMITTER_NAME='Philip J. Fry' GIT_COMMITTER_EMAIL='fry@futurama.test'")
139
- end
140
-
141
- it 'uses the first pair as author and the second as commiter' do
142
- GitPair.current_pair = ['fry', 'leela']
143
- expect(GitPair.author_command).to eql("export GIT_AUTHOR_NAME='Philip J. Fry' GIT_AUTHOR_EMAIL='fry@futurama.test' GIT_COMMITTER_NAME='Turanga Leela' GIT_COMMITTER_EMAIL='leela@futurama.test'")
144
- end
145
- end
146
-
147
- context 'when not pairing' do
148
- it 'returns the unset shell command for GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL' do
149
- GitPair.current_pair = []
150
- expect(GitPair.author_command).to eql("unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL")
151
- end
152
- end
153
-
154
- context 'with more than 2 developers' do
155
- it "ignores the everyone but the first two" do
156
- GitPair.current_pair = ['leela', 'fry', 'zoidberg']
157
- expect(GitPair.author_command).to eql("export GIT_AUTHOR_NAME='Turanga Leela' GIT_AUTHOR_EMAIL='leela@futurama.test' GIT_COMMITTER_NAME='Philip J. Fry' GIT_COMMITTER_EMAIL='fry@futurama.test'")
158
- end
159
- end
160
-
161
- end
162
-
163
- describe '.current_pair' do
164
- it 'returns an array of Github usernames' do
165
- allow(GitPair).to receive(:config) {gitpair_config}
166
- expect(GitPair.current_pair).to eql(['leela', 'fry'])
167
- end
168
- end
169
-
170
- describe '.current_pair=' do
171
-
172
- before { allow(GitPair).to receive(:write_file) }
173
-
174
- it 'writes the git-pairrc file' do
175
- expect(GitPair).to receive(:write_file)
176
- GitPair.current_pair = ['leela', 'fry']
177
- end
178
-
179
- context 'when there are no new participants' do
180
- it 'sets the current pair with the participants given' do
181
- GitPair.current_pair = ['leela', 'fry']
182
- expect(GitPair.current_pair).to eql(['leela', 'fry'])
183
- end
184
- end
185
-
186
- context 'when there are new participants' do
187
-
188
- let(:new_participant) { 'therubymug' }
189
-
190
- it "prompts for the new participant's info" do
191
- expect(GitPair::UI).to receive(:prompt_for_pair).with(new_participant)
192
- GitPair.current_pair = [new_participant, 'fry']
193
- end
194
-
195
- it 'adds the new participant to current pair' do
196
- allow(GitPair::UI).to receive(:prompt_for_pair) {new_participant}
197
- GitPair.current_pair = [new_participant, 'fry']
198
- expect(GitPair.current_pair).to eql([new_participant, 'fry'])
199
- end
200
-
201
- end
202
- end
203
-
204
- describe '.git_author_name' do
205
- it "returns the first participant's name" do
206
- allow(GitPair).to receive(:config) { gitpair_config }
207
- expect(GitPair.git_author_name).to eql('Turanga Leela')
208
- end
209
- end
210
-
211
- describe '.git_author_email' do
212
- it "returns the first participant's email" do
213
- allow(GitPair).to receive(:config) { gitpair_config }
214
- expect(GitPair.git_author_email).to eql('leela@futurama.test')
215
- end
216
- end
217
-
218
- describe '.git_committer_name' do
219
- it "returns the second participant's name" do
220
- allow(GitPair).to receive(:config) { gitpair_config }
221
- expect(GitPair.git_committer_name).to eql('Philip J. Fry')
222
- end
223
- end
224
-
225
- describe '.git_committer_email' do
226
- it "returns the second participant's email" do
227
- allow(GitPair).to receive(:config) { gitpair_config }
228
- expect(GitPair.git_committer_email).to eql('fry@futurama.test')
229
- end
230
- end
231
-
232
-
233
- end