ppgit 0.6.0 → 0.7.0

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 0.7.0
2
+ - added a --names_separator option, if you don't like the default '+'
3
+ * `ppgit ara nva` ==> user.name = 'ara+nva'
4
+ * `ppgit ara nva --names_separator _and` ==> user.name = 'ara_and_nva'
5
+ - improved (coloured) the result of `ppgit info`
6
+ - when a new version is available, display the changelog.
1
7
  0.6.0
2
8
  - use '+' in the pair name, instead of '_'
3
9
  0.5.0
@@ -6,7 +12,7 @@
6
12
  0.4.0
7
13
  - use a bash & platform-agnostic ruby location
8
14
  - fixed that ppgit.emailroot would be stored in the local config file, instead of ~/.gitconfig.
9
- - 'ppgit clear' does not restore user.email/user.name values if they are already present in ~/.gitconfig.
15
+ - `ppgit clear` does not restore user.email/user.name values if they are already present in ~/.gitconfig.
10
16
  - print Usage text when user enters invalid command
11
17
  0.3.0
12
18
  - display the info message after each command
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.7.0
data/bin/git-pp CHANGED
@@ -15,12 +15,20 @@ else
15
15
  LOCAL_CONFIG_FILE = in_test_mode ? config_file_part('--file' ) : '--file .git/config'
16
16
  GLOBAL_CONFIG_FILE = in_test_mode ? config_file_part('--global_file') : '--global'
17
17
 
18
+ if names_separator = argv_value_of('--names_separator')
19
+ set_global_git_value 'ppgit.namesseparator', names_separator
20
+ end
21
+
22
+ if get_global_git_value('ppgit.namesseparator').blank? && !ARGV.include?('clear')
23
+ # write the default value in the config file, as hint/documentation
24
+ set_global_git_value 'ppgit.namesseparator', Ppgit::DEFAULT_PAIR_NAME_SEPARATOR
25
+ end
26
+
18
27
  if emailroot = argv_value_of('--email_root')
19
- do_ppgit_emailroot(emailroot)
20
- do_ppgit_info() if ARGV.empty?
28
+ set_global_git_value 'ppgit.emailroot', emailroot
21
29
  end
22
30
 
23
- if ARGV == %w(info)
31
+ if ARGV.empty? || ARGV == %w(info)
24
32
  do_ppgit_info()
25
33
 
26
34
  elsif ARGV == %w(clear)
@@ -28,7 +36,7 @@ else
28
36
  do_ppgit_info()
29
37
 
30
38
  elsif [2, 3].include?(ARGV.length)
31
- do_ppgit_set_pair_as_a_user(user_1=ARGV[0], user_2=ARGV[1], pair_email=ARGV[2])
39
+ do_ppgit_set_pair_as_a_user(user_1=ARGV[0], user_2=ARGV[1], pair_email=ARGV[2], names_separator=get_global_git_value('ppgit.namesseparator'))
32
40
  do_ppgit_info()
33
41
 
34
42
  elsif 0 != ARGV.length
@@ -39,7 +47,10 @@ else
39
47
  puts "\n----------------------------\n\n"
40
48
  end
41
49
 
42
- unless in_test_mode
43
- print_message_if_new_version_available('alainravet', 'ppgit')
50
+ unless in_test_mode || 'true' == ENV['PPGIT_NO_VERSION_CHECK']
51
+ print_message_if_new_version_available
52
+ puts "Note: you can prevent the version check with :"
53
+ puts " PPGIT_NO_VERSION_CHECK=true ppgit <command>"
54
+ puts ''
44
55
  end
45
56
  end
data/bin/ppgit CHANGED
@@ -15,12 +15,20 @@ else
15
15
  LOCAL_CONFIG_FILE = in_test_mode ? config_file_part('--file' ) : '--file .git/config'
16
16
  GLOBAL_CONFIG_FILE = in_test_mode ? config_file_part('--global_file') : '--global'
17
17
 
18
+ if names_separator = argv_value_of('--names_separator')
19
+ set_global_git_value 'ppgit.namesseparator', names_separator
20
+ end
21
+
22
+ if get_global_git_value('ppgit.namesseparator').blank? && !ARGV.include?('clear')
23
+ # write the default value in the config file, as hint/documentation
24
+ set_global_git_value 'ppgit.namesseparator', Ppgit::DEFAULT_PAIR_NAME_SEPARATOR
25
+ end
26
+
18
27
  if emailroot = argv_value_of('--email_root')
