pandoc_binary 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +13 -0
- data/exe/pandoc +5 -0
- data/lib/pandoc_binary/version.rb +6 -0
- data/lib/pandoc_binary/version.rb.template +6 -0
- data/lib/pandoc_binary.rb +138 -0
- data/libexec/.keep +0 -0
- data/libexec/pandoc-linux-amd64.gz +0 -0
- data/libexec/pandoc-macOS.gz +0 -0
- data/libexec/pandoc-windows-x86_64.gz +0 -0
- data/pandoc_binary.gemspec +37 -0
- data/sig/pandoc_binary.rbs +4 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 318f96ea7e1d614092345650e0efd74bec424dc2956910b8b50c2d11bdf9f427
|
4
|
+
data.tar.gz: d3f5b53a11ff3d7b422504c51fcabc94468841328f04093e5cc59e88ab91ac18
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5affcf1d93660a13d07857b9ba2ca84f541f044e74813f3b2cdf58870673541a08ec8fd0ad26be9a3a1d6b8beb91895ea7a39fec7f112061ca29144ba2809320
|
7
|
+
data.tar.gz: d23ba4b17979ba5b5afc2a98f5ba271ea1659bd58c3fb18c1449739b98ee75339d5efba241f11a9c9595757813038c4b53cc437bf6236107b781919f44e081b7
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pandoc_binary (2.10.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
debug (1.5.0)
|
10
|
+
irb (>= 1.3.6)
|
11
|
+
reline (>= 0.2.7)
|
12
|
+
io-console (0.5.11)
|
13
|
+
irb (1.4.1)
|
14
|
+
reline (>= 0.3.0)
|
15
|
+
rake (13.0.6)
|
16
|
+
reline (0.3.1)
|
17
|
+
io-console (~> 0.5)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
x86_64-linux
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
debug
|
24
|
+
pandoc_binary!
|
25
|
+
rake (~> 13.0)
|
26
|
+
|
27
|
+
BUNDLED WITH
|
28
|
+
2.3.11
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2022 Yuya.Nishida.
|
2
|
+
|
3
|
+
X11 License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# PandocBinary
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Install the gem and add to the application's Gemfile by executing:
|
6
|
+
|
7
|
+
```console
|
8
|
+
$ bundle add pandoc_binary
|
9
|
+
```
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
+
|
13
|
+
```console
|
14
|
+
$ gem install pandoc_binary
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
After installation, we can use `pandoc` command:
|
20
|
+
|
21
|
+
```console
|
22
|
+
$ pandoc --from=gfm --to=html5 a.md > /tmp/a.html
|
23
|
+
```
|
24
|
+
|
25
|
+
And we can use `PandocBinary.executable_path` to get `pandoc` command path:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require "pandoc_binary"
|
29
|
+
|
30
|
+
p(PandocBinary.executable_path)
|
31
|
+
#=> #<Pathname:/home/yuya/.anyenv/envs/rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pandoc_binary-2.10/libexec/pandoc-linux-amd64>
|
32
|
+
```
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nishidayuya/pandoc_binary_gem .
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
|
5
|
+
gitignore_path = (Pathname(__dir__).expand_path / ".gitignore")
|
6
|
+
libexec_executable_paths = gitignore_path.
|
7
|
+
each_line(chomp: true).
|
8
|
+
lazy.
|
9
|
+
grep(%r{\A/libexec/}).
|
10
|
+
map { |path| Pathname(path.sub(%r{\A/}, "")) }
|
11
|
+
CLOBBER.include(*libexec_executable_paths)
|
12
|
+
|
13
|
+
task default: %i[]
|
data/exe/pandoc
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "net/http"
|
5
|
+
require "open3"
|
6
|
+
require "pathname"
|
7
|
+
require "rbconfig"
|
8
|
+
require "time"
|
9
|
+
require "uri"
|
10
|
+
require "zlib"
|
11
|
+
|
12
|
+
require_relative "pandoc_binary/version"
|
13
|
+
|
14
|
+
module PandocBinary
|
15
|
+
PREFIX = "pandoc"
|
16
|
+
TOP_PATH = Pathname(__dir__).parent.expand_path
|
17
|
+
LIBEXEC_PATH = TOP_PATH / "libexec"
|
18
|
+
|
19
|
+
module RawDataParsable
|
20
|
+
def from_raw_data(raw_data)
|
21
|
+
return new(raw_data.slice(*members))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module TimeAttributeParsable
|
26
|
+
def define_time_attribute(name)
|
27
|
+
define_method(:"#{name}_time") {
|
28
|
+
Time.iso8601(public_send(name))
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Architecture < Struct.new(:name, :archive_suffix, :bin_path, :bin_suffix, keyword_init: true)
|
34
|
+
def fetch_executable(version:, asset:)
|
35
|
+
bin_path_in_archive = Pathname("#{PREFIX}-#{version}") / bin_path
|
36
|
+
Open3.pipeline_r(
|
37
|
+
[*%w[curl --silent --location], asset.browser_download_url],
|
38
|
+
[*%w[bsdtar --to-stdout -xf -], bin_path_in_archive.to_s],
|
39
|
+
) do |stdout, wait_threads|
|
40
|
+
result = yield(stdout)
|
41
|
+
process_statuses = wait_threads.map(&:value)
|
42
|
+
raise "Command failed with exit: statuses=#{process_statuses.inspect}" if !process_statuses.all?(&:success?)
|
43
|
+
return result
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
ARCHITECTURES = [
|
49
|
+
Architecture.new(name: "linux-amd64", archive_suffix: "tar.gz", bin_path: "bin/pandoc"),
|
50
|
+
Architecture.new(name: "linux-arm64", archive_suffix: "tar.gz", bin_path: "bin/pandoc"),
|
51
|
+
Architecture.new(name: "macOS", archive_suffix: "zip", bin_path: "bin/pandoc"),
|
52
|
+
Architecture.new(name: "windows-x86_64", archive_suffix: "zip", bin_path: "pandoc.exe", bin_suffix: "exe"),
|
53
|
+
]
|
54
|
+
|
55
|
+
class Release < Struct.new(:assets, :tag_name, :published_at, keyword_init: true)
|
56
|
+
extend TimeAttributeParsable
|
57
|
+
|
58
|
+
define_time_attribute :published_at
|
59
|
+
|
60
|
+
class << self
|
61
|
+
include RawDataParsable
|
62
|
+
|
63
|
+
URI_BASE = "https://api.github.com/repos/jgm/pandoc/releases/tags/%{version}"
|
64
|
+
|
65
|
+
def from_raw_data(raw_data)
|
66
|
+
result = super
|
67
|
+
result.assets = raw_data[:assets].map { |raw_asset|
|
68
|
+
Asset.from_raw_data(raw_asset)
|
69
|
+
}
|
70
|
+
return result
|
71
|
+
end
|
72
|
+
|
73
|
+
def fetch_by_version(version)
|
74
|
+
uri = URI(URI_BASE % {version: version})
|
75
|
+
json = Net::HTTP.get(uri)
|
76
|
+
raw_release = JSON.parse(json, symbolize_names: true)
|
77
|
+
return from_raw_data(raw_release)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class Asset < Struct.new(:name, :updated_at, :browser_download_url, keyword_init: true)
|
82
|
+
extend RawDataParsable
|
83
|
+
extend TimeAttributeParsable
|
84
|
+
|
85
|
+
define_time_attribute :updated_at
|
86
|
+
end
|
87
|
+
|
88
|
+
def asset_by_architecture(architecture)
|
89
|
+
return assets.find { |asset|
|
90
|
+
asset.name.end_with?(architecture.archive_suffix) &&
|
91
|
+
asset.name.index(architecture.name)
|
92
|
+
}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
class << self
|
97
|
+
NAME_TO_ARCHITECTURE = ARCHITECTURES.map { |architecture| [architecture.name, architecture] }.to_h
|
98
|
+
|
99
|
+
def determine_architecture(host_os: RbConfig::CONFIG["host_os"], host_cpu: RbConfig::CONFIG["host_cpu"])
|
100
|
+
case host_os
|
101
|
+
when /linux/i
|
102
|
+
case host_cpu
|
103
|
+
when /amd64|x86_64|x64/i
|
104
|
+
return NAME_TO_ARCHITECTURE["linux-amd64"]
|
105
|
+
when /aarch64/i
|
106
|
+
return NAME_TO_ARCHITECTURE["linux-arm64"]
|
107
|
+
end
|
108
|
+
when /darwin/i
|
109
|
+
return NAME_TO_ARCHITECTURE["macOS"]
|
110
|
+
when /mingw|mswin/i
|
111
|
+
return NAME_TO_ARCHITECTURE["windows-x86_64"]
|
112
|
+
end
|
113
|
+
|
114
|
+
raise NotImplementedError, "This platform (#{host_os.inspect} #{host_cpu.inspect}) is not supported. Please send pull-request!"
|
115
|
+
end
|
116
|
+
|
117
|
+
def gzipped_executable_path(architecture: determine_architecture)
|
118
|
+
return LIBEXEC_PATH / "#{PREFIX}-#{architecture.name}.gz"
|
119
|
+
end
|
120
|
+
|
121
|
+
def executable_path(architecture: determine_architecture)
|
122
|
+
path = Pathname(
|
123
|
+
ENV["PANDOC_BINARY_EXTRACTED_PATH"] ||
|
124
|
+
LIBEXEC_PATH / "#{PREFIX}-#{architecture.name}"
|
125
|
+
)
|
126
|
+
path = path.sub_ext(".#{architecture.bin_suffix}") if architecture.bin_suffix
|
127
|
+
return path if path.exist?
|
128
|
+
|
129
|
+
gzipped_path = gzipped_executable_path(architecture: architecture)
|
130
|
+
Zlib::GzipReader.open(gzipped_path) do |gzip|
|
131
|
+
path.open("wb", 0o755) do |f|
|
132
|
+
IO.copy_stream(gzip, f)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
return path
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
data/libexec/.keep
ADDED
File without changes
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/pandoc_binary/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "pandoc_binary"
|
7
|
+
spec.version = PandocBinary::VERSION
|
8
|
+
spec.authors = ["Yuya.Nishida."]
|
9
|
+
spec.email = ["yuya@j96.org"]
|
10
|
+
|
11
|
+
spec.summary = "Provides binaries for Pandoc"
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "https://github.com/nishidayuya/pandoc_binary_gem"
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
23
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
# Uncomment to register a new dependency of your gem
|
31
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
32
|
+
|
33
|
+
# For more information and examples about making a new gem, check out our
|
34
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
35
|
+
|
36
|
+
spec.add_development_dependency("debug")
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pandoc_binary
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.10.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yuya.Nishida.
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-04-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: debug
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Provides binaries for Pandoc
|
28
|
+
email:
|
29
|
+
- yuya@j96.org
|
30
|
+
executables:
|
31
|
+
- pandoc
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- Gemfile
|
36
|
+
- Gemfile.lock
|
37
|
+
- LICENSE.txt
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- exe/pandoc
|
41
|
+
- lib/pandoc_binary.rb
|
42
|
+
- lib/pandoc_binary/version.rb
|
43
|
+
- lib/pandoc_binary/version.rb.template
|
44
|
+
- libexec/.keep
|
45
|
+
- libexec/pandoc-linux-amd64.gz
|
46
|
+
- libexec/pandoc-macOS.gz
|
47
|
+
- libexec/pandoc-windows-x86_64.gz
|
48
|
+
- pandoc_binary.gemspec
|
49
|
+
- sig/pandoc_binary.rbs
|
50
|
+
homepage: https://github.com/nishidayuya/pandoc_binary_gem
|
51
|
+
licenses: []
|
52
|
+
metadata:
|
53
|
+
homepage_uri: https://github.com/nishidayuya/pandoc_binary_gem
|
54
|
+
source_code_uri: https://github.com/nishidayuya/pandoc_binary_gem
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 2.6.0
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubygems_version: 3.3.7
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Provides binaries for Pandoc
|
74
|
+
test_files: []
|