fontist 1.2.1 → 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/fontist.gemspec +1 -0
- data/lib/fontist.rb +4 -0
- data/lib/fontist/font.rb +37 -2
- data/lib/fontist/registry.rb +1 -0
- data/lib/fontist/utils.rb +1 -0
- data/lib/fontist/utils/downloader.rb +5 -1
- data/lib/fontist/utils/ui.rb +15 -0
- data/lib/fontist/version.rb +1 -1
- data/spec/fontist/font_spec.rb +30 -4
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f45a43c4f700cd793576c4783b7098beea7d366c8aeb2654fcc5b6a38c986b0
|
4
|
+
data.tar.gz: 01ce25c4eae85e3fb20b7cdf0d106a04a2273e770a4261e937c344520a723651
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6aae04a73aa89e5a7919430cecf56a8da1361bbe7b4a40a5676abe1ca02cc011e95681b7520a2d0ec3f47dd793af48c462f9deb1377b2547ba5d5edbc8c864e4
|
7
|
+
data.tar.gz: 541d57da927636744955a5917ad39d57fe793bb37b0c31d167252da9efea8815c3675d2e998ed7ef585921415733e2b393de19f16be433d2ca62cfdbf0d00f02
|
data/fontist.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_runtime_dependency "down", "~> 5.0"
|
25
25
|
spec.add_runtime_dependency "libmspack", "~> 0.1.0"
|
26
26
|
spec.add_runtime_dependency "rubyzip", "~> 2.3.0"
|
27
|
+
spec.add_runtime_dependency "thor", "~> 1.0.1"
|
27
28
|
|
28
29
|
spec.add_development_dependency "pry"
|
29
30
|
spec.add_development_dependency "bundler", "~> 2.0"
|
data/lib/fontist.rb
CHANGED
data/lib/fontist/font.rb
CHANGED
@@ -62,17 +62,52 @@ module Fontist
|
|
62
62
|
if formula
|
63
63
|
raise(
|
64
64
|
Fontist::Errors::MissingFontError,
|
65
|
-
"Fonts are missing, please run " \
|
65
|
+
"#{name}" "Fonts are missing, please run " \
|
66
66
|
"Fontist::Font.install('#{name}', confirmation: 'yes') to " \
|
67
|
-
"download the font"
|
67
|
+
"download the font."
|
68
68
|
)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
def download_font
|
73
73
|
if formula
|
74
|
+
check_and_confirm_required_license(formula)
|
74
75
|
font_installer(formula).fetch_font(name, confirmation: confirmation)
|
75
76
|
end
|
76
77
|
end
|
78
|
+
|
79
|
+
def check_and_confirm_required_license(formula)
|
80
|
+
if formula.license_required && !confirmation.casecmp("yes").zero?
|
81
|
+
@confirmation = show_license_and_ask_for_input(formula.license)
|
82
|
+
|
83
|
+
if !confirmation.casecmp("yes").zero?
|
84
|
+
raise Fontist::Errors::LicensingError.new(
|
85
|
+
"Fontist will not download these fonts unless you accept the terms."
|
86
|
+
)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def show_license_and_ask_for_input(license)
|
92
|
+
Fontist.ui.say(license_agrement_message(license))
|
93
|
+
Fontist.ui.ask(
|
94
|
+
"\nDo you accept all presented font licenses, and want Fontist " \
|
95
|
+
"to download these fonts for you? => TYPE 'Yes' or 'No':"
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
def license_agrement_message(license)
|
100
|
+
<<~MSG
|
101
|
+
FONT LICENSE ACCEPTANCE REQUIRED FOR "#{name}":
|
102
|
+
|
103
|
+
Fontist can install this font if you accept its licensing conditions.
|
104
|
+
|
105
|
+
FONT LICENSE BEGIN ("#{name}")
|
106
|
+
-----------------------------------------------------------------------
|
107
|
+
#{license}
|
108
|
+
-----------------------------------------------------------------------
|
109
|
+
FONT LICENSE END ("#{name}")
|
110
|
+
MSG
|
111
|
+
end
|
77
112
|
end
|
78
113
|
end
|
data/lib/fontist/registry.rb
CHANGED
data/lib/fontist/utils.rb
CHANGED
@@ -4,8 +4,8 @@ module Fontist
|
|
4
4
|
def initialize(file, file_size: nil, sha: nil, progress_bar: nil)
|
5
5
|
# TODO: If the first mirror fails, try the second one
|
6
6
|
@file = file
|
7
|
-
@progress_bar = progress_bar
|
8
7
|
@sha = [sha].flatten.compact
|
8
|
+
@progress_bar = set_progress_bar(progress_bar)
|
9
9
|
@file_size = (file_size || default_file_size).to_i
|
10
10
|
end
|
11
11
|
|
@@ -42,6 +42,10 @@ module Fontist
|
|
42
42
|
options[:download_path] || Fontist.root_path.join("tmp")
|
43
43
|
end
|
44
44
|
|
45
|
+
def set_progress_bar(progress_bar)
|
46
|
+
ENV.fetch("TEST_ENV", "") === "CI" ? false : progress_bar
|
47
|
+
end
|
48
|
+
|
45
49
|
def download_file
|
46
50
|
bar = ProgressBar.new(file_size / byte_to_megabyte)
|
47
51
|
|
data/lib/fontist/version.rb
CHANGED
data/spec/fontist/font_spec.rb
CHANGED
@@ -46,13 +46,35 @@ RSpec.describe Fontist::Font do
|
|
46
46
|
|
47
47
|
describe ".install" do
|
48
48
|
context "with valid font name" do
|
49
|
-
it "installs
|
50
|
-
|
49
|
+
it "installs and returns paths for fonts with open license" do
|
50
|
+
stub_fontist_path_to_temp_path
|
51
|
+
|
52
|
+
font = { name: "Overpass Mono", filename: "overpass-mono-regular.otf" }
|
53
|
+
font_paths = Fontist::Font.install(font[:name], confirmation: "no")
|
54
|
+
|
55
|
+
expect(font_paths.join("|").downcase).to include(font[:filename])
|
56
|
+
end
|
51
57
|
|
58
|
+
it "install proprietary fonts with correct license agreement" do
|
52
59
|
stub_fontist_path_to_temp_path
|
53
|
-
|
60
|
+
stub_license_agreement_prompt_with("yes")
|
61
|
+
|
62
|
+
font = { name: "Calibri", filename: "calibri.ttf" }
|
63
|
+
font_paths = Fontist::Font.install(font[:name])
|
64
|
+
|
65
|
+
expect(font_paths.join("|").downcase).to include(font[:filename])
|
66
|
+
end
|
67
|
+
|
68
|
+
it "raises error for missing license agreement" do
|
69
|
+
stub_fontist_path_to_temp_path
|
70
|
+
stub_license_agreement_prompt_with("no")
|
54
71
|
|
55
|
-
|
72
|
+
font = { name: "Calibri", filename: "calibri.ttf" }
|
73
|
+
allow(Fontist::SystemFont).to receive(:find).and_return(nil)
|
74
|
+
|
75
|
+
expect { Fontist::Font.install(font[:name]) }.to raise_error(
|
76
|
+
Fontist::Errors::LicensingError
|
77
|
+
)
|
56
78
|
end
|
57
79
|
end
|
58
80
|
|
@@ -84,4 +106,8 @@ RSpec.describe Fontist::Font do
|
|
84
106
|
allow(Fontist::SystemFont).to receive(:find).
|
85
107
|
and_return(["spec/fixtures/fonts/#{name}"])
|
86
108
|
end
|
109
|
+
|
110
|
+
def stub_license_agreement_prompt_with(confirmation = "yes")
|
111
|
+
allow(Fontist.ui).to receive(:ask).and_return(confirmation)
|
112
|
+
end
|
87
113
|
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: 1.
|
4
|
+
version: 1.3.0
|
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-08-
|
12
|
+
date: 2020-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: down
|
@@ -53,6 +53,20 @@ dependencies:
|
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 2.3.0
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: thor
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.0.1
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.0.1
|
56
70
|
- !ruby/object:Gem::Dependency
|
57
71
|
name: pry
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,6 +173,7 @@ files:
|
|
159
173
|
- lib/fontist/utils/downloader.rb
|
160
174
|
- lib/fontist/utils/dsl.rb
|
161
175
|
- lib/fontist/utils/exe_extractor.rb
|
176
|
+
- lib/fontist/utils/ui.rb
|
162
177
|
- lib/fontist/utils/zip_extractor.rb
|
163
178
|
- lib/fontist/version.rb
|
164
179
|
- spec/fixtures/fonts/DejaVuSerif.ttf
|
@@ -209,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
224
|
- !ruby/object:Gem::Version
|
210
225
|
version: '0'
|
211
226
|
requirements: []
|
212
|
-
rubygems_version: 3.0.
|
227
|
+
rubygems_version: 3.0.4
|
213
228
|
signing_key:
|
214
229
|
specification_version: 4
|
215
230
|
summary: A libarary find or download fonts
|