Class: Javy::Asset
- Inherits:
-
Struct
- Object
- Struct
- Javy::Asset
- Defined in:
- ext/javy/javy.rb
Instance Attribute Summary collapse
-
#basename ⇒ Object
Returns the value of attribute basename.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
Instance Attribute Details
#basename ⇒ Object
Returns the value of attribute basename
107 108 109 |
# File 'ext/javy/javy.rb', line 107 def basename @basename end |
#owner ⇒ Object
Returns the value of attribute owner
107 108 109 |
# File 'ext/javy/javy.rb', line 107 def owner @owner end |
#platform ⇒ Object
Returns the value of attribute platform
107 108 109 |
# File 'ext/javy/javy.rb', line 107 def platform @platform end |
#repository ⇒ Object
Returns the value of attribute repository
107 108 109 |
# File 'ext/javy/javy.rb', line 107 def repository @repository end |
#version ⇒ Object
Returns the value of attribute version
107 108 109 |
# File 'ext/javy/javy.rb', line 107 def version @version end |
Instance Method Details
#download(target:) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'ext/javy/javy.rb', line 108 def download(target:) FileUtils.mkdir_p(BIN_FOLDER) source_file = url.open validate_sha!(source_file) source_file.seek(0) Dir.chdir(File.dirname(target)) do File.open(File.basename(target), "wb") do |target_file| decompress(source_file, target_file) end File.chmod(0755, target) end true rescue OpenURI::HTTPError false end |
#filename ⇒ Object
138 139 140 141 142 143 144 145 146 |
# File 'ext/javy/javy.rb', line 138 def filename format( "%{basename}-%{cpu}-%{os}-%{version}.gz", basename: basename, cpu: platform.cpu, os: platform.os, version: version ) end |
#url ⇒ Object
128 129 130 131 132 133 134 135 136 |
# File 'ext/javy/javy.rb', line 128 def url URI.parse(format( "https://github.com/%{owner}/%{repository}/releases/download/%{version}/%{filename}", owner: owner, repository: repository, version: version, filename: filename )) end |