19
- do_ppgit_emailroot(emailroot)
20
- do_ppgit_info() if ARGV.empty?
28
+ set_global_git_value 'ppgit.emailroot', emailroot
21
29
  end
22
30
 
23
- if ARGV == %w(info)
31
+ if ARGV.empty? || ARGV == %w(info)
24
32
  do_ppgit_info()
25
33
 
26
34
  elsif ARGV == %w(clear)
@@ -28,7 +36,7 @@ else
28
36
  do_ppgit_info()
29
37
 
30
38
  elsif [2, 3].include?(ARGV.length)
31
- do_ppgit_set_pair_as_a_user(user_1=ARGV[0], user_2=ARGV[1], pair_email=ARGV[2])
39
+ do_ppgit_set_pair_as_a_user(user_1=ARGV[0], user_2=ARGV[1], pair_email=ARGV[2], names_separator=get_global_git_value('ppgit.namesseparator'))
32
40
  do_ppgit_info()
33
41
 
34
42
  elsif 0 != ARGV.length
@@ -39,7 +47,10 @@ else
39
47
  puts "\n----------------------------\n\n"
40
48
  end
41
49
 
42
- unless in_test_mode
43
- print_message_if_new_version_available('alainravet', 'ppgit')
50
+ unless in_test_mode || 'true' == ENV['PPGIT_NO_VERSION_CHECK']
51
+ print_message_if_new_version_available
52
+ puts "Note: you can prevent the version check with :"
53
+ puts " PPGIT_NO_VERSION_CHECK=true ppgit <command>"
54
+ puts ''
44
55
  end
45
56
  end
data/lib/ppgit.rb CHANGED
@@ -1 +1,9 @@
1
+ class Ppgit
2
+ class Github
3
+ USER = 'alainravet'
4
+ PROJECT = 'ppgit'
5
+ end
6
+ DEFAULT_PAIR_NAME_SEPARATOR = '+'
7
+ DEFAULT_PAIR_EMAIL_USER_SEPARATOR = '_'
8
+ end
1
9
  require 'ppgit/commands'
@@ -1,7 +1,6 @@
1
1
  require 'ppgit/git_utils'
2
2
  require 'ppgit/ppgit_utils'
3
- require 'ppgit/version_utils'
4
-
3
+ require 'ppgit/gem_version_utils'
5
4
 
6
5
  def do_ppgit_clear
7
6
  backup_is_same_as_global?('name') ?
@@ -17,29 +16,23 @@ def do_ppgit_clear
17
16
  end
18
17
 
19
18
 
20
- def do_ppgit_emailroot(emailroot)
21
- set_global_git_value 'ppgit.emailroot', emailroot
22
- end
23
-
24
-
25
- def do_ppgit_set_pair_as_a_user(user_1, user_2, pair_email)
19
+ def do_ppgit_set_pair_as_a_user(user_1, user_2, pair_email, names_separator)
26
20
  backup_git_value :from => 'user.name' , :to => 'user-before-ppgit.name'
27
21
  backup_git_value :from => 'user.email', :to => 'user-before-ppgit.email'
28
22
 
29
- two_users = [user_1, user_2]
30
- pair_email ||= make_email_from_email_root_and_user(two_users.sort.join('_'))
23
+ pair_email ||= make_email_from_email_root_and_user(user_1, user_2)
31
24
 
32
- set_local_git_value 'user.name', two_users.sort.join('+')
25
+ set_local_git_value 'user.name', assemble_pair_name(user_1, user_2, names_separator)
33
26
  if pair_email
34
27
  set_local_git_value 'user.email', pair_email
35
28
  end
36
29
  end
37
30
 
38
- def make_email_from_email_root_and_user(pair_user)
31
+ def make_email_from_email_root_and_user(user_1, user_2)
39
32
  emailroot = get_global_git_value('ppgit.emailroot')
40
33
  emailroot.blank? ?
41
34
  nil :
42
- emailroot.gsub('*', pair_user)
35
+ emailroot.gsub('*', assemble_email_user(user_1, user_2))
43
36
  end
44
37
 
45
38
 
@@ -60,8 +53,9 @@ def do_ppgit_info
60
53
  end
61
54
 
62
55
  def ppgit_info(file)
