fontist 1.8.2 → 1.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +6 -6
- data/fontist.gemspec +7 -6
- data/lib/fontist.rb +4 -0
- data/lib/fontist/cli.rb +16 -24
- data/lib/fontist/errors.rb +51 -2
- data/lib/fontist/font.rb +39 -56
- data/lib/fontist/font_installer.rb +4 -0
- data/lib/fontist/font_path.rb +29 -0
- data/lib/fontist/formula.rb +8 -4
- data/lib/fontist/import/extractors.rb +4 -0
- data/lib/fontist/import/extractors/cpio_extractor.rb +39 -0
- data/lib/fontist/import/extractors/gzip_extractor.rb +27 -0
- data/lib/fontist/import/extractors/rpm_extractor.rb +45 -0
- data/lib/fontist/import/extractors/tar_extractor.rb +47 -0
- data/lib/fontist/import/recursive_extraction.rb +20 -6
- data/lib/fontist/index.rb +4 -65
- data/lib/fontist/indexes/base_index.rb +82 -0
- data/lib/fontist/indexes/filename_index.rb +19 -0
- data/lib/fontist/indexes/font_index.rb +21 -0
- data/lib/fontist/indexes/index_formula.rb +36 -0
- data/lib/fontist/manifest/install.rb +3 -2
- data/lib/fontist/manifest/locations.rb +1 -1
- data/lib/fontist/system_font.rb +33 -36
- data/lib/fontist/system_index.rb +46 -4
- data/lib/fontist/utils.rb +5 -0
- data/lib/fontist/utils/cache.rb +12 -4
- data/lib/fontist/utils/cpio/cpio.rb +199 -0
- data/lib/fontist/utils/cpio_extractor.rb +47 -0
- data/lib/fontist/utils/downloader.rb +7 -4
- data/lib/fontist/utils/gzip_extractor.rb +24 -0
- data/lib/fontist/utils/locking.rb +17 -0
- data/lib/fontist/utils/rpm_extractor.rb +44 -0
- data/lib/fontist/utils/tar_extractor.rb +61 -0
- data/lib/fontist/version.rb +1 -1
- metadata +37 -11
- data/lib/fontist/index_formula.rb +0 -30
@@ -0,0 +1,47 @@
|
|
1
|
+
module Fontist
|
2
|
+
module Utils
|
3
|
+
module CpioExtractor
|
4
|
+
def cpio_extract(resource)
|
5
|
+
file = @downloaded ? resource : download_file(resource)
|
6
|
+
|
7
|
+
dir = extract_cpio_file(file)
|
8
|
+
|
9
|
+
largest_file_in_dir(dir)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def extract_cpio_file(archive_path)
|
15
|
+
archive_file = File.open(archive_path, "rb")
|
16
|
+
dir = Dir.mktmpdir
|
17
|
+
extract_cpio_file_to_dir(archive_file, dir)
|
18
|
+
|
19
|
+
dir
|
20
|
+
end
|
21
|
+
|
22
|
+
def extract_cpio_file_to_dir(archive_file, dir)
|
23
|
+
cpio_reader_class.new(archive_file).each do |entry, file|
|
24
|
+
path = File.join(dir, entry.name)
|
25
|
+
if entry.directory?
|
26
|
+
FileUtils.mkdir_p(path)
|
27
|
+
else
|
28
|
+
File.write(path, file.read, mode: "wb")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def cpio_reader_class
|
34
|
+
@cpio_reader_class ||= begin
|
35
|
+
require "fontist/utils/cpio/cpio"
|
36
|
+
CPIO::ASCIIReader
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def largest_file_in_dir(dir)
|
41
|
+
Dir.glob(File.join(dir, "**/*")).max_by do |path|
|
42
|
+
File.size(path)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -3,6 +3,13 @@ require_relative "cache"
|
|
3
3
|
module Fontist
|
4
4
|
module Utils
|
5
5
|
class Downloader
|
6
|
+
class << self
|
7
|
+
def download(*args)
|
8
|
+
new(*args).download
|
9
|
+
end
|
10
|
+
ruby2_keywords :download if respond_to?(:ruby2_keywords, true)
|
11
|
+
end
|
12
|
+
|
6
13
|
def initialize(file, file_size: nil, sha: nil, progress_bar: nil)
|
7
14
|
# TODO: If the first mirror fails, try the second one
|
8
15
|
@file = file
|
@@ -27,10 +34,6 @@ module Fontist
|
|
27
34
|
file
|
28
35
|
end
|
29
36
|
|
30
|
-
def self.download(file, options = {})
|
31
|
-
new(file, options).download
|
32
|
-
end
|
33
|
-
|
34
37
|
private
|
35
38
|
|
36
39
|
attr_reader :file, :sha, :file_size
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Fontist
|
2
|
+
module Utils
|
3
|
+
module GzipExtractor
|
4
|
+
def gzip_extract(resource)
|
5
|
+
file = @downloaded ? resource : download_file(resource)
|
6
|
+
|
7
|
+
extract_gzip_file(file)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def extract_gzip_file(file)
|
13
|
+
Zlib::GzipReader.open(file) do |gz|
|
14
|
+
basename = File.basename(file, ".*")
|
15
|
+
dir = Dir.mktmpdir
|
16
|
+
path = File.join(dir, basename)
|
17
|
+
File.write(path, gz.read, mode: "wb")
|
18
|
+
|
19
|
+
path
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Fontist
|
2
|
+
module Utils
|
3
|
+
module Locking
|
4
|
+
def lock(lock_path)
|
5
|
+
File.dirname(lock_path).tap do |dir|
|
6
|
+
FileUtils.mkdir_p(dir) unless File.exist?(dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
f = File.open(lock_path, File::CREAT)
|
10
|
+
f.flock(File::LOCK_EX)
|
11
|
+
yield
|
12
|
+
ensure
|
13
|
+
f.flock(File::LOCK_UN)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Fontist
|
2
|
+
module Utils
|
3
|
+
module RpmExtractor
|
4
|
+
def rpm_extract(resource)
|
5
|
+
file = download_file(resource)
|
6
|
+
|
7
|
+
extract_rpm_file(file)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def extract_rpm_file(file)
|
13
|
+
rpm = rpm_class.new(file)
|
14
|
+
content = rpm.payload.read
|
15
|
+
path = rpm_target_path(file.path, rpm.tags)
|
16
|
+
File.write(path, content, mode: "wb")
|
17
|
+
|
18
|
+
path
|
19
|
+
end
|
20
|
+
|
21
|
+
def rpm_class
|
22
|
+
@rpm_class ||= begin
|
23
|
+
require "arr-pm"
|
24
|
+
|
25
|
+
# fix for Ruby 3.0
|
26
|
+
unless RPM::File::Header::HEADER_MAGIC == [0x8eade801, 0x00000000].pack("NN")
|
27
|
+
RPM::File::Header.send(:remove_const, "HEADER_MAGIC")
|
28
|
+
RPM::File::Header.const_set("HEADER_MAGIC", [0x8eade801, 0x00000000].pack("NN"))
|
29
|
+
end
|
30
|
+
|
31
|
+
RPM::File
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def rpm_target_path(archive, tags)
|
36
|
+
basename = File.basename(archive, ".*")
|
37
|
+
archive_format = tags[:payloadformat]
|
38
|
+
compression_format = tags[:payloadcompressor] == "gzip" ? "gz" : tags[:payloadcompressor]
|
39
|
+
filename = basename + "." + archive_format + "." + compression_format
|
40
|
+
File.join(Dir.mktmpdir, filename)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Fontist
|
2
|
+
module Utils
|
3
|
+
module TarExtractor
|
4
|
+
def tar_extract(resource)
|
5
|
+
file = @downloaded ? resource : download_file(resource)
|
6
|
+
|
7
|
+
dir = extract_tar_file(file)
|
8
|
+
|
9
|
+
save_fonts(dir)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def extract_tar_file(file)
|
15
|
+
archive_file = File.open(file, "rb")
|
16
|
+
dir = Dir.mktmpdir
|
17
|
+
tar_reader_class.new(archive_file) do |tar|
|
18
|
+
tar.each do |tarfile|
|
19
|
+
save_tar_file(tarfile, dir)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
dir
|
24
|
+
end
|
25
|
+
|
26
|
+
def tar_reader_class
|
27
|
+
@tar_reader_class ||= begin
|
28
|
+
require "rubygems/package"
|
29
|
+
Gem::Package::TarReader
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def save_tar_file(file, dir)
|
34
|
+
path = File.join(dir, file.full_name)
|
35
|
+
|
36
|
+
if file.directory?
|
37
|
+
FileUtils.mkdir_p(path)
|
38
|
+
else
|
39
|
+
File.open(path, "wb") do |f|
|
40
|
+
f.print(file.read)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def save_fonts(dir)
|
46
|
+
Array.new.tap do |fonts_paths|
|
47
|
+
Dir.glob(File.join(dir, "**/*")).each do |path|
|
48
|
+
filename = File.basename(path)
|
49
|
+
next unless font_file?(filename)
|
50
|
+
|
51
|
+
target_filename = target_filename(filename)
|
52
|
+
font_path = fonts_path.join(target_filename).to_s
|
53
|
+
FileUtils.mv(path, font_path)
|
54
|
+
|
55
|
+
fonts_paths << font_path
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/fontist/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fontist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
- Abu Nashir
|
9
8
|
autorequire:
|
10
9
|
bindir: exe
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2021-02-20 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: arr-pm
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.1
|
14
27
|
- !ruby/object:Gem::Dependency
|
15
28
|
name: down
|
16
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,14 +212,14 @@ dependencies:
|
|
199
212
|
requirements:
|
200
213
|
- - "~>"
|
201
214
|
- !ruby/object:Gem::Version
|
202
|
-
version:
|
215
|
+
version: '13'
|
203
216
|
type: :development
|
204
217
|
prerelease: false
|
205
218
|
version_requirements: !ruby/object:Gem::Requirement
|
206
219
|
requirements:
|
207
220
|
- - "~>"
|
208
221
|
- !ruby/object:Gem::Version
|
209
|
-
version:
|
222
|
+
version: '13'
|
210
223
|
- !ruby/object:Gem::Dependency
|
211
224
|
name: rspec
|
212
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -277,10 +290,9 @@ dependencies:
|
|
277
290
|
- - "~>"
|
278
291
|
- !ruby/object:Gem::Version
|
279
292
|
version: '1.0'
|
280
|
-
description:
|
293
|
+
description: Install openly-licensed fonts on Windows, Linux and Mac!
|
281
294
|
email:
|
282
|
-
-
|
283
|
-
- abunashir@gmail.com
|
295
|
+
- open.source@ribose.com
|
284
296
|
executables:
|
285
297
|
- fontist
|
286
298
|
extensions: []
|
@@ -304,6 +316,7 @@ files:
|
|
304
316
|
- lib/fontist/errors.rb
|
305
317
|
- lib/fontist/font.rb
|
306
318
|
- lib/fontist/font_installer.rb
|
319
|
+
- lib/fontist/font_path.rb
|
307
320
|
- lib/fontist/fontist_font.rb
|
308
321
|
- lib/fontist/formula.rb
|
309
322
|
- lib/fontist/formula_paths.rb
|
@@ -313,9 +326,13 @@ files:
|
|
313
326
|
- lib/fontist/import/create_formula.rb
|
314
327
|
- lib/fontist/import/extractors.rb
|
315
328
|
- lib/fontist/import/extractors/cab_extractor.rb
|
329
|
+
- lib/fontist/import/extractors/cpio_extractor.rb
|
316
330
|
- lib/fontist/import/extractors/extractor.rb
|
331
|
+
- lib/fontist/import/extractors/gzip_extractor.rb
|
317
332
|
- lib/fontist/import/extractors/ole_extractor.rb
|
333
|
+
- lib/fontist/import/extractors/rpm_extractor.rb
|
318
334
|
- lib/fontist/import/extractors/seven_zip_extractor.rb
|
335
|
+
- lib/fontist/import/extractors/tar_extractor.rb
|
319
336
|
- lib/fontist/import/extractors/zip_extractor.rb
|
320
337
|
- lib/fontist/import/files/collection_file.rb
|
321
338
|
- lib/fontist/import/files/file_requirement.rb
|
@@ -343,7 +360,10 @@ files:
|
|
343
360
|
- lib/fontist/import/template_helper.rb
|
344
361
|
- lib/fontist/import/text_helper.rb
|
345
362
|
- lib/fontist/index.rb
|
346
|
-
- lib/fontist/
|
363
|
+
- lib/fontist/indexes/base_index.rb
|
364
|
+
- lib/fontist/indexes/filename_index.rb
|
365
|
+
- lib/fontist/indexes/font_index.rb
|
366
|
+
- lib/fontist/indexes/index_formula.rb
|
347
367
|
- lib/fontist/manifest.rb
|
348
368
|
- lib/fontist/manifest/install.rb
|
349
369
|
- lib/fontist/manifest/locations.rb
|
@@ -352,14 +372,20 @@ files:
|
|
352
372
|
- lib/fontist/system_index.rb
|
353
373
|
- lib/fontist/utils.rb
|
354
374
|
- lib/fontist/utils/cache.rb
|
375
|
+
- lib/fontist/utils/cpio/cpio.rb
|
376
|
+
- lib/fontist/utils/cpio_extractor.rb
|
355
377
|
- lib/fontist/utils/downloader.rb
|
356
378
|
- lib/fontist/utils/dsl.rb
|
357
379
|
- lib/fontist/utils/dsl/collection_font.rb
|
358
380
|
- lib/fontist/utils/dsl/font.rb
|
359
381
|
- lib/fontist/utils/exe_extractor.rb
|
382
|
+
- lib/fontist/utils/gzip_extractor.rb
|
383
|
+
- lib/fontist/utils/locking.rb
|
360
384
|
- lib/fontist/utils/msi_extractor.rb
|
385
|
+
- lib/fontist/utils/rpm_extractor.rb
|
361
386
|
- lib/fontist/utils/seven_zip_extractor.rb
|
362
387
|
- lib/fontist/utils/system.rb
|
388
|
+
- lib/fontist/utils/tar_extractor.rb
|
363
389
|
- lib/fontist/utils/ui.rb
|
364
390
|
- lib/fontist/utils/zip_extractor.rb
|
365
391
|
- lib/fontist/version.rb
|
@@ -370,7 +396,7 @@ metadata:
|
|
370
396
|
homepage_uri: https://github.com/fontist/fontist
|
371
397
|
source_code_uri: https://github.com/fontist/fontist
|
372
398
|
changelog_uri: https://github.com/fontist/fontist
|
373
|
-
post_install_message: Please run `fontist update` to fetch formulas
|
399
|
+
post_install_message: Please run `fontist update` to fetch formulas.
|
374
400
|
rdoc_options: []
|
375
401
|
require_paths:
|
376
402
|
- lib
|
@@ -388,5 +414,5 @@ requirements: []
|
|
388
414
|
rubygems_version: 3.0.3
|
389
415
|
signing_key:
|
390
416
|
specification_version: 4
|
391
|
-
summary:
|
417
|
+
summary: Install openly-licensed fonts on Windows, Linux and Mac!
|
392
418
|
test_files: []
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Fontist
|
2
|
-
class IndexFormula
|
3
|
-
def initialize(path)
|
4
|
-
@path = path
|
5
|
-
end
|
6
|
-
|
7
|
-
def to_s
|
8
|
-
normalized
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_full
|
12
|
-
Formula.new_from_file(full_path)
|
13
|
-
end
|
14
|
-
|
15
|
-
def ==(other)
|
16
|
-
to_s == other.to_s
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def normalized
|
22
|
-
escaped = Regexp.escape(Fontist.formulas_path.to_s + "/")
|
23
|
-
@path.sub(Regexp.new("^" + escaped), "")
|
24
|
-
end
|
25
|
-
|
26
|
-
def full_path
|
27
|
-
Fontist.formulas_path.join(normalized).to_s
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|