pair-salad 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +6 -4
  2. data/lib/pair_salad_runner.rb +20 -14
  3. metadata +2 -2
data/README.md CHANGED
@@ -16,11 +16,13 @@ Or install it yourself as:
16
16
 
17
17
  ## Usage
18
18
 
19
- Add a .authors file to your project root.
19
+ Add a .pair file to your project root.
20
20
 
21
- ck Clark Kent
22
- bw Bruce Wayne
23
- pp Peter Parker
21
+ email: engineers@streamsend.com
22
+ authors:
23
+ - ck Clark Kent
24
+ - bw Bruce Wayne
25
+ - pp Peter Parker
24
26
 
25
27
  Run pair command with authors' initials.
26
28
 
@@ -1,12 +1,11 @@
1
- class PairSaladRunner
2
- EMAIL_PREFIX = "engineers"
3
- EMAIL_SUFFIX = "@streamsend.com"
1
+ require "yaml"
4
2
 
3
+ class PairSaladRunner
5
4
  def run(args)
6
5
  @pair_initials = args.sort
7
6
 
8
7
  check_for_git_directory
9
- check_for_authors_file
8
+ check_for_config_file
10
9
 
11
10
  @authors = parse_authors_from_file
12
11
 
@@ -38,14 +37,16 @@ user.email = #{git_email_address}
38
37
  end
39
38
  end
40
39
 
41
- def check_for_authors_file
42
- unless File.exists?(".authors")
40
+ def check_for_config_file
41
+ unless File.exists?(".pair")
43
42
  puts <<-message
44
- You do not have an .authors file in the repository.
45
- Repository needs a file named .authors in the following format:
46
- ck Clark Kent
47
- bw Bruce Wayne
48
- pp Peter Parker
43
+ You do not have an .pair file in the repository.
44
+ Repository needs a file named .pair in the following format:
45
+ email: engineers@streamsend.com
46
+ authors:
47
+ - ck Clark Kent
48
+ - bw Bruce Wayne
49
+ - pp Peter Parker
49
50
  message
50
51
 
51
52
  exit 1
@@ -54,8 +55,8 @@ Repository needs a file named .authors in the following format:
54
55
 
55
56
  def parse_authors_from_file
56
57
  authors = {}
57
- File.open('.authors').each_line do |line|
58
- initials, name = line.match(/^(\w+)\s+(.*)$/).captures
58
+ configuration["authors"].each do |author_line|
59
+ initials, name = author_line.match(/^(\w+)\s+(.*)$/).captures
59
60
  if @pair_initials.include? initials
60
61
  authors[initials] = name
61
62
  end
@@ -76,6 +77,11 @@ Repository needs a file named .authors in the following format:
76
77
  end
77
78
 
78
79
  def build_email_address
79
- "#{EMAIL_PREFIX}+#{@pair_initials.join("+")}#{EMAIL_SUFFIX}"
80
+ prefix, hostname = configuration["email"].split("@")
81
+ "#{prefix}+#{@pair_initials.join("+")}@#{hostname}"
82
+ end
83
+
84
+ def configuration
85
+ @configuration ||= YAML.load(File.read('.pair'))
80
86
  end
81
87
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pair-salad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
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-10-30 00:00:00.000000000 Z
12
+ date: 2012-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec