flash_rails_messages 0.0.5 → 0.0.6
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 +13 -5
- data/.gitignore +1 -0
- data/.rvmrc +15 -6
- data/Gemfile +2 -1
- data/README.md +18 -10
- data/Rakefile +3 -3
- data/flash_rails_messages.gemspec +12 -12
- data/images/alert.png +0 -0
- data/images/default.png +0 -0
- data/images/notice.png +0 -0
- data/images/success.png +0 -0
- data/images/success2.png +0 -0
- data/lib/flash_rails_messages/base.rb +6 -7
- data/lib/flash_rails_messages/helper.rb +2 -4
- data/lib/flash_rails_messages/version.rb +1 -1
- data/spec/flash_rails_messages_spec.rb +33 -27
- data/spec/spec_helper.rb +3 -0
- metadata +12 -7
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
M2JmMDAyMTJmOGU2MjI3Njg5ZTgwMGI4YWYzYThkYjBhODVjMjA3NA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NWE1NjZmODBlNjUxNzliYWJlN2MzMjMwNjlkMTc2YTRiMWRhMzc5NA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDQzMTUyY2RhZTkzZmQ2MzExZDI5YjY1NmMzOWUzZDBiYzU0NTNjZWJjM2U4
|
10
|
+
ZGE5YzQzNmY0MTE4NWU3MWJjNzBmNzk2ODJlYzViNDgxYzM4YTBiZjc0MTFj
|
11
|
+
NDIzMmEwMmM5YWZhNTEyYmYyNTlmNmFjYzVjZmZmMjZmZjJhNjY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MTZhN2JjMzk2Y2JiMTU0ZmVlYTY2MzdjYjU2MDAzY2I2YzI1N2IzOTAzYzBl
|
14
|
+
ZDVkMThmMmU3YjY2ZDQ5YzBlOGZjMmVlZjQ1NDIxNzY3ZTU3NTdiYTUyNDVh
|
15
|
+
ZDE3NGFmMGEyODE5ZjdhZjE1MzViMWM0YWQ4OTRlYTM3ZmViNzc=
|
data/.gitignore
CHANGED
data/.rvmrc
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
7
|
# Only full ruby name is supported here, for short names use:
|
8
|
-
# echo "rvm use
|
9
|
-
environment_id="ruby-
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p484@flash_rails_messages"
|
10
10
|
|
11
11
|
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
-
# rvmrc_rvm_version="1.
|
13
|
-
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} |
|
12
|
+
# rvmrc_rvm_version="1.25.14 (stable)" # 1.10.1 seems like a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | __rvm_awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
14
|
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
15
|
# return 1
|
16
16
|
# }
|
@@ -30,6 +30,15 @@ then
|
|
30
30
|
fi
|
31
31
|
done
|
32
32
|
unset __hook
|
33
|
+
if (( ${rvm_use_flag:=1} >= 2 )) # display only when forced
|
34
|
+
then
|
35
|
+
if [[ $- == *i* ]] # check for interactive shells
|
36
|
+
then printf "%b" "Using: $(tput setaf 2 2>/dev/null)$GEM_HOME$(tput sgr0 2>/dev/null)
|
37
|
+
" # show the user the ruby and gemset they are using in green
|
38
|
+
else printf "%b" "Using: $GEM_HOME
|
39
|
+
" # don't use colors in non-interactive shells
|
40
|
+
fi
|
41
|
+
fi
|
33
42
|
else
|
34
43
|
# If the environment file has not yet been created, use the RVM CLI to select.
|
35
44
|
rvm --create "$environment_id" || {
|
@@ -41,7 +50,7 @@ fi
|
|
41
50
|
# If you use bundler, this might be useful to you:
|
42
51
|
# if [[ -s Gemfile ]] && {
|
43
52
|
# ! builtin command -v bundle >/dev/null ||
|
44
|
-
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
53
|
+
# builtin command -v bundle | GREP_OPTIONS="" \grep $rvm_path/bin/bundle >/dev/null
|
45
54
|
# }
|
46
55
|
# then
|
47
56
|
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
@@ -49,5 +58,5 @@ fi
|
|
49
58
|
# fi
|
50
59
|
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
51
60
|
# then
|
52
|
-
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
61
|
+
# bundle install | GREP_OPTIONS="" \grep -vE '^Using|Your bundle is complete'
|
53
62
|
# fi
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
# FlashRailsMessages
|
2
|
-
|
3
|
-
[](https://travis-ci.org/alejandrogutierrez/flash_rails_messages)
|
1
|
+
# FlashRailsMessages [](https://travis-ci.org/alejandrogutierrez/flash_rails_messages) [](https://coveralls.io/r/alejandrogutierrez/flash_rails_messages)
|
4
2
|
|
5
3
|
This gem provides an easy and simple way to display flash messages in a fancy way. It requires the
|
6
4
|
[bootstrap](http://twitter.github.io/bootstrap)
|
@@ -30,22 +28,27 @@ You should add the line above in your html view. You can add it in multiple plac
|
|
30
28
|
|
31
29
|
## Defaults
|
32
30
|
|
33
|
-
The flash messages are displayed according to the flash
|
31
|
+
The flash messages are displayed according to the flash key. Examples...
|
34
32
|
|
35
33
|
**success**
|
36
|
-
|
34
|
+

|
37
35
|
|
38
36
|
**notice**
|
39
|
-
|
37
|
+

|
38
|
+
|
39
|
+
**alert or error**
|
40
|
+

|
40
41
|
|
41
|
-
**
|
42
|
-
|
42
|
+
**other key (default)**
|
43
|
+

|
43
44
|
|
44
45
|
## Customize alerts
|
45
46
|
|
46
47
|
By the way, the alerts are customizable. They will have a specific class according to the flash key. Example...
|
47
48
|
|
48
|
-
|
49
|
+
```ruby
|
50
|
+
flash[:whatever] = "Some flash rails message"
|
51
|
+
```
|
49
52
|
|
50
53
|
It'll generate a class in the html alert wrapper like this `alert-whatever` to customize the style.
|
51
54
|
|
@@ -54,7 +57,12 @@ It'll generate a class in the html alert wrapper like this `alert-whatever` to c
|
|
54
57
|
The alerts that will be generated can include html elements. You just need to add html elements in the flash message.
|
55
58
|
Example...
|
56
59
|
|
57
|
-
|
60
|
+
```ruby
|
61
|
+
flash[:success] = "<strong>This text will be bold</strong> and this will be normal"
|
62
|
+
```
|
63
|
+
|
64
|
+
The line above will generate this:
|
65
|
+

|
58
66
|
|
59
67
|
## Contributing
|
60
68
|
|
data/Rakefile
CHANGED
@@ -4,22 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'flash_rails_messages/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'flash_rails_messages'
|
8
8
|
spec.version = FlashRailsMessages::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.description =
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Alejandro Gutiérrez']
|
10
|
+
spec.email = ['alejandrodevs@gmail.com']
|
11
|
+
spec.description = 'A simple helper to display flash rails messages'
|
12
|
+
spec.summary = 'This gems provides an easy way to display flash rails messages'
|
13
|
+
spec.homepage = 'https://github.com/alejandrogutierrez/flash_rails_messages'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 2.14.0'
|
24
|
+
spec.add_development_dependency 'simplecov', '~> 0.7.1'
|
25
25
|
end
|
data/images/alert.png
ADDED
Binary file
|
data/images/default.png
ADDED
Binary file
|
data/images/notice.png
ADDED
Binary file
|
data/images/success.png
ADDED
Binary file
|
data/images/success2.png
ADDED
Binary file
|
@@ -3,7 +3,7 @@ module FlashRailsMessages
|
|
3
3
|
include ActionView::Helpers::TagHelper
|
4
4
|
|
5
5
|
def render flash
|
6
|
-
flash_messages =
|
6
|
+
flash_messages = ''
|
7
7
|
|
8
8
|
flash.each do |type, msg|
|
9
9
|
flash_messages << alert_element(type, msg) if msg
|
@@ -16,11 +16,11 @@ module FlashRailsMessages
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def alert_element type, msg
|
19
|
-
content_tag(:div, close_element + msg.html_safe, :
|
19
|
+
content_tag(:div, close_element + msg.html_safe, class: alert_classes(type))
|
20
20
|
end
|
21
21
|
|
22
22
|
def close_element
|
23
|
-
content_tag(:span,
|
23
|
+
content_tag(:span, '×'.html_safe, class: 'close', :"data-dismiss" => 'alert')
|
24
24
|
end
|
25
25
|
|
26
26
|
def alert_classes type
|
@@ -29,11 +29,10 @@ module FlashRailsMessages
|
|
29
29
|
|
30
30
|
def default_class type
|
31
31
|
case type
|
32
|
-
when :success
|
33
|
-
when :notice
|
34
|
-
when :alert
|
32
|
+
when :success then 'alert-success'
|
33
|
+
when :notice then 'alert-info'
|
34
|
+
when :alert, :error then 'alert-error'
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
38
37
|
end
|
39
38
|
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
module FlashRailsMessages
|
2
2
|
module Helper
|
3
|
-
|
4
|
-
#
|
5
|
-
# call this method from your html view.
|
3
|
+
# Returns flash rails messages that will be displayed in your DOM.
|
4
|
+
# Just call this method from your erb template.
|
6
5
|
#
|
7
6
|
# <%= render_flash_messages %>
|
8
7
|
#
|
9
8
|
def render_flash_messages
|
10
9
|
FlashRailsMessages::Base.new.render(flash)
|
11
10
|
end
|
12
|
-
|
13
11
|
end
|
14
12
|
end
|
@@ -3,45 +3,52 @@ require 'spec_helper'
|
|
3
3
|
describe FlashRailsMessages::Helper do
|
4
4
|
let!(:subject){ ActionView::Base.new }
|
5
5
|
|
6
|
-
describe
|
7
|
-
context
|
8
|
-
it
|
6
|
+
describe '#render_flash_messages' do
|
7
|
+
context 'when flash does not have messages' do
|
8
|
+
it 'returns nothing' do
|
9
9
|
subject.stub(:flash).and_return({})
|
10
|
-
expect(subject.render_flash_messages).to eql(
|
10
|
+
expect(subject.render_flash_messages).to eql('')
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
context
|
15
|
-
context
|
16
|
-
it
|
17
|
-
subject.stub(:flash).and_return({:notice
|
18
|
-
alert_expected = alert_element(
|
14
|
+
context 'when flash has messages' do
|
15
|
+
context 'when flash type is notice' do
|
16
|
+
it 'returns the correct message' do
|
17
|
+
subject.stub(:flash).and_return({ notice: 'notice' })
|
18
|
+
alert_expected = alert_element('notice', 'info', 'notice')
|
19
19
|
expect(subject.render_flash_messages).to eql(alert_expected)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
context
|
24
|
-
it
|
25
|
-
subject.stub(:flash).and_return({:success
|
26
|
-
alert_expected = alert_element(
|
23
|
+
context 'when flash type is success' do
|
24
|
+
it 'returns the correct message' do
|
25
|
+
subject.stub(:flash).and_return({ success: 'success' })
|
26
|
+
alert_expected = alert_element('success', 'success', 'success')
|
27
27
|
expect(subject.render_flash_messages).to eql(alert_expected)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
context
|
32
|
-
it
|
33
|
-
subject.stub(:flash).and_return({:alert
|
34
|
-
alert_expected = alert_element(
|
31
|
+
context 'when flash type is alert' do
|
32
|
+
it 'returns the correct message' do
|
33
|
+
subject.stub(:flash).and_return({ alert: 'alert' })
|
34
|
+
alert_expected = alert_element('alert', 'error', 'alert')
|
35
35
|
expect(subject.render_flash_messages).to eql(alert_expected)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
context
|
40
|
-
it
|
41
|
-
flash
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
context 'when flash type is error' do
|
40
|
+
it 'returns the correct message' do
|
41
|
+
subject.stub(:flash).and_return({ error: 'error' })
|
42
|
+
alert_expected = alert_element('error', 'error', 'error')
|
43
|
+
expect(subject.render_flash_messages).to eql(alert_expected)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when has more than one message' do
|
48
|
+
it 'returns all the correct messages' do
|
49
|
+
subject.stub(:flash).and_return({ alert: 'alert', notice: 'notice' })
|
50
|
+
alerts_expected = alert_element('alert', 'error', 'alert') +
|
51
|
+
alert_element('notice', 'info', 'notice')
|
45
52
|
expect(subject.render_flash_messages).to eql(alerts_expected)
|
46
53
|
end
|
47
54
|
end
|
@@ -50,12 +57,11 @@ describe FlashRailsMessages::Helper do
|
|
50
57
|
|
51
58
|
def alert_element msg, klass, type
|
52
59
|
subject.content_tag(:div, close_element + msg,
|
53
|
-
:
|
60
|
+
class: "alert alert-#{klass} alert-#{type}")
|
54
61
|
end
|
55
62
|
|
56
63
|
def close_element
|
57
|
-
subject.content_tag(:span,
|
58
|
-
:
|
59
|
-
:"data-dismiss" => "alert")
|
64
|
+
subject.content_tag(:span, '×'.html_safe, class: 'close',
|
65
|
+
:"data-dismiss" => 'alert')
|
60
66
|
end
|
61
67
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flash_rails_messages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alejandro Gutiérrez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '>='
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - '>='
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -82,6 +82,11 @@ files:
|
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
84
|
- flash_rails_messages.gemspec
|
85
|
+
- images/alert.png
|
86
|
+
- images/default.png
|
87
|
+
- images/notice.png
|
88
|
+
- images/success.png
|
89
|
+
- images/success2.png
|
85
90
|
- lib/flash_rails_messages.rb
|
86
91
|
- lib/flash_rails_messages/base.rb
|
87
92
|
- lib/flash_rails_messages/helper.rb
|
@@ -98,17 +103,17 @@ require_paths:
|
|
98
103
|
- lib
|
99
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
105
|
requirements:
|
101
|
-
- - '>='
|
106
|
+
- - ! '>='
|
102
107
|
- !ruby/object:Gem::Version
|
103
108
|
version: '0'
|
104
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
110
|
requirements:
|
106
|
-
- - '>='
|
111
|
+
- - ! '>='
|
107
112
|
- !ruby/object:Gem::Version
|
108
113
|
version: '0'
|
109
114
|
requirements: []
|
110
115
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
116
|
+
rubygems_version: 2.2.2
|
112
117
|
signing_key:
|
113
118
|
specification_version: 4
|
114
119
|
summary: This gems provides an easy way to display flash rails messages
|