fontist 1.8.1 → 1.8.2
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 +5 -5
- data/README.md +14 -0
- data/fontist.gemspec +1 -0
- data/lib/fontist/cli.rb +6 -0
- data/lib/fontist/font.rb +4 -4
- data/lib/fontist/import/create_formula.rb +3 -2
- data/lib/fontist/import/google/skiplist.yml +3 -0
- data/lib/fontist/import/recursive_extraction.rb +1 -1
- data/lib/fontist/import/sil_import.rb +99 -0
- data/lib/fontist/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1fea467133e3e6a8a287dd36a2a03790fb63859f983b0398f0f558de519a0a64
|
4
|
+
data.tar.gz: b8c717aef31834b5a9b3c3f903dacf0d267ddd85aa6f0a1eca34566a45b219bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20d44b20267db6f15f1b36be660f91690cef7c6f4b0653341231b3f18658ec0f88ea8225884b7b2ac1d06f3e8aa5be79aea600fed5be91513f43031a10b5de5b
|
7
|
+
data.tar.gz: 6138e6bed40c741f21c6d116f021aef9f6c7cca24506337fe681ba5e6c6e996c8e8e6a84e50103601231d6cab9f5cafc7b5527b418d65fbd6c1477c67ceda201
|
data/README.md
CHANGED
@@ -434,6 +434,20 @@ git commit -m "Google Fonts update"
|
|
434
434
|
git push
|
435
435
|
```
|
436
436
|
|
437
|
+
### Import of SIL fonts
|
438
|
+
|
439
|
+
Fontist contains formulas of [SIL fonts](https://software.sil.org/fonts/). They
|
440
|
+
can be updated with:
|
441
|
+
|
442
|
+
```sh
|
443
|
+
fontist import-sil
|
444
|
+
cd ~/.fontist/formulas
|
445
|
+
git add Formulas/sil
|
446
|
+
git add index.yml
|
447
|
+
git commit -m "SIL fonts update"
|
448
|
+
git push
|
449
|
+
```
|
450
|
+
|
437
451
|
### Releasing
|
438
452
|
|
439
453
|
Releasing is done automatically with GitHub Action. Just bump and tag with `gem-release`.
|
data/fontist.gemspec
CHANGED
@@ -40,6 +40,7 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_development_dependency "pry"
|
41
41
|
spec.add_development_dependency "bundler", "~> 2.0"
|
42
42
|
spec.add_development_dependency "gem-release"
|
43
|
+
spec.add_development_dependency "nokogiri", "~> 1.0"
|
43
44
|
spec.add_development_dependency "rake", "~> 12.3.3"
|
44
45
|
spec.add_development_dependency "rspec", "~> 3.0"
|
45
46
|
spec.add_development_dependency "rubocop", "0.75.0"
|
data/lib/fontist/cli.rb
CHANGED
data/lib/fontist/font.rb
CHANGED
@@ -3,9 +3,9 @@ require "fontist/font_installer"
|
|
3
3
|
module Fontist
|
4
4
|
class Font
|
5
5
|
def initialize(options = {})
|
6
|
-
@name = options
|
7
|
-
@confirmation = options
|
8
|
-
@force = options
|
6
|
+
@name = options[:name]
|
7
|
+
@confirmation = options[:confirmation] || "no"
|
8
|
+
@force = options[:force] || false
|
9
9
|
|
10
10
|
check_or_create_fontist_path!
|
11
11
|
end
|
@@ -121,7 +121,7 @@ module Fontist
|
|
121
121
|
if formula.license_required && !confirmation.casecmp("yes").zero?
|
122
122
|
@confirmation = show_license_and_ask_for_input(formula.license)
|
123
123
|
|
124
|
-
|
124
|
+
unless confirmation&.casecmp?("yes")
|
125
125
|
raise Fontist::Errors::LicensingError.new(
|
126
126
|
"Fontist will not download these fonts unless you accept the terms."
|
127
127
|
)
|
@@ -50,9 +50,10 @@ module Fontist
|
|
50
50
|
|
51
51
|
def save(hash)
|
52
52
|
filename = Import.name_to_filename(hash[:name])
|
53
|
+
path = @options[:formula_dir] ? File.join(@options[:formula_dir], filename) : filename
|
53
54
|
yaml = YAML.dump(Helpers::HashHelper.stringify_keys(hash))
|
54
|
-
File.write(
|
55
|
-
|
55
|
+
File.write(path, yaml)
|
56
|
+
path
|
56
57
|
end
|
57
58
|
end
|
58
59
|
end
|
@@ -7,7 +7,7 @@ module Fontist
|
|
7
7
|
class RecursiveExtraction
|
8
8
|
FONTS_PATTERN = "**/*.{ttf,otf,ttc}".freeze
|
9
9
|
ARCHIVE_EXTENSIONS = %w[zip msi exe cab].freeze
|
10
|
-
LICENSE_PATTERN = /(
|
10
|
+
LICENSE_PATTERN = /(ofl\.txt|ufl\.txt|licenses?\.txt|copying)$/i.freeze
|
11
11
|
|
12
12
|
def initialize(archive, subarchive: nil, subdir: nil)
|
13
13
|
@archive = archive
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
require "fontist/import/create_formula"
|
3
|
+
|
4
|
+
module Fontist
|
5
|
+
module Import
|
6
|
+
class SilImport
|
7
|
+
ROOT = "https://software.sil.org/fonts/".freeze
|
8
|
+
|
9
|
+
def call
|
10
|
+
links = font_links
|
11
|
+
Fontist.ui.success("Found #{links.size} links.")
|
12
|
+
|
13
|
+
paths = []
|
14
|
+
links.each do |link|
|
15
|
+
path = create_formula_by_page_link(link)
|
16
|
+
paths << path if path
|
17
|
+
end
|
18
|
+
|
19
|
+
Fontist::Index.rebuild
|
20
|
+
|
21
|
+
Fontist.ui.success("Created #{paths.size} formulas.")
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def font_links
|
27
|
+
html = URI.parse(ROOT).open.read
|
28
|
+
document = Nokogiri::HTML.parse(html)
|
29
|
+
document.css("table.products div.title > a")
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_formula_by_page_link(link)
|
33
|
+
url = find_archive_url_by_page_link(link)
|
34
|
+
return unless url
|
35
|
+
|
36
|
+
create_formula_by_archive_url(url)
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_formula_by_archive_url(url)
|
40
|
+
path = Fontist::Import::CreateFormula.new(url, formula_dir: formula_dir).call
|
41
|
+
Fontist.ui.success("Formula has been successfully created: #{path}")
|
42
|
+
|
43
|
+
path
|
44
|
+
end
|
45
|
+
|
46
|
+
def find_archive_url_by_page_link(link)
|
47
|
+
Fontist.ui.print("Searching for an archive of #{link.content}... ")
|
48
|
+
|
49
|
+
page_uri = URI.join(ROOT, link[:href])
|
50
|
+
archive_uri = find_archive_url_by_page_uri(page_uri)
|
51
|
+
unless archive_uri
|
52
|
+
Fontist.ui.error("NOT FOUND")
|
53
|
+
return
|
54
|
+
end
|
55
|
+
|
56
|
+
Fontist.ui.success("DONE")
|
57
|
+
|
58
|
+
archive_uri.to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
def find_archive_url_by_page_uri(uri)
|
62
|
+
response = uri.open
|
63
|
+
current_url = response.base_uri
|
64
|
+
html = response.read
|
65
|
+
document = Nokogiri::HTML.parse(html)
|
66
|
+
link = find_archive_link(document)
|
67
|
+
return URI.join(current_url, link[:href]) if link
|
68
|
+
|
69
|
+
page_link = find_download_page(document)
|
70
|
+
return unless page_link
|
71
|
+
|
72
|
+
page_uri = URI.join(current_url, page_link[:href])
|
73
|
+
find_archive_url_by_page_uri(page_uri)
|
74
|
+
end
|
75
|
+
|
76
|
+
def find_archive_link(document)
|
77
|
+
links = document.css("a.btn-download")
|
78
|
+
download_links = links.select { |tag| tag.content.include?("DOWNLOAD CURRENT VERSION") }
|
79
|
+
return download_links.first unless download_links.empty?
|
80
|
+
|
81
|
+
links = document.css("a")
|
82
|
+
download_links = links.select { |tag| tag.content.match?(/Download.*\.zip/) }
|
83
|
+
download_links.first
|
84
|
+
end
|
85
|
+
|
86
|
+
def find_download_page(document)
|
87
|
+
links = document.css("a.btn-download")
|
88
|
+
page_links = links.select { |tag| tag.content == "DOWNLOADS" }
|
89
|
+
page_links.first
|
90
|
+
end
|
91
|
+
|
92
|
+
def formula_dir
|
93
|
+
@formula_dir ||= Fontist.formulas_path.join("sil").tap do |path|
|
94
|
+
FileUtils.mkdir_p(path) unless File.exist?(path)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/fontist/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
- Abu Nashir
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-12-
|
12
|
+
date: 2020-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: down
|
@@ -179,6 +179,20 @@ dependencies:
|
|
179
179
|
- - ">="
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
|
+
- !ruby/object:Gem::Dependency
|
183
|
+
name: nokogiri
|
184
|
+
requirement: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - "~>"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '1.0'
|
189
|
+
type: :development
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - "~>"
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '1.0'
|
182
196
|
- !ruby/object:Gem::Dependency
|
183
197
|
name: rake
|
184
198
|
requirement: !ruby/object:Gem::Requirement
|
@@ -325,6 +339,7 @@ files:
|
|
325
339
|
- lib/fontist/import/otfinfo/template.erb
|
326
340
|
- lib/fontist/import/otfinfo_generate.rb
|
327
341
|
- lib/fontist/import/recursive_extraction.rb
|
342
|
+
- lib/fontist/import/sil_import.rb
|
328
343
|
- lib/fontist/import/template_helper.rb
|
329
344
|
- lib/fontist/import/text_helper.rb
|
330
345
|
- lib/fontist/index.rb
|
@@ -370,9 +385,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
370
385
|
- !ruby/object:Gem::Version
|
371
386
|
version: '0'
|
372
387
|
requirements: []
|
373
|
-
|
374
|
-
|
375
|
-
signing_key:
|
388
|
+
rubygems_version: 3.0.3
|
389
|
+
signing_key:
|
376
390
|
specification_version: 4
|
377
391
|
summary: A libarary find or download fonts
|
378
392
|
test_files: []
|