fontist 0.1.0 → 1.1.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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macosx.yml +30 -0
  3. data/.github/workflows/ubuntu.yml +2 -2
  4. data/.github/workflows/windows.yml +32 -0
  5. data/.gitignore +4 -0
  6. data/README.md +97 -1
  7. data/bin/console +2 -5
  8. data/fontist.gemspec +5 -0
  9. data/lib/fontist.rb +44 -2
  10. data/lib/fontist/errors.rb +9 -0
  11. data/lib/fontist/font.rb +78 -0
  12. data/lib/fontist/font_formula.rb +123 -0
  13. data/lib/fontist/formula.rb +90 -0
  14. data/lib/fontist/formulas.rb +15 -0
  15. data/lib/fontist/formulas/andale_font.rb +79 -0
  16. data/lib/fontist/formulas/arial_black_font.rb +78 -0
  17. data/lib/fontist/formulas/cleartype_fonts.rb +226 -0
  18. data/lib/fontist/formulas/comic_font.rb +77 -0
  19. data/lib/fontist/formulas/courier_font.rb +80 -0
  20. data/lib/fontist/formulas/euphemia_font.rb +85 -0
  21. data/lib/fontist/formulas/georgia_font.rb +79 -0
  22. data/lib/fontist/formulas/impact_font.rb +77 -0
  23. data/lib/fontist/formulas/montserrat_font.rb +132 -0
  24. data/lib/fontist/formulas/ms_truetype_fonts.rb +124 -0
  25. data/lib/fontist/formulas/open_sans_fonts.rb +263 -0
  26. data/lib/fontist/formulas/overpass_font.rb +73 -0
  27. data/lib/fontist/formulas/source_fonts.rb +109 -0
  28. data/lib/fontist/formulas/stix_fonts.rb +108 -0
  29. data/lib/fontist/formulas/tahoma_font.rb +147 -0
  30. data/lib/fontist/formulas/webding_font.rb +77 -0
  31. data/lib/fontist/registry.rb +42 -0
  32. data/lib/fontist/system.yml +17 -0
  33. data/lib/fontist/system_font.rb +72 -0
  34. data/lib/fontist/utils.rb +9 -0
  35. data/lib/fontist/utils/downloader.rb +72 -0
  36. data/lib/fontist/utils/dsl.rb +77 -0
  37. data/lib/fontist/utils/exe_extractor.rb +72 -0
  38. data/lib/fontist/utils/zip_extractor.rb +38 -0
  39. data/lib/fontist/version.rb +1 -1
  40. data/spec/fontist/font_formula_spec.rb +67 -0
  41. data/spec/fontist/font_spec.rb +87 -0
  42. data/spec/fontist/formula_spec.rb +67 -0
  43. data/spec/fontist/formulas/andale_font_spec.rb +29 -0
  44. data/spec/fontist/formulas/arial_black_font_spec.rb +29 -0
  45. data/spec/fontist/formulas/cleartype_fonts_spec.rb +38 -0
  46. data/spec/fontist/formulas/comic_font_spec.rb +29 -0
  47. data/spec/fontist/formulas/courier_font_spec.rb +29 -0
  48. data/spec/fontist/formulas/euphemia_font_spec.rb +29 -0
  49. data/spec/fontist/formulas/georgia_font_spec.rb +29 -0
  50. data/spec/fontist/formulas/impact_font_spec.rb +29 -0
  51. data/spec/fontist/formulas/montserrat_font_spec.rb +29 -0
  52. data/spec/fontist/formulas/ms_truetype_fonts_spec.rb +29 -0
  53. data/spec/fontist/formulas/open_sans_fonts_spec.rb +29 -0
  54. data/spec/fontist/formulas/overpass_font_spec.rb +29 -0
  55. data/spec/fontist/formulas/source_fonts_spec.rb +31 -0
  56. data/spec/fontist/formulas/stix_fonts_spec.rb +29 -0
  57. data/spec/fontist/formulas/tahoma_font_spec.rb +29 -0
  58. data/spec/fontist/formulas/webding_font_spec.rb +29 -0
  59. data/spec/fontist/registry_spec.rb +47 -0
  60. data/spec/fontist/system_font_spec.rb +44 -0
  61. data/spec/fontist/utils/downloader_spec.rb +35 -0
  62. data/spec/spec_helper.rb +8 -0
  63. data/spec/support/fontist_helper.rb +10 -0
  64. metadata +113 -2
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fontist::Formulas::StixFont do
4
+ describe "initializing" do
5
+ it "builds the data dictionary" do
6
+ formula = Fontist::Formulas::StixFont.instance
7
+
8
+ expect(formula.fonts.count).to eq(2)
9
+ expect(formula.fonts.first[:name]).to eq("STIX Two Math")
10
+ end
11
+ end
12
+
13
+ describe "installation" do
14
+ context "with valid licence agreement" do
15
+ it "installs the valid fonts" do
16
+ name = "STIX Two Math"
17
+ confirmation = "yes"
18
+
19
+ stub_fontist_path_to_temp_path
20
+ paths = Fontist::Formulas::StixFont.fetch_font(
21
+ name, confirmation: confirmation
22
+ )
23
+
24
+ expect(Fontist::Font.find(name)).not_to be_empty
25
+ expect(paths.first).to include("fonts/STIX2Math.otf")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fontist::Formulas::TahomaFont do
4
+ describe "initializing" do
5
+ it "builds the data dictionary" do
6
+ formula = Fontist::Formulas::TahomaFont.instance
7
+
8
+ expect(formula.fonts.count).to eq(1)
9
+ expect(formula.fonts.first[:name]).to eq("Tahoma")
10
+ end
11
+ end
12
+
13
+ describe "installation" do
14
+ context "with valid licence agreement", slow: true do
15
+ it "installs the valid fonts", skip_in_windows: true do
16
+ name = "Tahoma"
17
+ confirmation = "yes"
18
+
19
+ stub_fontist_path_to_temp_path
20
+ paths = Fontist::Formulas::TahomaFont.fetch_font(
21
+ name, confirmation: confirmation
22
+ )
23
+
24
+ expect(Fontist::Font.find(name)).not_to be_empty
25
+ expect(paths.first).to include("fonts/#{name.downcase}.ttf")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fontist::Formulas::WebdingFont do
4
+ describe "initializing" do
5
+ it "builds the data dictionary" do
6
+ formula = Fontist::Formulas::WebdingFont.instance
7
+
8
+ expect(formula.fonts.count).to eq(1)
9
+ expect(formula.fonts.first[:name]).to eq("Webdings")
10
+ end
11
+ end
12
+
13
+ describe "installation" do
14
+ context "with valid licence agreement", slow: true do
15
+ it "installs the valid fonts", skip_in_windows: true do
16
+ name = "Webdings"
17
+ confirmation = "yes"
18
+
19
+ stub_fontist_path_to_temp_path
20
+ paths = Fontist::Formulas::WebdingFont.fetch_font(
21
+ name, confirmation: confirmation
22
+ )
23
+
24
+ expect(Fontist::Font.find(name)).not_to be_empty
25
+ expect(paths.first).to include("fonts/#{name}.TTF")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,47 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fontist::Registry do
4
+ describe ".register" do
5
+ context "with no key provided" do
6
+ it "registers a fontist formula with default key" do
7
+ Fontist::Registry.register(Fontist::Formulas::DemoFormula)
8
+ demo_formula = Fontist::Registry.formulas.demo_formula
9
+
10
+ expect(demo_formula.license).to eq("Vendor specific font licences")
11
+ expect(demo_formula.fonts.first.styles.first.type).to eq("Regular")
12
+ expect(demo_formula.installer).to eq("Fontist::Formulas::DemoFormula")
13
+ expect(demo_formula.homepage).to eq("https://github.com/fontist/fontist")
14
+ end
15
+ end
16
+
17
+ context "with custom key provided" do
18
+ it "registers the formula with this custom key" do
19
+ Fontist::Registry.register(Fontist::Formulas::DemoFormula, :custom_key)
20
+
21
+ expect(Fontist::Registry.formulas.custom_key).not_to be_nil
22
+ end
23
+ end
24
+ end
25
+
26
+ module Fontist
27
+ module Formulas
28
+ class DemoFormula < FontFormula
29
+ key :demo_formula
30
+ desc "Demo font formula"
31
+ homepage "https://github.com/fontist/fontist"
32
+ requires_license_agreement "Vendor specific font licences"
33
+
34
+ resource "demo-formula" do
35
+ urls [ "https://github.com/fontist/fontist" ]
36
+ sha256 "594e0f42e6581add4dead70c1dfb9"
37
+ file_size "1234567890"
38
+ end
39
+
40
+ provides_font "Demo font", match_styles_from_file: {
41
+ "Regular" => "demo-font.ttf",
42
+ "Italic" => "demo-fonti.ttf"
43
+ }
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,44 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fontist::SystemFont do
4
+ describe ".find" do
5
+ context "with a vlaid existing font" do
6
+ it "returns the complete font path" do
7
+ name = "DejaVuSerif.ttf"
8
+ dejavu_ttf = Fontist::SystemFont.find(name, sources: [font_sources])
9
+
10
+ expect(dejavu_ttf).not_to be_nil
11
+ expect(dejavu_ttf.first).to include("spec/fixtures/fonts/")
12
+ end
13
+ end
14
+
15
+ context "with valid font name" do
16
+ it "returns the complete font path", slow: true do
17
+ name = "Calibri"
18
+ stub_fontist_path_to_temp_path
19
+ Fontist::Formulas::ClearTypeFonts.fetch_font(name, confirmation: "yes")
20
+
21
+ calbiri = Fontist::SystemFont.find(name, sources: [font_sources])
22
+ expect(calbiri.join("|").downcase).to include("#{name.downcase}.ttf")
23
+ end
24
+ end
25
+
26
+ context "with invalid font" do
27
+ it "returns nil for partial-not match" do
28
+ name = "Deje"
29
+ expect(Fontist::SystemFont.find(name)).to be_nil
30
+ end
31
+
32
+ it "returns nill to the caller" do
33
+ name = "invalid-font.ttf"
34
+ invalid_font = Fontist::SystemFont.find(name, sources: [font_sources])
35
+
36
+ expect(invalid_font).to be_nil
37
+ end
38
+ end
39
+ end
40
+
41
+ def font_sources
42
+ @font_sources ||= Fontist.root_path.join("spec/fixtures/fonts/*")
43
+ end
44
+ end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fontist::Utils::Downloader do
4
+ describe ".download" do
5
+ it "return the valid downloaded file" do
6
+ tempfile = Fontist::Utils::Downloader.download(
7
+ sample_file[:file],
8
+ sha: sample_file[:sha],
9
+ file_size: sample_file[:file_size],
10
+ )
11
+
12
+ expect(tempfile).not_to be_nil
13
+ expect(tempfile.size).to eq(sample_file[:file_size])
14
+ end
15
+
16
+ it "raises an error for tempared file" do
17
+ expect{
18
+ Fontist::Utils::Downloader.download(
19
+ sample_file[:file],
20
+ sha: sample_file[:sha] + "mm",
21
+ file_size: sample_file[:file_size]
22
+ )
23
+ }.to raise_error(Fontist::Errors::TemparedFileError)
24
+ end
25
+ end
26
+
27
+ def sample_file
28
+ @sample_file ||= {
29
+ file_size: 150899,
30
+ file: "https://drive.google.com/u/0/uc?id=1Kk-rpLyQk98ubgxhTRKD2ZkMoY9KqKXk&export=download",
31
+ sha: "5e513e4bfdada0ff10dd5b96414fcaeade84e235ce043865416ad7673cb6f3d8"
32
+ }
33
+ end
34
+ end
35
+
@@ -1,13 +1,21 @@
1
1
  require "bundler/setup"
2
2
  require "fontist"
3
3
 
4
+ Dir["./spec/support/**/*.rb"].sort.each { |file| require file }
5
+
4
6
  RSpec.configure do |config|
5
7
  # Enable flags like --only-failures and --next-failure
6
8
  config.example_status_persistence_file_path = ".rspec_status"
9
+ config.include Fontist::Helper
7
10
 
8
11
  # Disable RSpec exposing methods globally on `Module` and `main`
9
12
  config.disable_monkey_patching!
10
13
 
14
+ # Skip the slow tests locally
15
+ unless ENV.fetch("TEST_ENV", "local").upcase === "CI"
16
+ config.filter_run_excluding slow: true
17
+ end
18
+
11
19
  config.expect_with :rspec do |c|
12
20
  c.syntax = :expect
13
21
  end
@@ -0,0 +1,10 @@
1
+ module Fontist
2
+ module Helper
3
+ def stub_fontist_path_to_temp_path
4
+ allow(Fontist).to receive(:fontist_path).and_return(
5
+ Fontist.root_path.join("spec", "fixtures")
6
+ )
7
+ end
8
+ end
9
+ end
10
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -9,8 +9,64 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-26 00:00:00.000000000 Z
12
+ date: 2020-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: down
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '5.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '5.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: libmspack
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.1.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.1.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: rubyzip
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 2.3.0
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 2.3.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: pry
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
14
70
  - !ruby/object:Gem::Dependency
