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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e69677eb6bc3da3fe0581dfbd318fe62013e0468
4
- data.tar.gz: 810c5f748ea5a6d607e1e5ca79054ff5b069d5d1
3
+ metadata.gz: 88e01e2c23dbd475085ec48154f2b5cb6d81b401
4
+ data.tar.gz: 0302f5f7183b3e546ca4d38a1fe496014d151510
5
5
  SHA512:
6
- metadata.gz: 40ae66a777f28320d5d9261beb1c2a86bdf69d3ce122a6b9b1e604a7c9478c5506cf56ff23edcc61613e9a5d1ee677006bbc03be267eff3e41bfb999cd58acb8
7
- data.tar.gz: 00ec1362b200165de8ece6b6148128a66d3a21f16f2b0c36a1ddb09a9a55d7501060137891c017369e7a8c89fd50b0fe9e07e416438487678b05148e9633cd22
6
+ metadata.gz: 4bbac6767ec71024b41c451fa0481d08ca576169c8bcf5276e67f966defaec753c9a640ef809279cdd06b5abfc7755306e6b1b3a25f11111ec017bf76ee83375
7
+ data.tar.gz: d623f069c0efa1d461f54eec769a346fcbe1d42ce579fe9cee364ea31e30d0217663330f3eb57905b55b4a93f1913ed77833a307aea7d618dcc3ff82ca47f9f7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crystal_flash_messages (1.0.0)
4
+ crystal_flash_messages (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- config = local_config(options)
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
- private
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
@@ -2,7 +2,7 @@ module CrystalFlashMessages
2
2
  module VERSION
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
8
8
  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.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-26 00:00:00.000000000 Z
11
+ date: 2016-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake