Class: Remote
- Inherits:
-
Object
- Object
- Remote
- Defined in:
- lib/cocoapods-flutter/native/archive/remote.rb
Instance Method Summary collapse
- #delete(name, version, tag) ⇒ Object
- #download_flutter_sdk_dsym(version, hash, des_path) ⇒ Object
- #download_url(name, version, tag) ⇒ Object
- #exist?(name, version, tag) ⇒ Boolean
-
#initialize ⇒ Remote
constructor
A new instance of Remote.
- #upload(name, version, tag, file) ⇒ Object
- #upload_flutter_sdk_dsym(version, hash, file_path) ⇒ Object
Constructor Details
#initialize ⇒ Remote
Returns a new instance of Remote.
6 7 8 9 10 11 |
# 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'] end |
Instance Method Details
#delete(name, version, tag) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 20 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
46 47 48 49 50 51 52 53 |
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 46 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
39 40 41 42 43 44 |
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 39 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
13 14 15 16 17 18 |
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 13 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
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 27 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
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/cocoapods-flutter/native/archive/remote.rb', line 55 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 |