Class: Pod::Command::Trunk::Me::CleanSessions

Inherits:
Pod::Command::Trunk::Me show all
Defined in:
lib/pod/command/trunk/me.rb

Constant Summary

Constants inherited from Pod::Command::Trunk

BASE_URL, SCHEME_AND_HOST

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CleanSessions

Returns a new instance of CleanSessions.



96
97
98
99
# File 'lib/pod/command/trunk/me.rb', line 96

def initialize(argv)
  @remove_all = argv.flag?('all', false)
  super
end

Class Method Details

.optionsObject



90
91
92
93
94
# File 'lib/pod/command/trunk/me.rb', line 90

def self.options
  [
    ['--all', 'Removes all your sessions, except for the current one'],
  ].concat(super)
end

Instance Method Details

#runObject



108
109
110
111
112
113
114
# File 'lib/pod/command/trunk/me.rb', line 108

def run
  path = @remove_all ? 'sessions/all' : 'sessions'
  request_path(:delete, path, auth_headers)
rescue REST::Error => e
  raise Informative, 'There was an error cleaning up your ' \
                           "sessions from trunk: #{e.message}"
end

#validate!Object



101
102
103
104
105
106
# File 'lib/pod/command/trunk/me.rb', line 101

def validate!
  super
  unless token
    help! 'You need to register a session first.'
  end
end