spark_components 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spark_components/element.rb +15 -7
- data/lib/spark_components/engine.rb +2 -2
- data/lib/spark_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 704f5cb250fa2871cd46c09bba22444ccff15f0a65628ba9d1f775074c834c9d
|
4
|
+
data.tar.gz: 4f02e1ceafb246bfb47c9e71b5b85d5071135c2a42755aee1b242fce8ff6ee32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fb2ec83c0d223310322b5fb65dbe243338ee2010f9270960aaeb448c37927bcdae7b19369b14f7a4edbd9de79026ca424664587d6d782f7b5a36ab4d8baaa23
|
7
|
+
data.tar.gz: 346da75ed6aeaceefac656133870c4834149be7a7d048ed90e9a507b2da12ea24e50337f5189b0d457df9f1c760830ffd5b7fa543d7dcfeb5dd36350932972ec
|
@@ -66,13 +66,21 @@ module SparkComponents
|
|
66
66
|
@tag_attrs ||= SparkComponents::Attributes::Tag.new
|
67
67
|
end
|
68
68
|
|
69
|
-
def self.validates_choice(name, choices)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
69
|
+
def self.validates_choice(name, choices, required: true)
|
70
|
+
choices = [choices] unless choices.is_a?(Array)
|
71
|
+
supported_choices = choices.map { |c| c.is_a?(String) ? c.to_sym : c.to_s }.concat(choices)
|
72
|
+
|
73
|
+
unless required
|
74
|
+
# Allow nil if option is not required
|
75
|
+
supported_choices.unshift(nil)
|
76
|
+
# Add `nil` to the error messsages list of valid options
|
77
|
+
choices.push("nil")
|
78
|
+
end
|
79
|
+
|
80
|
+
choices = choices.to_sentence(last_word_connector: ", or ")
|
81
|
+
message = "\"%<value>s\" is not valid. Options for #{name} include: #{choices}"
|
82
|
+
|
83
|
+
validates(name, inclusion: { in: supported_choices, message: message })
|
76
84
|
end
|
77
85
|
|
78
86
|
# rubocop:disable Metrics/AbcSize
|
@@ -8,8 +8,8 @@ module SparkComponents
|
|
8
8
|
app.config.assets.paths << SparkComponents.components_path if app.config.respond_to?(:assets)
|
9
9
|
end
|
10
10
|
|
11
|
-
initializer
|
12
|
-
app.config.autoload_paths << File.join(app.root,
|
11
|
+
initializer "components.autoload", before: :set_autoload_paths do |app|
|
12
|
+
app.config.autoload_paths << File.join(app.root, "app/components")
|
13
13
|
end
|
14
14
|
|
15
15
|
initializer "components.view_helpers" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spark_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|