show_message 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -9
- data/lib/show_message.rb +15 -1
- data/lib/show_message/engine.rb +1 -1
- data/lib/show_message/version.rb +1 -1
- data/lib/show_message/view_helpers.rb +1 -1
- data/show_message.gemspec +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c774847ade95f82663243b53157f29e9bba67f30c81ef386f18bcedafd355e7
|
4
|
+
data.tar.gz: c0a231c4fa0bb6a5bd8c33ed6870b0194ff8694b3a8122a8c043919abb50f4b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d0d4eca4de826b563c7f790158b6bf2220d1dcedfebfb0a6808b290346047337408a0c21e9836431cf60cc95fc2a858f692d977c3dc70c0a9d7b1f72f6fd78e
|
7
|
+
data.tar.gz: a5e3012b0f55d8a0bc1553dfc74fb2bf68daef53783bed34f97efc5ee3693c6801ff908d7618e56b03fc0d24df7a94c7fa9991af476d1a98e83249cacb79b30d
|
data/README.md
CHANGED
@@ -19,41 +19,40 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
-
Add this code where you want your messages to be shown. You will need to create some styles for the message box.
|
22
|
+
Add this code where you want your messages to be shown. You will need to create some styles for the message box.
|
23
23
|
See further down for the HTML this outputs so you know how to style it.
|
24
24
|
|
25
25
|
```erb
|
26
26
|
<%= show_message %>
|
27
27
|
```
|
28
28
|
|
29
|
-
Now, set a message in your controller. You can use :error, :success, :myCoolMessage or :whatever. You get the point.
|
29
|
+
Now, set a message in your controller. You can use :error, :success, :myCoolMessage or :whatever. You get the point.
|
30
30
|
The only thing you should not use is and "_". Read on to see why.
|
31
31
|
|
32
32
|
Also, it you can set a single message as a String or multiple as an Array
|
33
33
|
|
34
34
|
```ruby
|
35
35
|
class MyController
|
36
|
-
|
36
|
+
|
37
37
|
def test_function
|
38
38
|
flash[:success] = "Some Success Message"
|
39
|
-
flash[:error] = ["Error Message 1", "Error Message 2"]
|
40
39
|
end
|
41
40
|
|
42
41
|
end
|
43
42
|
```
|
44
43
|
|
45
|
-
Now, when using remote forms I came across the issue where I would have multiple show_message helpers on the same page.
|
44
|
+
Now, when using remote forms I came across the issue where I would have multiple show_message helpers on the same page.
|
46
45
|
This led to some issues so I added the ability to set an id on show_message
|
47
46
|
|
48
47
|
```erb
|
49
48
|
<%= show_message(id: :create_object) %>
|
50
49
|
```
|
51
50
|
|
52
|
-
There is a slight twist to setting the flash now. I use an "_" to find what I call "scoped" messages.
|
51
|
+
There is a slight twist to setting the flash now. I use an "_" to find what I call "scoped" messages.
|
53
52
|
|
54
53
|
```ruby
|
55
54
|
class MyController
|
56
|
-
|
55
|
+
|
57
56
|
def test_function
|
58
57
|
flash[:error_create_object] = "Some Error Message"
|
59
58
|
end
|
@@ -70,7 +69,7 @@ Lastly, I found the need to insert a margin below the message sometimes.
|
|
70
69
|
|
71
70
|
## show_message - HTML Output
|
72
71
|
|
73
|
-
Below is HTML that show_message will output. You will need to create a few styles to make yours look nice.
|
72
|
+
Below is HTML that show_message will output. You will need to create a few styles to make yours look nice.
|
74
73
|
I left it free of styles since I was using Zurb Foundation. I also figured most people would want to style their own anyway.
|
75
74
|
|
76
75
|
```html
|
@@ -84,7 +83,7 @@ I left it free of styles since I was using Zurb Foundation. I also figured most
|
|
84
83
|
## Contributing
|
85
84
|
|
86
85
|
If anyone has any suggestions on a better way to do the "scoped" messages or anything for that matter,
|
87
|
-
feel free to submit a pull request.
|
86
|
+
feel free to submit a pull request.
|
88
87
|
|
89
88
|
1. Fork it
|
90
89
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
data/lib/show_message.rb
CHANGED
@@ -2,4 +2,18 @@ require 'show_message/view_helpers'
|
|
2
2
|
if defined? Rails
|
3
3
|
require 'show_message/railtie'
|
4
4
|
require 'show_message/engine'
|
5
|
-
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module ShowMessage
|
8
|
+
|
9
|
+
def show_message(type, message)
|
10
|
+
flash_sym =
|
11
|
+
if type.to_s.include?('_')
|
12
|
+
type
|
13
|
+
else
|
14
|
+
"#{type}_#{controller_name}"
|
15
|
+
end
|
16
|
+
flash[flash_sym] = message
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/show_message/engine.rb
CHANGED
data/lib/show_message/version.rb
CHANGED
data/show_message.gemspec
CHANGED
@@ -3,10 +3,10 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
require 'show_message/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = 'show_message'
|
7
7
|
spec.version = ShowMessage::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
8
|
+
spec.authors = ['Jarrett Lusso']
|
9
|
+
spec.email = ['jclusso@gmail.com']
|
10
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
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"
|
@@ -15,8 +15,8 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.files = `git ls-files`.split($/)
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
-
spec.require_paths = [
|
18
|
+
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.add_development_dependency
|
21
|
-
spec.add_development_dependency
|
20
|
+
spec.add_development_dependency 'bundler'
|
21
|
+
spec.add_development_dependency 'rake'
|
22
22
|
end
|
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: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarrett Lusso
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.7.
|
82
|
+
rubygems_version: 2.7.8
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: show_message makes it easy to output your flash[:success], flash[:error]
|