Class: ShopifyExtensions::Asset
- Inherits:
-
Struct
- Object
- Struct
- ShopifyExtensions::Asset
- Defined in:
- ext/shopify-extensions/shopify_extensions.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
68 69 70 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 68 def basename @basename end |
#owner ⇒ Object
Returns the value of attribute owner
68 69 70 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 68 def owner @owner end |
#platform ⇒ Object
Returns the value of attribute platform
68 69 70 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 68 def platform @platform end |
#repository ⇒ Object
Returns the value of attribute repository
68 69 70 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 68 def repository @repository end |
#version ⇒ Object
Returns the value of attribute version
68 69 70 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 68 def version @version end |
Instance Method Details
#download(target:) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 69 def download(target:) Dir.chdir(File.dirname(target)) do File.open(File.basename(target), "wb") do |target_file| decompress(url.open, target_file) end File.chmod(0755, target) end true rescue OpenURI::HTTPError false end |
#filename ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 92 def filename format( "%{basename}-%{os}-%{cpu}.%{extension}", basename: basename, os: platform.os, cpu: platform.cpu, extension: platform.os == "windows" ? "exe.gz" : "gz" ) end |
#url ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 82 def url URI.parse(format( "https://github.com/%{owner}/%{repository}/releases/download/%{version}/%{filename}", owner: owner, repository: repository, version: version, filename: filename )) end |