flash_rails_messages 0.0.4 → 0.0.5

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: ba9acc1b60b8fc0d96d578d7dd2e88f7eacab3f2
4
- data.tar.gz: b8760c7385bfafdfb12da84b5e57542886d66122
3
+ metadata.gz: e108c28cb06cb0f6d576880d8e72b776830d389e
4
+ data.tar.gz: ea97b21b3779de63aa6644b38a9b08946a517443
5
5
  SHA512:
6
- metadata.gz: 57dadbbf6ab066d18eb74d22d4751c0fa804c1c35efb8c45eb468178c7a080f570b891f9b6f0c76396f0e31a1369d95f89b591773a7f6465679b9528cc91859f
7
- data.tar.gz: c6212427be6a71c368a84cf949c189ac0686c9e1e21a1fc0cdf1a7ce9f2f02e738f6658378962f95f73d9f83c50954882987a01fcc561a156112f7c0d4c22d5a
6
+ metadata.gz: f4905439ea2b5980178921b5adcf4351771a8b6a411fdfc9433802c74651ea085e4b6da031c2b75deaaa16f5a9cd8eb25cde4c81be4a4d6442c621b7c8aaa8d4
7
+ data.tar.gz: 7233690a32a35d1c9a76b747b7d342cf4be00ff00b06ab3c65468ffceddb50e748cb44cf5a404bbd93f6cfcaf6b39531940781ec70c2c5b85b99b371f1197980
data/Gemfile CHANGED
@@ -1,6 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in flash_rails_messages.gemspec
4
3
  gemspec
5
4
 
