Class: Spade::CLI::Owner

Inherits:
Thor
  • Object
show all
Defined in:
lib/spade/cli/owner.rb

Instance Method Summary collapse

Instance Method Details

#add(package, email) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/spade/cli/owner.rb', line 26

def add(package, email)
  remote = Spade::Remote.new
  if remote.logged_in?
    say remote.add_owner(package, email)
  else
    abort LOGIN_MESSAGE
  end
end

#list(package) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/spade/cli/owner.rb', line 6

def list(package)
  remote = Spade::Remote.new
  if remote.logged_in?
    yaml   = remote.list_owners(package)
    owners = YAML.load(yaml)

    if owners.is_a?(Array)
      say "Owners for package: #{package}"
      owners.each do |owner|
        say "- #{owner['email']}"
      end
    else
      say owners
    end
  else
    abort LOGIN_MESSAGE
  end
end

#remove(package, email) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/spade/cli/owner.rb', line 36

def remove(package, email)
  remote = Spade::Remote.new
  if remote.logged_in?
    say remote.remove_owner(package, email)
  else
    abort LOGIN_MESSAGE
  end
end