Class: Sem::CLI::Teams

Inherits:
Dracula
  • Object
show all
Defined in:
lib/sem/cli/teams.rb

Defined Under Namespace

Classes: Members, Projects, SharedConfigs

Instance Method Summary collapse

Instance Method Details

#create(team_name) ⇒ Object



25
26
27
28
29
# File 'lib/sem/cli/teams.rb', line 25

def create(team_name)
  team = Sem::API::Team.create!(team_name, :permission => options[:permission])

  Sem::Views::Teams.info(team)
end

#delete(team_name) ⇒ Object



57
58
59
60
61
62
# File 'lib/sem/cli/teams.rb', line 57

def delete(team_name)
  team = Sem::API::Team.find!(team_name)
  team.delete!

  puts "Team #{team_name} deleted."
end

#info(team_name) ⇒ Object



15
16
17
18
19
# File 'lib/sem/cli/teams.rb', line 15

def info(team_name)
  team = Sem::API::Team.find!(team_name)

  Sem::Views::Teams.info(team)
end

#listObject



4
5
6
7
8
9
10
11
12
# File 'lib/sem/cli/teams.rb', line 4

def list
  teams = Sem::API::Team.all

  if !teams.empty?
    Sem::Views::Teams.list(teams)
  else
    Sem::Views::Teams.create_first_team
  end
end

#rename(old_team_name, new_team_name) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sem/cli/teams.rb', line 32

def rename(old_team_name, new_team_name)
  old_org_name, _old_name = Sem::SRN.parse_team(old_team_name)
  new_org_name, new_name = Sem::SRN.parse_team(new_team_name)

  abort "Team can't change its organization" unless new_org_name == old_org_name

  team = Sem::API::Team.find!(old_team_name)
  team = team.update(:name => new_name)

  Sem::Views::Teams.info(team)
end

#set_permission(team_name) ⇒ Object

rubocop:disable Style/AccessorMethodName



49
50
51
52
53
54
# File 'lib/sem/cli/teams.rb', line 49

def set_permission(team_name) # rubocop:disable Style/AccessorMethodName
  team = Sem::API::Team.find!(team_name)
  team = team.update(:permission => options[:permission])

  Sem::Views::Teams.info(team)
end