63
- name, email = get_value('user.name', file), get_value('user.email', file)
64
- email_root = get_value('ppgit.emailroot', file)
56
+ name, email = get_value('user.name', file), get_value('user.email', file)
57
+ names_separator = get_value('ppgit.namesseparator', file)
58
+ email_root = get_value('ppgit.emailroot' , file)
65
59
  s = []
66
60
  s << "-------------------------------------------------------"
67
61
  s << "file = " + ((file == '--global') ? '~/.gitconfig' : file.gsub('--file ',''))
@@ -70,18 +64,27 @@ def ppgit_info(file)
70
64
  # s << ' [user] is empty (user.email and user.name are not set)'
71
65
  # else
72
66
  s << ' [user]'
73
- s << " name = #{name }" unless name.blank?
74
- s << " email = #{email}" unless email.blank?
67
+ s << red(" name = #{name }") unless name.blank?
68
+ s << red(" email = #{email}") unless email.blank?
75
69
  s << ' -------------------------------------------------------'
76
70
  end
77
- unless email_root.blank?
71
+
72
+ unless email_root.blank? && names_separator.blank?
78
73
  s << ' [ppgit]'
79
- s << " emailroot = #{email_root}" unless email_root.blank?
74
+ unless email_root.blank?
75
+ sample_email = make_email_from_email_root_and_user('ann', 'bob')
76
+ s << " emailroot = #{yellow(email_root)} # -> `ppgit ann bob` -> user.email = #{yellow(sample_email)}"
77
+ end
78
+ unless names_separator.blank?
79
+ sample_name = assemble_pair_name('ann', 'bob', names_separator)
80
+ s << " namesseparator = #{yellow(names_separator)} # -> `ppgit ann bob` -> user.name = #{yellow(sample_name)}"
81
+ end
80
82
  s << ' -------------------------------------------------------'
81
83
  end
84
+
82
85
  name, email = get_value('user-before-ppgit.name', file), get_value('user-before-ppgit.email', file)
83
86
  unless name.blank? && email.blank?
84
- s << ' [user-before-ppgit]'
87
+ s << ' [user-before-ppgit] # values restored by `ppgit clear`'
85
88
  s << " name = #{name }" unless name.blank?
86
89
  s << " email = #{email}" unless email.blank?
87
90
  s << ' -------------------------------------------------------'
@@ -0,0 +1,40 @@
1
+ require 'ppgit/github_utils'
2
+
3
+ def this_version
4
+ version_file = File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'VERSION')
5
+ File.open(version_file).read.chomp
6
+ end
7
+
8
+ def new_version_available?(user, project)
9
+ latest_version = latest_github_version(user, project)
10
+ # latest_version.nil? if the info cannot be retrieved from github.com
11
+ latest_version && this_version != latest_version
12
+ end
13
+
14
+ def print_message_if_new_version_available
15
+ user = Ppgit::Github::USER
16
+ project = Ppgit::Github::PROJECT
17
+ changelog = latest_github_changelog(user, project, 'master', 'CHANGELOG', this_version)
18
+
19
+ if new_version_available?(user, project)
20
+ s = ["\033[1;33m"] # yellow
21
+ s << '------------------------------------------------------'
22
+ s << " There is a new version of #{project} (#{latest_github_version(user, project)})."
23
+ s << " You are using version #{this_version}"
24
+ s << ' To update :'
25
+ s << " #{red("gem update " + project)}"
26
+ s << '------------------------------------------------------'
27
+ s << "\033[0m" # no color
28
+ s << '------------------------------------------------------'
29
+ unless changelog.empty?
30
+ s << " CHANGELOG :"
31
+ s << '------------------------------------------------------'
32
+ s << changelog.map{|l| l.chomp}
33
+ s << this_version
34
+ s << ' ...'
35
+ s << '------------------------------------------------------'
36
+ end
37
+ msg = s.join("\n")
38
+ puts msg
39
+ end
40
+ end
@@ -0,0 +1,32 @@
1
+ require 'open-uri'
2
+
3
+ def latest_github_version(user, project, branch='master', file='VERSION')
4
+ @@latest_github_version ||= read_file_from_github(user, project, branch, file)
5
+ end
6
+
7
+ def latest_github_changelog(user, project, branch='master', file='CHANGELOG', old_version=nil)
8
+ all_lines = read_file_lines_from_github(user, project, branch, file)
9
+ (all_lines || []).map{|line| line.chomp}.take_while{|line| line != old_version}
10
+ end
11
+
12
+
13
+ def read_file_from_github(user, project, branch, file)
14
+ file_path = "http://github.com/#{user}/#{project}/raw/#{branch}/#{file}"
15
+ begin
16
+ contents = open(file_path).read.chomp # ex: '1.2.3'
17
+ rescue => e #SocketError, OpenURI::HTTPError
18
+ puts file_path
19
+ puts e.inspect
20
+ nil # unable to read the file
21
+ end
22
+ end
23
+
24
+ def read_file_lines_from_github(user, project, branch, file)
25
+ file_path = "http://github.com/#{user}/#{project}/raw/#{branch}/#{file}"
26
+ begin
27
+ open(file_path).readlines
28
+ rescue SocketError, OpenURI::HTTPError
29
+ nil # unable to read the file
30
+ end
31
+ end
32
+
@@ -1,6 +1,22 @@
1
1
  require 'ppgit/utils'
