effective_bootstrap 0.9.44 → 0.9.45

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: '092f884d4e2928c9cda4247f62caeba2dc0a7b7e7c56b42a4292d611c5d62ee1'
4
- data.tar.gz: 8059eaec1762f8846cc1d16d668d0e29dd5fa4e7b27edfbb91434c1f9e8d70f0
3
+ metadata.gz: 33fc32e5f8a20002ec07cc4cab552f7bd2e7386b162ce3043b9d2ba73771d2cb
4
+ data.tar.gz: d28055c2b76376a8efb83c2d89632883c4c599ccca5b5337eabb42f1242d8e6c
5
5
  SHA512:
6
- metadata.gz: f9a5de0079ce76d9fe570233344b892ddb8b56407611cb231dbefe9e46c996894a73f3a48f0df377269a0fbd5472ee8bcbb7fae19968da52f50ff3b1ca0b7926
7
- data.tar.gz: af189c0bd213dd06adb690673221582d47838ef9ab711e03fc9058c70a8938bfef2da2d6a8c38e14a74c1e4b99f6cc98b004e21e9477355c22c9091fef21ba5b
6
+ metadata.gz: b748f7cabd901caa3b9626c5bf4a0bc5d00cbc8269c8db15b809708895ac4e08104ec9f75cdf0dd5da0314c8182d882212beedb1aaf9ef72e0c9db43ad8dc0dc
7
+ data.tar.gz: 6c8259a2cf99443611d197da78129382d1a6c4f870d7678458bf71a49f3ed60cbc64c7c8876482fa93244fdb2b139cb9396af4b8276fa0b858d25431cfad766f
@@ -371,7 +371,22 @@ module Effective
371
371
  when String
372
372
  defaults.merge(text: obj)
373
373
  when Hash
374
- obj.reverse_merge!(defaults); obj
374
+ html_classes = ((obj[:class] || '').split(' ') + (defaults[:class] || '').split(' ')).uniq
375
+
376
+ # Try to smart merge bootstrap classes
377
+ if (exclusive = html_classes.select { |c| c.include?('-') }).length > 1
378
+ EXCLUSIVE_CLASS_PREFIXES.each do |prefix|
379
+ prefixed = exclusive.select { |c| c.start_with?(prefix) }
380
+ prefixed[1..-1].each { |c| html_classes.delete(c) } if prefixed.length > 1
381
+ end
382
+
383
+ suffixed = exclusive.select { |c| EXCLUSIVE_CLASS_SUFFIXES.any? { |suffix| c.end_with?(suffix) } }
384
+ suffixed[1..-1].each { |c| html_classes.delete(c) } if suffixed.length > 1
385
+ end
386
+
387
+ obj[:class] = html_classes.join(' ') if html_classes.present?
388
+ obj.reverse_merge!(defaults)
389
+ obj
375
390
  else
376
391
  defaults.merge(text: obj.to_s)
377
392
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.9.44'.freeze
2
+ VERSION = '0.9.45'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.44
4
+ version: 0.9.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-29 00:00:00.000000000 Z
11
+ date: 2021-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails