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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e108c28cb06cb0f6d576880d8e72b776830d389e
4
- data.tar.gz: ea97b21b3779de63aa6644b38a9b08946a517443
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2JmMDAyMTJmOGU2MjI3Njg5ZTgwMGI4YWYzYThkYjBhODVjMjA3NA==
5
+ data.tar.gz: !binary |-
6
+ NWE1NjZmODBlNjUxNzliYWJlN2MzMjMwNjlkMTc2YTRiMWRhMzc5NA==
5
7
  SHA512:
6
- metadata.gz: f4905439ea2b5980178921b5adcf4351771a8b6a411fdfc9433802c74651ea085e4b6da031c2b75deaaa16f5a9cd8eb25cde4c81be4a4d6442c621b7c8aaa8d4
7
- data.tar.gz: 7233690a32a35d1c9a76b747b7d342cf4be00ff00b06ab3c65468ffceddb50e748cb44cf5a404bbd93f6cfcaf6b39531940781ec70c2c5b85b99b371f1197980
8
+ metadata.gz: !binary |-
9
+ MDQzMTUyY2RhZTkzZmQ2MzExZDI5YjY1NmMzOWUzZDBiYzU0NTNjZWJjM2U4
10
+ ZGE5YzQzNmY0MTE4NWU3MWJjNzBmNzk2ODJlYzViNDgxYzM4YTBiZjc0MTFj
11
+ NDIzMmEwMmM5YWZhNTEyYmYyNTlmNmFjYzVjZmZmMjZmZjJhNjY=
12
+ data.tar.gz: !binary |-
13
+ MTZhN2JjMzk2Y2JiMTU0ZmVlYTY2MzdjYjU2MDAzY2I2YzI1N2IzOTAzYzBl
14
+ ZDVkMThmMmU3YjY2ZDQ5YzBlOGZjMmVlZjQ1NDIxNzY3ZTU3NTdiYTUyNDVh
15
+ ZDE3NGFmMGEyODE5ZjdhZjE1MzViMWM0YWQ4OTRlYTM3ZmViNzc=
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  *.gem
2
2
  *.rbc
3
3
  .bundle
4
+ .rvmrc
4
5
  .config
5
6
  .yardoc
6
7
  Gemfile.lock
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 2.0.0" > .rvmrc
9
- environment_id="ruby-2.0.0-p0@flash_rails_messages"
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.19.1 (stable)" # 1.10.1 seams as a safe start
13
- # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
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
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails'
5
+ gem 'rails', '~> 3.2.13'
6
6
  gem 'rspec'
7
7
  gem 'simplecov'
8
+ gem 'coveralls', require: false
data/README.md CHANGED
@@ -1,6 +1,4 @@
1
- # FlashRailsMessages
2
-
3
- [![Build Status](https://travis-ci.org/alejandrogutierrez/flash_rails_messages.png?branch=master)](https://travis-ci.org/alejandrogutierrez/flash_rails_messages)
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)
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 type. By default shows a yellow alert.
31
+ The flash messages are displayed according to the flash key. Examples...
34
32
 
35
33
  **success**
36
- - Shows a green alert
34
+ ![Success Alert](https://raw.github.com/alejandrogutierrez/flash_rails_messages/master/images/success.png)
37
35
 
38
36
  **notice**
39
- - Shows a blue alert
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)
40
41
 
41
- **alert**
42
- - Shows a red alert
42
+ **other key (default)**
43
+ ![Default Alert](https://raw.github.com/alejandrogutierrez/flash_rails_messages/master/images/default.png)
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
- flash[:whatever] = "Some flash rails message"
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
- flash[:success] = "<strong>This text will be bold</strong> and this one will be normal"
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
+ ![Success HTML Alert](https://raw.github.com/alejandrogutierrez/flash_rails_messages/master/images/success2.png)
58
66
 
59
67
  ## Contributing
60
68
 
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
 
3
3
  namespace :rspec do
4
- desc "Running all tests"
4
+ desc 'Running all tests'
5
5
  task :all do
6
- system("rspec")
6
+ system('rspec')
7
7
  end
8
8
  end
9
9
 
@@ -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 = "flash_rails_messages"
7
+ spec.name = 'flash_rails_messages'
8
8
  spec.version = FlashRailsMessages::VERSION
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"
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 = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
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"
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
Binary file
data/images/notice.png ADDED
Binary file
Binary file
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, :class => alert_classes(type))
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, "&times;".html_safe, :class => "close", :"data-dismiss" => "alert")
23
+ content_tag(:span, '&times;'.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 then "alert-success"
33
- when :notice then "alert-info"
34
- when :alert then "alert-error"
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
- # Returns flash rails messages that will be displayed in your DOM. Just
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
@@ -1,3 +1,3 @@
1
1
  module FlashRailsMessages
2
- VERSION = "0.0.5"
2
+ VERSION = '0.0.6'
3
3
  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 "#render_flash_messages" do
7
- context "when flash does not have messages" do
8
- it "returns nothing" do
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 "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")
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 "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")
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 "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")
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 "when has more than one message" do
40
- it "returns all the correct messages" do
41
- flash = {:alert => "alert", :notice => "notice"}
42
- subject.stub(:flash).and_return(flash)
43
- alerts_expected = alert_element("alert", "error", "alert") +
44
- alert_element("notice", "info", "notice")
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
- :class => "alert alert-#{klass} alert-#{type}")
60
+ class: "alert alert-#{klass} alert-#{type}")
54
61
  end
55
62
 
56
63
  def close_element
57
- subject.content_tag(:span, "&times;".html_safe,
58
- :class => "close",
59
- :"data-dismiss" => "alert")
64
+ subject.content_tag(:span, '&times;'.html_safe, class: 'close',
65
+ :"data-dismiss" => 'alert')
60
66
  end
61
67
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+ Coveralls::Output.silent = true
2
5
 
3
6
  require 'action_view'
4
7
  require 'flash_rails_messages'
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.5
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: 2013-09-30 00:00:00.000000000 Z
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.0.0
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