git-pp 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. data/.rvmrc +48 -0
  2. data/README.md +12 -10
  3. data/bin/git-pp +60 -14
  4. data/lib/git-pp.rb +6 -0
  5. data/lib/git-pp/version.rb +1 -1
  6. metadata +3 -2
data/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p0@git-pp"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.16.17 (master)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
data/README.md CHANGED
@@ -1,24 +1,26 @@
1
- # Git::Pp
1
+ # git-pp
2
2
 
3
- TODO: Write a gem description
3
+ Extension for git supporting pair programming.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Install it yourself as:
8
8
 
9
- gem 'git-pp'
9
+ $ gem install git-pp
10
+ $ git pp setup
10
11
 
11
- And then execute:
12
+ ## Usage
12
13
 
13
- $ bundle
14
+ Edit your ~/.git-pp.yml and switch to pairing mode:
14
15
 
15
- Or install it yourself as:
16
+ $ git pp matt
17
+ Activating: Pairing Matt Doe + Artur Roszczyk
16
18
 
17
- $ gem install git-pp
19
+ Now, when you do a commit, author will be set to `Pairing Matt Doe + Artur Roszczyk`
18
20
 
19
- ## Usage
21
+ Following will bring you back to defaults:
20
22
 
21
- TODO: Write usage instructions here
23
+ $ git pp
22
24
 
23
25
  ## Contributing
24
26
 
data/bin/git-pp CHANGED
@@ -2,27 +2,73 @@
2
2
  # encoding: utf-8
3
3
  require 'yaml'
4
4
 
5
- Person = Struct.new(:name, :email) do
6
- def activate
7
- `git config user.name '#{name}'`
8
- `git config user.email '#{email}'`
5
+ CONFIG_FILE_PATH="#{ENV['HOME']}/.git-pp.yml"
6
+
7
+ module Git
8
+ module Pp
9
+ module Activable
10
+ def activate
11
+ `git config user.name '#{name}'`
12
+ `git config user.email '#{email}'`
13
+ end
14
+ end
9
15
  end
10
16
  end
11
17
 
12
- class Pair < Person
18
+ Person = Struct.new(:name, :email) do
19
+ include Git::Pp::Activable
20
+ end
21
+
22
+ class Pair < Struct.new(:left, :right)
23
+ include Git::Pp::Activable
24
+
13
25
  def name
14
- "Pairing #{super} + #{$me.name}"
26
+ "Pairing #{left.name} + #{right.name}"
27
+ end
28
+
29
+ def email
30
+ "#{left.email}, #{right.email}"
15
31
  end
16
32
  end
17
33
 
18
- $config = YAML.load(File.read("#{ENV['HOME']}/.git-pp.yml"))
34
+ def setup
35
+ unless File.exists?(CONFIG_FILE_PATH)
36
+ File.open(CONFIG_FILE_PATH, 'w') do |file|
37
+ file << <<-TEMPLATE
38
+ me:
39
+ name: #{`git config user.name`.strip}
40
+ email: #{`git config user.email`.strip}
41
+ pairs:
42
+ matt:
43
+ name: Matt Doe
44
+ email: me_and_matt@example.com
45
+ TEMPLATE
46
+ end
47
+
48
+ puts "#{CONFIG_FILE_PATH} created."
49
+ puts "Press ENTER key to edit config..."
50
+ STDIN.getc
51
+ `#{ENV['EDITOR']} #{CONFIG_FILE_PATH}`
52
+ end
53
+ end
19
54
 
20
- $me = Person.new($config['me']['name'], $config['me']['email'])
21
- $pairs = {}
22
- $config['pairs'].each do |pair_name, config|
23
- $pairs[pair_name] = Pair.new(config['name'], config['email'])
55
+ def switch(mate_name)
56
+ config = begin
57
+ YAML.load(File.read(CONFIG_FILE_PATH))
58
+ rescue
59
+ STDERR.puts "Config file does not exist, creating..."
60
+ setup
61
+ exit 1
62
+ end
63
+
64
+ me = Person.new(config['me']['name'], config['me']['email'])
65
+ pairs = {}
66
+ config['pairs'].each do |pair_name, c|
67
+ pairs[pair_name] = Pair.new(Person.new(c['name'], c['email']), me)
68
+ end
69
+ person = pairs[mate_name.to_s.downcase] || me
70
+ puts "Activating: #{person.name}"
71
+ person.activate
24
72
  end
25
73
 
26
- person = $pairs[ARGV[0]] || $me
27
- puts "Activating: #{person.name}"
28
- person.activate
74
+ switch ARGV[0]
@@ -2,5 +2,11 @@ require "git-pp/version"
2
2
 
3
3
  module Git
4
4
  module Pp
5
+ module Activable
6
+ def activate
7
+ `git config user.name '#{name}'`
8
+ `git config user.email '#{email}'`
9
+ end
10
+ end
5
11
  end
6
12
  end
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Pp
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-pp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-09 00:00:00.000000000 Z
12
+ date: 2012-11-10 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Extension for pairing with git
15
15
  email:
@@ -20,6 +20,7 @@ extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
22
  - .gitignore
23
+ - .rvmrc
23
24
  - Gemfile
24
25
  - LICENSE.txt
25
26
  - README.md