simple_messages 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +22 -0
- data/.rspec +3 -0
- data/.travis.yml +15 -0
- data/Gemfile +4 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +62 -0
- data/Rakefile +6 -0
- data/lib/simple_messages.rb +18 -0
- data/lib/simple_messages/action_controller.rb +34 -0
- data/lib/simple_messages/action_view.rb +57 -0
- data/lib/simple_messages/builder.rb +93 -0
- data/lib/simple_messages/engine.rb +4 -0
- data/lib/simple_messages/version.rb +3 -0
- data/simple_messages.gemspec +32 -0
- data/spec/lib/simple_messages/builder_spec.rb +80 -0
- data/spec/spec_helper.rb +13 -0
- data/vendor/assets/javascripts/simple_messages.js +54 -0
- metadata +205 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 83d41874ead77c11ec3bbef3c22a0fa3f86cabb8
|
4
|
+
data.tar.gz: 468cb9500317cd2763c90d4d4cfe32bc8d94a997
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ba07a6d9deba03c3b90981bcbef2bdac17844d959a0adb05d338ac2d752de0f3452c0ce3f1d49c2faa47e620f3e955f4e6931efa05275cd580d02e1668e50a5
|
7
|
+
data.tar.gz: 5d93ec3b49b3bc631c09845c0798386604100fbeca9ae5be54c0bbd9b540f30c9a6a7508cfc9477d1a4280ebb61f4cba2e39629f15fd79982b4720d9f1f35efa
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
|
4
|
+
rvm:
|
5
|
+
- 2.0.0
|
6
|
+
|
7
|
+
script: 'bundle exec rake'
|
8
|
+
|
9
|
+
notifications:
|
10
|
+
email:
|
11
|
+
recipients:
|
12
|
+
- felipe@29sul.com.br
|
13
|
+
- elton@29sul.com.br
|
14
|
+
on_failure: change # [always|never|change]
|
15
|
+
on_success: change # [always|never|change]
|
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Elton Luis Kolling
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Simple Messages
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/29sul/simple_messages.svg?branch=master)](https://travis-ci.org/29sul/simple_messages)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/29sul/simple_messages/badge.png?branch=master)](https://coveralls.io/r/29sul/simple_messages?branch=master)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/29sul/simple_messages/badges/gpa.svg)](https://codeclimate.com/github/29sul/simple_messages)
|
6
|
+
|
7
|
+
Gem for displaying flash messages and validation of ActiveRecord.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'simple_messages'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install simple_messages
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### View helpers
|
26
|
+
|
27
|
+
Show messages from flash and ActiveRecord. Options: { flash_messages: true, validation_messages: true, closable: false }
|
28
|
+
|
29
|
+
= simple_messages
|
30
|
+
|
31
|
+
Show only messages from flash. Options: { closable: false }
|
32
|
+
|
33
|
+
= simple_messages_flash closable: true
|
34
|
+
|
35
|
+
Show only messages from validations of ActiveRecord. Options: { closable: false }
|
36
|
+
|
37
|
+
= simple_messages_validation closable: false
|
38
|
+
|
39
|
+
Show messages on remote request.
|
40
|
+
|
41
|
+
js_simple_messages
|
42
|
+
|
43
|
+
Show messages in a alert javascript.
|
44
|
+
|
45
|
+
js_simple_messages_alert [ 'This message 1.', 'This message 2.' ]
|
46
|
+
|
47
|
+
### Controller helpers
|
48
|
+
|
49
|
+
Add product object ActiveRecord
|
50
|
+
|
51
|
+
simple_messages_for_model :product
|
52
|
+
|
53
|
+
Skipping product object ActiveRecord
|
54
|
+
|
55
|
+
dont_simple_messages_for_model :product
|
56
|
+
|
57
|
+
List objects ActiveRecord
|
58
|
+
|
59
|
+
simple_messages_models
|
60
|
+
|
61
|
+
by default is added the controller_name.singular.
|
62
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "simple_messages/engine"
|
2
|
+
require "simple_messages/version"
|
3
|
+
|
4
|
+
module SimpleMessages
|
5
|
+
|
6
|
+
autoload :ActionController, 'simple_messages/action_controller'
|
7
|
+
|
8
|
+
autoload :ActionView, 'simple_messages/action_view'
|
9
|
+
|
10
|
+
autoload :Builder, 'simple_messages/builder'
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
# Include ActionController functionality
|
15
|
+
ActionController::Base.send :include, SimpleMessages::ActionController
|
16
|
+
|
17
|
+
# Include ActionView functionality
|
18
|
+
ActionView::Base.send :include, SimpleMessages::ActionView
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module SimpleMessages
|
2
|
+
module ActionController
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
helper_method :simple_messages_for_model, :dont_simple_messages_for_model, :simple_messages_models
|
7
|
+
|
8
|
+
before_action :simple_messages_initialize, :simple_messages_for_current_controller
|
9
|
+
end
|
10
|
+
|
11
|
+
def simple_messages_for_model(*model_name)
|
12
|
+
@simple_messages_models.concat model_name
|
13
|
+
end
|
14
|
+
|
15
|
+
def dont_simple_messages_for_model(*model_name)
|
16
|
+
@dont_simple_messages_models.concat model_name
|
17
|
+
end
|
18
|
+
|
19
|
+
def simple_messages_models
|
20
|
+
(@simple_messages_models.collect(&:to_sym) - @dont_simple_messages_models.collect(&:to_sym)).compact.uniq
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def simple_messages_initialize
|
26
|
+
@dont_simple_messages_models ||= []
|
27
|
+
@simple_messages_models ||= []
|
28
|
+
end
|
29
|
+
|
30
|
+
def simple_messages_for_current_controller
|
31
|
+
@simple_messages_models << controller_name.singularize.to_sym
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module SimpleMessages
|
2
|
+
module ActionView
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def simple_messages(options = {})
|
6
|
+
options.reverse_merge! flash_messages: true, validation_messages: true
|
7
|
+
|
8
|
+
html = ''.html_safe
|
9
|
+
|
10
|
+
html << simple_messages_flash(options) if options.delete(:flash_messages)
|
11
|
+
|
12
|
+
html << simple_messages_validation(options) if options.delete(:validation_messages)
|
13
|
+
|
14
|
+
html
|
15
|
+
end
|
16
|
+
|
17
|
+
def simple_messages_flash(options = {})
|
18
|
+
html = flash.collect do |kind, content|
|
19
|
+
builder = Builder.new({ kind: kind, body: content }.reverse_merge(options))
|
20
|
+
|
21
|
+
builder.to_html
|
22
|
+
end
|
23
|
+
|
24
|
+
flash.clear if flash.any?
|
25
|
+
|
26
|
+
html.join.html_safe
|
27
|
+
end
|
28
|
+
|
29
|
+
def simple_messages_objects
|
30
|
+
simple_messages_models.collect do |model_name|
|
31
|
+
object = instance_variable_get("@#{model_name}")
|
32
|
+
|
33
|
+
object if object.present? and object.errors.any?
|
34
|
+
end.compact
|
35
|
+
end
|
36
|
+
|
37
|
+
def simple_messages_validation(options = {})
|
38
|
+
simple_messages_objects.collect do |object|
|
39
|
+
title = I18n.t('errors.template.header', count: object.errors.count, model: object.class.model_name.human)
|
40
|
+
|
41
|
+
builder = Builder.new({ kind: :error, body: object.errors.full_messages, header: title }.reverse_merge(options))
|
42
|
+
|
43
|
+
builder.to_html
|
44
|
+
end.join.html_safe
|
45
|
+
end
|
46
|
+
|
47
|
+
def js_simple_messages
|
48
|
+
"SimpleMessages.flash('#{j simple_messages}');".html_safe
|
49
|
+
end
|
50
|
+
|
51
|
+
def js_simple_messages_alert(messages = [])
|
52
|
+
"SimpleMessages.alert(#{messages.to_json});".html_safe
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module SimpleMessages
|
2
|
+
class Builder
|
3
|
+
ALERT_CLASS_MAPPING = { alert: 'warning', notice: 'success', error: 'danger' }
|
4
|
+
|
5
|
+
attr_accessor :header, :body, :kind, :closable, :html
|
6
|
+
|
7
|
+
def initialize(params = {})
|
8
|
+
params.each do |attr, value|
|
9
|
+
instance_variable_set "@#{attr}", value
|
10
|
+
end
|
11
|
+
|
12
|
+
set_defaults
|
13
|
+
end
|
14
|
+
|
15
|
+
def closable?
|
16
|
+
closable
|
17
|
+
end
|
18
|
+
|
19
|
+
def has_header?
|
20
|
+
header.present?
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_html
|
24
|
+
wrapper = "<div #{alert_attributes}>"
|
25
|
+
wrapper << close_wrapper if closable?
|
26
|
+
wrapper << header_wrapper if has_header?
|
27
|
+
wrapper << body_to_s
|
28
|
+
wrapper << "</div>"
|
29
|
+
wrapper
|
30
|
+
end
|
31
|
+
|
32
|
+
def close_wrapper
|
33
|
+
wrapper = "<button type='button' class='close' data-dismiss='alert'>"
|
34
|
+
wrapper << "<span aria-hidden='true'>×</span>"
|
35
|
+
wrapper << "<span class='sr-only'>#{close_text}</span>"
|
36
|
+
wrapper << "</button>"
|
37
|
+
wrapper
|
38
|
+
end
|
39
|
+
|
40
|
+
def header_wrapper
|
41
|
+
return unless has_header?
|
42
|
+
|
43
|
+
"<h4>#{header}</h4>"
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
def set_defaults
|
48
|
+
kind_default
|
49
|
+
closable_default
|
50
|
+
end
|
51
|
+
|
52
|
+
def kind_default
|
53
|
+
@kind = 'success' if @kind.nil?
|
54
|
+
end
|
55
|
+
|
56
|
+
def closable_default
|
57
|
+
@closable = true if @closable.nil?
|
58
|
+
end
|
59
|
+
|
60
|
+
def adjust_html
|
61
|
+
@html ||= {}
|
62
|
+
@html = { class: '', role: 'alert' }.merge(@html)
|
63
|
+
@html[:class] << ' alert '
|
64
|
+
@html[:class] << alert_kind_class
|
65
|
+
@html[:class] << ' alert-dismissible' if closable?
|
66
|
+
@html[:class].strip!
|
67
|
+
end
|
68
|
+
|
69
|
+
def alert_attributes
|
70
|
+
adjust_html
|
71
|
+
|
72
|
+
html_to_attributes
|
73
|
+
end
|
74
|
+
|
75
|
+
def alert_kind_class
|
76
|
+
"alert-#{ALERT_CLASS_MAPPING.fetch(kind.to_sym, kind)}"
|
77
|
+
end
|
78
|
+
|
79
|
+
def body_to_s
|
80
|
+
return @body unless @body.is_a? Array
|
81
|
+
|
82
|
+
@body.join '<br />'
|
83
|
+
end
|
84
|
+
|
85
|
+
def close_text
|
86
|
+
I18n.t 'text.close', default: 'Close'
|
87
|
+
end
|
88
|
+
|
89
|
+
def html_to_attributes
|
90
|
+
@html.collect { |a, v| "#{a}='#{v}'" }.join(' ')
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
require 'simple_messages/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "simple_messages"
|
8
|
+
spec.version = SimpleMessages::VERSION
|
9
|
+
spec.authors = ["29sul"]
|
10
|
+
spec.email = ["contato@29sul.com.br"]
|
11
|
+
spec.summary = "Gem for simplify display of validation messages and flash."
|
12
|
+
spec.description = "Gem for simplify display of validation messages and flash."
|
13
|
+
spec.homepage = "http://29sul.com.br"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "rails", "~> 4.0.8"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "coveralls"
|
25
|
+
spec.add_development_dependency "fuubar", '2.0.0.rc1'
|
26
|
+
spec.add_development_dependency "guard"
|
27
|
+
spec.add_development_dependency "guard-rspec"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
spec.add_development_dependency "rspec"
|
30
|
+
spec.add_development_dependency "rspec-nc"
|
31
|
+
spec.add_development_dependency "rspec-rails"
|
32
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SimpleMessages::Builder do
|
4
|
+
before do
|
5
|
+
@builder = SimpleMessages::Builder.new header: 'This title my alert message.',
|
6
|
+
body: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.'
|
7
|
+
end
|
8
|
+
|
9
|
+
it { expect(@builder.header_wrapper).to eq '<h4>This title my alert message.</h4>' }
|
10
|
+
|
11
|
+
it { expect(@builder.close_wrapper).to eq "<button type='button' class='close' data-dismiss='alert'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button>" }
|
12
|
+
|
13
|
+
it { expect(@builder.closable?).to eq true }
|
14
|
+
|
15
|
+
it { expect(@builder.has_header?).to eq true }
|
16
|
+
|
17
|
+
it { expect(@builder.to_html).to eq "<div class='alert alert-success alert-dismissible' role='alert'><button type='button' class='close' data-dismiss='alert'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button><h4>This title my alert message.</h4>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>" }
|
18
|
+
|
19
|
+
context "without close" do
|
20
|
+
before do
|
21
|
+
@builder.closable = false
|
22
|
+
end
|
23
|
+
|
24
|
+
it { expect(@builder.closable?).to eq false }
|
25
|
+
|
26
|
+
it { expect(@builder.to_html).to eq "<div class='alert alert-success' role='alert'><h4>This title my alert message.</h4>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>" }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "without header" do
|
30
|
+
before do
|
31
|
+
@builder.header = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
it { expect(@builder.has_header?).to eq false }
|
35
|
+
|
36
|
+
it { expect(@builder.to_html).to eq "<div class='alert alert-success alert-dismissible' role='alert'><button type='button' class='close' data-dismiss='alert'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>" }
|
37
|
+
|
38
|
+
it { expect(@builder.header_wrapper).to eq nil }
|
39
|
+
end
|
40
|
+
|
41
|
+
context "body is a array" do
|
42
|
+
before do
|
43
|
+
@builder.body = [ 'Line 1.', 'Line 2.' ]
|
44
|
+
end
|
45
|
+
|
46
|
+
it { expect(@builder.to_html).to eq "<div class='alert alert-success alert-dismissible' role='alert'><button type='button' class='close' data-dismiss='alert'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button><h4>This title my alert message.</h4>Line 1.<br />Line 2.</div>" }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "notice kind" do
|
50
|
+
before do
|
51
|
+
@builder.kind = :notice
|
52
|
+
end
|
53
|
+
|
54
|
+
it { expect(@builder.to_html).to eq "<div class='alert alert-success alert-dismissible' role='alert'><button type='button' class='close' data-dismiss='alert'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button><h4>This title my alert message.</h4>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>" }
|
55
|
+
end
|
56
|
+
|
57
|
+
context "danger kind" do
|
58
|
+
before do
|
59
|
+
@builder.kind = :danger
|
60
|
+
end
|
61
|
+
|
62
|
+
it { expect(@builder.to_html).to eq "<div class='alert alert-danger alert-dismissible' role='alert'><button type='button' class='close' data-dismiss='alert'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button><h4>This title my alert message.</h4>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>" }
|
63
|
+
end
|
64
|
+
|
65
|
+
context "alert kind" do
|
66
|
+
before do
|
67
|
+
@builder.kind = :alert
|
68
|
+
end
|
69
|
+
|
70
|
+
it { expect(@builder.to_html).to eq "<div class='alert alert-warning alert-dismissible' role='alert'><button type='button' class='close' data-dismiss='alert'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button><h4>This title my alert message.</h4>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>" }
|
71
|
+
end
|
72
|
+
|
73
|
+
context "with html attributes" do
|
74
|
+
before do
|
75
|
+
@builder.html = { class: 'my-class', id: 'my-id' }
|
76
|
+
end
|
77
|
+
|
78
|
+
it { expect(@builder.to_html).to eq "<div class='my-class alert alert-success alert-dismissible' role='alert' id='my-id'><button type='button' class='close' data-dismiss='alert'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button><h4>This title my alert message.</h4>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>" }
|
79
|
+
end
|
80
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
var SimpleMessages = {
|
2
|
+
alert: function (data) {
|
3
|
+
var msg = "",
|
4
|
+
i;
|
5
|
+
|
6
|
+
for (i = 0; i < data.length; i += 1) {
|
7
|
+
msg = msg + data[i] + "\n";
|
8
|
+
}
|
9
|
+
|
10
|
+
alert(msg);
|
11
|
+
},
|
12
|
+
|
13
|
+
flash: function (data, settings) {
|
14
|
+
if (settings === undefined) {
|
15
|
+
settings = {};
|
16
|
+
}
|
17
|
+
|
18
|
+
$.extend(settings, {
|
19
|
+
context: '#content'
|
20
|
+
});
|
21
|
+
|
22
|
+
if (typeof(data) === 'object' && data.success !== undefined && (data.notice !== undefined || data.alert !== undefined)) {
|
23
|
+
if (data.notice !== undefined) {
|
24
|
+
Message.flash_notice(data.notice);
|
25
|
+
} else {
|
26
|
+
Message.flash_alert(data.alert);
|
27
|
+
}
|
28
|
+
} else if ($.isArray(data)) {
|
29
|
+
Message.flash_alert(data.join('<br>'));
|
30
|
+
} else {
|
31
|
+
$(settings.context).before(data).show();
|
32
|
+
$.goTo('body');
|
33
|
+
}
|
34
|
+
},
|
35
|
+
|
36
|
+
flash_notice: function (data) {
|
37
|
+
Message.flash($('<div />', { 'class' : "alert alert-success", 'text' : data }));
|
38
|
+
},
|
39
|
+
|
40
|
+
flash_alert: function (data) {
|
41
|
+
Message.flash($('<div />', { 'class' : "alert alert-danger", 'text' : data }));
|
42
|
+
},
|
43
|
+
|
44
|
+
show: function (data, type) {
|
45
|
+
if (type === undefined) {
|
46
|
+
type = 'alert';
|
47
|
+
}
|
48
|
+
Message[type](data);
|
49
|
+
},
|
50
|
+
|
51
|
+
hide: function () {
|
52
|
+
return $(".alert").alert();
|
53
|
+
},
|
54
|
+
};
|
metadata
ADDED
@@ -0,0 +1,205 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple_messages
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- 29sul
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.8
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.8
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coveralls
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fuubar
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.0.rc1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.0.rc1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec-nc
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec-rails
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: Gem for simplify display of validation messages and flash.
|
154
|
+
email:
|
155
|
+
- contato@29sul.com.br
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- .coveralls.yml
|
161
|
+
- .gitignore
|
162
|
+
- .rspec
|
163
|
+
- .travis.yml
|
164
|
+
- Gemfile
|
165
|
+
- Guardfile
|
166
|
+
- LICENSE.txt
|
167
|
+
- README.md
|
168
|
+
- Rakefile
|
169
|
+
- lib/simple_messages.rb
|
170
|
+
- lib/simple_messages/action_controller.rb
|
171
|
+
- lib/simple_messages/action_view.rb
|
172
|
+
- lib/simple_messages/builder.rb
|
173
|
+
- lib/simple_messages/engine.rb
|
174
|
+
- lib/simple_messages/version.rb
|
175
|
+
- simple_messages.gemspec
|
176
|
+
- spec/lib/simple_messages/builder_spec.rb
|
177
|
+
- spec/spec_helper.rb
|
178
|
+
- vendor/assets/javascripts/simple_messages.js
|
179
|
+
homepage: http://29sul.com.br
|
180
|
+
licenses:
|
181
|
+
- MIT
|
182
|
+
metadata: {}
|
183
|
+
post_install_message:
|
184
|
+
rdoc_options: []
|
185
|
+
require_paths:
|
186
|
+
- lib
|
187
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - '>='
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - '>='
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '0'
|
197
|
+
requirements: []
|
198
|
+
rubyforge_project:
|
199
|
+
rubygems_version: 2.2.2
|
200
|
+
signing_key:
|
201
|
+
specification_version: 4
|
202
|
+
summary: Gem for simplify display of validation messages and flash.
|
203
|
+
test_files:
|
204
|
+
- spec/lib/simple_messages/builder_spec.rb
|
205
|
+
- spec/spec_helper.rb
|