gitsu 2.0.1 → 2.0.3

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: 9fcb4e063806b45b31ab1b4bcc30778e940a622a
4
- data.tar.gz: a9d60a564b7471e0b955a23c305d8514607aa6dc
3
+ metadata.gz: c6052b324417250518afe887bcb191d981627958
4
+ data.tar.gz: 23ede1aa4fd3875f1dba10b1ee388d2f2fc50e00
5
5
  SHA512:
6
- metadata.gz: ea559f31632320ecc0608a2250a68b55838d0033685c12fde8e19b70a1f68f91a7616550fd1accb100435457241707231542bab66688be0b3a1135858acf8dff
7
- data.tar.gz: 98cabf2934b2b6d50ed5531c2bcefe0bf5794e2de11ad19035415688f822a2b2f59faf6e79bc7eb5cf2a3baee3e90b5691df14e8cadff032bad7f1209011c6b1
6
+ metadata.gz: 70dc9713701d5e8ea3170df85c5faddf5460729b3a6326b082e2ed442d0ff99fb4e6502011b431646c65b720c21dfb69f8ca4875e303c9cba4b01d0d82af21a2
7
+ data.tar.gz: 33553abab3b5f6e8a4a49e50505e2c4fc549ba78f9029dd98cc746fd8bbb09f75d11a40e07e3bae87b41dc4e74aad71faa06e0b1b1bcb3ba63aa102392dd2290
@@ -20,7 +20,3 @@ rvm:
20
20
  - "1.9.2"
21
21
  - "1.9.3"
22
22
  - "2.0.0"