2
2
  require 'ppgit/git_utils'
3
3
 
4
+ # ------------------------------------------------------------------------
5
+
6
+ # 'ann', 'bob' => ''ann+bob'
7
+ def assemble_pair_name(user_1, user_2, names_separator)
8
+ names_separator = Ppgit::DEFAULT_PAIR_NAME_SEPARATOR if names_separator.blank?
9
+ [user_1, user_2].sort.join(names_separator)
10
+ end
11
+
12
+ # 'ann', ''bob' => ''ann+bob'
13
+
14
+ def assemble_email_user(user_1, user_2)
15
+ [user_1, user_2].sort.join(Ppgit::DEFAULT_PAIR_EMAIL_USER_SEPARATOR)
16
+ end
17
+
18
+ # ------------------------------------------------------------------------
19
+
4
20
  # separator = --file, or --global_file
5
21
  # Returns :
6
22
  # nil
data/lib/ppgit/usage.txt CHANGED
@@ -6,12 +6,12 @@ ppgit : quickly update ~/.gitconfig for pair-programming sessions.
6
6
 
7
7
  Quick Usage:
8
8
 
9
- $ ppgit john andy andy_john@acme.com
9
+ $ ppgit john andy
10
10
  $ ppgit clear
11
11
  $ ppgit info
12
12
 
13
- $ ppgit --email_root *@acme.com
14
- $ ppgit john andy
13
+ $ ppgit john andy andy_john@acme.com
14
+ $ ppgit --email_root *@acme.com --names_separator _and_
15
15
 
16
16
  remark : 'ppgit' is a synonym of 'git pp' => you can write
17
17
 
