Class: Remote

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-flutter/native/archive/remote.rb

Instance Method Summary collapse

Constructor Details

#initializeRemote

Returns a new instance of Remote.



6
7
8
9
10
11
12
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 6

def initialize
  if ENV['FLUTTER_BINARY_SERVER_BASEURL'].nil?
    raise StandardError, "Need 'FLUTTER_BINARY_SERVER_BASEURL' in env"
  end
  @base_url = ENV['FLUTTER_BINARY_SERVER_BASEURL']
  @coverage_base_url = ENV['COVERAGE_SERVER_BASEURL']
end

Instance Method Details

#config_coverage(bundle_id, version, git_commit_hash, index_db_path, git_repo, build_base_dir) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 74

def config_coverage(bundle_id, version, git_commit_hash, index_db_path, git_repo, build_base_dir)
  uri = URI.join @coverage_base_url, "/coverage/flutter/report/config"
  Pod::UserInterface.info "Uploading coverage config info to #{uri.to_s}"
  resp = RestClient.post(uri.to_s, {
      index_db: File.new(index_db_path, 'rb'),
      git_commit_hash: git_commit_hash,
      git_repo: git_repo,
      build_base_dir: build_base_dir,
      bundle_id: bundle_id,
      version: version
  })
end

#delete(name, version, tag) ⇒ Object



21
22
23
24
25
26
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 21

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_flutter_sdk_dsym(version, hash, des_path) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 47

def download_flutter_sdk_dsym(version, hash, des_path)
  uri = URI.join @base_url, "/dsyms/download/flutter/#{version}/#{hash}/file.zip"
  Pod::UserInterface.info "Start download Flutter.framework.dSYM from #{uri.to_s}"
  data = RestClient::Request.execute(:method => :get, :url => uri.to_s, :timeout => 3600, :raw_response => true)
  file = File.new(des_path, 'w+')
  file.write data
  file.close
end

#download_url(name, version, tag) ⇒ Object



40
41
42
43
44
45
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 40

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)


14
15
16
17
18
19
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 14

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



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 28

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

#upload_flutter_sdk_dsym(version, hash, file_path) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 56

def upload_flutter_sdk_dsym(version, hash, file_path)
  uri = URI.join @base_url, "/dsyms"
  Pod::UserInterface.info "Start upload '#{file_path}' to #{uri.to_s}"
  req = RestClient::Request.new(
      :method => :post,
      :url => uri.to_s,
      :timeout => 3600,
      :payload => {
          :multipart => true,
          :file => File.new(file_path, 'rb'),
          :name => 'flutter',
          :version => version,
          :tag => hash
      }
  )
  req.execute
end