Class: ShopifyExtensions::Platform

Inherits:
Struct
  • Object
show all
Defined in:
ext/shopify-extensions/shopify_extensions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ruby_config = RbConfig::CONFIG) ⇒ Platform

Returns a new instance of Platform.



113
114
115
# File 'ext/shopify-extensions/shopify_extensions.rb', line 113

def initialize(ruby_config = RbConfig::CONFIG)
  super(ruby_config)
end

Instance Attribute Details

#ruby_configObject

Returns the value of attribute ruby_config

Returns:

  • (Object)

    the current value of ruby_config



112
113
114
# File 'ext/shopify-extensions/shopify_extensions.rb', line 112

def ruby_config
  @ruby_config
end

Instance Method Details

#cpuObject



141
142
143
144
145
146
147
148
149
150
# File 'ext/shopify-extensions/shopify_extensions.rb', line 141

def cpu
  case ruby_config.fetch("host_cpu")
  when /arm.*64/
    "arm64"
  when /64/
    "amd64"
  else
    "386"
  end
end

#format_path(path) ⇒ Object



117
118
119
120
121
122
123
124
# File 'ext/shopify-extensions/shopify_extensions.rb', line 117

def format_path(path)
  case os
  when "windows"
    File.extname(path) != ".exe" ? path + ".exe" : path
  else
    path
  end
end

#osObject



130
131
132
133
134
135
136
137
138
139
# File 'ext/shopify-extensions/shopify_extensions.rb', line 130

def os
  case ruby_config.fetch("host_os")
  when /linux/
    "linux"
  when /darwin/
    "darwin"
  else
    "windows"
  end
end

#to_sObject



126
127
128
# File 'ext/shopify-extensions/shopify_extensions.rb', line 126

def to_s
  format("%{os}-%{cpu}", os: os, cpu: cpu)
end