23
- - jruby-18mode
24
- - jruby-19mode
25
- - rbx-18mode
26
- - rbx-19mode
data/README.md CHANGED
@@ -4,7 +4,8 @@
4
4
  [![Coverage Status](https://coveralls.io/repos/drrb/gitsu/badge.png?branch=master)](https://coveralls.io/r/drrb/gitsu)
5
5
  [![Code Climate](https://codeclimate.com/github/drrb/gitsu.png)](https://codeclimate.com/github/drrb/gitsu)
6
6
 
7
- [![Gem Version](https://badge.fury.io/rb/gitsu.png)](http://badge.fury.io/rb/gitsu)
7
+ [![Gem Version](https://badge.fury.io/rb/gitsu.png)](https://badge.fury.io/rb/gitsu)
8
+ [![Dependency Status](https://gemnasium.com/drrb/gitsu.png)](https://gemnasium.com/drrb/gitsu)
8
9
 
9
10
  Gitsu helps to manage your Git users, by making it easy to switch
10
11
  between users. Gitsu also supports pair programming by allowing you
data/Rakefile CHANGED
@@ -40,7 +40,7 @@ task 'push-release' => ['check-license', :verify] do
40
40
  end
41
41
 
42
42
  version = GitSu::Version.prompt($stdin, $stdout, "Enter the version to release", GitSu::Version.current)
43
- next_version = GitSu::Version.prompt($stdin, $stdout, "Enter the next development version", version.next_minor)
43
+ next_version = GitSu::Version.prompt($stdin, $stdout, "Enter the next development version", version.next_patch)
44
44
 
45
45
  puts "Releasing #{version} and preparing for #{next_version}"
46
46
 
@@ -64,4 +64,5 @@ end
64
64
 
65
65
  def update_version(new_version)
66
66
  system(%q[sed -i '' -E 's/VERSION = ".*"/VERSION = "] + new_version.to_s + %q["/' lib/gitsu/version.rb])
67
+ GitSu::VERSION.replace new_version.to_s
67
68
  end
@@ -53,7 +53,7 @@ Feature: Switch to multiple users
53
53
  b@example.com: Johnny B
54
54
  """
55
55
  When I type "git su ja jb ja"
56
- Then I should see "Couldn't find a combination of unique users matching 'ja', 'jb' and 'ja'"
56
+ Then I should see "Couldn't find a combination of users matching 'ja', 'jb' and 'ja'"
57
57
 
58
58
  Scenario: No group email configured
59
59
  Given the Git configuration has "gitsu.groupEmailAddress" set to ""
@@ -38,9 +38,10 @@ Gem::Specification.new do |gem|
38
38
  gem.require_paths = ["lib"]
39
39
 
40
40
  # Dependencies
41
- gem.add_development_dependency('coveralls', '>= 0.6.3')
42
- gem.add_development_dependency('json') # Coveralls needs it
43
- gem.add_development_dependency('rake')
44
- gem.add_development_dependency('rspec')
45
- gem.add_development_dependency('cucumber')
41
+ gem.add_development_dependency 'bundler', '~> 1.3'
42
+ gem.add_development_dependency 'rake'
43
+ gem.add_development_dependency 'coveralls', '>= 0.6.3'
44
+ gem.add_development_dependency 'json' # Coveralls needs it
45
+ gem.add_development_dependency 'rspec'
46
+ gem.add_development_dependency 'cucumber'
46
47
  end
@@ -21,11 +21,15 @@ class Array
21
21
  elsif size == 1
22
22
  last.to_s
23
23
  else
24
- "#{self[0..-2].map{|e| e.to_s}.join(", ")} and #{last.to_s}"
24
+ "#{self[0...-1].map{|e| e.to_s}.join(", ")} and #{last.to_s}"
25
25
  end
26
26
  end
27
27
 
28
28
  def pluralize(word)
29
29
  size > 1 ? word + "s" : word
30
30
  end
31
+
32
+ def quote
33
+ map { |element| "'#{element}'" }
34
+ end
31
35
  end
@@ -99,7 +99,7 @@ module GitSu
99
99
 
100
100
  def add_parsed_user(user)
101
101
  if @user_list.list.include? user
102
- @output.puts "User '#{user}' already in user list"
102
+ @output.puts "User '#{user}' already in user list (try switching to them with 'git su #{user.initials}')"
103
103
  else
104
104
  @user_list.add user
105
105
  @output.puts "User '#{user}' added to users"
@@ -82,6 +82,10 @@ module GitSu
82
82
  end
83
83
  end
84
84
 
85
+ def initials
86
+ names.join(" ").split(" ").map { |word| word.chars.first }.join.downcase
87
+ end
88
+
85
89
  def none?
86
90
  self === NONE
87
91
  end
@@ -16,6 +16,22 @@
16
16
 
17
17
  module GitSu
18
18
  class UserList
19
+ MATCH_STRATEGIES = [
20
+ # Whole word of name
21
+ lambda { |search_term, user| user.name =~ /\b#{search_term}\b/i },
22
+
23
+ # Beginning of word in name
24
+ lambda { |search_term, user| user.name =~ /\b#{search_term}/i },
25
+
26
+ # Initials
27
+ lambda { |search_term, user| user.initials =~ /#{search_term}/i },
28
+
29
+ # Segment anywhere in name or email
30
+ lambda do |search_term, user|
31
+ "#{user.name} #{user.email}" =~ /#{search_term}/i
32
+ end
33
+ ]
34
+
19
35
  def initialize(user_file)
20
36
  @user_file = user_file
21
37
  end
@@ -37,7 +53,7 @@ module GitSu
37
53
  end
38
54
  end
39
55
 
40
- find_unique_combination(searches) or raise "Couldn't find a combination of unique users matching #{search_terms.map {|t| "'#{t}'" }.to_sentence}"
56
+ find_unique_combination(searches) or raise "Couldn't find a combination of users matching #{search_terms.quote.to_sentence}"
41
57
  end
42
58
 
43
59
  private
@@ -51,7 +67,7 @@ module GitSu
51
67
  def all_matching_users(all_users, search_terms)
52
68
  searches = search_terms.map {|search_term| Search.new(search_term)}
53
69
  searches.each do |search|
54
- match_strategies.each do |strategy|
70
+ MATCH_STRATEGIES.each do |strategy|
55
71
  search.matches += all_users.select { |user| strategy.call(search.term, user) }
56
72
  end
57
73
  search.matches.uniq!
@@ -77,27 +93,6 @@ module GitSu
77
93
  combo.uniq.size == combo.size
78
94
  end
79
95
  end
80
-
81
- def match_strategies
82
- [
83
- # Whole word of name
84
- lambda { |search_term, user| user.name =~ /\b#{search_term}\b/i },
85
-
86
- # Beginning of word in name
87
- lambda { |search_term, user| user.name =~ /\b#{search_term}/i },
88
-
89
- # Initials
90
- lambda do |search_term, user|
91
- initials = user.name.split(" ").map { |word| word.chars.first }.join
92
- initials =~ /#{search_term}/i
93
- end,
94
-
95
- # Segment anywhere in name or email
96
- lambda do |search_term, user|
97
- "#{user.name} #{user.email}" =~ /#{search_term}/i
98
- end
99
- ]
100
- end
101
96
  end
102
97
  end
103
98
 
@@ -15,7 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
  module GitSu
18
- VERSION = "2.0.1"
18
+ VERSION = "2.0.3"
19
19
 
20
20
  class Version
21
21
  class ParseError < StandardError
@@ -48,7 +48,11 @@ module GitSu
48
48
  end
49
49
 
50
50
  def next_minor
51
- Version.new(@major, @minor + 1, @patch)
51
+ Version.new(@major, @minor + 1, 0)
52
+ end
53
+
54
+ def next_patch
55
+ Version.new(@major, @minor, @patch + 1)
52
56
  end
53
57
 
54
58
  def ==(other)
@@ -68,4 +68,18 @@ describe Array do
68
68
  end
69
69
  end
70
70
  end
71
+
72
+ describe "#quote" do
73
+ let(:array) { [:apple, :orange] }
74
+
75
+ it "quotes all elements in the array" do
76
+ array.quote.should == ["'apple'", "'orange'"]
77
+ end
78
+
79
+ context "when the array is empty" do
80
+ it "returns an empty array" do
81
+ [].quote.should == []
82
+ end
83
+ end
84
+ end
71
85
  end
@@ -173,7 +173,7 @@ module GitSu
173
173
  context "when the user already exists in the user list" do
174
174
  it "doesn't add the user to the user list" do
175
175
  user_list.should_receive(:list).and_return [User.new('John Galt', 'jgalt@example.com')]
176
- output.should_receive(:puts).with("User 'John Galt <jgalt@example.com>' already in user list")
176
+ output.should_receive(:puts).with("User 'John Galt <jgalt@example.com>' already in user list (try switching to them with 'git su jg')")
177
177
  switcher.add("John Galt <jgalt@example.com>")
178
178
  end
179
179
  end
@@ -110,7 +110,7 @@ module GitSu
110
110
  user_file.add("Johnny A", "ja@example.com")
111
111
  user_file.add("Johnny B", "jb@example.com")
112
112
 
113
- expect {user_list.find("ja", "jb", "j")}.to raise_error "Couldn't find a combination of unique users matching 'ja', 'jb' and 'j'"
113
+ expect {user_list.find("ja", "jb", "j")}.to raise_error "Couldn't find a combination of users matching 'ja', 'jb' and 'j'"
114
114
  end
115
115
  end
116
116
  context "when a search term only matches a user that was already matched, but the matching search term matched multiple users" do
@@ -60,12 +60,22 @@ module GitSu
60
60
  end
61
61
 
62
62
  describe "#next_minor" do
63
- it "increments the minor version by 1" do
63
+ it "increments the minor version by 1 and resets the patch version to 0" do
64
64
  version = Version.parse("1.2.3")
65
65
  next_version = version.next_minor
66
66
  next_version.major.should be 1
67
67
  next_version.minor.should be 3
68
- next_version.patch.should be 3
68
+ next_version.patch.should be 0
69
+ end
70
+ end
71
+
72
+ describe "#next_patch" do
73
+ it "increments the patch number by 1" do
74
+ version = Version.parse("1.2.3")
75
+ next_version = version.next_patch
76
+ next_version.major.should be 1
77
+ next_version.minor.should be 2
78
+ next_version.patch.should be 4
69
79
  end
70
80
  end
71
81
  end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitsu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - drrb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-21 00:00:00.000000000 Z
11
+ date: 2013-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: coveralls
14
+ name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.3
19
+ version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 0.6.3
26
+ version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
- name: json
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '>='
@@ -39,7 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.6.3
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.6.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - '>='