flash_rails_messages 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: deb23dfab9f19d4dce2a82dfbcd69b72169d63f1
4
- data.tar.gz: 9acce72fe337fdee59540916c0067e279f3c8df3
3
+ metadata.gz: 67ba8dde12a18d4c16ff0e2d58a21c59c087cde1
4
+ data.tar.gz: cc7773f7c89fc2e9dfca6da573b16e2e6f29126f
5
5
  SHA512:
6
- metadata.gz: b35805e4907edaa03698c4bee4ba75406e9cbfe61c14676174097f2a9c22c732f5e76534572485e5cb30223b0d90a3879049368e4f483afa619c2baff0b30038
7
- data.tar.gz: 18629c9de86d70f6724a77edbd3bab167be560c8e8dd7cdcb983754d6a91b9fe40a2e60efe090746d419db8aab58a580142398d752596dcfed3d3518d79e2138
6
+ metadata.gz: 8db89afe871558fda7b3cd47580a1dc64a7ffdc94fddbbcc310939dc7bba0f429ba1c6c2a7303bc23c2891f712f9e151e754dc92b41668a30751f125174d6de7
7
+ data.tar.gz: 3c8a3cc14a42e57a86455ddf8bf5b60ba0a9780e097794fc9cb3465b465c52f1281122554562e21a6569aa696f4dc7296a51e5902fd934e27856e90133843a1f
data/.rvmrc CHANGED
@@ -6,10 +6,10 @@
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
8
  # echo "rvm use 2.0.0" > .rvmrc
9
- environment_id="ruby-2.0.0-p195@flash_rails_messages"
9
+ environment_id="ruby-2.0.0-p0@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.20.13 (version)" # 1.10.1 seams as a safe start
12
+ # rvmrc_rvm_version="1.19.1 (stable)" # 1.10.1 seams as a safe start
13
13
  # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | 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
@@ -30,13 +30,6 @@ 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: \E[32m$GEM_HOME\E[0m" # show the user the ruby and gemset they are using in green
37
- else printf "%b" "Using: $GEM_HOME" # don't use colors in non-interactive shells
38
- fi
39
- fi
40
33
  else
41
34
  # If the environment file has not yet been created, use the RVM CLI to select.
42
35
  rvm --create "$environment_id" || {
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # FlashRailsMessages[![Build Status](https://travis-ci.org/alejandrogutierrez/flash_rails_messages.png?branch=master)](https://travis-ci.org/alejandrogutierrez/flash_rails_messages)
2
2
 
3
- This gem provides an easy and simple way to display flash messages to your users to inform them that an action has or hasn't taken place. It's using the bootstrap framework.
3
+ This gem provides an easy and simple way to display flash messages to your users to inform them that an action has or hasn't taken place. It's using the
4
+ [bootstrap](http://twitter.github.io/bootstrap)
5
+ framework.
4
6
 
5
7
  ## Installation
6
8
 
@@ -26,15 +28,26 @@ You can add the line above in your html in multiple places.
26
28
 
27
29
 
28
30
  The flash messages are displayed according to the flash type.
31
+ By default shows a yellow alert.
29
32
 
30
- - success = green alert
31
- - notice = blue alert
32
- - alert = red alert
33
+ **success**
34
+ - Shows a green alert
33
35
 
34
- **By default shows a yellow alert.**
36
+ **notice**
37
+ - Shows a blue alert
35
38
 
36
- *NOTE:*
37
- In next versions styles will be customizable.
39
+ **alert**
40
+ - Shows a red alert
41
+
42
+ ## Customize alerts
43
+
44
+ By the way, the alerts are customizable. They will have a specific class according to the flash key. Example...
45
+
46
+ A flash message like this...
47
+
48
+ flash[:whatever] = "Some flash rails message"
49
+
50
+ Will generate a html class in the alert wrapper like this `alert-whatever` to customize the css style.
38
51
 
39
52
  ## Contributing
40
53
 
@@ -1,3 +1,3 @@
1
1
  module FlashRailsMessages
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -7,7 +7,7 @@ module ActionView
7
7
  def render_flash_messages
8
8
  flash.each do |type, msg|
9
9
  flash_messages << alert_element(type, msg) if msg
10
- clean_flash_message(type)
10
+ flash[type] = nil
11
11
  end
12
12
 
13
13
  flash_messages.html_safe
@@ -15,10 +15,6 @@ module ActionView
15
15
 
16
16
  private
17
17
 
18
- def clean_flash_message type
19
- flash[type] = nil
20
- end
21
-
22
18
  def alert_element type, msg
23
19
  content_tag(:div, close_element + msg, :class => alert_classes(type))
24
20
  end
@@ -28,10 +24,10 @@ module ActionView
28
24
  end
29
25
 
30
26
  def alert_classes type
31
- "alert #{custom_classes(type)}"
27
+ "alert #{default_class(type)} alert-#{type}"
32
28
  end
33
29
 
34
- def custom_classes type
30
+ def default_class type
35
31
  case type
36
32
  when :success then "alert-success"
37
33
  when :notice then "alert-info"
@@ -15,21 +15,24 @@ describe ActionView::Helpers::FlashRailsMessagesHelper 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
- expect(subject.render_flash_messages).to eql(alert_element("notice", "info"))
18
+ alert_expected = alert_element("notice", "info", "notice")
19
+ expect(subject.render_flash_messages).to eql(alert_expected)
19
20
  end
20
21
  end
21
22
 
22
23
  context "when flash type is success" do
23
24
  it "returns the correct message" do
24
25
  subject.stub(:flash).and_return({:success => "success"})
25
- expect(subject.render_flash_messages).to eql(alert_element("success", "success"))
26
+ alert_expected = alert_element("success", "success", "success")
27
+ expect(subject.render_flash_messages).to eql(alert_expected)
26
28
  end
27
29
  end
28
30
 
29
31
  context "when flash type is alert" do
30
32
  it "returns the correct message" do
31
33
  subject.stub(:flash).and_return({:alert => "alert"})
32
- expect(subject.render_flash_messages).to eql(alert_element("alert", "error"))
34
+ alert_expected = alert_element("alert", "error", "alert")
35
+ expect(subject.render_flash_messages).to eql(alert_expected)
33
36
  end
34
37
  end
35
38
 
@@ -37,19 +40,22 @@ describe ActionView::Helpers::FlashRailsMessagesHelper do
37
40
  it "returns all the correct messages" do
38
41
  flash = {:alert => "alert", :notice => "notice"}
39
42
  subject.stub(:flash).and_return(flash)
40
- alerts_expected = alert_element("alert", "error") +
41
- alert_element("notice", "info")
43
+ alerts_expected = alert_element("alert", "error", "alert") +
44
+ alert_element("notice", "info", "notice")
42
45
  expect(subject.render_flash_messages).to eql(alerts_expected)
43
46
  end
44
47
  end
45
48
  end
46
49
  end
47
50
 
48
- def alert_element msg, type
49
- subject.content_tag(:div, close_element + msg ,:class => "alert alert-#{type}")
51
+ def alert_element msg, klass, type
52
+ subject.content_tag(:div, close_element + msg,
53
+ :class => "alert alert-#{klass} alert-#{type}")
50
54
  end
51
55
 
52
56
  def close_element
53
- subject.content_tag(:span, "&times;".html_safe, :class => "close", :"data-dismiss" => "alert")
57
+ subject.content_tag(:span, "&times;".html_safe,
58
+ :class => "close",
59
+ :"data-dismiss" => "alert")
54
60
  end
55
61
  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.1
4
+ version: 0.0.2
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-07-10 00:00:00.000000000 Z
11
+ date: 2013-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler