fontist 1.7.3 → 1.8.5

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +38 -0
  3. data/.github/workflows/rspec.yml +58 -0
  4. data/README.md +48 -4
  5. data/{bin → exe}/fontist +0 -0
  6. data/fontist.gemspec +10 -7
  7. data/lib/fontist.rb +9 -2
  8. data/lib/fontist/cli.rb +64 -55
  9. data/lib/fontist/errors.rb +63 -12
  10. data/lib/fontist/font.rb +33 -64
  11. data/lib/fontist/font_installer.rb +118 -0
  12. data/lib/fontist/font_path.rb +29 -0
  13. data/lib/fontist/fontist_font.rb +3 -49
  14. data/lib/fontist/formula.rb +101 -35
  15. data/lib/fontist/formula_paths.rb +43 -0
  16. data/lib/fontist/helpers.rb +7 -0
  17. data/lib/fontist/import/create_formula.rb +3 -2
  18. data/lib/fontist/import/extractors.rb +4 -0
  19. data/lib/fontist/import/extractors/cpio_extractor.rb +39 -0
  20. data/lib/fontist/import/extractors/gzip_extractor.rb +27 -0
  21. data/lib/fontist/import/extractors/rpm_extractor.rb +45 -0
  22. data/lib/fontist/import/extractors/tar_extractor.rb +47 -0
  23. data/lib/fontist/import/google/skiplist.yml +3 -0
  24. data/lib/fontist/import/google_check.rb +1 -1
  25. data/lib/fontist/import/google_import.rb +3 -4
  26. data/lib/fontist/import/otfinfo_generate.rb +1 -1
  27. data/lib/fontist/import/recursive_extraction.rb +26 -8
  28. data/lib/fontist/import/sil_import.rb +99 -0
  29. data/lib/fontist/index.rb +11 -0
  30. data/lib/fontist/indexes/base_index.rb +82 -0
  31. data/lib/fontist/indexes/filename_index.rb +19 -0
  32. data/lib/fontist/indexes/font_index.rb +21 -0
  33. data/lib/fontist/indexes/index_formula.rb +36 -0
  34. data/lib/fontist/manifest/install.rb +4 -5
  35. data/lib/fontist/manifest/locations.rb +9 -1
  36. data/lib/fontist/system_font.rb +32 -62
  37. data/lib/fontist/system_index.rb +47 -5
  38. data/lib/fontist/utils.rb +5 -0
  39. data/lib/fontist/utils/cache.rb +12 -4
  40. data/lib/fontist/utils/cpio/cpio.rb +199 -0
  41. data/lib/fontist/utils/cpio_extractor.rb +47 -0
  42. data/lib/fontist/utils/exe_extractor.rb +1 -1
  43. data/lib/fontist/utils/gzip_extractor.rb +24 -0
  44. data/lib/fontist/utils/locking.rb +17 -0
  45. data/lib/fontist/utils/rpm_extractor.rb +37 -0
  46. data/lib/fontist/utils/tar_extractor.rb +61 -0
  47. data/lib/fontist/utils/zip_extractor.rb +1 -1
  48. data/lib/fontist/version.rb +1 -1
  49. metadata +74 -26
  50. data/.github/workflows/macosx.yml +0 -33
  51. data/.github/workflows/ubuntu.yml +0 -30
  52. data/.github/workflows/windows.yml +0 -32
  53. data/bin/check_google +0 -8
  54. data/bin/console +0 -11
  55. data/bin/convert_formulas +0 -8
  56. data/bin/generate_otfinfo +0 -8
  57. data/bin/import_google +0 -8
  58. data/bin/rspec +0 -29
  59. data/bin/setup +0 -7
  60. data/lib/fontist/font_formula.rb +0 -169
  61. data/lib/fontist/formula_template.rb +0 -122
  62. data/lib/fontist/formulas.rb +0 -56
  63. data/lib/fontist/registry.rb +0 -43
@@ -0,0 +1,37 @@
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
+ RPM::File
25
+ end
26
+ end
27
+
28
+ def rpm_target_path(archive, tags)
29
+ basename = File.basename(archive, ".*")
30
+ archive_format = tags[:payloadformat]
31
+ compression_format = tags[:payloadcompressor] == "gzip" ? "gz" : tags[:payloadcompressor]
32
+ filename = basename + "." + archive_format + "." + compression_format
33
+ File.join(Dir.mktmpdir, filename)
34
+ end
35
+ end
36
+ end
37
+ 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
@@ -8,7 +8,7 @@ module Fontist
8
8
  zip_file = download_file(resource) if download
9
9
  zip_file ||= resource.urls.first
10
10
 
