bigcartel-theme-fonts 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 +4 -4
- data/bigcartel-theme-fonts.gemspec +1 -1
- data/lib/bigcartel/theme/fonts/theme_font.rb +5 -5
- data/spec/theme_font_spec.rb +14 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d58b062226017f9cf542de6c90d1cdb4a2f6ffc780948745c497d7b0384ef4a1
|
4
|
+
data.tar.gz: a1f4600d2e543286f9a4312216387b183b0534734cc66bef62155a3a0f0ab2fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cc9c664c5678b0005512f22cfcf23f142bf158838adf52042535da9468a7a6a1d7c98d8841a034e5ed5b48b9acf9d132df2beb69aa38dfb10a03a10fbdcd3cf
|
7
|
+
data.tar.gz: 15cccfc9483a7391b06cc7fee064fdbc9f0e452ef02b933f71562c7f31ce560eadca6f1c38a9b9b58047a87c51f3cfe0b4e8388f260372e18eb747bef5564b8b
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'bigcartel-theme-fonts'
|
7
|
-
spec.version = '1.8.
|
7
|
+
spec.version = '1.8.2'
|
8
8
|
spec.authors = ['Big Cartel']
|
9
9
|
spec.email = ['dev@bigcartel.com']
|
10
10
|
spec.description = %q{A simple class for working with Big Cartel's supported theme fonts.}
|
@@ -69,12 +69,12 @@ class ThemeFont < Struct.new(:name, :family, :weights, :collection)
|
|
69
69
|
def google_font_url_for_theme_json(account_theme)
|
70
70
|
# Cosmos and Lunch Break use the secondary font for the primary text font
|
71
71
|
font_setting = if ["cosmos", "lunch break"].include?(account_theme.theme.name.downcase)
|
72
|
-
account_theme.settings[
|
72
|
+
account_theme.settings[:secondary_font]
|
73
73
|
else
|
74
|
-
account_theme.settings[
|
75
|
-
account_theme.settings[
|
76
|
-
account_theme.settings[
|
77
|
-
account_theme.settings[
|
74
|
+
account_theme.settings[:primary_font] ||
|
75
|
+
account_theme.settings[:text_font] ||
|
76
|
+
account_theme.settings[:font] ||
|
77
|
+
account_theme.settings[:serif_font]
|
78
78
|
end
|
79
79
|
|
80
80
|
font = find_by_name(font_setting)
|
data/spec/theme_font_spec.rb
CHANGED
@@ -158,7 +158,7 @@ describe ThemeFont do
|
|
158
158
|
|
159
159
|
context "with default theme" do
|
160
160
|
it "uses primary_font when present" do
|
161
|
-
stub(account_theme).settings { {
|
161
|
+
stub(account_theme).settings { { primary_font: "One Font" } }
|
162
162
|
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
163
163
|
result.should == {
|
164
164
|
"primary_text_font" => "https://fonts.googleapis.com/css?family=One+Font"
|
@@ -167,7 +167,7 @@ describe ThemeFont do
|
|
167
167
|
|
168
168
|
context "font setting fallback stack" do
|
169
169
|
it "falls back to text_font when primary_font is absent" do
|
170
|
-
stub(account_theme).settings { {
|
170
|
+
stub(account_theme).settings { { text_font: "Three" } }
|
171
171
|
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
172
172
|
result.should == {
|
173
173
|
"primary_text_font" => "https://fonts.googleapis.com/css?family=Three"
|
@@ -175,7 +175,7 @@ describe ThemeFont do
|
|
175
175
|
end
|
176
176
|
|
177
177
|
it "falls back to font when primary_font and text_font are absent" do
|
178
|
-
stub(account_theme).settings { {
|
178
|
+
stub(account_theme).settings { { font: "One Font" } }
|
179
179
|
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
180
180
|
result.should == {
|
181
181
|
"primary_text_font" => "https://fonts.googleapis.com/css?family=One+Font"
|
@@ -183,7 +183,7 @@ describe ThemeFont do
|
|
183
183
|
end
|
184
184
|
|
185
185
|
it "falls back to serif_font when all others are absent" do
|
186
|
-
stub(account_theme).settings { {
|
186
|
+
stub(account_theme).settings { { serif_font:"Three" } }
|
187
187
|
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
188
188
|
result.should == {
|
189
189
|
"primary_text_font" => "https://fonts.googleapis.com/css?family=Three"
|
@@ -192,10 +192,10 @@ describe ThemeFont do
|
|
192
192
|
|
193
193
|
it "prefers primary_font over other settings" do
|
194
194
|
stub(account_theme).settings { {
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
195
|
+
primary_font: "One Font",
|
196
|
+
text_font: "Three",
|
197
|
+
font: "Three",
|
198
|
+
serif_font: "Three"
|
199
199
|
} }
|
200
200
|
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
201
201
|
result.should == {
|
@@ -205,13 +205,13 @@ describe ThemeFont do
|
|
205
205
|
end
|
206
206
|
|
207
207
|
it "returns empty hash for non-Google font" do
|
208
|
-
stub(account_theme).settings { {
|
208
|
+
stub(account_theme).settings { { primary_font: "Two" } }
|
209
209
|
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
210
210
|
result.should == {}
|
211
211
|
end
|
212
212
|
|
213
213
|
it "returns empty hash for unknown font" do
|
214
|
-
stub(account_theme).settings { {
|
214
|
+
stub(account_theme).settings { { primary_font: "Unknown" } }
|
215
215
|
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
216
216
|
result.should == {}
|
217
217
|
end
|
@@ -221,7 +221,7 @@ describe ThemeFont do
|
|
221
221
|
let(:theme) { double("Theme", name: "cosmos") }
|
222
222
|
|
223
223
|
it "uses secondary_font setting" do
|
224
|
-
stub(account_theme).settings { {
|
224
|
+
stub(account_theme).settings { { secondary_font: "Three" } }
|
225
225
|
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
226
226
|
result.should == {
|
227
227
|
"primary_text_font" => "https://fonts.googleapis.com/css?family=Three"
|
@@ -230,8 +230,8 @@ describe ThemeFont do
|
|
230
230
|
|
231
231
|
it "ignores primary_font when secondary_font is present" do
|
232
232
|
stub(account_theme).settings { {
|
233
|
-
|
234
|
-
|
233
|
+
secondary_font: "Three",
|
234
|
+
primary_font: "One Font"
|
235
235
|
} }
|
236
236
|
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
237
237
|
result.should == {
|
@@ -244,7 +244,7 @@ describe ThemeFont do
|
|
244
244
|
let(:theme) { double("Theme", name: "lunch break") }
|
245
245
|
|
246
246
|
it "uses secondary_font setting" do
|
247
|
-
stub(account_theme).settings { {
|
247
|
+
stub(account_theme).settings { { secondary_font: "One Font" } }
|
248
248
|
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
249
249
|
result.should == {
|
250
250
|
"primary_text_font" => "https://fonts.googleapis.com/css?family=One+Font"
|