flash_rails_messages 0.0.7 → 0.0.8

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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NjlkNzhmOTQ3MWQ3NjU5ZTgxY2UyZGJhMzNkOWUwY2MwZDg3YjFmOA==
5
- data.tar.gz: !binary |-
6
- OWQyZjMxMGY0NGY1ZDcxNWRmNzA3ZjBjZDZlYTQ1MDM2MjRkMTViMw==
2
+ SHA1:
3
+ metadata.gz: d010a0262e10db2f4c82d7fd08b97b03dcdd8b3d
4
+ data.tar.gz: 99a060000ef1a468409e468994648a14a51df2ef
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZDVlNjc0NDZmNGNmODc3MDA5ZDk4MDVkYTg5MWQzZmU4NThmMTlhYWRlMGVk
10
- YjgyYzMxMjMyOGI2Yjg0YmRjZWRlZjUzNWNlMGYyZjZkYjAxMjhiMDUwN2E5
11
- ZTIwYTkwMDljNDc1NmQ3OTdhMmNiYWU1MTNmM2ZlYjk1MTI3ZmQ=
12
- data.tar.gz: !binary |-
13
- YTdhYmYyYjU3NjY0OGUzNGU3OGQwZGVhYWQxYmRiZjQ4MTVhZTRjMjQ1N2Vh
14
- YWQxNWNhOWZlNjJkN2RhNDFlNDRlNjEyZmQwMzRiMWM0M2QyYjhmZmYxMjMy
15
- NjY5MGYzMzBhYjUwYTUxZTNhNjgyZDJhZGFjMDc5OGY0MWFhNjI=
6
+ metadata.gz: 7f8e758bc8f38691de4c92c342c9c4a1a05f9afef82b9e8a775d56d7af7dd0e8364cc7fbb2032d43abb52cbfb59670998df348cd44c75aa4d2e2f4d7c4eeabd6
7
+ data.tar.gz: 87e7afb7398af07e95febd60336f9d7b0ec3efafc9e994a9960def2897c3ecdc45748662fe03d8a7ace1c16561ba7247c6d0828a4aa407ad69ae953c4da935dd
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "2.0.0"
4
- - "1.9.3"
3
+ - '2.0.0'
4
+ - '1.9.3'
data/README.md CHANGED
@@ -1,71 +1,49 @@
1
- # FlashRailsMessages [![Build Status](https://travis-ci.org/alejandrogutierrez/flash_rails_messages.png?branch=master)](https://travis-ci.org/alejandrogutierrez/flash_rails_messages) [![Coverage Status](https://coveralls.io/repos/alejandrogutierrez/flash_rails_messages/badge.png)](https://coveralls.io/r/alejandrogutierrez/flash_rails_messages)
1
+ # FlashRailsMessages
2
2
 
