show_message 0.0.1 → 0.0.2
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.
- data/README.md +17 -1
- data/app/views/show_message/_show_message.html.erb +3 -2
- data/lib/show_message/version.rb +1 -1
- data/lib/show_message/view_helpers.rb +29 -30
- data/show_message.gemspec +2 -2
- metadata +3 -3
data/README.md
CHANGED
@@ -19,7 +19,23 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
-
|
22
|
+
Add this code where you want your error messages to be shown.
|
23
|
+
|
24
|
+
```erb
|
25
|
+
<%= show_message %>
|
26
|
+
```
|
27
|
+
|
28
|
+
Set a message in your controller.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
class MyController
|
32
|
+
|
33
|
+
def test_function
|
34
|
+
flash[:error] = "Some Error Message"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
```
|
23
39
|
|
24
40
|
## Contributing
|
25
41
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
<% data.each do |m| %>
|
2
|
-
<div class="alert-box <%= m[:class] %>
|
2
|
+
<div class="alert-box <%= m[:class] %>" style= "<%= (m != data.last) ? "margin-bottom:5px;" : "" %>">
|
3
3
|
<div class="message">
|
4
4
|
<%= raw m[:message] %>
|
5
5
|
</div>
|
6
6
|
</div>
|
7
|
-
<% end %>
|
7
|
+
<% end %>
|
8
|
+
<div style="margin-top:#{options[:space]}px;"></div>
|
data/lib/show_message/version.rb
CHANGED
@@ -1,43 +1,42 @@
|
|
1
1
|
module ShowMessage
|
2
2
|
module ViewHelpers
|
3
3
|
|
4
|
-
def show_message(options = {}
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
else
|
15
|
-
class_mappings = {:success => "success", :error => "error", :warning => "warning", :info => "info"}
|
4
|
+
def show_message(options = {})
|
5
|
+
|
6
|
+
scope = options[:id]
|
7
|
+
|
8
|
+
|
9
|
+
if scope.present?
|
10
|
+
flash_is_empty = false
|
11
|
+
flash.keys.each do |k|
|
12
|
+
puts k.to_s.index(scope.to_s).present?
|
13
|
+
flash_is_empty = true unless k.to_s.index(scope.to_s).present?
|
16
14
|
end
|
15
|
+
return if flash_is_empty
|
16
|
+
end
|
17
17
|
|
18
|
-
data = []
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
data = []
|
20
|
+
|
21
|
+
flash.each do |k, v|
|
22
|
+
f = flash[k]
|
23
|
+
if f.kind_of?(Array)
|
24
|
+
if f
|
25
|
+
f.each do |m|
|
26
|
+
data << {message: m, class: k.to_s.split("_").first}
|
26
27
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
args.each do |k|
|
34
|
-
data << k
|
28
|
+
end
|
29
|
+
else
|
30
|
+
if f
|
31
|
+
data << {message: v, class: k.to_s.split("_").first}
|
32
|
+
end
|
35
33
|
end
|
36
|
-
class_mappings.each_key { |k| flash[k] = nil }
|
37
34
|
|
38
|
-
|
39
|
-
|
35
|
+
flash.discard(k)
|
40
36
|
end
|
41
37
|
|
38
|
+
render partial: "show_message/show_message", locals: {data: data, options: options}
|
39
|
+
end
|
40
|
+
|
42
41
|
end
|
43
42
|
end
|
data/show_message.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = ShowMessage::VERSION
|
8
8
|
spec.authors = ["Jarrett Lusso"]
|
9
9
|
spec.email = ["jarrett@graphicflash.com"]
|
10
|
-
spec.description = %q{
|
11
|
-
spec.summary = %q{
|
10
|
+
spec.description = %q{show_message makes it easy to output your flash[:success], flash[:error] or flash[:whatever] to the view using one simple helper.}
|
11
|
+
spec.summary = %q{show_message makes it easy to output your flash[:success], flash[:error] or flash[:whatever] to the view using one simple helper.}
|
12
12
|
spec.homepage = "http://github.com/jclusso/show_message"
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: show_message
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
- - '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
-
description:
|
46
|
+
description: show_message makes it easy to output your flash[:success], flash[:error]
|
47
47
|
or flash[:whatever] to the view using one simple helper.
|
48
48
|
email:
|
49
49
|
- jarrett@graphicflash.com
|
@@ -88,6 +88,6 @@ rubyforge_project:
|
|
88
88
|
rubygems_version: 1.8.25
|
89
89
|
signing_key:
|
90
90
|
specification_version: 3
|
91
|
-
summary:
|
91
|
+
summary: show_message makes it easy to output your flash[:success], flash[:error]
|
92
92
|
or flash[:whatever] to the view using one simple helper.
|
93
93
|
test_files: []
|