Class: CBin::Remote::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-fy-bin/helpers/remote_helper.rb

Instance Method Summary collapse

Constructor Details

#initializeHelper

Returns a new instance of Helper.



6
7
8
# File 'lib/cocoapods-fy-bin/helpers/remote_helper.rb', line 6

def initialize
  @base_url = CBin.config.binary_upload_url
end

Instance Method Details

#delete(name, version, tag) ⇒ Object



17
18
19
20
21
22
# File 'lib/cocoapods-fy-bin/helpers/remote_helper.rb', line 17

def delete(name, version, tag)
  uri = URI.join @base_url, "/frameworks/#{name}/#{version}/#{tag}"
  resp = RestClient.delete uri.to_s
  json = JSON.parse(resp.body)
  json["status"]['code'] == 0
end

#download_url(name, version, tag) ⇒ Object



36
37
38
39
40
41
# File 'lib/cocoapods-fy-bin/helpers/remote_helper.rb', line 36

def download_url(name, version, tag)
  uri = URI.join @base_url, "/frameworks/#{name}/#{version}/#{tag}"
  resp = RestClient.get uri.to_s
  json = JSON.parse(resp.body)
  @base_url + json["data"]['download_url']
end

#exist?(name, version, tag) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
# File 'lib/cocoapods-fy-bin/helpers/remote_helper.rb', line 10

def exist?(name, version, tag)
  uri = URI.join @base_url, "/frameworks/exit/#{name}/#{version}/#{tag}"
  resp = RestClient.get(uri.to_s)
  json = JSON.parse(resp.body)
  json["data"]
end

#upload(name, version, tag, file) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cocoapods-fy-bin/helpers/remote_helper.rb', line 24

def upload(name, version, tag, file)
  uri = URI.join @base_url, "/frameworks"
  resp = RestClient.post(uri.to_s, {
    file: File.new(file, 'rb'),
    name: name,
    version: version,
    tag: tag
  })
  json = JSON.parse(resp.body)
  @base_url + json["data"]['download_url']
end