Class: PandocBinary::Architecture

Inherits:
Struct
  • Object
show all
Defined in:
lib/pandoc_binary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#archive_suffixObject

Returns the value of attribute archive_suffix

Returns:

  • (Object)

    the current value of archive_suffix



33
34
35
# File 'lib/pandoc_binary.rb', line 33

def archive_suffix
  @archive_suffix
end

#bin_pathObject

Returns the value of attribute bin_path

Returns:

  • (Object)

    the current value of bin_path



33
34
35
# File 'lib/pandoc_binary.rb', line 33

def bin_path
  @bin_path
end

#bin_suffixObject

Returns the value of attribute bin_suffix

Returns:

  • (Object)

    the current value of bin_suffix



33
34
35
# File 'lib/pandoc_binary.rb', line 33

def bin_suffix
  @bin_suffix
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



33
34
35
# File 'lib/pandoc_binary.rb', line 33

def name
  @name
end

Instance Method Details

#fetch_executable(version:, asset:) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pandoc_binary.rb', line 34

def fetch_executable(version:, asset:)
  bin_path_in_archive = Pathname("#{PREFIX}-#{version}") / bin_path
  # super special case
  bin_path_in_archive = Pathname("pandoc-2.12/usr/bin/pandoc") if version == "2.12" && name == "linux-arm64"
  Open3.pipeline_r(
    [*%w[curl --silent --location], asset.browser_download_url],
    [*%w[bsdtar --to-stdout -xf -], bin_path_in_archive.to_s],
  ) do |stdout, wait_threads|
    result = yield(stdout)
    process_statuses = wait_threads.map(&:value)
    raise "Command failed with exit: statuses=#{process_statuses.inspect}" if !process_statuses.all?(&:success?)
    return result
  end
end