data/ppgit.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ppgit}
8
- s.version = "0.6.0"
8
+ s.version = "0.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alain Ravet"]
12
- s.date = %q{2010-10-07}
12
+ s.date = %q{2010-10-10}
13
13
  s.description = %q{git users' pairs switcher}
14
14
  s.email = %q{alain.ravet+git@gmail.com}
15
15
  s.executables = ["git-pp", "ppgit"]
@@ -32,16 +32,18 @@ Gem::Specification.new do |s|
32
32
  "doc/ppgit-img3.png",
33
33
  "lib/ppgit.rb",
34
34
  "lib/ppgit/commands.rb",
35
+ "lib/ppgit/gem_version_utils.rb",
35
36
  "lib/ppgit/git_utils.rb",
37
+ "lib/ppgit/github_utils.rb",
36
38
  "lib/ppgit/ppgit_utils.rb",
37
39
  "lib/ppgit/quick_usage.txt",
38
40
  "lib/ppgit/usage.txt",
39
41
  "lib/ppgit/utils.rb",
40
- "lib/ppgit/version_utils.rb",
41
42
  "ppgit.gemspec",
42
43
  "spec/ppgit_clear_spec.rb",
43
44
  "spec/ppgit_email_root_spec.rb",
44
- "spec/ppgit_info_spec.rb",
45
+ "spec/ppgit_info_spec.rb.disabled",
46
+ "spec/ppgit_names_separator_spec.rb",
45
47
  "spec/ppgit_spec.rb",
46
48
  "spec/ppgit_usage_spec.rb",
47
49
  "spec/spec.opts",
@@ -55,7 +57,7 @@ Gem::Specification.new do |s|
55
57
  s.test_files = [
56
58
  "spec/ppgit_clear_spec.rb",
57
59
  "spec/ppgit_email_root_spec.rb",
58
- "spec/ppgit_info_spec.rb",
60
+ "spec/ppgit_names_separator_spec.rb",
59
61
  "spec/ppgit_spec.rb",
60
62
  "spec/ppgit_usage_spec.rb",
61
63
  "spec/spec_helper.rb"
@@ -16,7 +16,8 @@ describe "simple: `ppgit --email_root acme+*@gmail.com`" do
16
16
 
17
17
  it 'stores the emailroot in --global (~/.gitconfig)' do
18
18
  expected_global= ['[ppgit]' ,
19
- ' emailroot = acme+*@gmail.com'
19
+ ' namesseparator = +' ,
20
+ ' emailroot = acme+*@gmail.com' ,
20
21
  ]
21
22
  @actual_global.should == expected_global.join("\n")
22
23
  end
@@ -27,7 +28,8 @@ describe "simple: `ppgit --email_root acme+*@gmail.com`" do
27
28
  before(:all) do
28
29
  @before_local = [ ]
29
30
  @before_global = ['[ppgit]' ,
30
- ' emailroot = old+*@gmail.com' # <= the old value to replace
31
+ ' namesseparator = +' ,
32
+ ' emailroot = old+*@gmail.com', # <= the old value to replace
31
33
  ]
32
34
  @actual_local, @actual_global = execute_command_g(@cmd, @before_local, @before_global)
33
35
  end
@@ -36,7 +38,8 @@ describe "simple: `ppgit --email_root acme+*@gmail.com`" do
36
38
 
37
39
  it 'stores the new emailroot in --global (~/.gitconfig)' do
38
40
  expected_global= ['[ppgit]' ,
39
- ' emailroot = acme+*@gmail.com'
41
+ ' namesseparator = +' ,
42
+ ' emailroot = acme+*@gmail.com' ,
40
43
  ]
41
44
  @actual_global.should == expected_global.join("\n")
42
45
  end
@@ -60,6 +63,7 @@ describe "medium: `ppgit john andy --email_root acme+*@gmail.com`" do
60
63
  end
61
64
  it 'stores the emailroot in --global (~/.gitconfig)' do
62
65
  expected_global= ['[ppgit]' ,
66
+ ' namesseparator = +' ,
63
67
  ' emailroot = acme+*@gmail.com'
64
68
  ].join("\n")
65
69
  @actual_global.should == expected_global
@@ -85,6 +89,7 @@ describe "complex: `ppgit john andy andy_john@test.com --email_root acme+*@gmail
85
89
 
86
90
  it 'stores the emailroot in --global (~/.gitconfig)' do
87
91
  expected_global= ['[ppgit]' ,
92
+ ' namesseparator = +' ,
88
93
  ' emailroot = acme+*@gmail.com'
89
94
  ].join("\n")
90
95
  @actual_global.should == expected_global
@@ -13,6 +13,7 @@ describe "`ppgit info`" do
13
13
  ' email = johnuser@gmail.be' ]
14
14
 
15
15
  before_global = [ '[ppgit]' ,
16
+ 'namesseparator = ZEP' ,
16
17
  ' emailroot = acme+*@gmail.com' ]
17
18
  ignore, ignore, @output = execute_command_g( ppgit("info"), before_local, before_global)
18
19
  end
@@ -22,6 +23,9 @@ describe "`ppgit info`" do
22
23
  it('should display the [ppgit].emailroot info' ) {
23
24
  @output.should match(/\[ppgit\].+emailroot\s+=\s+acme\+\*@gmail.com/mi)
24
25
  }
26
+ it('should display the [ppgit].namesseparator info' ) {
27
+ @output.should match(/\[ppgit\].+namesseparator\s+=\s+ZEP/mi)
28
+ }
25
29
  end
26
30
 
27
31
  context "when NONE of the [user] and the ppgit variables are stored in the config file" do
@@ -35,6 +39,8 @@ describe "`ppgit info`" do
35
39
  it('should not display the empty [user] section' ) { @output.should_not match(/\[user\]/mi) }
36
40
 
37
41
  it('should NOT display the empty [user-before-ppgit] section') { @output.should_not match(/\[user-before-ppgit\]/mi) }
38
- it('should NOT display the [ppgit] info' ) { @output.should_not match(/\[ppgit\]/mi) }
42
+ it('should insert and display the default [ppgit].namesseparator info' ) {
43
+ @output.should match(/\[ppgit\].+namesseparator\s+=\s+\+/mi)
44
+ }
39
45
  end
40
46
  end
@@ -0,0 +1,68 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "simple: `ppgit --names_separator _SEP_`" do
4
+
5
+ before(:all) do
6
+ @cmd = "#{PPGIT_CMD} --names_separator _SEP_"
7
+ end
8
+
9
+ context 'when there is no namesseparator yet' do
10
+ before(:all) do
11
+ @before_local = [ ]
12
+ @before_global = [ ] # no pair_separator here.
13
+ @actual_local, @actual_global = execute_command_g(@cmd, @before_local, @before_global)
14
+ end
15
+
16
+ it("doesn't change .git/config") { @actual_local.should == @before_local.join("\n") }
17
+
18
+ it 'stores the names separator in --global (~/.gitconfig)' do
19
+ expected_global= ['[ppgit]' ,
20
+ ' namesseparator = _SEP_'
21
+ ]
22
+ @actual_global.should == expected_global.join("\n")
23
+ end
24
+ end
25
+
26
+ context 'when there is already an namesseparator' do
27
+ before(:all) do
28
+ @before_local = [ ]
29
+ @before_global = ['[ppgit]' ,
30
+ ' namesseparator = OLD_SEP' # <= the old value to replace
31
+ ]
32
+ @actual_local, @actual_global = execute_command_g(@cmd, @before_local, @before_global)
33
+ end
34
+
35
+ it("doesn't change .git/config") { @actual_local.should == @before_local.join("\n") }
36
+
37
+ it 'stores the new names separator in --global (~/.gitconfig)' do
38
+ expected_global= ['[ppgit]' ,
39
+ ' namesseparator = _SEP_'
40
+ ]
41
+ @actual_global.should == expected_global.join("\n")
42
+ end
43
+ end
44
+ end
45
+
46
+ describe "medium: `ppgit john andy --names_separator _SEP_`" do
47
+ before(:all) do
48
+ @cmd = "#{PPGIT_CMD} john andy --names_separator _SEP_"
49
+ before_local = [ ]
50
+ before_global = [ ]
51
+ @actual_local, @actual_global = execute_command_g(@cmd, before_local, before_global)
52
+ end
53
+
54
+ it 'stores the user in local (.git/config)' do
55
+ expected_local = [ '[user]' ,
56
+ ' name = andy_SEP_john' ,
57
+ ].join("\n")
58
+ @actual_local.should == expected_local
59
+ end
60
+ it 'stores the names separator in --global (~/.gitconfig)' do
61
+ expected_global= ['[ppgit]' ,
62
+ ' namesseparator = _SEP_'
63
+ ].join("\n")
64
+ @actual_global.should == expected_global
65
+ end
66
+ end
67
+
68
+
data/spec/ppgit_spec.rb CHANGED
@@ -18,7 +18,10 @@ context "with empty git config files" do
18
18
  ' name = andy+john' ]
