Class: GitPairs::Commands

Inherits:
Object
  • Object
show all
Defined in:
lib/commands.rb

Class Method Summary collapse

Class Method Details

.add(conf, path_to_conf, partners) ⇒ Object



5
6
7
8
9
# File 'lib/commands.rb', line 5

def self.add(conf, path_to_conf, partners)
  partners.uniq.each do |partner|
    GitPairs::Helper.add(conf, path_to_conf, partner)
  end
end

.rm(conf, path_to_conf, partners) ⇒ Object



11
12
13
14
15
# File 'lib/commands.rb', line 11

def self.rm(conf, path_to_conf, partners)
  partners.uniq.each do |partner|
    GitPairs::Helper.delete(conf, path_to_conf, partner)
  end
end

.set(conf, path_to_conf, partners) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/commands.rb', line 17

def self.set(conf, path_to_conf, partners)
  if partners.size < 2
    puts ""
    puts Paint["To configure pairing for this repo, supply a list of parnter initials.  E.g., 'git pair sq jo'", :yellow]
    Trollop::die "Wrong number of arguments"
  end
  authors = []
  partners.uniq.each do |partner|
    unless GitPairs::Helper.exists?(conf, partner)
      GitPairs::Helper.add(conf, path_to_conf, partner)
    end
    #concatenate each partner's info into delimited strings
    author =  GitPairs::Helper.fetch(conf, partner)
    name = author["username"]
    email = author["email"]
    authors << ["#{name}","#{partner}", "#{email}"]
  end
  GitPairs::Helper.set(conf, authors)
end