pear 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 28a67c8113b82c9c71639c1ad69fcbde175d4ee3
4
+ data.tar.gz: 96b2002c7dd64684a68bda14e465b702b66e5ac4
5
+ SHA512:
6
+ metadata.gz: f074c5d2a4df01c257e0dfb917251a092546cae8a0bb66b08bc58eabb881eb4dea8743c622e877e8565c4d7882547bf974a26fb47963e092945b53f1ce23a2ce
7
+ data.tar.gz: c8af44667f283240b22272ab95b847187b0f83034b41fb61cf20c1554e1f7a63af56a72fc3bc3e56c535401b0914856ffb44a44068dcaa2ccc5ec1101fc939c6
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --format documentation
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ pear
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.1-head
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Horacio Bertorello
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,48 @@
1
+ PEAR(1) -- pair-programming tool for Git
2
+
3
+ SYNOPSIS
4
+
5
+ pear -i, --init
6
+ pear -s, --start-session [initials ...]
7
+ pear -c, --clean
8
+
9
+ DESCRIPTION
10
+
11
+ Pear helps you set pair-programming sessions with your co-workers.
12
+
13
+ EXAMPLES
14
+
15
+ pear --init
16
+ pear --start-session hb,np
17
+ pear --clean
18
+
19
+ OPTIONS
20
+
21
+ -i, --init
22
+ This command initializes Pear in your working directory (that must
23
+ be a Git repository), writing a sample configuration file named
24
+ `.pear.yml` on it. Of course, you can provide this configuration
25
+ file manually and skip this command.
26
+
27
+ -s, --start-session [initials ...]
28
+ This command starts the pair-programming session setting your
29
+ `user.name` and `user.email` Git configuration variables to
30
+ display properly all collaborators working on subsequent commits.
31
+
32
+ On the latest version, you must provide a list of registered
33
+ authors initials separated by commas. See EXAMPLES to check out
34
+ how this works.
35
+
36
+ -c, --clean
37
+ This commands removes the `user` section added by Pear from your
38
+ local Git repository configuration. It doesn't remove any global
39
+ configuration. Please, remember to re-set your local Git repository
40
+ configuration if you had one before running Pear.
41
+
42
+ HISTORY
43
+
44
+ I wanted to design and build a tool that would help me do what I found
45
+ most exciting to do while working in teams: pair programming. So I started
46
+ pronouncing 'pair programming' a lot, specially 'pair'. Like, /peə(r)/.
47
+
48
+ Well, that's pretty much it.
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => [:spec]
4
+
5
+ begin
6
+ require 'rspec/core/rake_task'
7
+ desc "Run the specs"
8
+ RSpec::Core::RakeTask.new(:spec)
9
+ rescue LoadError
10
+ puts "Unfortunately, it seems that RSpec is unavailable."
11
+ end
data/bin/pear ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'pear'
5
+
6
+ class PearOptionParser
7
+ def self.parse(args)
8
+ options_parser = OptionParser.new do |parser|
9
+ parser.on('-i',
10
+ '--init',
11
+ 'Initialize Pear on the Git repository.') do
12
+ configuration = Pear::Configuration.new
13
+ configuration.write_sample_configuration
14
+
15
+ puts 'Writing sample configuration file... done.'
16
+ end
17
+
18
+ parser.on('-s',
19
+ '--start-session p1,p2,pN',
20
+ Array,
21
+ 'Start pairing session.') do |pair|
22
+ pairing_session = Pear::PairingSession.new(participants: pair)
23
+ pairing_session.configure_repository
24
+
25
+ puts <<-MESSAGE
26
+ Git has been reconfigured for your pairing session!
27
+ Remember to run `pear -c` to end your pairing session.
28
+ MESSAGE
29
+ end
30
+
31
+ parser.on('-c',
32
+ '--clean',
33
+ 'Clean leftovers from the Git repository.') do
34
+ runner = Pear::SystemRunner.new
35
+ runner.run("git config --remove-section user")
36
+
37
+ puts 'Done. Re-set your repository-specific user configuration at will.'
38
+ end
39
+
40
+ parser.on_tail('-v',
41
+ '--version',
42
+ 'Shows current version.') do
43
+ puts Pear::VERSION
44
+ end
45
+
46
+ parser.on_tail('-h',
47
+ '--help',
48
+ 'Shows this message.') do
49
+ puts parser
50
+ end
51
+ end
52
+
53
+ begin
54
+ options_parser.parse!(args)
55
+ rescue OptionParser::InvalidOption => invalid_option
56
+ puts invalid_option
57
+ abort('Please run `pear --help` to see the available commands.')
58
+ end
59
+ end
60
+ end
61
+
62
+ PearOptionParser.parse(ARGV)
data/lib/pear.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "yaml"
2
+
3
+ require "pear/configuration"
4
+ require "pear/pairing_session"
5
+ require "pear/system_runner"
6
+ require "pear/version"
7
+
8
+ module Pear
9
+ end
@@ -0,0 +1,49 @@
1
+ module Pear
2
+ class Configuration
3
+ CONFIG_FILE = '.pear.yml'
4
+
5
+ attr_reader :authors, :email
6
+
7
+ def write_sample_configuration
8
+ abort('This doesn\'t look like a Git repository.') \
9
+ unless Dir.exists?('.git')
10
+
11
+ abort('Whoa there! A configuration file is already present.') \
12
+ if File.exists?('.pear.yml')
13
+
14
+ File.write(CONFIG_FILE, <<-config)
15
+ email: team@example.com
16
+ authors:
17
+ - ad Alice Doe
18
+ - bd Bob Doe
19
+ config
20
+ end
21
+
22
+ def authors
23
+ @authors ||= \
24
+ configuration['authors'].each_with_object({}) do |author_data, hash|
25
+ author = Author.new(author_data)
26
+ hash[author.initials] = author.full_name
27
+ end
28
+ end
29
+
30
+ def email
31
+ @email ||= configuration['email']
32
+ end
33
+
34
+ private
35
+
36
+ def configuration
37
+ @configuration ||= YAML.load(File.open(CONFIG_FILE))
38
+ end
39
+ end
40
+
41
+ class Author
42
+ attr_reader :initials, :full_name
43
+
44
+ def initialize(author_data)
45
+ @initials, *full_name = author_data.split
46
+ @full_name = full_name.join(' ')
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,59 @@
1
+ module Pear
2
+ class PairingSession
3
+ attr_reader :participants, :runner
4
+
5
+ def initialize(participants:,
6
+ configuration: Pear::Configuration.new,
7
+ runner: Pear::SystemRunner.new)
8
+ @configuration = configuration
9
+ @runner = runner
10
+
11
+ set_session_participants(participants)
12
+ end
13
+
14
+ def configure_repository
15
+ if repository_already_configured?
16
+ abort('Already pairing! Run `pear -c` to start over.')
17
+ else
18
+ runner.run("git config --add user.name \'#{git_user_name}\'")
19
+ runner.run("git config --add user.email \'#{git_user_email}\'")
20
+ end
21
+ end
22
+
23
+ def git_user_name
24
+ to_sentence(session_participants_names)
25
+ end
26
+
27
+ def git_user_email
28
+ to_email(participants)
29
+ end
30
+
31
+ private
32
+
33
+ def set_session_participants(participants)
34
+ raise ArgumentError, 'Participants must be registered' \
35
+ unless participants.all? { |p| @configuration.authors.key?(p) }
36
+ @participants = participants
37
+ end
38
+
39
+ def repository_already_configured?
40
+ runner.run("git config --get-all user.name").split(/\n/).any? do |name|
41
+ name == git_user_name
42
+ end
43
+ end
44
+
45
+ def session_participants_names
46
+ participants.map { |p| @configuration.authors[p] }
47
+ end
48
+
49
+ def to_sentence(full_names)
50
+ last_name = full_names.pop
51
+ [full_names.join(', '), last_name].join(' and ')
52
+ end
53
+
54
+ def to_email(initials)
55
+ team, domain = @configuration.email.split('@')
56
+ "#{team}+#{initials.join('-')}@#{domain}"
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,7 @@
1
+ module Pear
2
+ class SystemRunner
3
+ def run(command)
4
+ %x(#{command}).strip
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Pear
2
+ VERSION = "0.0.1"
3
+ end
data/pear.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pear/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pear"
8
+ spec.version = Pear::VERSION
9
+ spec.authors = ["Horacio Bertorello"]
10
+ spec.email = ["syrii@msn.com"]
11
+ spec.summary = %q{Pear is a simple pair-programmint tool for teams.}
12
+ spec.homepage = "https://github.com/svankmajer/pear"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake", "~> 10.3"
22
+ spec.add_development_dependency "rspec", "~> 3.0"
23
+ end
data/spec/pear_spec.rb ADDED
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pear do
4
+ before do
5
+ allow(File).to receive(:open).and_return(<<-config)
6
+ email: team@example.com
7
+ authors:
8
+ - hb Horacio Bertorello
9
+ - mp Markus Persson
10
+ config
11
+ end
12
+
13
+ describe Pear::Configuration do
14
+ subject(:configuration) { Pear::Configuration.new }
15
+
16
+ describe '#configuration' do
17
+ it 'contains an Hash of registered authors' do
18
+ expect(configuration.authors).to \
19
+ match('hb' => 'Horacio Bertorello', 'mp' => 'Markus Persson')
20
+ end
21
+
22
+ it 'contains a custom team email address' do
23
+ expect(configuration.email).to be_a(String)
24
+ end
25
+ end
26
+ end
27
+
28
+ describe Pear::PairingSession do
29
+ describe '.new' do
30
+ it 'fails without a list of initials from registered authors' do
31
+ expect { Pear::PairingSession.new(participants: %w(mm sw)) }.to \
32
+ raise_error(ArgumentError, 'Participants must be registered')
33
+ end
34
+ end
35
+
36
+ context 'valid pairing session' do
37
+ subject(:session) do
38
+ Pear::PairingSession.new(participants: %w(hb mp))
39
+ end
40
+
41
+ describe '#git_user_name' do
42
+ it 'returns a compound user name for the participants' do
43
+ expect(session.git_user_name).to \
44
+ eq('Horacio Bertorello and Markus Persson')
45
+ end
46
+ end
47
+
48
+ describe '#git_user_email' do
49
+ it 'returns a compound user email addres for the participants' do
50
+ expect(session.git_user_email).to \
51
+ eq('team+hb-mp@example.com')
52
+ end
53
+ end
54
+
55
+ describe '#configure_repository' do
56
+ subject(:session) do
57
+ Pear::PairingSession.new(
58
+ participants: %w(hb mp),
59
+ runner: instance_double('Pear::SystemRunner')
60
+ )
61
+ end
62
+
63
+ it 'configures the repository for a pairing session' do
64
+ expect(session.runner).to receive(:run)
65
+ .with("git config --get-all user.name")
66
+ .and_return("Horacio Bertorello\n")
67
+
68
+ expect(session.runner).to receive(:run).with \
69
+ "git config --add user.name 'Horacio Bertorello and Markus Persson'"
70
+
71
+ expect(session.runner).to receive(:run).with \
72
+ "git config --add user.email 'team+hb-mp@example.com'"
73
+
74
+ session.configure_repository
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,12 @@
1
+ require 'pear'
2
+
3
+ RSpec.configure do |config|
4
+ config.expect_with :rspec do |expectations|
5
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
6
+ end
7
+
8
+ config.mock_with :rspec do |mocks|
9
+ mocks.verify_partial_doubles = true
10
+ mocks.verify_doubled_constant_names = true
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pear
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Horacio Bertorello
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description:
56
+ email:
57
+ - syrii@msn.com
58
+ executables:
59
+ - pear
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".ruby-gemset"
66
+ - ".ruby-version"
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README
70
+ - Rakefile
71
+ - bin/pear
72
+ - lib/pear.rb
73
+ - lib/pear/configuration.rb
74
+ - lib/pear/pairing_session.rb
75
+ - lib/pear/system_runner.rb
76
+ - lib/pear/version.rb
77
+ - pear.gemspec
78
+ - spec/pear_spec.rb
79
+ - spec/spec_helper.rb
80
+ homepage: https://github.com/svankmajer/pear
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.4.1
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Pear is a simple pair-programmint tool for teams.
104
+ test_files:
105
+ - spec/pear_spec.rb
106
+ - spec/spec_helper.rb