fontist 0.4.0 → 1.3.0
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 +4 -4
- data/.github/workflows/macosx.yml +1 -1
- data/.github/workflows/ubuntu.yml +1 -1
- data/.gitignore +4 -2
- data/README.md +87 -25
- data/fontist.gemspec +1 -0
- data/lib/fontist.rb +30 -13
- data/lib/fontist/errors.rb +3 -1
- data/lib/fontist/font.rb +113 -0
- data/lib/fontist/font_formula.rb +123 -0
- data/lib/fontist/formula.rb +90 -0
- data/lib/fontist/formulas.rb +10 -5
- data/lib/fontist/formulas/andale_font.rb +80 -0
- data/lib/fontist/formulas/arial_black_font.rb +79 -0
- data/lib/fontist/formulas/cleartype_fonts.rb +227 -0
- data/lib/fontist/formulas/comic_font.rb +78 -0
- data/lib/fontist/formulas/courier_font.rb +68 -12
- data/lib/fontist/formulas/euphemia_font.rb +85 -0
- data/lib/fontist/formulas/georgia_font.rb +80 -0
- data/lib/fontist/formulas/impact_font.rb +78 -0
- data/lib/fontist/formulas/montserrat_font.rb +132 -0
- data/lib/fontist/formulas/ms_truetype_fonts.rb +125 -0
- data/lib/fontist/formulas/open_sans_fonts.rb +263 -0
- data/lib/fontist/formulas/overpass_font.rb +73 -0
- data/lib/fontist/formulas/source_fonts.rb +109 -0
- data/lib/fontist/formulas/stix_fonts.rb +108 -0
- data/lib/fontist/formulas/tahoma_font.rb +147 -0
- data/lib/fontist/formulas/webding_font.rb +78 -0
- data/lib/fontist/registry.rb +43 -0
- data/lib/fontist/{data/source.yml → system.yml} +5 -8
- data/lib/fontist/system_font.rb +19 -14
- data/lib/fontist/utils.rb +10 -0
- data/lib/fontist/utils/downloader.rb +79 -0
- data/lib/fontist/utils/dsl.rb +77 -0
- data/lib/fontist/utils/exe_extractor.rb +72 -0
- data/lib/fontist/utils/ui.rb +15 -0
- data/lib/fontist/utils/zip_extractor.rb +38 -0
- data/lib/fontist/version.rb +1 -1
- data/spec/fontist/font_formula_spec.rb +67 -0
- data/spec/fontist/font_spec.rb +113 -0
- data/spec/fontist/formula_spec.rb +67 -0
- data/spec/fontist/formulas/andale_font_spec.rb +29 -0
- data/spec/fontist/formulas/arial_black_font_spec.rb +29 -0
- data/spec/fontist/formulas/cleartype_fonts_spec.rb +38 -0
- data/spec/fontist/formulas/comic_font_spec.rb +29 -0
- data/spec/fontist/formulas/courier_font_spec.rb +18 -19
- data/spec/fontist/formulas/euphemia_font_spec.rb +29 -0
- data/spec/fontist/formulas/georgia_font_spec.rb +29 -0
- data/spec/fontist/formulas/impact_font_spec.rb +29 -0
- data/spec/fontist/formulas/montserrat_font_spec.rb +29 -0
- data/spec/fontist/formulas/ms_truetype_fonts_spec.rb +29 -0
- data/spec/fontist/formulas/open_sans_fonts_spec.rb +29 -0
- data/spec/fontist/formulas/overpass_font_spec.rb +29 -0
- data/spec/fontist/formulas/source_fonts_spec.rb +31 -0
- data/spec/fontist/formulas/stix_fonts_spec.rb +29 -0
- data/spec/fontist/formulas/tahoma_font_spec.rb +29 -0
- data/spec/fontist/formulas/webding_font_spec.rb +29 -0
- data/spec/fontist/registry_spec.rb +47 -0
- data/spec/fontist/system_font_spec.rb +12 -7
- data/spec/fontist/{downloader_spec.rb → utils/downloader_spec.rb} +6 -5
- data/spec/spec_helper.rb +4 -2
- data/spec/support/fontist_helper.rb +4 -2
- metadata +62 -27
- data/lib/fontist/data/formulas/courier.yml +0 -26
- data/lib/fontist/data/formulas/ms_system.yml +0 -68
- data/lib/fontist/data/formulas/ms_vista.yml +0 -118
- data/lib/fontist/data/formulas/source_font.yml +0 -163
- data/lib/fontist/downloader.rb +0 -70
- data/lib/fontist/finder.rb +0 -45
- data/lib/fontist/formula_finder.rb +0 -94
- data/lib/fontist/formulas/base.rb +0 -72
- data/lib/fontist/formulas/helpers/exe_extractor.rb +0 -45
- data/lib/fontist/formulas/helpers/zip_extractor.rb +0 -36
- data/lib/fontist/formulas/ms_system.rb +0 -29
- data/lib/fontist/formulas/ms_vista.rb +0 -42
- data/lib/fontist/formulas/source_font.rb +0 -25
- data/lib/fontist/installer.rb +0 -42
- data/lib/fontist/source.rb +0 -58
- data/spec/fontist/finder_spec.rb +0 -41
- data/spec/fontist/formula_finder_spec.rb +0 -54
- data/spec/fontist/formulas/ms_system_spec.rb +0 -31
- data/spec/fontist/formulas/ms_vista_spec.rb +0 -27
- data/spec/fontist/formulas/source_font_spec.rb +0 -18
- data/spec/fontist/installer_spec.rb +0 -48
- data/spec/fontist/source_spec.rb +0 -24
data/spec/fontist/finder_spec.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Fontist::Finder do
|
4
|
-
describe ".find" do
|
5
|
-
context "with valid font name" do
|
6
|
-
it "returns the fonts path" do
|
7
|
-
name = "DejaVuSerif.ttf"
|
8
|
-
stub_system_font_finder_to_fixture(name)
|
9
|
-
dejavu_ttf = Fontist::Finder.find(name)
|
10
|
-
|
11
|
-
expect(dejavu_ttf.first).to include(name)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "with downloadable ms vista font" do
|
16
|
-
it "returns missing font error" do
|
17
|
-
name = "Calibri"
|
18
|
-
allow(Fontist::SystemFont).to receive(:find).and_return(nil)
|
19
|
-
|
20
|
-
expect {
|
21
|
-
Fontist::Finder.find(name)
|
22
|
-
}.to raise_error(Fontist::Errors::MissingFontError)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "with invalid font name" do
|
27
|
-
it "raise an missing font error" do
|
28
|
-
font_name = "InvalidFont.ttf"
|
29
|
-
|
30
|
-
expect {
|
31
|
-
Fontist::Finder.find(font_name)
|
32
|
-
}.to raise_error(Fontist::Errors::NonSupportedFontError)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def stub_system_font_finder_to_fixture(name)
|
38
|
-
allow(Fontist::SystemFont).to receive(:find).
|
39
|
-
and_return(["spec/fixtures/fonts/#{name}"])
|
40
|
-
end
|
41
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Fontist::FormulaFinder do
|
4
|
-
describe ".find" do
|
5
|
-
context "by font name" do
|
6
|
-
it "returns the font formulas" do
|
7
|
-
name = "Calibri"
|
8
|
-
formulas = Fontist::FormulaFinder.find(name)
|
9
|
-
|
10
|
-
expect(formulas.count).to eq(1)
|
11
|
-
expect(formulas.first[:key]).to eq("msvista")
|
12
|
-
expect(formulas.first[:installer]).to eq(Fontist::Formulas::MsVista)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "by exact font" do
|
17
|
-
it "returns the font formulas" do
|
18
|
-
name = "CAMBRIAI.TTF"
|
19
|
-
formulas = Fontist::FormulaFinder.find(name)
|
20
|
-
|
21
|
-
expect(formulas.count).to eq(1)
|
22
|
-
expect(formulas.first[:key]).to eq("msvista")
|
23
|
-
expect(formulas.first[:installer]).to eq(Fontist::Formulas::MsVista)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "for invalid font" do
|
28
|
-
it "returns nil to the caller" do
|
29
|
-
name = "Calibri Made Up Name"
|
30
|
-
formulas = Fontist::FormulaFinder.find(name)
|
31
|
-
|
32
|
-
expect(formulas).to be_nil
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe ".find_fonts" do
|
38
|
-
it "returns the exact font font names" do
|
39
|
-
name = "Calibri"
|
40
|
-
font = Fontist::FormulaFinder.find_fonts(name).first
|
41
|
-
|
42
|
-
expect(font.styles.map(&:font)).to include("CALIBRI.TTF")
|
43
|
-
expect(font.styles.map(&:font)).to include("CALIBRIB.TTF")
|
44
|
-
expect(font.styles.map(&:font)).to include("CALIBRII.TTF")
|
45
|
-
end
|
46
|
-
|
47
|
-
it "returns nil if invalid name provided" do
|
48
|
-
name = "Calibri Invlaid"
|
49
|
-
fonts = Fontist::FormulaFinder.find_fonts(name)
|
50
|
-
|
51
|
-
expect(fonts).to be_nil
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Fontist::Formulas::MsSystem do
|
4
|
-
describe ".fetch_font" do
|
5
|
-
context "with valid licence", skip_in_windows: false do
|
6
|
-
it "downloads and returns font paths", file_download: true do
|
7
|
-
name = "Times"
|
8
|
-
stub_fontist_path_to_assets
|
9
|
-
|
10
|
-
fonts = Fontist::Formulas::MsSystem.fetch_font(
|
11
|
-
name, confirmation: "yes"
|
12
|
-
)
|
13
|
-
|
14
|
-
expect(fonts).not_to be_empty
|
15
|
-
expect(fonts.first).to include(name)
|
16
|
-
expect(Fontist::Finder.find(name)).not_to be_empty
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "with invalid licence agreement" do
|
21
|
-
it "raise an licensing error" do
|
22
|
-
font_name = "Times"
|
23
|
-
stub_fontist_path_to_assets
|
24
|
-
|
25
|
-
expect {
|
26
|
-
Fontist::Formulas::MsSystem.fetch_font(font_name, confirmation: "no")
|
27
|
-
}.to raise_error(Fontist::Errors::LicensingError)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Fontist::Formulas::MsVista do
|
4
|
-
describe ".fetch_font" do
|
5
|
-
context "with valid licence" do
|
6
|
-
it "downloads and returns font paths", file_download: true do
|
7
|
-
name = "CANDARAI.TTF"
|
8
|
-
fonts = Fontist::Formulas::MsVista.fetch_font(
|
9
|
-
name, confirmation: "yes"
|
10
|
-
)
|
11
|
-
|
12
|
-
expect(fonts.count).to eq(1)
|
13
|
-
expect(fonts.first).to include("CANDARAI.TTF")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context "with invalid licence agreement" do
|
18
|
-
it "raise an licensing error" do
|
19
|
-
font_name = "CANDARAI.TTF"
|
20
|
-
|
21
|
-
expect {
|
22
|
-
Fontist::Formulas::MsVista.fetch_font(font_name, confirmation: "no")
|
23
|
-
}.to raise_error(Fontist::Errors::LicensingError)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Fontist::Formulas::SourceFont do
|
4
|
-
describe ".fetch_font" do
|
5
|
-
it "downloads and extract out fonts", file_download: true do
|
6
|
-
name = "SourceCodePro"
|
7
|
-
stub_fontist_path_to_assets
|
8
|
-
|
9
|
-
fonts = Fontist::Formulas::SourceFont.fetch_font(
|
10
|
-
name, confirmation: "yes", force_download: true,
|
11
|
-
)
|
12
|
-
|
13
|
-
expect(fonts).not_to be_empty
|
14
|
-
expect(fonts.first).to include(name)
|
15
|
-
expect(Fontist::Finder.find(name)).not_to be_empty
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Fontist::Installer do
|
4
|
-
describe ".download" do
|
5
|
-
context "with already downloaded fonts", skip_in_windows: true do
|
6
|
-
it "returns the font path", file_download: true do
|
7
|
-
name = "Arial"
|
8
|
-
Fontist::Formulas::MsVista.fetch_font(name, confirmation: "yes")
|
9
|
-
|
10
|
-
allow(Fontist::Formulas::MsVista).to receive(:fetch_font).and_return(nil)
|
11
|
-
paths = Fontist::Installer.download(name, confirmation: "yes")
|
12
|
-
|
13
|
-
expect(paths.first).to include("fonts/#{name}")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context "with missing but downloadable fonts" do
|
18
|
-
it "downloads and install the fonts", skip_in_windows: true do
|
19
|
-
name = "Arial"
|
20
|
-
confirmation = "yes"
|
21
|
-
allow(Fontist::SystemFont).to receive(:find).and_return(nil)
|
22
|
-
|
23
|
-
paths = Fontist::Installer.download(name, confirmation: confirmation)
|
24
|
-
|
25
|
-
expect(paths.first).to include("fonts/#{name}")
|
26
|
-
end
|
27
|
-
|
28
|
-
it "do not download if user didn't agree" do
|
29
|
-
name = "Calibri"
|
30
|
-
allow(Fontist::SystemFont).to receive(:find).and_return(nil)
|
31
|
-
|
32
|
-
expect {
|
33
|
-
Fontist::Installer.download(name, confirmation: "no")
|
34
|
-
}.to raise_error(Fontist::Errors::LicensingError)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context "with unsupported fonts" do
|
39
|
-
it "raise an unsupported error" do
|
40
|
-
name = "InvalidFont.ttf"
|
41
|
-
|
42
|
-
expect {
|
43
|
-
Fontist::Installer.download(name, confirmation: "yes")
|
44
|
-
}.to raise_error(Fontist::Errors::NonSupportedFontError)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
data/spec/fontist/source_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Fontist::Source do
|
4
|
-
describe ".all" do
|
5
|
-
it "returns all of the dataset" do
|
6
|
-
sources = Fontist::Source.all
|
7
|
-
|
8
|
-
expect(sources.system.linux.paths).not_to be_nil
|
9
|
-
expect(sources.system.macosx.paths).not_to be_nil
|
10
|
-
expect(sources.system.windows.paths).not_to be_nil
|
11
|
-
expect(sources.remote.formulas.first).to include("./formulas")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe ".formulas" do
|
16
|
-
it "returns all available dataset" do
|
17
|
-
formulas = Fontist::Source.formulas
|
18
|
-
|
19
|
-
expect(formulas.msvista.license).not_to be_nil
|
20
|
-
expect(formulas.msvista.file_size).to eq("62914560")
|
21
|
-
expect(formulas.msvista.fonts.map(&:name)).to include("Calibri")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|