Class: Linguist::Command::Collaborator

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

Instance Attribute Summary

Attributes inherited from Base

#args, #autodetected_app

Instance Method Summary collapse

Methods inherited from Base

#app_urls, #escape, #extract_app_from_git_config, #extract_option, #extract_project_title_from_args, #extract_project_title_from_dir_name, #extract_project_title_from_git, #git_remotes, #git_url, #initialize, #linguist, #project, #project_title

Methods included from Helpers

#ask, #confirm, #confirm_command, #deprecate, #display, #error, #format_date, #git, #has_git?, #home_directory, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #shell

Constructor Details

This class inherits a constructor from Linguist::Command::Base

Instance Method Details

#inviteObject



13
14
15
16
17
18
19
20
# File 'lib/linguist_ruby/commands/collaborator.rb', line 13

def invite
  email = extract_email_from_args
  project.invite_collaborator(email)

  display("Invitation sent to #{email}")
rescue RestClient::BadRequest
  display("Error sending invitation to '#{email}'")
end

#listObject



3
4
5
6
7
8
9
10
11
# File 'lib/linguist_ruby/commands/collaborator.rb', line 3

def list
  list = project.collaborators
  if list.size > 0
    display "Collaborators:\n"
    list.each { |c| display("- #{c.display_name} | #{c.email} | #{c.permissions}") }
  else
    display "No collaborators found"
  end
end

#removeObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/linguist_ruby/commands/collaborator.rb', line 22

def remove
  email = extract_email_from_args
  collaborator = project.collaborators.find { |c| c.email == email }

  if collaborator.nil?
    display("Collaborator with email '#{email}' not found")
  else
    collaborator.destroy
    display("Collaborator with email #{email} was removed")
  end
rescue RestClient::BadRequest
  display("Error removing collaborator with email '#{email}'")
end