easol-canvas 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canvas/checks/valid_sass_check.rb +30 -0
- data/lib/canvas/validators/custom_type.rb +12 -0
- data/lib/canvas/validators/sass.rb +26 -0
- data/lib/canvas/version.rb +1 -1
- data/lib/canvas.rb +10 -10
- data/lib/easol/canvas.rb +4 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97ee44a992eb400c6fe2eedd35e6bb395ebc05e2f59f039ea9335194ff64fe83
|
4
|
+
data.tar.gz: 2684ff4ca3910fab9f0cd3bc36cb0c847f31565b1d3f8576964102a28773f247
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28c155af546e6898977757280894cba8ab26942aa1883c5b3ff752f3d7256b68c0631b9d18b6e29df8629d79e94a488739d2c9d0d1d1563dc8f4672f91d164ff
|
7
|
+
data.tar.gz: 3f743a067e8621d1b0893fe41afa8746b60dcc87a4398214b7d8b45ae66648088c22db84e2ed23b26df72c586f19b0547df3a6c8c354f36a005556262fef5a98
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Canvas
|
4
|
+
# :documented:
|
5
|
+
#
|
6
|
+
# This check will find all files ending in .css, .scss or .sass
|
7
|
+
# and run them through the sass validator - {Canvas::Validator::Sass}.
|
8
|
+
class ValidSassCheck < Check
|
9
|
+
def run
|
10
|
+
sass_files.each do |filename|
|
11
|
+
file = File.read(filename)
|
12
|
+
validator = Validator::Sass.new(file)
|
13
|
+
|
14
|
+
next if validator.validate
|
15
|
+
|
16
|
+
validator.errors.each do |message|
|
17
|
+
@offenses << Offense.new(
|
18
|
+
message: "Invalid Sass: #{filename} - \n#{message}"
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def sass_files
|
27
|
+
Dir.glob("**/*.{css,scss,sass}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -38,6 +38,7 @@ module Canvas
|
|
38
38
|
ensure_has_required_keys &&
|
39
39
|
ensure_no_unrecognized_keys &&
|
40
40
|
ensure_keys_are_correct_types &&
|
41
|
+
ensure_key_value_is_not_reserved &&
|
41
42
|
ensure_no_duplicate_attributes &&
|
42
43
|
ensure_attributes_are_valid &&
|
43
44
|
ensure_first_attribute_not_array
|
@@ -91,6 +92,17 @@ module Canvas
|
|
91
92
|
true
|
92
93
|
end
|
93
94
|
|
95
|
+
# Ensuring the value for key doesn't clash with our primitive type keys.
|
96
|
+
# See {Canvas::Constants::PRIMITIVE_TYPES}
|
97
|
+
def ensure_key_value_is_not_reserved
|
98
|
+
if schema["key"] && Constants::PRIMITIVE_TYPES.include?(schema["key"].downcase)
|
99
|
+
@errors << "\"key\" can't be one of these reserved words: #{Constants::PRIMITIVE_TYPES.join(', ')}"
|
100
|
+
return false
|
101
|
+
end
|
102
|
+
|
103
|
+
true
|
104
|
+
end
|
105
|
+
|
94
106
|
def ensure_no_duplicate_attributes
|
95
107
|
attribute_names = schema["attributes"].map { |a| a["name"] }
|
96
108
|
duplicated_names = attribute_names.select { |a| attribute_names.count(a) > 1 }.uniq
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "sassc"
|
4
|
+
|
5
|
+
module Canvas
|
6
|
+
module Validator
|
7
|
+
# :documented:
|
8
|
+
#
|
9
|
+
# This validator can be used to validate Sass.
|
10
|
+
class Sass
|
11
|
+
attr_reader :errors
|
12
|
+
|
13
|
+
def initialize(file)
|
14
|
+
@file = file
|
15
|
+
end
|
16
|
+
|
17
|
+
def validate
|
18
|
+
SassC::Engine.new(@file, style: :compressed).render
|
19
|
+
true
|
20
|
+
rescue SassC::SyntaxError => e
|
21
|
+
@errors = [e.message]
|
22
|
+
false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/canvas/version.rb
CHANGED
data/lib/canvas.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
module Canvas
|
4
|
+
autoload :Check, "canvas/check"
|
5
|
+
autoload :Checks, "canvas/checks"
|
6
|
+
autoload :Cli, "canvas/cli"
|
7
|
+
autoload :Constants, "canvas/constants"
|
8
|
+
autoload :Lint, "canvas/lint"
|
9
|
+
autoload :Offense, "canvas/offense"
|
10
|
+
autoload :Version, "canvas/version"
|
11
|
+
end
|
10
12
|
|
11
13
|
# We need to ensure Canvas::Validator::SchemaAttribute::Base is required first
|
12
14
|
require_relative "canvas/validators/schema_attributes/base"
|
@@ -26,10 +28,8 @@ Canvas::Checks.register(Canvas::RequiredFilesCheck)
|
|
26
28
|
Canvas::Checks.register(Canvas::ValidHtmlCheck)
|
27
29
|
Canvas::Checks.register(Canvas::ValidLiquidCheck)
|
28
30
|
Canvas::Checks.register(Canvas::ValidJsonCheck)
|
31
|
+
Canvas::Checks.register(Canvas::ValidSassCheck)
|
29
32
|
Canvas::Checks.register(Canvas::ValidBlockSchemasCheck)
|
30
33
|
Canvas::Checks.register(Canvas::ValidMenuSchemaCheck)
|
31
34
|
Canvas::Checks.register(Canvas::ValidFooterSchemaCheck)
|
32
35
|
Canvas::Checks.register(Canvas::ValidCustomTypesCheck)
|
33
|
-
|
34
|
-
module Canvas
|
35
|
-
end
|
data/lib/easol/canvas.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easol-canvas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Byrne
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-06-
|
12
|
+
date: 2022-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '5.3'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: sassc
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.4'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '2.4'
|
70
84
|
description: |
|
71
85
|
Canvas is a command line tool to help with building themes for Easol.
|
72
86
|
It provides tooling to check theme directories for errors and to make sure
|
@@ -90,6 +104,7 @@ files:
|
|
90
104
|
- lib/canvas/checks/valid_json_check.rb
|
91
105
|
- lib/canvas/checks/valid_liquid_check.rb
|
92
106
|
- lib/canvas/checks/valid_menu_schema_check.rb
|
107
|
+
- lib/canvas/checks/valid_sass_check.rb
|
93
108
|
- lib/canvas/cli.rb
|
94
109
|
- lib/canvas/constants.rb
|
95
110
|
- lib/canvas/lint.rb
|
@@ -104,6 +119,7 @@ files:
|
|
104
119
|
- lib/canvas/validators/json.rb
|
105
120
|
- lib/canvas/validators/liquid.rb
|
106
121
|
- lib/canvas/validators/menu_schema.rb
|
122
|
+
- lib/canvas/validators/sass.rb
|
107
123
|
- lib/canvas/validators/schema_attribute.rb
|
108
124
|
- lib/canvas/validators/schema_attributes/base.rb
|
109
125
|
- lib/canvas/validators/schema_attributes/color.rb
|
@@ -118,6 +134,7 @@ files:
|
|
118
134
|
- lib/canvas/validators/schema_attributes/select.rb
|
119
135
|
- lib/canvas/validators/schema_attributes/variant.rb
|
120
136
|
- lib/canvas/version.rb
|
137
|
+
- lib/easol/canvas.rb
|
121
138
|
homepage: https://rubygems.org/gems/easol-canvas
|
122
139
|
licenses:
|
123
140
|
- MIT
|