hitch 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/MIT_LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2010 Rogelio J. Samour
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,94 @@
1
+ hitch
2
+ =====
3
+ by Rogelio J. Samour
4
+ http://blog.therubymug.com
5
+
6
+ Description:
7
+ -----------
8
+
9
+ Hitch allows developers to be properly credited when Pair Programming and using Git.
10
+
11
+ Features:
12
+ --------
13
+
14
+ * Persists pair(s) between different terminal instances.
15
+ * Creates a unique email address for the pair. (e.g. dev+fry+leela@hashrocket.com) This provides the ability to create a Gravatar for the pair.
16
+
17
+ Synopsis:
18
+ --------
19
+
20
+ - For leela and fry to pair:
21
+ - hitch leela fry
22
+ - To clear pair info:
23
+ - hitch -u
24
+ - For a complete list of features:
25
+ - hitch -h
26
+ - Creating a Gravatar for your pair:
27
+ - Once I've hitched with my pair. (e.g. hitch leela fry) I have now created a unique email: dev+fry+leela@hashrocket.com
28
+ - Then, I go to gravatar.com. Add an image to that particular email address and I'm done.
29
+
30
+ Install:
31
+ -------
32
+
33
+ * gem install hitch
34
+ * rvm users run this:
35
+ <pre><code>for x in $(rvm list strings); do rvm use $x@global && gem install hitch; done</code></pre>
36
+ * hitch --setup >> ~/.bashrc
37
+ - this prints out the necessary shell function and aliases you need to add to your ~/.bashrc or ~/.zshrc
38
+ * Or copy/paste the following into your ~/.bashrc or ~/.zshrc:
39
+ <pre><code>hitch() {
40
+ command hitch "$@"
41
+ if [[ -s "$HOME/.hitch_export_authors" ]] ; then source "$HOME/.hitch_export_authors" ; fi
42
+ }
43
+ alias unhitch='hitch -u'
44
+ # Uncomment to persist pair info between terminal instances
45
+ # hitch
46
+ </code></pre>
47
+
48
+ Development:
49
+ -----------
50
+
51
+ * It's easier if you use rvm.
52
+ * Fork hitch
53
+ * When you cd into the directory the .rvmrc will activate and create a hitch gemset
54
+ * gem install bundler --pre
55
+ * bundle install
56
+ * rake # run the test suite
57
+
58
+ Requirements:
59
+ ------------
60
+
61
+ * Git, HighLine
62
+
63
+ Acknowledgements:
64
+ ----------------
65
+
66
+ * Stephen Caudill
67
+ * Les Hill
68
+ * Tim Pope
69
+
70
+ License:
71
+ -------
72
+
73
+ (The MIT License)
74
+
75
+ Copyright (c) 2010 Rogelio J. Samour
76
+
77
+ Permission is hereby granted, free of charge, to any person obtaining
78
+ a copy of this software and associated documentation files (the
79
+ 'Software'), to deal in the Software without restriction, including
80
+ without limitation the rights to use, copy, modify, merge, publish,
81
+ distribute, sublicense, and/or sell copies of the Software, and to
82
+ permit persons to whom the Software is furnished to do so, subject to
83
+ the following conditions:
84
+
85
+ The above copyright notice and this permission notice shall be
86
+ included in all copies or substantial portions of the Software.
87
+
88
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
89
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
90
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
91
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
92
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
93
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
94
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,30 +1,4 @@
1
- require 'spec/rake/spectask'
1
+ require 'rspec/core/rake_task'
2
+ RSpec::Core::RakeTask.new(:spec)
2
3
 
3
4
  task :default => :spec
4
-
5
- desc "Run specs"
6
- Spec::Rake::SpecTask.new do |t|
7
- t.spec_files = FileList['spec/**/*_spec.rb']
8
- t.spec_opts = %w(-ps --color)
9
- end
10
-
11
- begin
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gemspec|
14
- gemspec.name = %q{hitch}
15
- gemspec.version = '0.6.1'
16
- gemspec.summary = %q{Hitch allows developers to be properly credited when Pair Programming and using Git.}
17
- gemspec.email = %q{rogelio@therubymug.com}
18
- gemspec.homepage = %q{http://github.com/therubymug/hitch}
19
- gemspec.has_rdoc = false
20
- gemspec.authors = ["Rogelio J. Samour"]
21
- gemspec.files = %w( README.rdoc Rakefile ) + Dir["{bin,lib}/**/*"].sort
22
- gemspec.extra_rdoc_files = ["README.rdoc"]
23
- gemspec.executables = ["hitch"]
24
- gemspec.add_development_dependency "rspec", ">= 1.3.0"
25
- gemspec.add_dependency('highline', '>= 1.5.0')
26
- end
27
- Jeweler::GemcutterTasks.new
28
- rescue LoadError
29
- puts "Jeweler not available. Install it with: gem install jeweler"
30
- end
data/bin/hitch CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib hitch]))
4
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib hitch version]))
4
5
 
5
6
  args = ARGV
6
7
  options = []
@@ -11,6 +12,9 @@ opts = OptionParser.new do |opts|
11
12
  opts.on("-s", "--setup", "Print out shell goodies") do
12
13
  options = [:setup]
13
14
  end
15
+ opts.on("-e N", "--expire N", Integer, "Expire pair information in N hours.") do |n|
16
+ options = [:expire, n]
17
+ end
14
18
  opts.on("-u", "--unhitch", "Clear pair information") do
15
19
  options = [:unhitch]
16
20
  end
@@ -21,11 +25,15 @@ opts = OptionParser.new do |opts|
21
25
  exit
22
26
  end
23
27
  opts.on_tail("-v", "--version", "Show version") do
24
- abort "hitch v#{Hitch.version}"
28
+ abort "hitch v#{Hitch::VERSION}"
25
29
  end
26
30
  end
31
+
27
32
  if args.any?
28
33
  opts.parse!(args)
34
+ if options.delete(:expire)
35
+ system(Hitch.expire_command(options.pop))
36
+ end
29
37
  options = [:export, args] if options.empty?
30
38
  else
31
39
  options = [:print_info]
data/lib/hitch.rb CHANGED
@@ -6,12 +6,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib hitch ui]))
6
6
 
7
7
  module Hitch
8
8
 
9
- VERSION = '0.6.1'
10
-
11
- def self.version
12
- VERSION
13
- end
14
-
15
9
  def self.print_info
16
10
  if Hitch.pairing? && STDOUT.tty?
17
11
  Hitch::UI.highline.say("#{Hitch.git_author_name} <#{Hitch.git_author_email}>")
@@ -24,6 +18,10 @@ module Hitch
24
18
  print_info
25
19
  end
26
20
 
21
+ def self.expire_command(time)
22
+ %Q(sleep #{to_seconds(time)} && #{Hitch.bin_path} --unhitch&)
23
+ end
24
+
27
25
  def self.unhitch
28
26
  Hitch.current_pair = []
29
27
  write_export_file
@@ -123,10 +121,23 @@ module Hitch
123
121
  File.expand_path('~/.hitch_export_authors')
124
122
  end
125
123
 
124
+ def self.bin_path
125
+ %x[which hitch].chomp
126
+ end
127
+
126
128
  def self.pairing?
127
129
  current_pair.any?
128
130
  end
129
131
 
132
+ def self.to_seconds(value)
133
+ value = value.to_s.gsub(/[^\d]/, '').to_i
134
+ unless value.zero?
135
+ value * 60 * 60
136
+ else
137
+ raise StandardError
138
+ end
139
+ end
140
+
130
141
  def self.write_export_file
131
142
  File.open(hitch_export_authors, 'w'){|f| f.write(author_command) }
132
143
  end
data/lib/hitch/ui.rb CHANGED
@@ -14,7 +14,7 @@ module Hitch
14
14
  highline.say("I don't know who #{new_author} is.")
15
15
  if highline.agree("Do you want to add #{new_author} to ~/.hitch_pairs?", true)
16
16
  author_name = highline.ask("What is #{new_author}'s full name?") do |q|
17
- q.validate = /\A[-(\w|.,)+\s?]+\Z/
17
+ q.validate = /\A[\w.,-]+(?: [\w.,-]+)*\z/
18
18
  end
19
19
  Hitch::Author.add(new_author, author_name)
20
20
  Hitch::Author.write_file
@@ -0,0 +1,3 @@
1
+ module Hitch
2
+ VERSION = "0.7.0"
3
+ end
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Hitch::Author do
4
4
 
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Hitch::UI do
4
4
 
data/spec/hitch_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Hitch do
4
4
 
@@ -14,6 +14,34 @@ describe Hitch do
14
14
  Hitch::Author.stub(:available_pairs).and_return(hitch_pairs)
15
15
  end
16
16
 
17
+ describe '.expire_command' do
18
+ before do
19
+ Hitch.stub(:bin_path).and_return('/usr/local/bin/hitch')
20
+ end
21
+
22
+ context 'with a valid string' do
23
+ let(:time_string) { '8' }
24
+ it 'returns the system command to call' do
25
+ Hitch.expire_command(time_string).should == 'sleep 28800 && /usr/local/bin/hitch --unhitch&'
26
+ end
27
+ end
28
+
29
+ context 'with a valid integer' do
30
+ let(:time_string) { 8 }
31
+ it 'returns the system command to call' do
32
+ Hitch.expire_command(time_string).should == 'sleep 28800 && /usr/local/bin/hitch --unhitch&'
33
+ end
34
+ end
35
+
36
+ context 'with an invalid string' do
37
+ let(:time_string) { 'BAR' }
38
+ it 'raises an error' do
39
+ expect {Hitch.expire_command(time_string)}.to raise_error(StandardError)
40
+ end
41
+ end
42
+
43
+ end
44
+
17
45
  describe '.author_command' do
18
46
 
19
47
  context 'when pairing' do
@@ -1,11 +1,12 @@
1
- require 'yaml'
2
- require 'highline'
1
+ require 'rspec'
3
2
  require 'fileutils'
4
3
  require 'tempfile'
5
4
 
6
5
  require File.join(File.dirname(__FILE__), '..', 'lib', 'hitch')
7
6
 
8
- Spec::Runner.configure do |config|
7
+ RSpec.configure do |config|
8
+ config.color_enabled = true
9
+ config.formatter = 'progress'
9
10
  config.before(:each) do
10
11
  Hitch.stub(:hitchrc).and_return(Tempfile.new('hitchrc').path)
11
12
  Hitch.stub(:hitch_export_authors).and_return(Tempfile.new('hitch_export_authors').path)
metadata CHANGED
@@ -1,109 +1,85 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: hitch
3
- version: !ruby/object:Gem::Version
4
- hash: 5
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 6
9
- - 1
10
- version: 0.6.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Rogelio J. Samour
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-10-10 00:00:00 -04:00
19
- default_executable: hitch
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-09-05 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70190445636280 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 27
30
- segments:
31
- - 1
32
- - 3
33
- - 0
34
- version: 1.3.0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.6.0
35
22
  type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: highline
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70190445636280
25
+ - !ruby/object:Gem::Dependency
26
+ name: highline
27
+ requirement: &70190445635800 !ruby/object:Gem::Requirement
41
28
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 1
48
- - 5
49
- - 0
50
- version: 1.5.0
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.6.2
51
33
  type: :runtime
52
- version_requirements: *id002
53
- description:
34
+ prerelease: false
35
+ version_requirements: *70190445635800
36
+ description: Git author attribution helper for pair programmers.
54
37
  email: rogelio@therubymug.com
55
- executables:
38
+ executables:
56
39
  - hitch
57
40
  extensions: []
58
-
59
41
  extra_rdoc_files: []
60
-
61
- files:
62
- - Rakefile
63
- - bin/hitch
64
- - lib/hitch.rb
42
+ files:
65
43
  - lib/hitch/author.rb
66
44
  - lib/hitch/ui.rb
67
- - spec/helper.rb
45
+ - lib/hitch/version.rb
46
+ - lib/hitch.rb
47
+ - bin/hitch
48
+ - Rakefile
49
+ - MIT_LICENSE
50
+ - README.md
68
51
  - spec/hitch/author_spec.rb
69
52
  - spec/hitch/ui_spec.rb
70
53
  - spec/hitch_spec.rb
71
- has_rdoc: true
54
+ - spec/spec_helper.rb
72
55
  homepage: http://github.com/therubymug/hitch
73
56
  licenses: []
74
-
75
57
  post_install_message:
76
- rdoc_options:
58
+ rdoc_options:
77
59
  - --charset=UTF-8
78
- require_paths:
60
+ require_paths:
79
61
  - lib
80
- required_ruby_version: !ruby/object:Gem::Requirement
62
+ required_ruby_version: !ruby/object:Gem::Requirement
81
63
  none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
89
- required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
69
  none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- hash: 3
95
- segments:
96
- - 0
97
- version: "0"
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: 1.3.6
98
74
  requirements: []
99
-
100
75
  rubyforge_project:
101
- rubygems_version: 1.3.7
76
+ rubygems_version: 1.8.6
102
77
  signing_key:
103
78
  specification_version: 3
104
- summary: Hitch allows developers to be properly credited when Pair Programming and using Git.
105
- test_files:
106
- - spec/helper.rb
79
+ summary: Hitch allows developers to be properly credited when Pair Programming and
80
+ using Git.
81
+ test_files:
107
82
  - spec/hitch/author_spec.rb
108
83
  - spec/hitch/ui_spec.rb
109
84
  - spec/hitch_spec.rb
85
+ - spec/spec_helper.rb