Module: PandocBinary
- Defined in:
- lib/pandoc_binary/version.rb,
lib/pandoc_binary.rb
Overview
-*- mode: ruby -*- frozen_string_literal: true
Defined Under Namespace
Modules: RawDataParsable, TimeAttributeParsable
Classes: Architecture, Release
Constant Summary
collapse
- PREFIX =
"pandoc"
- TOP_PATH =
Pathname(__dir__).parent.expand_path
- LIBEXEC_PATH =
TOP_PATH / "libexec"
- ARCHITECTURES =
[
Architecture.new(name: "linux-amd64", archive_suffix: "tar.gz", bin_path: "bin/pandoc"),
Architecture.new(name: "linux-arm64", archive_suffix: "tar.gz", bin_path: "bin/pandoc"),
Architecture.new(name: "macOS", archive_suffix: "zip", bin_path: "bin/pandoc"),
Architecture.new(name: "windows-x86_64", archive_suffix: "zip", bin_path: "pandoc.exe", bin_suffix: "exe"),
]
- NAME_TO_ARCHITECTURE =
ARCHITECTURES.map { |architecture| [architecture.name, architecture] }.to_h
- VERSION =
"3.0.1"
Class Method Summary
collapse
Class Method Details
.determine_architecture(host_os: , host_cpu: ) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/pandoc_binary.rb', line 101
def determine_architecture(host_os: RbConfig::CONFIG["host_os"], host_cpu: RbConfig::CONFIG["host_cpu"])
case host_os
when /linux/i
case host_cpu
when /amd64|x86_64|x64/i
return NAME_TO_ARCHITECTURE["linux-amd64"]
when /aarch64/i
return NAME_TO_ARCHITECTURE["linux-arm64"]
end
when /darwin/i
return NAME_TO_ARCHITECTURE["macOS"]
when /mingw|mswin/i
return NAME_TO_ARCHITECTURE["windows-x86_64"]
end
raise NotImplementedError, "This platform (#{host_os.inspect} #{host_cpu.inspect}) is not supported. Please send pull-request!"
end
|
.executable_path(architecture: determine_architecture) ⇒ Object
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/pandoc_binary.rb', line 123
def executable_path(architecture: determine_architecture)
path = Pathname(
ENV["PANDOC_BINARY_EXTRACTED_PATH"] ||
LIBEXEC_PATH / "#{PREFIX}-#{architecture.name}"
)
path = path.sub_ext(".#{architecture.bin_suffix}") if architecture.bin_suffix
return path if path.exist?
gzipped_path = gzipped_executable_path(architecture: architecture)
Zlib::GzipReader.open(gzipped_path) do |gzip|
path.open("wb", 0o755) do |f|
IO.copy_stream(gzip, f)
end
end
return path
end
|
.gzipped_executable_path(architecture: determine_architecture) ⇒ Object
119
120
121
|
# File 'lib/pandoc_binary.rb', line 119
def gzipped_executable_path(architecture: determine_architecture)
return LIBEXEC_PATH / "#{PREFIX}-#{architecture.name}.gz"
end
|