dugway 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dugway/theme.rb +70 -1
- data/lib/dugway/version.rb +1 -1
- data/spec/fixtures/theme/settings.json +38 -1
- data/spec/units/dugway/theme_spec.rb +2 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8390ef193bc160dedfcd4745df7b5b96e2bb702b10bd3cd9794cd7f951edc03d
|
4
|
+
data.tar.gz: bbba535b7d2c34823c50bdac3f83418ad74091063fc3cd6957fe1f70a36a0145
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecc5b434330a537eba7f403815975fbff7fbec5d1ab3256fc324392fdde90bd8228cd741897517ba92464a0a2023cf870d579ddd2fd192a27667b5d3d4098c9a
|
7
|
+
data.tar.gz: 2557195c107df99b5ae72cfd027d6a4c43463b4d2c39b8a2d5022ddf4bdeab5d2c3fe34efdba8fff6bb5b5777fcdc39cf0ba5f14ff7c9f0c31dda507d081ab01
|
data/lib/dugway/theme.rb
CHANGED
@@ -98,13 +98,82 @@ module Dugway
|
|
98
98
|
|
99
99
|
@errors << 'Missing theme name in source/settings.json' if name.blank?
|
100
100
|
@errors << 'Invalid theme version in source/settings.json (ex: 1.0.3)' unless !!(version =~ /\d+\.\d+\.\d+/)
|
101
|
-
|
101
|
+
|
102
|
+
if settings['preset_styles']
|
103
|
+
validate_preview
|
104
|
+
if settings['preset_styles']['presets']
|
105
|
+
settings['preset_styles']['presets'].each do |preset|
|
106
|
+
validate_preset_styles(preset)
|
107
|
+
validate_style_references(preset)
|
108
|
+
end
|
109
|
+
else
|
110
|
+
@errors << "Missing presets"
|
111
|
+
end
|
112
|
+
end
|
102
113
|
|
103
114
|
@errors.empty?
|
104
115
|
end
|
105
116
|
|
106
117
|
private
|
107
118
|
|
119
|
+
def validate_preview
|
120
|
+
preview = settings['preset_styles']['preview']
|
121
|
+
if preview
|
122
|
+
%w[title_font body_font text_color background_color].each do |key|
|
123
|
+
@errors << "Missing #{key} in preview" unless preview[key]
|
124
|
+
end
|
125
|
+
else
|
126
|
+
@errors << "Missing preview in preset_styles"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def validate_preset_styles(preset)
|
131
|
+
@errors << 'Preset is missing group_name' unless preset['group_name'].is_a?(String)
|
132
|
+
@errors << 'Preset is missing styles' unless preset['styles'].is_a?(Array)
|
133
|
+
|
134
|
+
preset['styles'].each do |style|
|
135
|
+
@errors << 'Style is missing style_name' unless style['style_name'].is_a?(String)
|
136
|
+
|
137
|
+
if style['fonts'].is_a?(Hash) && !style['fonts'].empty?
|
138
|
+
style['fonts'].each_value do |font|
|
139
|
+
@errors << 'Font value should be a string' unless font.is_a?(String)
|
140
|
+
end
|
141
|
+
else
|
142
|
+
@errors << 'Style is missing fonts'
|
143
|
+
end
|
144
|
+
|
145
|
+
if style['colors'].is_a?(Hash) && !style['colors'].empty?
|
146
|
+
style['colors'].each do |key, color|
|
147
|
+
@errors << 'Invalid color format' unless color =~ /^#[0-9A-Fa-f]{6}$/
|
148
|
+
end
|
149
|
+
else
|
150
|
+
@errors << 'Style is missing colors'
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
@errors << 'Style names should be unique' unless preset['styles'].map { |style| style['style_name'] }.uniq.length == preset['styles'].length
|
155
|
+
end
|
156
|
+
|
157
|
+
def validate_style_references(preset)
|
158
|
+
['fonts', 'colors'].each do |key_type|
|
159
|
+
validate_keys(preset, settings[key_type], key_type)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def validate_keys(preset, settings, key_type)
|
164
|
+
variables = settings.map { |item| item['variable'] }
|
165
|
+
|
166
|
+
preset['styles'].each do |style|
|
167
|
+
style_keys = style[key_type].keys
|
168
|
+
|
169
|
+
extra_keys = style_keys - variables
|
170
|
+
missing_keys = variables - style_keys
|
171
|
+
|
172
|
+
@errors << "Extra #{key_type} keys: #{extra_keys.join(', ')}" unless extra_keys.empty?
|
173
|
+
@errors << "Missing #{key_type} keys: #{missing_keys.join(', ')}" unless missing_keys.empty?
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
108
177
|
def source_dir
|
109
178
|
Dugway.source_dir
|
110
179
|
end
|
data/lib/dugway/version.rb
CHANGED
@@ -38,13 +38,50 @@
|
|
38
38
|
"variable": "header_font",
|
39
39
|
"label": "Header Font",
|
40
40
|
"default": "Helvetica"
|
41
|
-
},
|
41
|
+
},
|
42
42
|
{
|
43
43
|
"variable": "font",
|
44
44
|
"label": "Font",
|
45
45
|
"default": "Georgia"
|
46
46
|
}
|
47
47
|
],
|
48
|
+
"preset_styles": {
|
49
|
+
"preview": {
|
50
|
+
"title_font": "header_font",
|
51
|
+
"body_font": "font",
|
52
|
+
"text_color": "link_color",
|
53
|
+
"background_color": "background_color"
|
54
|
+
},
|
55
|
+
"presets": [
|
56
|
+
{
|
57
|
+
"group_name": "Classic",
|
58
|
+
"styles": [
|
59
|
+
{
|
60
|
+
"style_name": "Classic #1",
|
61
|
+
"fonts": {
|
62
|
+
"header_font": "DM Sans",
|
63
|
+
"font": "DM Sans"
|
64
|
+
},
|
65
|
+
"colors": {
|
66
|
+
"background_color": "#FFFFFF",
|
67
|
+
"link_color": "#111111"
|
68
|
+
}
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"style_name": "Classic #2",
|
72
|
+
"fonts": {
|
73
|
+
"header_font": "Lora",
|
74
|
+
"font": "Roboto"
|
75
|
+
},
|
76
|
+
"colors": {
|
77
|
+
"background_color": "#F7F7F7",
|
78
|
+
"link_color": "#222222"
|
79
|
+
}
|
80
|
+
}
|
81
|
+
]
|
82
|
+
}
|
83
|
+
]
|
84
|
+
},
|
48
85
|
"colors": [
|
49
86
|
{
|
50
87
|
"variable": "background_color",
|
@@ -151,7 +151,7 @@ describe Dugway::Theme do
|
|
151
151
|
end
|
152
152
|
|
153
153
|
describe "#font_files" do
|
154
|
-
it "
|
154
|
+
it "should return an array of all font files" do
|
155
155
|
theme.font_files.should include("fonts/icons.ttf", "fonts/icons.woff")
|
156
156
|
end
|
157
157
|
end
|
@@ -210,28 +210,15 @@ describe Dugway::Theme do
|
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
|
-
describe "when missing at least one image" do
|
214
|
-
before(:each) do
|
215
|
-
theme.stub(:image_files) { [] }
|
216
|
-
end
|
217
|
-
|
218
|
-
it "should not be valid" do
|
219
|
-
theme.valid?.should be(false)
|
220
|
-
theme.errors.size.should == 1
|
221
|
-
theme.errors.first.should == 'Missing images in source/images'
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
213
|
describe "when there are several errors" do
|
226
214
|
before(:each) do
|
227
215
|
theme.stub(:name) { nil }
|
228
216
|
theme.stub(:version) { nil }
|
229
|
-
theme.stub(:image_files) { [] }
|
230
217
|
end
|
231
218
|
|
232
219
|
it "should return all of them" do
|
233
220
|
theme.valid?.should be(false)
|
234
|
-
theme.errors.size.should ==
|
221
|
+
theme.errors.size.should == 2
|
235
222
|
end
|
236
223
|
end
|
237
224
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dugway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Big Cartel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -577,7 +577,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
577
577
|
- !ruby/object:Gem::Version
|
578
578
|
version: '0'
|
579
579
|
requirements: []
|
580
|
-
rubygems_version: 3.
|
580
|
+
rubygems_version: 3.2.3
|
581
581
|
signing_key:
|
582
582
|
specification_version: 4
|
583
583
|
summary: Easily build and test Big Cartel themes.
|