19
19
  @actual_local.should == expected_local.join("\n")
20
20
  end
21
- it("doesn't change --global (~/.gitconfig)") { @actual_global.should == @before_global.join("\n") }
21
+ it("adds the default names separator to the global config (~/.gitconfig)") do
22
+ augmented_global = @before_global + ['[ppgit]', " namesseparator = #{Ppgit::DEFAULT_PAIR_NAME_SEPARATOR}"]
23
+ @actual_global.should == (augmented_global).join("\n")
24
+ end
22
25
  end
23
26
 
24
27
 
@@ -34,7 +37,10 @@ context "with empty git config files" do
34
37
 
35
38
  @actual_local.should == expected_local.join("\n")
36
39
  end
37
- it("doesn't change --global (~/.gitconfig)") { @actual_global.should == @before_global.join("\n") }
40
+ it("adds the default names separator to the global config (~/.gitconfig)") do
41
+ augmented_global = @before_global + ['[ppgit]', " namesseparator = #{Ppgit::DEFAULT_PAIR_NAME_SEPARATOR}"]
42
+ @actual_global.should == (augmented_global).join("\n")
43
+ end
38
44
  end
39
45
  end
40
46
 
@@ -56,7 +62,10 @@ context 'when there is only a ppgit.emailroot' do
56
62
  ' email = pp+andy_john@gmail.com' ]
57
63
  @actual_local.should == expected_local.join("\n")
58
64
  end
