dugway 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6ca983943ee8afe7ba688da15820a8523976fd12a11d2e21bea7ae4ce894e60
4
- data.tar.gz: d38a64fa74907af55c4e65e3b66e4549be39ceaf242bd9c64d5908ff7e0f0a62
3
+ metadata.gz: 8390ef193bc160dedfcd4745df7b5b96e2bb702b10bd3cd9794cd7f951edc03d
4
+ data.tar.gz: bbba535b7d2c34823c50bdac3f83418ad74091063fc3cd6957fe1f70a36a0145
5
5
  SHA512:
6
- metadata.gz: 31f99a38d7c4334838c1c5d294dab362cbdbe224668c32dbcb205492441bd25165e3ad1c816947feaa244f9a2d1e4346b2df89c454d0de07c59933ed6217c5ad
7
- data.tar.gz: 3ba085450d4fb399e6c10c15a4ea433188b8f228e67013d334f0b7216fd9d8a7a0d3fb54dfdf1b43223a50563421db5e7ae8f3875817de7955db5b77695c67dc
6
+ metadata.gz: ecc5b434330a537eba7f403815975fbff7fbec5d1ab3256fc324392fdde90bd8228cd741897517ba92464a0a2023cf870d579ddd2fd192a27667b5d3d4098c9a
7
+ data.tar.gz: 2557195c107df99b5ae72cfd027d6a4c43463b4d2c39b8a2d5022ddf4bdeab5d2c3fe34efdba8fff6bb5b5777fcdc39cf0ba5f14ff7c9f0c31dda507d081ab01
data/dugway.gemspec CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
37
37
  s.add_dependency('htmlentities', '~> 4.3.1')
38
38
  s.add_dependency('thor', '~> 0.20.3')
39
39
  s.add_dependency('rubyzip', '~> 0.9.9')
40
- s.add_dependency('uglifier', '~> 4.1')
40
+ s.add_dependency('terser', '~> 1.1')
41
41
  s.add_dependency('thin', '~> 1.8.0')
42
42
  s.add_dependency('bigcartel-theme-fonts', '>= 1.0.0')
43
43
  s.add_dependency('bigcartel-currency-locales', '>= 1.0.0')
data/lib/dugway/theme.rb CHANGED
@@ -3,7 +3,7 @@ require 'sass'
3
3
  require 'sprockets'
4
4
  require 'sprockets-sass'
5
5
  require 'compass'
6
- require 'uglifier'
6
+ require 'terser'
7
7
 
8
8
  module Dugway
9
9
  class Theme
@@ -57,7 +57,7 @@ module Dugway
57
57
  case name
58
58
  when 'theme.js'
59
59
  if @building
60
- Uglifier.new(harmony: true).compile(sprockets[name].to_s)
60
+ Terser.new.compile(sprockets[name].to_s)
61
61
  else
62
62
  sprockets[name].to_s
63
63
  end
@@ -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
- @errors << 'Missing images in source/images' if image_files.empty?
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
@@ -1,3 +1,3 @@
1
1
  module Dugway
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.7"
3
3
  end
@@ -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 "shoud return an array of all font files" do
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 == 3
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.5
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Big Cartel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-23 00:00:00.000000000 Z
11
+ date: 2024-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -263,19 +263,19 @@ dependencies:
263
263
  - !ruby/object:Gem::Version
264
264
  version: 0.9.9
265
265
  - !ruby/object:Gem::Dependency
266
- name: uglifier
266
+ name: terser
267
267
  requirement: !ruby/object:Gem::Requirement
268
268
  requirements:
269
269
  - - "~>"
270
270
  - !ruby/object:Gem::Version
271
- version: '4.1'
271
+ version: '1.1'
272
272
  type: :runtime
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - "~>"
277
277
  - !ruby/object:Gem::Version
278
- version: '4.1'
278
+ version: '1.1'
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: thin
281
281
  requirement: !ruby/object:Gem::Requirement
@@ -559,7 +559,7 @@ homepage: https://github.com/bigcartel/dugway
559
559
  licenses:
560
560
  - MIT
561
561
  metadata: {}
562
- post_install_message:
562
+ post_install_message:
563
563
  rdoc_options: []
564
564
  require_paths:
565
565
  - lib
@@ -577,8 +577,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
577
577
  - !ruby/object:Gem::Version
578
578
  version: '0'
579
579
  requirements: []
580
- rubygems_version: 3.0.8
581
- signing_key:
580
+ rubygems_version: 3.2.3
581
+ signing_key:
582
582
  specification_version: 4
583
583
  summary: Easily build and test Big Cartel themes.
584
584
  test_files: