crystal_flash_messages 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/crystal_flash_messages/helpers.rb +21 -13
- data/lib/crystal_flash_messages/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88e01e2c23dbd475085ec48154f2b5cb6d81b401
|
4
|
+
data.tar.gz: 0302f5f7183b3e546ca4d38a1fe496014d151510
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bbac6767ec71024b41c451fa0481d08ca576169c8bcf5276e67f966defaec753c9a640ef809279cdd06b5abfc7755306e6b1b3a25f11111ec017bf76ee83375
|
7
|
+
data.tar.gz: d623f069c0efa1d461f54eec769a346fcbe1d42ce579fe9cee364ea31e30d0217663330f3eb57905b55b4a93f1913ed77833a307aea7d618dcc3ff82ca47f9f7
|
data/Gemfile.lock
CHANGED
@@ -1,27 +1,25 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
1
3
|
module CrystalFlashMessages
|
2
4
|
module Helpers
|
3
|
-
include ActionView::Helpers::TagHelper
|
4
|
-
|
5
5
|
def crystal_flash_messages(options = {})
|
6
6
|
return '' if flash.empty?
|
7
|
-
|
7
|
+
private_helpers = CrystalFlashMessages::PrivateHelpers
|
8
8
|
|
9
|
+
config = private_helpers.local_config(options)
|
9
10
|
flash.map do |key, message|
|
10
|
-
wrapper(key.to_s, message, config)
|
11
|
+
private_helpers.wrapper(key.to_s, message, config)
|
11
12
|
end.join.html_safe
|
12
13
|
end
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
def wrapper(key, message, config)
|
16
|
+
module PrivateHelpers
|
17
|
+
def self.wrapper(key, message, config)
|
17
18
|
class_attr = wrapper_class_attr(key, config)
|
18
|
-
|
19
|
-
content_tag(:div, class: class_attr, role: 'alert') do
|
20
|
-
message
|
21
|
-
end
|
19
|
+
tag(:div, message, class: class_attr, role: 'alert')
|
22
20
|
end
|
23
21
|
|
24
|
-
def wrapper_class_attr(key, config)
|
22
|
+
def self.wrapper_class_attr(key, config)
|
25
23
|
boostrap_translations = { 'error' => 'danger', 'notice' => 'info' }
|
26
24
|
boostrap_translations.default = key
|
27
25
|
base = []
|
@@ -32,12 +30,22 @@ module CrystalFlashMessages
|
|
32
30
|
base.join(' ')
|
33
31
|
end
|
34
32
|
|
35
|
-
def local_config(options)
|
33
|
+
def self.local_config(options)
|
36
34
|
config = CrystalFlashMessages.configuration.clone
|
37
35
|
options.each_pair do |k, v|
|
38
36
|
config.send(k.to_s + '=', v)
|
39
37
|
end
|
40
38
|
config
|
41
39
|
end
|
40
|
+
|
41
|
+
def self.tag(name, value, attributes = {})
|
42
|
+
string_attributes = attributes.inject('') do |attrs, pair|
|
43
|
+
unless pair.last.nil?
|
44
|
+
attrs << %( #{pair.first}="#{CGI.escapeHTML(pair.last.to_s)}")
|
45
|
+
end
|
46
|
+
attrs
|
47
|
+
end
|
48
|
+
"<#{name}#{string_attributes}>#{value}</#{name}>"
|
49
|
+
end
|
42
50
|
end
|
43
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crystal_flash_messages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christophe Maximin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|