Class: Jiveapps::Command::Sharing

Inherits:
BaseWithApp show all
Defined in:
lib/jiveapps/commands/sharing.rb

Instance Attribute Summary

Attributes inherited from BaseWithApp

#app

Attributes inherited from Base

#args, #autodetected_app

Instance Method Summary collapse

Methods inherited from BaseWithApp

#initialize

Methods inherited from Base

#extract_app, #extract_app_from_git_config, #extract_app_in_dir, #extract_option, #git_remotes, #initialize, #jiveapps

Methods included from Helpers

#ask, #catch_args, #check_git_version, #confirm, #confirm_command, #debug, #debug_mode?, #display, #display_oauth_services, #error, #get_app_prop_with_default, #get_or_set_git_prop, #git_version, #has_program?, #home_directory, #run, #running_on_a_mac?, #running_on_windows?, #sh, #usage, #user_git_version

Constructor Details

This class inherits a constructor from Jiveapps::Command::BaseWithApp

Instance Method Details

#addObject



8
9
10
11
12
13
14
15
# File 'lib/jiveapps/commands/sharing.rb', line 8

def add
  usage "jiveapps sharing:add <username>"
  catch_args :username

  display "=== Adding commit access to #{app} for \"#{@username}\""
  jiveapps.add_collaborator(app, @username)
  display_collaborators
end

#display_collaboratorsObject



27
28
29
30
31
32
33
# File 'lib/jiveapps/commands/sharing.rb', line 27

def display_collaborators
  collaborators = jiveapps.list_collaborators(app)
  display "=== #{collaborators.length} #{collaborators.length == 1 ? 'user has' : 'users have'} commit access to #{app}"
  collaborators.each_with_index do |collaborator, index|
    display "#{index+1}. #{collaborator[:username]}"
  end
end

#listObject Also known as: index



3
4
5
# File 'lib/jiveapps/commands/sharing.rb', line 3

def list
  display_collaborators
end

#removeObject



17
18
19
20
21
22
23
24
25
# File 'lib/jiveapps/commands/sharing.rb', line 17

def remove
  usage "jiveapps sharing:remove <username>"
  catch_args :username

  return unless confirm("Are you sure you wish to remove commit access to #{app} for \"#{@username}\"? (y/n)?")
  display "=== Removing commit access to #{app} for \"#{@username}\""
  jiveapps.remove_collaborator(app, @username)
  display_collaborators
end