11
- Fontist.ui.say(%(Installing font "#{key}".))
11
+ Fontist.ui.say(%(Installing font "#{formula.key}".))
12
12
  fonts_paths = unzip_fonts(zip_file, fonts_sub_dir)
13
13
  block_given? ? yield(fonts_paths) : fonts_paths
14
14
  end
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "1.7.3".freeze
2
+ VERSION = "1.8.5".freeze
3
3
  end
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.7.3
4
+ version: 1.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- - Abu Nashir
9
- autorequire:
10
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
11
10
  cert_chain: []
12
- date: 2020-12-10 00:00:00.000000000 Z
11
+ date: 2021-02-03 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
@@ -165,6 +178,34 @@ dependencies:
165
178
  - - "~>"
166
179
  - !ruby/object:Gem::Version
167
180
  version: '2.0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: gem-release
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: nokogiri
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '1.0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '1.0'
168
209
  - !ruby/object:Gem::Dependency
169
210
  name: rake
170
211
  requirement: !ruby/object:Gem::Requirement
@@ -249,19 +290,17 @@ dependencies:
249
290
  - - "~>"
250
291
  - !ruby/object:Gem::Version
251
292
  version: '1.0'
252
- description: A libarary find or download fonts
293
+ description: Install openly-licensed fonts on Windows, Linux and Mac!
253
294
  email:
254
- - operations@ribose.com
255
- - abunashir@gmail.com
295
+ - open.source@ribose.com
256
296
  executables:
257
297
  - fontist
258
298
  extensions: []
259
299
  extra_rdoc_files: []
260
300
  files:
261
301
  - ".github/workflows/check_google.yml"
262
- - ".github/workflows/macosx.yml"
263
- - ".github/workflows/ubuntu.yml"
264
- - ".github/workflows/windows.yml"
302
+ - ".github/workflows/release.yml"
303
+ - ".github/workflows/rspec.yml"
265
304
  - ".gitignore"
266
305
  - ".hound.yml"
267
306
  - ".rspec"
@@ -270,32 +309,30 @@ files:
270
309
  - LICENSE.txt
271
310
  - README.md
272
311
  - Rakefile
273
- - bin/check_google
274
- - bin/console
275
- - bin/convert_formulas
276
- - bin/fontist
277
- - bin/generate_otfinfo
278
- - bin/import_google
279
- - bin/rspec
280
- - bin/setup
312
+ - exe/fontist
281
313
  - fontist.gemspec
282
314
  - lib/fontist.rb
283
315
  - lib/fontist/cli.rb
284
316
  - lib/fontist/errors.rb
285
317
  - lib/fontist/font.rb
286
- - lib/fontist/font_formula.rb
318
+ - lib/fontist/font_installer.rb
319
+ - lib/fontist/font_path.rb
287
320
  - lib/fontist/fontist_font.rb
288
321
  - lib/fontist/formula.rb
289
- - lib/fontist/formula_template.rb
290
- - lib/fontist/formulas.rb
322
+ - lib/fontist/formula_paths.rb
323
+ - lib/fontist/helpers.rb
291
324
  - lib/fontist/import.rb
292
325
  - lib/fontist/import/convert_formulas.rb
293
326
  - lib/fontist/import/create_formula.rb
294
327
  - lib/fontist/import/extractors.rb
295
328
  - lib/fontist/import/extractors/cab_extractor.rb
329
+ - lib/fontist/import/extractors/cpio_extractor.rb
296
330
  - lib/fontist/import/extractors/extractor.rb
331
+ - lib/fontist/import/extractors/gzip_extractor.rb
297
332
  - lib/fontist/import/extractors/ole_extractor.rb
333
+ - lib/fontist/import/extractors/rpm_extractor.rb
298
334
  - lib/fontist/import/extractors/seven_zip_extractor.rb
335
+ - lib/fontist/import/extractors/tar_extractor.rb
299
336
  - lib/fontist/import/extractors/zip_extractor.rb
300
337
  - lib/fontist/import/files/collection_file.rb
301
338
  - lib/fontist/import/files/file_requirement.rb
@@ -319,25 +356,36 @@ files:
319
356
  - lib/fontist/import/otfinfo/template.erb
320
357
  - lib/fontist/import/otfinfo_generate.rb
321
358
  - lib/fontist/import/recursive_extraction.rb
359
+ - lib/fontist/import/sil_import.rb
322
360
  - lib/fontist/import/template_helper.rb
323
361
  - lib/fontist/import/text_helper.rb
362
+ - lib/fontist/index.rb
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
324
367
  - lib/fontist/manifest.rb
325
368
  - lib/fontist/manifest/install.rb
326
369
  - lib/fontist/manifest/locations.rb
327
- - lib/fontist/registry.rb
328
370
  - lib/fontist/system.yml
329
371
  - lib/fontist/system_font.rb
