Class: Pod::Command::Trunk::Deprecate

Inherits:
Pod::Command::Trunk show all
Defined in:
lib/pod/command/trunk/deprecate.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) ⇒ Deprecate

Returns a new instance of Deprecate.



18
19
20
21
22
# File 'lib/pod/command/trunk/deprecate.rb', line 18

def initialize(argv)
  @name = argv.shift_argument
  @in_favor_of = argv.option('in-favor-of')
  super
end

Class Method Details

.optionsObject



12
13
14
15
16
# File 'lib/pod/command/trunk/deprecate.rb', line 12

def self.options
  [
    ['--in-favor-of=OTHER_NAME', 'The pod to deprecate this pod in favor of.'],
  ].concat(super)
end

Instance Method Details

#deprecateObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pod/command/trunk/deprecate.rb', line 34

def deprecate
  body = {
    :in_favor_of => @in_favor_of,
  }.to_json
  response = request_path(:patch, "pods/#{@name}/deprecated", body, auth_headers)
  url = response.headers['location'].first
  json(request_url(:get, url, default_headers))
rescue REST::Error => e
  raise Informative, 'There was an error deprecating the pod ' \
                           "via trunk: #{e.message}"
end

#runObject



29
30
31
32
# File 'lib/pod/command/trunk/deprecate.rb', line 29

def run
  json = deprecate
  print_messages(json['data_url'], json['messages'], nil, nil)
end

#validate!Object



24
25
26
27
# File 'lib/pod/command/trunk/deprecate.rb', line 24

def validate!
  super
  help! 'Please specify a pod name.' unless @name
end