3
- This gem provides an easy and simple way to display flash messages in a fancy way. It requires the
4
- [bootstrap](http://twitter.github.io/bootstrap)
5
- framework.
3
+ [![Build Status](https://travis-ci.org/alejandrogutierrez/flash_rails_messages.png?branch=master)](https://travis-ci.org/alejandrogutierrez/flash_rails_messages)
4
+ [![Coverage Status](https://coveralls.io/repos/alejandrogutierrez/flash_rails_messages/badge.png)](https://coveralls.io/r/alejandrogutierrez/flash_rails_messages)
6
5
 
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- gem 'flash_rails_messages'
12
-
13
- And then execute:
14
-
15
- $ bundle install
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install flash_rails_messages
20
-
21
- ## Usage
22
-
23
- You only need to add this line wherever you want to display the messages:
24
-
25
- <%= render_flash_messages %>
26
-
27
- You should add the line above in your html view. You can add it in multiple places.
28
6
 
29
- ## Defaults
7
+ This gem provides an easy and simple way to display flash rails messages.
8
+ This works with [Bootstrap](http://getbootstrap.com/) and [Zurb Foundation 3](http://foundation.zurb.com/) frameworks.
30
9
 
31
- The flash messages are displayed according to the flash key. Examples...
32
10
 
33
- **success**
34
- ![Success Alert](https://raw.github.com/alejandrogutierrez/flash_rails_messages/master/images/success.png)
35
-
36
- **notice**
37
- ![Notice Alert](https://raw.github.com/alejandrogutierrez/flash_rails_messages/master/images/notice.png)
38
-
39
- **alert or error**
40
- ![Alert Alert](https://raw.github.com/alejandrogutierrez/flash_rails_messages/master/images/alert.png)
11
+ ## Installation
12
+ Add this line to your application's Gemfile:
13
+ ```ruby
14
+ gem 'flash_rails_messages'
15
+ ```
16
+ Run the bundle command to install it.
41
17
 
42
- **other key (default)**
43
- ![Default Alert](https://raw.github.com/alejandrogutierrez/flash_rails_messages/master/images/default.png)
44
18
 
45
- ## Customize alerts
19
+ ### Bootstrap
20
+ To integrate **FlashRailsMessages** with [Bootstrap](http://getbootstrap.com/) run the next:
21
+ ```console
22
+ rails generate flash_rails_messages:install --bootstrap
23
+ ```
24
+ NOTE: Be sure that you added Bootstrap assets on your application.
46
25
 
47
- By the way, the alerts are customizable. They will have a specific class according to the flash key. Example...
48
26
 
49
- ```ruby
50
- flash[:whatever] = "Some flash rails message"
27
+ ### Zurb Foundation 3
28
+ To integrate **FlashRailsMessages** with [Zurb Foundation 3](http://foundation.zurb.com/) run the next:
29
+ ```console
30
+ rails generate flash_rails_messages:install --foundation
51
31
  ```
32
+ NOTE: Be sure that you added Foundation assets on your application.
52
33
 
53
- It'll generate a class in the html alert wrapper like this `alert-whatever` to customize the style.
54
34
 
55
- ## Adding HTML elements
35
+ ## Usage
36
+ You just need to add the line below in your layout:
37
+ ```erb
38
+ <%= render_flash_messages %>
39
+ ```
56
40
 
57
- The alerts that will be generated can include html elements. You just need to add html elements in the flash message.
58
- Example...
59
41
 
60
- ```ruby
61
- flash[:success] = "<strong>This text will be bold</strong> and this will be normal"
62
- ```
42
+ ## Customize alert
43
+ Just update your **FlashRailsMessages** initializer according to your needs.
63
44
 
64
- The line above will generate this:
65
- ![Success HTML Alert](https://raw.github.com/alejandrogutierrez/flash_rails_messages/master/images/success2.png)
66
45
 
67
46
  ## Contributing
68
-
69
47
  1. Fork it
70
48
  2. Create your feature branch (`git checkout -b my-new-feature`)
71
49
  3. Commit your changes (`git commit -am 'Add some feature'`)
@@ -17,13 +17,13 @@ module FlashRailsMessages
17
17
  end
18
18
 
19
19
  def close_element
20
- content_tag :span, class: 'close', :'data-dismiss' => 'alert' do
20
+ content_tag :a, class: 'close', href: '#' do
21
21
  '&times;'.html_safe
22
22
  end
23
23
  end
24
24
 
25
25
  def alert_classes(type)
26
- "#{default_alert_class} #{alert_type_classes[type]} #{custom_alert_class(type)}"
26
+ "#{default_alert_class} #{alert_type_classes[type]} #{custom_alert_classes}".strip
27
27
  end
28
28
 
29
29
  def default_alert_class
@@ -31,16 +31,10 @@ module FlashRailsMessages
31
31
  end
32
32
 
33
33
  def alert_type_classes
34
- {
35
- success: 'alert-success',
36
- notice: 'alert-info',
37
- alert: 'alert-error',
38
- error: 'alert-error',
39
- }
34
+ {}
40
35
  end
41
36
 
42
- def custom_alert_class(type)
43
- "alert-#{type}"
37
+ def custom_alert_classes
44
38
  end
45
39
  end
46
40
  end
@@ -1,3 +1,3 @@
1
1
  module FlashRailsMessages
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
@@ -0,0 +1,25 @@
1
+ module FlashRailsMessages
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc 'FlashRailsMessages initializer'
5
+ source_root File.expand_path('../templates', __FILE__)
6
+ class_option :bootstrap, type: :boolean, desc: 'Use Bootstrap in flash alerts.'
7
+ class_option :foundation, type: :boolean, desc: 'Use Foundation in flash alerts.'
8
+
9
+ def install_info
10
+ return if options.bootstrap? || options.foundation?
11
+ puts 'FlashRailsMessages supports Bootstrap and Zurb Foundation 3. If you want '\
12
+ 'a configuration that is compatible with one of these frameworks, then please ' \
13
+ 're-run this generator with --bootstrap or --foundation as an option.'
14
+ end
15
+
16
+ def install_initializer
17
+ if options.bootstrap?
18
+ template 'config/initializers/flash_rails_messages_bootstrap.rb'
19
+ elsif options.foundation?
20
+ template 'config/initializers/flash_rails_messages_foundation.rb'
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,36 @@
1
+ module FlashRailsMessages
2
+ class Base
3
+ # BOOTSTRAP FRAMEWORK
4
+ # =========================================
5
+
6
+ def alert_element(type, message)
7
+ content_tag :div, class: alert_classes(type), role: 'alert' do
8
+ close_element + message.html_safe
9
+ end
10
+ end
11
+
12
+ def close_element
13
+ content_tag :button, type: 'button', class: 'close', :'data-dismiss' => 'alert' do
14
+ content_tag(:span, '&times;'.html_safe, :'aria-hidden' => 'true') +
15
+ content_tag(:span, 'Close', class: 'sr-only')
16
+ end
17
+ end
18
+
19
+ def default_alert_class
20
+ 'alert'
21
+ end
22
+
23
+ def alert_type_classes
24
+ {
25
+ success: 'alert-success',
26
+ notice: 'alert-info',
27
+ alert: 'alert-error',
28
+ error: 'alert-error',
29
+ }
30
+ end
31
+
32
+ def custom_alert_class
33
+ 'alert-dismissible'
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,35 @@
1
+ module FlashRailsMessages
2
+ class Base
3
+ # ZURB FOUNDATION FRAMEWORK
4
+ # =========================================
5
+
6
+ def alert_element(type, message)
7
+ content_tag :div, class: alert_classes(type), :'data-alert' => '' do
8
+ close_element + message.html_safe
9
+ end
10
+ end
11
+
12
+ #def close_element
13
+ #content_tag :a, class: 'close', href: '#' do
14
+ #'&times;'.html_safe
15
+ #end
16
+ #end
17
+
18
+ def default_alert_class
19
+ 'alert-box'
20
+ end
21
+
22
+ def alert_type_classes
23
+ {
24
+ success: 'success',
25
+ notice: 'info',
26
+ alert: 'alert',
27
+ error: 'alert',
28
+ }
29
+ end
30
+
31
+ #def custom_alert_class
32
+ #Add custom alert classes as a string
33
+ #end
34
+ end
35
+ end
@@ -15,7 +15,7 @@ describe FlashRailsMessages::Helper do
15
15
  context 'when flash type is notice' do
16
16
  it 'returns the correct message' do
17
17
  subject.stub(:flash).and_return({ notice: 'notice' })
18
- alert_expected = alert_element('notice', 'info', 'notice')
18
+ alert_expected = alert_element('notice', 'info')
19
19
  expect(subject.render_flash_messages).to eql(alert_expected)
20
20
  end
21
21
  end
@@ -23,7 +23,7 @@ describe FlashRailsMessages::Helper do
23
23
  context 'when flash type is success' do
24
24
  it 'returns the correct message' do
25
25
  subject.stub(:flash).and_return({ success: 'success' })
26
- alert_expected = alert_element('success', 'success', 'success')
26
+ alert_expected = alert_element('success', 'success')
27
27
  expect(subject.render_flash_messages).to eql(alert_expected)
28
28
  end
29
29
  end
@@ -31,7 +31,7 @@ describe FlashRailsMessages::Helper do
31
31
  context 'when flash type is alert' do
32
32
  it 'returns the correct message' do
33
33
  subject.stub(:flash).and_return({ alert: 'alert' })
34
- alert_expected = alert_element('alert', 'error', 'alert')
34
+ alert_expected = alert_element('alert', 'error')
35
35
  expect(subject.render_flash_messages).to eql(alert_expected)
36
36
  end
37
37
  end
@@ -39,7 +39,7 @@ describe FlashRailsMessages::Helper do
39
39
  context 'when flash type is error' do
40
40
  it 'returns the correct message' do
41
41
  subject.stub(:flash).and_return({ error: 'error' })
42
- alert_expected = alert_element('error', 'error', 'error')
42
+ alert_expected = alert_element('error', 'error')
43
43
  expect(subject.render_flash_messages).to eql(alert_expected)
44
44
  end
45
45
  end
@@ -47,21 +47,19 @@ describe FlashRailsMessages::Helper do
47
47
  context 'when has more than one message' do
48
48
  it 'returns all the correct messages' do
49
49
  subject.stub(:flash).and_return({ alert: 'alert', notice: 'notice' })
50
- alerts_expected = alert_element('alert', 'error', 'alert') +
51
- alert_element('notice', 'info', 'notice')
50
+ alerts_expected = alert_element('alert', 'error') +
51
+ alert_element('notice', 'info')
52
52
  expect(subject.render_flash_messages).to eql(alerts_expected)
53
53
  end
54
54
  end
55
55
  end
56
56
  end
57
57
 
58
- def alert_element msg, klass, type
59
- subject.content_tag(:div, close_element + msg,
60
- class: "alert alert-#{klass} alert-#{type}")
58
+ def alert_element msg, klass
59
+ subject.content_tag(:div, close_element + msg.html_safe, class: 'alert')
61
60
  end
62
61
 
63
62
  def close_element
64
- subject.content_tag(:span, '&times;'.html_safe, class: 'close',
65
- :"data-dismiss" => 'alert')
63
+ subject.content_tag(:a, '&times;'.html_safe, class: 'close', href: '#')
66
64
  end
67
65
  end
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.7
4
+ version: 0.0.8
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: 2014-08-06 00:00:00.000000000 Z
11
+ date: 2014-08-19 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
@@ -75,22 +75,19 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - .gitignore
77
77
  - .rspec
78
- - .rvmrc
79
78
  - .travis.yml
80
79
  - Gemfile
81
80
  - LICENSE.txt
82
81
  - README.md
83
82
  - Rakefile
84
83
  - flash_rails_messages.gemspec
85
- - images/alert.png
86
- - images/default.png
87
- - images/notice.png
88
- - images/success.png
89
- - images/success2.png
90
84
  - lib/flash_rails_messages.rb
91
85
  - lib/flash_rails_messages/base.rb
92
86
  - lib/flash_rails_messages/helper.rb
93
87
  - lib/flash_rails_messages/version.rb
88
+ - lib/generators/flash_rails_messages/install_generator.rb
89
+ - lib/generators/flash_rails_messages/templates/config/initializers/flash_rails_messages_bootstrap.rb
90
+ - lib/generators/flash_rails_messages/templates/config/initializers/flash_rails_messages_foundation.rb
94
91
  - spec/flash_rails_messages_spec.rb
95
92
  - spec/spec_helper.rb
96
93
  homepage: https://github.com/alejandrogutierrez/flash_rails_messages
@@ -103,12 +100,12 @@ require_paths:
103
100
  - lib
104
101
  required_ruby_version: !ruby/object:Gem::Requirement
105
102
  requirements:
106
- - - ! '>='
103
+ - - '>='
107
104
  - !ruby/object:Gem::Version
108
105
  version: '0'
109
106
  required_rubygems_version: !ruby/object:Gem::Requirement
110
107
  requirements:
111
- - - ! '>='
108
+ - - '>='
112
109
  - !ruby/object:Gem::Version
113
110
  version: '0'
114
111
  requirements: []
data/.rvmrc DELETED
@@ -1,62 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
- # development environment upon cd'ing into the directory
5
-
6
- # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
- # Only full ruby name is supported here, for short names use:
8
- # echo "rvm use 1.9.3" > .rvmrc
9
- environment_id="ruby-1.9.3-p484@flash_rails_messages"
10
-
11
- # Uncomment the following lines if you want to verify rvm version per project
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
- # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
- # return 1
16
- # }
17
-
18
- # First we attempt to load the desired environment directly from the environment
19
- # file. This is very fast and efficient compared to running through the entire
20
- # CLI and selector. If you want feedback on which environment was used then
21
- # insert the word 'use' after --create as this triggers verbose mode.
22
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
- then
25
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
- for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*
27
- do
28
- if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]
29
- then \. "${__hook}" || true
30
- fi
31
- done
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
42
- else
43
- # If the environment file has not yet been created, use the RVM CLI to select.
44
- rvm --create "$environment_id" || {
45
- echo "Failed to create RVM environment '${environment_id}'."
46
- return 1
47
- }
48
- fi
49
-
50
- # If you use bundler, this might be useful to you:
51
- # if [[ -s Gemfile ]] && {
52
- # ! builtin command -v bundle >/dev/null ||
53
- # builtin command -v bundle | GREP_OPTIONS="" \grep $rvm_path/bin/bundle >/dev/null
54
- # }
55
- # then
56
- # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
57
- # gem install bundler
58
- # fi
59
- # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
60
- # then
61
- # bundle install | GREP_OPTIONS="" \grep -vE '^Using|Your bundle is complete'
62
- # fi
data/images/alert.png DELETED
Binary file
data/images/default.png DELETED
Binary file
data/images/notice.png DELETED
Binary file
data/images/success.png DELETED
Binary file
data/images/success2.png DELETED
Binary file