6
5
  gem 'rails'
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # FlashRailsMessages[![Build Status](https://travis-ci.org/alejandrogutierrez/flash_rails_messages.png?branch=master)](https://travis-ci.org/alejandrogutierrez/flash_rails_messages)
1
+ # FlashRailsMessages
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
3
+ [![Build Status](https://travis-ci.org/alejandrogutierrez/flash_rails_messages.png?branch=master)](https://travis-ci.org/alejandrogutierrez/flash_rails_messages)
4
+
5
+ This gem provides an easy and simple way to display flash messages in a fancy way. It requires the
4
6
  [bootstrap](http://twitter.github.io/bootstrap)
5
7
  framework.
6
8
 
@@ -12,7 +14,7 @@ Add this line to your application's Gemfile:
12
14
 
13
15
  And then execute:
14
16
 
15
- $ bundle
17
+ $ bundle install
16
18
 
17
19
  Or install it yourself as:
18
20
 
@@ -24,8 +26,9 @@ You only need to add this line wherever you want to display the messages:
24
26
 
25
27
  <%= render_flash_messages %>
26
28
 
27
- You can add the line above in your html in multiple places.
29
+ You should add the line above in your html view. You can add it in multiple places.
28
30
 
31
+ ## Defaults
29
32
 
30
33
  The flash messages are displayed according to the flash type. By default shows a yellow alert.
31
34
 
@@ -44,11 +47,11 @@ By the way, the alerts are customizable. They will have a specific class accordi
44
47
 
45
48
  flash[:whatever] = "Some flash rails message"
46
49
 
47
- Will generate a html class in the alert wrapper like this `alert-whatever` to customize the css style.
50
+ It'll generate a class in the html alert wrapper like this `alert-whatever` to customize the style.
48
51
 
49
52
  ## Adding HTML elements
50
53
 
51
- The alerts that will be generated can include html elements. You just add html elements in the flash message.
54
+ The alerts that will be generated can include html elements. You just need to add html elements in the flash message.
52
55
  Example...
53
56
 
54
57
  flash[:success] = "<strong>This text will be bold</strong> and this one will be normal"
@@ -20,4 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~> 2.14.0"
24
+ spec.add_development_dependency "simplecov", "~> 0.7.1"
23
25
  end
@@ -1,48 +1,9 @@
1
- require "flash_rails_messages/version"
2
-
3
- module ActionView
4
- module Helpers
5
- module FlashRailsMessagesHelper
6
-
7
- def render_flash_messages
8
- flash.each do |type, msg|
9
- flash_messages << alert_element(type, msg) if msg
10
- flash[type] = nil
11
- end
12
-
13
- flash_messages.html_safe
14
- end
15
-
16
- private
17
-
18
- def alert_element type, msg
19
- content_tag(:div, close_element + msg.html_safe, :class => alert_classes(type))
20
- end
21
-
22
- def close_element
23
- content_tag(:span, "&times;".html_safe, :class => "close", :"data-dismiss" => "alert")
24
- end
25
-
26
- def alert_classes type
27
- "alert #{default_class(type)} alert-#{type}"
28
- end
29
-
30
- def default_class type
31
- case type
32
- when :success then "alert-success"
33
- when :notice then "alert-info"
34
- when :alert then "alert-error"
35
- end
36
- end
37
-
38
- def flash_messages
39
- @flash_messages ||= ""
40
- end
41
-
42
- end
43
- end
1
+ module FlashRailsMessages
2
+ autoload :Base, 'flash_rails_messages/base'
3
+ autoload :Helper, 'flash_rails_messages/helper'
4
+ autoload :VERSION, 'flash_rails_messages/version'
44
5
  end
45
6
 
46
7
  if defined?(ActionView::Helpers)
47
- ActionView::Helpers.send(:include, ActionView::Helpers::FlashRailsMessagesHelper)
8
+ ActionView::Helpers.send(:include, FlashRailsMessages::Helper)
48
9
  end
@@ -0,0 +1,39 @@
1
+ module FlashRailsMessages
2
+ class Base
3
+ include ActionView::Helpers::TagHelper
4
+
5
+ def render flash
6
+ flash_messages = ""
7
+
8
+ flash.each do |type, msg|
9
+ flash_messages << alert_element(type, msg) if msg
10
+ flash[type] = nil
11
+ end
12
+
13
+ flash_messages.html_safe
14
+ end
15
+
16
+ private
17
+
18
+ def alert_element type, msg
19
+ content_tag(:div, close_element + msg.html_safe, :class => alert_classes(type))
20
+ end
21
+
22
+ def close_element
23
+ content_tag(:span, "&times;".html_safe, :class => "close", :"data-dismiss" => "alert")
24
+ end
25
+
26
+ def alert_classes type
27
+ "alert #{default_class(type)} alert-#{type}"
28
+ end
29
+
30
+ def default_class type
31
+ case type
32
+ when :success then "alert-success"
33
+ when :notice then "alert-info"
34
+ when :alert then "alert-error"
35
+ end
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,14 @@
1
+ module FlashRailsMessages
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.
6
+ #
7
+ # <%= render_flash_messages %>
8
+ #
9
+ def render_flash_messages
10
+ FlashRailsMessages::Base.new.render(flash)
11
+ end
12
+
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module FlashRailsMessages
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ActionView::Helpers::FlashRailsMessagesHelper do
3
+ describe FlashRailsMessages::Helper do
4
4
  let!(:subject){ ActionView::Base.new }
5
5
 
6
6
  describe "#render_flash_messages" do
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
4
+ version: 0.0.5
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-08-20 00:00:00.000000000 Z
11
+ date: 2013-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 2.14.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.14.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.7.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.7.1
41
69
  description: A simple helper to display flash rails messages
42
70
  email:
43
71
  - alejandrodevs@gmail.com
@@ -55,6 +83,8 @@ files:
55
83
  - Rakefile
56
84
  - flash_rails_messages.gemspec
57
85
  - lib/flash_rails_messages.rb
86
+ - lib/flash_rails_messages/base.rb
87
+ - lib/flash_rails_messages/helper.rb
58
88
  - lib/flash_rails_messages/version.rb
59
89
  - spec/flash_rails_messages_spec.rb
60
90
  - spec/spec_helper.rb