59
- it("doesn't change --global (~/.gitconfig)") { @actual_global.should == @before_global.join("\n") }
65
+ it("adds the default names separtor to the global config (~/.gitconfig)") do
66
+ augmented_global = @before_global + [" namesseparator = #{Ppgit::DEFAULT_PAIR_NAME_SEPARATOR}"]
67
+ @actual_global.should == (augmented_global).join("\n")
68
+ end
60
69
  end
61
70
  end
62
71
 
data/spec/spec_helper.rb CHANGED
@@ -10,14 +10,6 @@ Spec::Runner.configure do |config|
10
10
  end
11
11
 
12
12
  require 'tempfile'
13
- require 'ftools'
14
-
15
- def temp_from_model(model, file_basename=nil)
16
- newfile = Tempfile.new(file_basename)
17
- source_path = File.expand_path(File.dirname(__FILE__) + "/fixtures/#{model}")
18
- File.copy(source_path, newfile.path)
19
- newfile
20
- end
21
13
 
22
14
  def temp_from_string(string, file_basename=nil)
23
15
  f = Tempfile.new(file_basename)
@@ -26,11 +18,6 @@ def temp_from_string(string, file_basename=nil)
26
18
  f
27
19
  end
28
20
 
29
- def expected_contents(file_name)
30
- f = File.expand_path(File.dirname(__FILE__) + "/fixtures/#{file_name}")
31
- File.open(f).read
32
- end
33
-
34
21
 
35
22
  PPGIT_CMD = File.expand_path(File.dirname(__FILE__)) + '/../bin/ppgit'
36
23
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ppgit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 6
8
+ - 7
9
9
  - 0
10
- version: 0.6.0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alain Ravet
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-07 00:00:00 +02:00
18
+ date: 2010-10-10 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -59,16 +59,18 @@ files:
59
59
  - doc/ppgit-img3.png
60
60
  - lib/ppgit.rb
61
61
  - lib/ppgit/commands.rb
62
+ - lib/ppgit/gem_version_utils.rb
62
63
  - lib/ppgit/git_utils.rb
64
+ - lib/ppgit/github_utils.rb
63
65
  - lib/ppgit/ppgit_utils.rb
64
66
  - lib/ppgit/quick_usage.txt
65
67
  - lib/ppgit/usage.txt
66
68
  - lib/ppgit/utils.rb
67
- - lib/ppgit/version_utils.rb
68
69
  - ppgit.gemspec
69
70
  - spec/ppgit_clear_spec.rb
70
71
  - spec/ppgit_email_root_spec.rb
71
- - spec/ppgit_info_spec.rb
72
+ - spec/ppgit_info_spec.rb.disabled
73
+ - spec/ppgit_names_separator_spec.rb
72
74
  - spec/ppgit_spec.rb
73
75
  - spec/ppgit_usage_spec.rb
74
76
  - spec/spec.opts
@@ -110,7 +112,7 @@ summary: git users' pairs switcher
110
112
  test_files:
111
113
  - spec/ppgit_clear_spec.rb
112
114
  - spec/ppgit_email_root_spec.rb
113
- - spec/ppgit_info_spec.rb
115
+ - spec/ppgit_names_separator_spec.rb
114
116
  - spec/ppgit_spec.rb
115
117
  - spec/ppgit_usage_spec.rb
116
118
  - spec/spec_helper.rb
@@ -1,34 +0,0 @@
1
- require 'open-uri'
2
-
3
- def latest_github_version(user, project)
4
- version_path = "http://github.com/#{user}/#{project}/raw/master/VERSION"
5
- begin
6
- version = open(version_path).read.chomp # ex: '1.2.3'
7
- rescue SocketError
8
- # unable to fetch the version
9
- end
10
- end
11
-
12
- def this_version
13
- version_file = File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'VERSION')
14
- File.open(version_file).read.chomp
15
- end
16
-
17
- def new_version_available?(project, user)
18
- this_version != latest_github_version(user, project)
19
- end
20
-
21
- def print_message_if_new_version_available(user, project)
22
- if new_version_available?(project, user)
23
- s = ["\033[1;33m"] # yellow
24
- s << '------------------------------------------------------'
25
- s << " There is a new version of #{project} (#{latest_github_version(user, project)})."
26
- s << " You are using version #{this_version}"
27
- s << ' To update :'
28
- s << " gem update #{project}"
29
- s << '------------------------------------------------------'
30
- s << "\033[0m" # no color
31
- msg = s.join("\n")
32
- puts msg
33
- end
34
- end