330
372
  - lib/fontist/system_index.rb
331
373
  - lib/fontist/utils.rb
332
374
  - lib/fontist/utils/cache.rb
375
+ - lib/fontist/utils/cpio/cpio.rb
376
+ - lib/fontist/utils/cpio_extractor.rb
333
377
  - lib/fontist/utils/downloader.rb
334
378
  - lib/fontist/utils/dsl.rb
335
379
  - lib/fontist/utils/dsl/collection_font.rb
336
380
  - lib/fontist/utils/dsl/font.rb
337
381
  - lib/fontist/utils/exe_extractor.rb
382
+ - lib/fontist/utils/gzip_extractor.rb
383
+ - lib/fontist/utils/locking.rb
338
384
  - lib/fontist/utils/msi_extractor.rb
385
+ - lib/fontist/utils/rpm_extractor.rb
339
386
  - lib/fontist/utils/seven_zip_extractor.rb
340
387
  - lib/fontist/utils/system.rb
388
+ - lib/fontist/utils/tar_extractor.rb
341
389
  - lib/fontist/utils/ui.rb
342
390
  - lib/fontist/utils/zip_extractor.rb
343
391
  - lib/fontist/version.rb
@@ -348,7 +396,7 @@ metadata:
348
396
  homepage_uri: https://github.com/fontist/fontist
349
397
  source_code_uri: https://github.com/fontist/fontist
350
398
  changelog_uri: https://github.com/fontist/fontist
351
- post_install_message: Please run `fontist update` to fetch formulas
399
+ post_install_message: Please run `fontist update` to fetch formulas.
352
400
  rdoc_options: []
353
401
  require_paths:
354
402
  - lib
@@ -364,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
364
412
  version: '0'
365
413
  requirements: []
366
414
  rubygems_version: 3.0.3
367
- signing_key:
415
+ signing_key:
368
416
  specification_version: 4
369
- summary: A libarary find or download fonts
417
+ summary: Install openly-licensed fonts on Windows, Linux and Mac!
370
418
  test_files: []
@@ -1,33 +0,0 @@
1
- name: macos
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
-
8
- pull_request:
9
- branches:
10
- - master
11
-
12
- jobs:
13
- build:
14
- runs-on: macos-latest
15
-
16
- steps:
17
- - uses: actions/checkout@v2
18
-
19
- - uses: actions/setup-ruby@v1
20
- with:
21
- ruby-version: 2.6
22
-
23
- - name: Install otfinfo
24
- run: brew install lcdf-typetools
25
-
26
- - name: Install bundler
27
- run: gem install bundler
28
-
29
- - name: Setup
30
- run: bin/setup
31
-
32
- - name: Run tests
33
- run: TEST_ENV=CI bin/rspec
@@ -1,30 +0,0 @@
1
- name: ubuntu
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
-
8
- pull_request:
9
- branches:
10
- - master
11
-
12
- jobs:
13
- build:
14
- runs-on: ubuntu-latest
15
-
16
- steps:
17
- - uses: actions/checkout@v2
18
-
19
- - uses: actions/setup-ruby@v1
20
- with:
21
- ruby-version: 2.6
22
-
23
- - name: Install bundler
24
- run: gem install bundler
25
-
26
- - name: Setup
27
- run: bin/setup
28
-
29
- - name: Run tests
30
- run: TEST_ENV=CI bin/rspec --tag ~dev
@@ -1,32 +0,0 @@
1
- name: windows
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
-
8
- pull_request:
9
- branches:
10
- - master
11
-
12
- jobs:
13
- build:
14
- runs-on: windows-latest
15
-
16
- steps:
17
- - uses: actions/checkout@v2
18
-
19
- - uses: actions/setup-ruby@v1
20
- with:
21
- ruby-version: 2.6
22
- architecture: "x64"
23
-
24
- - name: Setup
25
- shell: pwsh
26
- run: |
27
- gem install bundler
28
- bundle config --local path vendor/bundle
29
- bundle install --jobs 4 --retry 3
30
-
31
- - name: Run tests
32
- run: bundle exec rspec --tag ~skip_in_windows --tag ~dev
data/bin/check_google DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "fontist"
6
- require "fontist/import/google_check"
7
-
8
- Fontist::Import::GoogleCheck.new.call
data/bin/console DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "fontist"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- require "pry"
11
- Pry.start
data/bin/convert_formulas DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "fontist"
6
- require "fontist/import/convert_formulas"
7
-
8
- Fontist::Import::ConvertFormulas.new.call
data/bin/generate_otfinfo DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "fontist"
6
- require "fontist/import/otfinfo_generate"
7
-
8
- Fontist::Import::OtfinfoGenerate.new(ARGV[0]).call