15
71
  name: bundler
16
72
  requirement: !ruby/object:Gem::Requirement
@@ -61,7 +117,9 @@ executables: []
61
117
  extensions: []
62
118
  extra_rdoc_files: []
63
119
  files:
120
+ - ".github/workflows/macosx.yml"
64
121
  - ".github/workflows/ubuntu.yml"
122
+ - ".github/workflows/windows.yml"
65
123
  - ".gitignore"
66
124
  - ".rspec"
67
125
  - Gemfile
@@ -73,9 +131,62 @@ files:
73
131
  - bin/setup
74
132
  - fontist.gemspec
75
133
  - lib/fontist.rb
134
+ - lib/fontist/errors.rb
135
+ - lib/fontist/font.rb
136
+ - lib/fontist/font_formula.rb
137
+ - lib/fontist/formula.rb
138
+ - lib/fontist/formulas.rb
139
+ - lib/fontist/formulas/andale_font.rb
140
+ - lib/fontist/formulas/arial_black_font.rb
141
+ - lib/fontist/formulas/cleartype_fonts.rb
142
+ - lib/fontist/formulas/comic_font.rb
143
+ - lib/fontist/formulas/courier_font.rb
144
+ - lib/fontist/formulas/euphemia_font.rb
145
+ - lib/fontist/formulas/georgia_font.rb
146
+ - lib/fontist/formulas/impact_font.rb
147
+ - lib/fontist/formulas/montserrat_font.rb
148
+ - lib/fontist/formulas/ms_truetype_fonts.rb
149
+ - lib/fontist/formulas/open_sans_fonts.rb
150
+ - lib/fontist/formulas/overpass_font.rb
151
+ - lib/fontist/formulas/source_fonts.rb
152
+ - lib/fontist/formulas/stix_fonts.rb
153
+ - lib/fontist/formulas/tahoma_font.rb
154
+ - lib/fontist/formulas/webding_font.rb
155
+ - lib/fontist/registry.rb
156
+ - lib/fontist/system.yml
157
+ - lib/fontist/system_font.rb
158
+ - lib/fontist/utils.rb
159
+ - lib/fontist/utils/downloader.rb
160
+ - lib/fontist/utils/dsl.rb
161
+ - lib/fontist/utils/exe_extractor.rb
162
+ - lib/fontist/utils/zip_extractor.rb
76
163
  - lib/fontist/version.rb
164
+ - spec/fixtures/fonts/DejaVuSerif.ttf
165
+ - spec/fontist/font_formula_spec.rb
166
+ - spec/fontist/font_spec.rb
167
+ - spec/fontist/formula_spec.rb
168
+ - spec/fontist/formulas/andale_font_spec.rb
169
+ - spec/fontist/formulas/arial_black_font_spec.rb
170
+ - spec/fontist/formulas/cleartype_fonts_spec.rb
171
+ - spec/fontist/formulas/comic_font_spec.rb
172
+ - spec/fontist/formulas/courier_font_spec.rb
173
+ - spec/fontist/formulas/euphemia_font_spec.rb
174
+ - spec/fontist/formulas/georgia_font_spec.rb
175
+ - spec/fontist/formulas/impact_font_spec.rb
176
+ - spec/fontist/formulas/montserrat_font_spec.rb
177
+ - spec/fontist/formulas/ms_truetype_fonts_spec.rb
178
+ - spec/fontist/formulas/open_sans_fonts_spec.rb
179
+ - spec/fontist/formulas/overpass_font_spec.rb
180
+ - spec/fontist/formulas/source_fonts_spec.rb
181
+ - spec/fontist/formulas/stix_fonts_spec.rb
182
+ - spec/fontist/formulas/tahoma_font_spec.rb
183
+ - spec/fontist/formulas/webding_font_spec.rb
184
+ - spec/fontist/registry_spec.rb
185
+ - spec/fontist/system_font_spec.rb
186
+ - spec/fontist/utils/downloader_spec.rb
77
187
  - spec/fontist_spec.rb
78
188
  - spec/spec_helper.rb
189
+ - spec/support/fontist_helper.rb
79
190
  homepage: https://github.com/fontist/fontist
80
191
  licenses:
81
192
  - BSD-2-Clause