class Pod::Command::Trunk

Constants

BASE_URL
SCHEME_AND_HOST

Private Instance Methods

auth_headers() click to toggle source
# File lib/pod/command/trunk.rb, line 122
def auth_headers
  default_headers.merge('Authorization' => "Token #{token}")
end
create_request(*args) click to toggle source
# File lib/pod/command/trunk.rb, line 39
def create_request(*args)
  if verbose?
    REST.send(*args) do |request|
      request.set_debug_output($stdout)
    end
  else
    REST.send(*args)
  end
end
default_headers() click to toggle source
# File lib/pod/command/trunk.rb, line 114
def default_headers
  {
    'Content-Type' => 'application/json; charset=utf-8',
    'Accept' => 'application/json; charset=utf-8',
    'User-Agent' => "CocoaPods/#{Pod::VERSION}",
  }
end
formatted_time(time_string) click to toggle source
# File lib/pod/command/trunk.rb, line 126
def formatted_time(time_string)
  require 'active_support/time'
  @tz_offset ||= Time.zone_offset(time_zone)
  @current_year ||= Date.today.year

  time = Time.parse(time_string) + @tz_offset
  formatted = time.to_formatted_s(:long_ordinal)
  # No need to show the current year, the user will probably know.
  if time.year == @current_year
    formatted.sub!(" #{@current_year}", '')
  end
  formatted
end
json(response) click to toggle source
# File lib/pod/command/trunk.rb, line 101
def json(response)
  JSON.parse(response.body)
end
netrc() click to toggle source
# File lib/pod/command/trunk.rb, line 105
def netrc
  @@netrc ||= Netrc.read
end
print_error(body) click to toggle source
print_messages(data_url, messages, spec = nil, action = nil) click to toggle source
request_path(action, path, *args) click to toggle source
# File lib/pod/command/trunk.rb, line 35
def request_path(action, path, *args)
  request_url(action, "#{BASE_URL}/#{path}", *args)
end
request_url(action, url, *args) click to toggle source
# File lib/pod/command/trunk.rb, line 27
def request_url(action, url, *args)
  response = create_request(action, url, *args)
  if (400...600).cover?(response.status_code)
    print_error(response.body)
  end
  response
end
time_zone() click to toggle source
# File lib/pod/command/trunk.rb, line 140
def time_zone
  out, = Executable.capture_command('/bin/date', %w(+%Z), :capture => :out)
  out.strip
end
token() click to toggle source
# File lib/pod/command/trunk.rb, line 109
def token
  ENV['COCOAPODS_TRUNK_TOKEN'] ||
    (netrc['trunk.cocoapods.org'] && netrc['trunk.cocoapods.org'].password)
end