class_variants 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/class_variants.rb +5 -37
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a0d49412628b8d47161a0687b06d95d11728e15d2ac3f311b68e91023c29d3e
4
- data.tar.gz: c4e984bbfa5d0378d918acc7e4fc188957933a49d109788ec5affb54f8681194
3
+ metadata.gz: 2792db3c19b185d0e6742eda0c1a2f0857875aafbed636ce538b2dcab7ec9fd5
4
+ data.tar.gz: 9fa284780eb2349119f181f88fb34cb11c6aae3dbdbbda66f26ba7f806e3ea4f
5
5
  SHA512:
6
- metadata.gz: f37d9c9e5e03405fd9eb6e559fb5b9c70e5cf97aa1d74d51029b9ac1d816cff544c4c576920e42dd28e5a5fd661420025a3cea24095a51ee4f3dc09f576938ed
7
- data.tar.gz: 46fb46e7b181571f94118530e6181ebf906e0643d875200a0125319c27c242723db11977f135a5e3467e248c9ed314d2a48ee5e5d99c17bceb9ba03ce6b7647a
6
+ metadata.gz: 887fdd4337ce24b0c6821d64db55b457fc78c507958ae4d4d7d328b4b4ff67452651eb1fab0e6b56e42cd42790159e23610fee68ac6525a5adca3a3a6830d127
7
+ data.tar.gz: 8076a00c2878faf314c01cbf4c2a5fa82a63888d4a38f755a8a054b0bd0f0067a2e6fc097bc9e5457f5816f83d2f7269e8ba0aed5917f12ed8d1ee9de7d1081e
@@ -1,39 +1,7 @@
1
- class ClassVariants
2
- attr_reader :classes
3
- attr_reader :variants
4
- attr_reader :defaults
1
+ require "class_variants/version"
2
+ require "class_variants/action_view/helpers"
3
+ require "class_variants/instance"
4
+ require "class_variants/railtie" if defined?(Rails)
5
5
 
6
- def initialize(classes = "", variants: {}, defaults: {})
7
- @classes = classes
8
- @variants = variants
9
- @defaults = defaults
10
- end
11
-
12
- def render(**settings)
13
- result = []
14
-
15
- # Add the default classes if any provided
16
- result << classes if classes
17
-
18
- # Keep the applied variants so we can later apply the defaults
19
- applied_options = []
20
-
21
- # Go through each keys provided
22
- settings.each do |key, value|
23
- if variants.keys.include? key
24
- applied_options << key
25
- result << variants[key][value]
26
- end
27
- end
28
-
29
- if defaults.present?
30
- defaults.each do |key, key_to_use|
31
- unless applied_options.include? key
32
- result << @variants[key][key_to_use] if @variants[key].present?
33
- end
34
- end
35
- end
36
-
37
- result.join " "
38
- end
6
+ module ClassVariants
39
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: class_variants
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin