helper_methods 1.0.0.rc1 → 1.0.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24f01c10ecb456e684d0eb7f3f93d364c8cddce4
4
- data.tar.gz: 2e679a8275f2ab6b9ad3a6d063d4c0ebc3888453
3
+ metadata.gz: e0ee6329a068146220ee5900ac1e03fa7ec36f27
4
+ data.tar.gz: 5e32c9df7985a78d53b7690a1fbd89dc23af0a85
5
5
  SHA512:
6
- metadata.gz: 1f14ae87bee92d04ce44d945ce01dab51b93e12ba78c0c4a3d11bf011742e7db54a47b7918c2703faa5e492e328e032bbb65f32ffd490317ee85c66060abc84d
7
- data.tar.gz: c425b153fcc1bb117ad52297cdf418f09670cb2d8ddec44b68add95f0e40474a5259ae4711a1016d25d6e732a457f3e0598ee98a085e287c01e3ced8ec1f890b
6
+ metadata.gz: 16853644b3f4d62f2b0289791f38b59dcaa0d41ae15176703558c64dcfd63bc4f663abd3fe6d8aa7ddb0f91ef86f3f10b173002f9f5bc0b59dbb05dc8842c8a5
7
+ data.tar.gz: 8f33fff02fe4ad877f3771fc7a85d29a89ba7364f311a08dcd3bd4d4806c07d1eac6078bd84765af06ec3e70e9998aa81bff5527c8f059a662e5f7ae52c1d7d5
@@ -1,8 +1,8 @@
1
1
  module HelperMethods
2
2
 
3
- def error_messages_for(resource, style = 'danger')
3
+ def error_messages_for(resource:, style: 'danger')
4
4
  if resource.errors.any?
5
- content_tag :div, class: "alert alert-#{style} alert-dismissable" do
5
+ content_tag :div, class: "alert alert-#{styles[style]} alert-dismissible" do
6
6
  content_tag :ol do
7
7
  resource.errors.collect do |key, value|
8
8
  content_tag :li, value
@@ -13,17 +13,28 @@ module HelperMethods
13
13
  end
14
14
 
15
15
  def flash_messages
16
- if flash.any?
17
- content_tag :div, class: "alert alert-success alert-dismissable" do
18
- content_tag :ul do
19
- flash.collect do |key, value|
20
- unless [true, false, nil].include?(value)
21
- content_tag :li, value
22
- end
23
- end.join.html_safe
24
- end
25
- end
16
+ flash.collect do |key, value|
17
+ content_tag :div, class: "alert alert-#{styles[key]} alert-dismissable", role: "alert" do
18
+ [close_button, value].join.html_safe
19
+ end unless [true, false, nil].include?(value)
20
+ end.join.html_safe
21
+ end
22
+
23
+ def close_button
24
+ content_tag :button, type: 'button', class: 'close', data: { dismiss: 'alert' } do
25
+ content_tag(:span, '×', aria: { hidden: 'true' }) + content_tag(:span, 'Close', class: 'sr-only')
26
26
  end
27
27
  end
28
28
 
29
+ def styles
30
+ {
31
+ 'notice' => 'success',
32
+ 'alert' => 'warning',
33
+ 'success' => 'success',
34
+ 'info' => 'info',
35
+ 'warning' => 'warning',
36
+ 'danger' => 'danger'
37
+ }
38
+ end
39
+
29
40
  end
@@ -1,3 +1,3 @@
1
1
  module HelperMethods
2
- VERSION = '1.0.0.rc1'
2
+ VERSION = '1.0.0.rc2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helper_methods
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francisco Martins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-27 00:00:00.000000000 Z
11
+ date: 2014-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec