fontist 0.3.0 → 1.2.1

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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macosx.yml +1 -1
  3. data/.github/workflows/ubuntu.yml +1 -1
  4. data/.gitignore +4 -2
  5. data/README.md +91 -5
  6. data/lib/fontist.rb +26 -12
  7. data/lib/fontist/errors.rb +3 -1
  8. data/lib/fontist/font.rb +78 -0
  9. data/lib/fontist/font_formula.rb +123 -0
  10. data/lib/fontist/formula.rb +90 -0
  11. data/lib/fontist/formulas.rb +10 -3
  12. data/lib/fontist/formulas/andale_font.rb +80 -0
  13. data/lib/fontist/formulas/arial_black_font.rb +79 -0
  14. data/lib/fontist/formulas/cleartype_fonts.rb +227 -0
  15. data/lib/fontist/formulas/comic_font.rb +78 -0
  16. data/lib/fontist/formulas/courier_font.rb +81 -0
  17. data/lib/fontist/formulas/euphemia_font.rb +85 -0
  18. data/lib/fontist/formulas/georgia_font.rb +80 -0
  19. data/lib/fontist/formulas/impact_font.rb +78 -0
  20. data/lib/fontist/formulas/montserrat_font.rb +132 -0
  21. data/lib/fontist/formulas/ms_truetype_fonts.rb +125 -0
  22. data/lib/fontist/formulas/open_sans_fonts.rb +263 -0
  23. data/lib/fontist/formulas/overpass_font.rb +73 -0
  24. data/lib/fontist/formulas/source_fonts.rb +109 -0
  25. data/lib/fontist/formulas/stix_fonts.rb +108 -0
  26. data/lib/fontist/formulas/tahoma_font.rb +147 -0
  27. data/lib/fontist/formulas/webding_font.rb +78 -0
  28. data/lib/fontist/registry.rb +42 -0
  29. data/lib/fontist/{data/source.yml → system.yml} +5 -6
  30. data/lib/fontist/system_font.rb +27 -11
  31. data/lib/fontist/utils.rb +9 -0
  32. data/lib/fontist/utils/downloader.rb +75 -0
  33. data/lib/fontist/utils/dsl.rb +77 -0
  34. data/lib/fontist/utils/exe_extractor.rb +72 -0
  35. data/lib/fontist/utils/zip_extractor.rb +38 -0
  36. data/lib/fontist/version.rb +1 -1
  37. data/spec/fontist/font_formula_spec.rb +67 -0
  38. data/spec/fontist/font_spec.rb +87 -0
  39. data/spec/fontist/formula_spec.rb +67 -0
  40. data/spec/fontist/formulas/andale_font_spec.rb +29 -0
  41. data/spec/fontist/formulas/arial_black_font_spec.rb +29 -0
  42. data/spec/fontist/formulas/cleartype_fonts_spec.rb +38 -0
  43. data/spec/fontist/formulas/comic_font_spec.rb +29 -0
  44. data/spec/fontist/formulas/courier_font_spec.rb +29 -0
  45. data/spec/fontist/formulas/euphemia_font_spec.rb +29 -0
  46. data/spec/fontist/formulas/georgia_font_spec.rb +29 -0
  47. data/spec/fontist/formulas/impact_font_spec.rb +29 -0
  48. data/spec/fontist/formulas/montserrat_font_spec.rb +29 -0
  49. data/spec/fontist/formulas/ms_truetype_fonts_spec.rb +29 -0
  50. data/spec/fontist/formulas/open_sans_fonts_spec.rb +29 -0
  51. data/spec/fontist/formulas/overpass_font_spec.rb +29 -0
  52. data/spec/fontist/formulas/source_fonts_spec.rb +31 -0
  53. data/spec/fontist/formulas/stix_fonts_spec.rb +29 -0
  54. data/spec/fontist/formulas/tahoma_font_spec.rb +29 -0
  55. data/spec/fontist/formulas/webding_font_spec.rb +29 -0
  56. data/spec/fontist/registry_spec.rb +47 -0
  57. data/spec/fontist/system_font_spec.rb +17 -1
  58. data/spec/fontist/{downloader_spec.rb → utils/downloader_spec.rb} +6 -5
  59. data/spec/spec_helper.rb +4 -2
  60. data/spec/support/fontist_helper.rb +4 -2
  61. metadata +50 -20
  62. data/lib/fontist/data/formulas/ms_vista.yml +0 -39
  63. data/lib/fontist/data/formulas/source_font.yml +0 -51
  64. data/lib/fontist/downloader.rb +0 -70
  65. data/lib/fontist/finder.rb +0 -47
  66. data/lib/fontist/formulas/base.rb +0 -25
  67. data/lib/fontist/formulas/ms_vista.rb +0 -74
  68. data/lib/fontist/formulas/source_font.rb +0 -48
  69. data/lib/fontist/installer.rb +0 -47
  70. data/lib/fontist/source.rb +0 -58
  71. data/spec/fontist/finder_spec.rb +0 -41
  72. data/spec/fontist/formulas/ms_vista_spec.rb +0 -27
  73. data/spec/fontist/formulas/source_font_spec.rb +0 -18
  74. data/spec/fontist/installer_spec.rb +0 -48
  75. data/spec/fontist/source_spec.rb +0 -24
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fontist::Formulas::OpenSansFonts do
4
+ describe "initializing" do
5
+ it "builds the data dictionary" do
6
+ formula = Fontist::Formulas::OpenSansFonts.instance
7
+
8
+ expect(formula.fonts.count).to eq(1)
9
+ expect(formula.fonts.first[:name]).to eq("OpenSans")
10
+ end
11
+ end
12
+
13
+ describe "installation" do
14
+ context "with valid licence agreement", slow: true do
15
+ it "installs the valid fonts" do
16
+ name = "OpenSans"
17
+ confirmation = "yes"
18
+
19
+ stub_fontist_path_to_temp_path
20
+ paths = Fontist::Formulas::OpenSansFonts.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}-Light.ttf")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fontist::Formulas::OverpassFont do
4
+ describe "initializing" do
5
+ it "builds the data dictionary" do
6
+ formula = Fontist::Formulas::OverpassFont.instance
7
+
8
+ expect(formula.fonts.count).to eq(2)
9
+ expect(formula.fonts.first[:name]).to eq("Overpass")
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 = "Overpass"
17
+ confirmation = "yes"
18
+
19
+ stub_fontist_path_to_temp_path
20
+ paths = Fontist::Formulas::OverpassFont.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}-bold-italic.otf")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fontist::Formulas::SourceFonts do
4
+ describe "initializing" do
5
+ it "builds the data dictionary" do
6
+ formula = Fontist::Formulas::SourceFonts.instance
7
+
8
+ expect(formula.fonts.count).to eq(33)
9
+ expect(formula.fonts.first[:name]).to eq("Source Code Pro")
10
+ end
11
+ end
12
+
13
+ describe "installation" do
14
+ context "with valid licence agreement", slow: true do
15
+ it "installs the valid fonts" do
16
+ name = "Source Code Pro"
17
+ confirmation = "yes"
18
+
19
+ stub_fontist_path_to_temp_path
20
+ paths = Fontist::Formulas::SourceFonts.fetch_font(
21
+ name, confirmation: confirmation
22
+ )
23
+
24
+ expect(Fontist::Font.find(name)).not_to be_empty
25
+ expect(paths).to include(
26
+ Fontist.fonts_path.join("SourceCodePro-Black.ttf").to_s
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
@@ -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
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe Fontist::SystemFont do
4
4
  describe ".find" do
5
- context "with a vlaid existing font" do
5
+ context "with a valid existing font" do
6
6
  it "returns the complete font path" do
7
7
  name = "DejaVuSerif.ttf"
8
8
  dejavu_ttf = Fontist::SystemFont.find(name, sources: [font_sources])
@@ -12,7 +12,23 @@ RSpec.describe Fontist::SystemFont do
12
12
  end
13
13
  end
14
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
+
15
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
+
16
32
  it "returns nill to the caller" do
17
33
  name = "invalid-font.ttf"
18
34
  invalid_font = Fontist::SystemFont.find(name, sources: [font_sources])
@@ -1,8 +1,9 @@
1
1
  require "spec_helper"
2
- RSpec.describe Fontist::Downloader do
3
- describe ".download", file_download: true do
2
+
3
+ RSpec.describe Fontist::Utils::Downloader do
4
+ describe ".download" do
4
5
  it "return the valid downloaded file" do
5
- tempfile = Fontist::Downloader.download(
6
+ tempfile = Fontist::Utils::Downloader.download(
6
7
  sample_file[:file],
7
8
  sha: sample_file[:sha],
8
9
  file_size: sample_file[:file_size],
@@ -14,12 +15,12 @@ RSpec.describe Fontist::Downloader do
14
15
 
15
16
  it "raises an error for tempared file" do
16
17
  expect{
17
- Fontist::Downloader.download(
18
+ Fontist::Utils::Downloader.download(
18
19
  sample_file[:file],
19
20
  sha: sample_file[:sha] + "mm",
20
21
  file_size: sample_file[:file_size]
21
22
  )
22
- }.to raise_error(Fontist::Errors::TemparedFileError)
23
+ }.to raise_error(Fontist::Errors::TamperedFileError)
23
24
  end
24
25
  end
25
26
 
@@ -11,8 +11,10 @@ RSpec.configure do |config|
11
11
  # Disable RSpec exposing methods globally on `Module` and `main`
12
12
  config.disable_monkey_patching!
13
13
 
14
- # Skip the actual file_download by default
15
- config.filter_run_excluding file_download: true
14
+ # Skip the slow tests locally
15
+ unless ENV.fetch("TEST_ENV", "local").upcase === "CI"
16
+ config.filter_run_excluding slow: true
17
+ end
16
18
 
17
19
  config.expect_with :rspec do |c|
18
20
  c.syntax = :expect
@@ -1,7 +1,9 @@
1
1
  module Fontist
2
2
  module Helper
3
- def stub_fontist_path_to_assets
4
- allow(Fontist).to receive(:fontist_path).and_return(Fontist.assets_path)
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
+ )
5
7
  end
6
8
  end
7
9
  end
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.3.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-05-08 00:00:00.000000000 Z
12
+ date: 2020-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: down
@@ -126,34 +126,64 @@ files:
126
126
  - LICENSE.txt
127
127
  - README.md
128
128
  - Rakefile
129
- - assets/fonts/.keep
130
129
  - bin/console
131
130
  - bin/rspec
132
131
  - bin/setup
133
132
  - fontist.gemspec
134
133
  - lib/fontist.rb
135
- - lib/fontist/data/formulas/ms_vista.yml
136
- - lib/fontist/data/formulas/source_font.yml
137
- - lib/fontist/data/source.yml
138
- - lib/fontist/downloader.rb
139
134
  - lib/fontist/errors.rb
140
- - lib/fontist/finder.rb
135
+ - lib/fontist/font.rb
136
+ - lib/fontist/font_formula.rb
137
+ - lib/fontist/formula.rb
141
138
  - lib/fontist/formulas.rb
142
- - lib/fontist/formulas/base.rb
143
- - lib/fontist/formulas/ms_vista.rb
144
- - lib/fontist/formulas/source_font.rb
145
- - lib/fontist/installer.rb
146
- - lib/fontist/source.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
147
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
148
163
  - lib/fontist/version.rb
149
164
  - spec/fixtures/fonts/DejaVuSerif.ttf
150
- - spec/fontist/downloader_spec.rb
151
- - spec/fontist/finder_spec.rb
152
- - spec/fontist/formulas/ms_vista_spec.rb
153
- - spec/fontist/formulas/source_font_spec.rb
154
- - spec/fontist/installer_spec.rb
155
- - spec/fontist/source_spec.rb
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
156
185
  - spec/fontist/system_font_spec.rb
186
+ - spec/fontist/utils/downloader_spec.rb
157
187
  - spec/fontist_spec.rb
158
188
  - spec/spec_helper.rb
159
189
  - spec/support/fontist_helper.rb
@@ -179,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
209
  - !ruby/object:Gem::Version
180
210
  version: '0'
181
211
  requirements: []
182
- rubygems_version: 3.0.4
212
+ rubygems_version: 3.0.3
183
213
  signing_key:
184
214
  specification_version: 4
185
215
  summary: A libarary find or download fonts
@@ -1,39 +0,0 @@
1
- msvista:
2
- agreement: "yes"
3
-
4
- fonts:
5
- - CALIBRI.TTF
6
- - CALIBRII.TTF
7
- - CAMBRIA.TTC
8
- - CAMBRIAI.TTF
9
- - CANDARA.TTF
10
- - CANDARAI.TTF
11
- - CONSOLA.TTF
12
- - CONSOLAI.TTF
13
- - CONSTAN.TTF
14
- - CONSTANI.TTF
15
- - CORBEL.TTF
16
- - CORBELI.TTF
17
- - MEIRYO.TTC
18
- - CALIBRIB.TTF
19
- - CALIBRIZ.TTF
20
- - CAMBRIAB.TTF
21
- - CAMBRIAZ.TTF
22
- - CANDARAB.TTF
23
- - CANDARAZ.TTF
24
- - CONSOLAB.TTF
25
- - CONSOLAZ.TTF
26
- - CONSTANB.TTF
27
- - CONSTANZ.TTF
28
- - CORBELB.TTF
29
- - CORBELZ.TTF
30
- - MEIRYOB.TTC
31
-
32
- file_size: "62914560"
33
- sha: "249473568eba7a1e4f95498acba594e0f42e6581add4dead70c1dfb908a09423"
34
- urls:
35
- - "https://www.dropbox.com/s/dl/6lclhxpydwgkjzh/PowerPointViewer.exe?dl=1"
36
- - "https://web.archive.org/web/20171225132744/http://download.microsoft.com/download/E/6/7/E675FFFC-2A6D-4AB0-B3EB-27C9F8C8F696/PowerPointViewer.exe"
37
-
38
- license: |
39
- Complete MS licence;