alert_message 1.1.5.1 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.rspec +3 -1
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +2 -1
- data/README.md +31 -33
- data/Rakefile +4 -0
- data/alert_message.gemspec +7 -3
- data/lib/alert_message/engine.rb +8 -1
- data/lib/generators/alert_message/templates/_alerts.html.erb +5 -5
- data/lib/version/version.rb +1 -1
- data/spec/spec_helper.rb +5 -86
- data/vendor/assets/javascripts/alert_message.js +13 -0
- data/vendor/assets/stylesheets/alert_message.scss +28 -7
- metadata +74 -20
- data/spec/alert_message/alert_message_spec.rb +0 -10
- data/spec/alert_message/version_spec.rb +0 -10
- data/vendor/assets/javascripts/alert_message.coffee +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 234d2de56e49797898e40f2d62bb36bfb9d5855ce1892e5d4c73b3b5108778a7
|
4
|
+
data.tar.gz: 1dcf5a11973c3c386a7a009e3a0f595e8bb5bbcac9ec6ad6beebfc7c8b81e042
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 636ac0138b09d2443de3b2edb1211c2bcbffffbb9e29ba860482250239cdfd12924890068355e08f26ca9c9d693572c7c7709d1996f16a26c9754cd9b53ecb1d
|
7
|
+
data.tar.gz: a048001948e473a9c9ba3271cf5dc751373696c8a8293a5ae0a6a64a4b8c909b97d73b1303564632b196f5fd759936b7be20dc1b6db0b26eac7e7caaec88f390
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
alert_message
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.5
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Alert Message
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/alert_message.svg)](http://badge.fury.io/rb/alert_message)
|
4
|
+
[![Build Status](https://travis-ci.org/luizpicolo/alert_message.svg?branch=master)](https://travis-ci.org/luizpicolo/alert_message)
|
4
5
|
|
5
|
-
This is a simple gem for [alerts messages](http://rubygems.org/gems/alert_message).
|
6
|
+
This is a simple gem for [alerts messages](http://rubygems.org/gems/alert_message).
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -22,18 +23,41 @@ Run install script:
|
|
22
23
|
|
23
24
|
Add styles in app/assets/application.css
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
```ruby
|
27
|
+
*= require alert_message
|
28
|
+
```
|
29
|
+
** For less than Rails 6 **
|
27
30
|
Add scripts in app/assets/application.js
|
28
31
|
|
29
|
-
|
32
|
+
```ruby
|
33
|
+
//= require alert_message
|
34
|
+
```
|
30
35
|
|
36
|
+
For greater than Rails 6 add in `app\javascript\packs\application.js`
|
37
|
+
|
38
|
+
```javascript
|
39
|
+
document.addEventListener('DOMContentLoaded', () => {
|
40
|
+
let alertMessage = document.getElementById('alert');
|
41
|
+
|
42
|
+
alertMessage.classList.add('alert-message--visible');
|
43
|
+
|
44
|
+
setTimeout((() => {
|
45
|
+
alertMessage.classList.remove('alert-message--visible');
|
46
|
+
}), 10000);
|
47
|
+
|
48
|
+
alertMessage.addEventListener('click', () => {
|
49
|
+
alertMessage.classList.remove('alert-message--visible');
|
50
|
+
});
|
51
|
+
});
|
52
|
+
```
|
31
53
|
|
32
54
|
## How to use
|
33
55
|
|
34
56
|
Add in app/views/layouts/application.html.erb
|
35
57
|
|
36
|
-
|
58
|
+
```ruby
|
59
|
+
<%= render "layouts/alerts" %>
|
60
|
+
```
|
37
61
|
|
38
62
|
To show your alerts, use:
|
39
63
|
|
@@ -53,35 +77,9 @@ class HomeController < ApplicationController
|
|
53
77
|
end
|
54
78
|
```
|
55
79
|
|
56
|
-
|
57
|
-
|
58
|
-
Some devise screens do not accept Flash Messages. For this we will use a custom helper.
|
59
|
-
|
60
|
-
Add in your app/views/layouts/_alerts.html.erb
|
61
|
-
|
62
|
-
<%= show_messages %>
|
63
|
-
|
64
|
-
Create helper alert_message_helper.rb
|
65
|
-
|
66
|
-
```ruby
|
67
|
-
module AlertMessageHelper
|
68
|
-
def show_messages
|
69
|
-
return "" if resource.errors.empty?
|
70
|
-
messages = resource.errors.full_messages
|
71
|
-
html = <<-HTML
|
72
|
-
<div class="alert alert-danger">
|
73
|
-
#{messages.first}
|
74
|
-
</div>
|
75
|
-
HTML
|
76
|
-
html.html_safe
|
77
|
-
end
|
78
|
-
end
|
79
|
-
```
|
80
|
-
|
81
|
-
## Demo
|
82
|
-
|
83
|
-
[alert-message.herokuapp.com](https://alert-message.herokuapp.com/)
|
80
|
+
# Run testes
|
84
81
|
|
82
|
+
in progress
|
85
83
|
|
86
84
|
## Contributing
|
87
85
|
|
data/Rakefile
CHANGED
data/alert_message.gemspec
CHANGED
@@ -16,11 +16,15 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.license = "MIT"
|
17
17
|
|
18
18
|
s.files = `git ls-files -z`.split("\x0")
|
19
|
+
s.test_files = Dir["spec/**/*"]
|
19
20
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
21
|
s.test_files = s.files.grep(%r{^(test|s|features)/})
|
21
22
|
s.require_paths = ["lib"]
|
22
23
|
|
23
|
-
s.add_development_dependency
|
24
|
-
s.add_development_dependency
|
25
|
-
s.
|
24
|
+
s.add_development_dependency 'bundler', '~> 2.1'
|
25
|
+
s.add_development_dependency 'capybara', '~> 3.0', '>= 3.0.0'
|
26
|
+
s.add_development_dependency 'rake', '>= 12.3.3'
|
27
|
+
s.add_development_dependency 'rails', ['>= 6.0', '< 7']
|
28
|
+
s.add_development_dependency 'rspec-rails', '~> 4.0'
|
29
|
+
s.add_development_dependency 'selenium-webdriver', '~> 2.53', '>= 2.53.4'
|
26
30
|
end
|
data/lib/alert_message/engine.rb
CHANGED
@@ -3,5 +3,12 @@ module AlertMessage
|
|
3
3
|
initializer 'alert_message.load_static_assets' do |app|
|
4
4
|
app.middleware.use ::ActionDispatch::Static, "#{root}/vendor"
|
5
5
|
end
|
6
|
+
|
7
|
+
config.generators do |g|
|
8
|
+
g.test_framework :rspec, :fixture => false
|
9
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
10
|
+
g.assets false
|
11
|
+
g.helper false
|
12
|
+
end
|
6
13
|
end
|
7
|
-
end
|
14
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<% flash.each do |key, value| %>
|
2
2
|
<%
|
3
|
-
|
4
|
-
key = '
|
3
|
+
unless ['success', 'danger', 'error'].include?(key)
|
4
|
+
key = 'notice'
|
5
5
|
end
|
6
6
|
%>
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
<div id="alert" class="alert-message alert-message-<%= key %>">
|
8
|
+
<%= value.to_s.html_safe %>
|
9
|
+
</div>
|
10
10
|
<% end %>
|
data/lib/version/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,89 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
-
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
-
#
|
6
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
-
# individual file that may not need all of that loaded. Instead, consider making
|
10
|
-
# a separate helper file that requires the additional dependencies and performs
|
11
|
-
# the additional setup, and require it from the spec files that actually need it.
|
12
|
-
#
|
13
|
-
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
-
# users commonly want.
|
15
|
-
#
|
16
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
-
RSpec.configure do |config|
|
18
|
-
# rspec-expectations config goes here. You can use an alternate
|
19
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
20
|
-
# assertions if you prefer.
|
21
|
-
config.expect_with :rspec do |expectations|
|
22
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
23
|
-
# and `failure_message` of custom matchers include text for helper methods
|
24
|
-
# defined using `chain`, e.g.:
|
25
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
26
|
-
# # => "be bigger than 2 and smaller than 4"
|
27
|
-
# ...rather than:
|
28
|
-
# # => "be bigger than 2"
|
29
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
|
-
end
|
31
|
-
|
32
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
33
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
34
|
-
config.mock_with :rspec do |mocks|
|
35
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
36
|
-
# a real object. This is generally recommended, and will default to
|
37
|
-
# `true` in RSpec 4.
|
38
|
-
mocks.verify_partial_doubles = true
|
39
|
-
end
|
40
|
-
|
41
|
-
# The settings below are suggested to provide a good initial experience
|
42
|
-
# with RSpec, but feel free to customize to your heart's content.
|
43
|
-
=begin
|
44
|
-
# These two settings work together to allow you to limit a spec run
|
45
|
-
# to individual examples or groups you care about by tagging them with
|
46
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
47
|
-
# get run.
|
48
|
-
config.filter_run :focus
|
49
|
-
config.run_all_when_everything_filtered = true
|
50
|
-
|
51
|
-
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
52
|
-
# For more details, see:
|
53
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
54
|
-
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
55
|
-
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
56
|
-
config.disable_monkey_patching!
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.setup
|
57
3
|
|
58
|
-
|
59
|
-
# be too noisy due to issues in dependencies.
|
60
|
-
config.warnings = true
|
4
|
+
require 'alert_message' # and any other gems you need
|
61
5
|
|
62
|
-
|
63
|
-
#
|
64
|
-
# individual spec file.
|
65
|
-
if config.files_to_run.one?
|
66
|
-
# Use the documentation formatter for detailed output,
|
67
|
-
# unless a formatter has already been configured
|
68
|
-
# (e.g. via a command-line flag).
|
69
|
-
config.default_formatter = 'doc'
|
70
|
-
end
|
71
|
-
|
72
|
-
# Print the 10 slowest examples and example groups at the
|
73
|
-
# end of the spec run, to help surface which specs are running
|
74
|
-
# particularly slow.
|
75
|
-
config.profile_examples = 10
|
76
|
-
|
77
|
-
# Run specs in random order to surface order dependencies. If you find an
|
78
|
-
# order dependency and want to debug it, you can fix the order by providing
|
79
|
-
# the seed, which is printed after each run.
|
80
|
-
# --seed 1234
|
81
|
-
config.order = :random
|
82
|
-
|
83
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
84
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
85
|
-
# test failures related to randomization by passing the same `--seed` value
|
86
|
-
# as the one that triggered the failure.
|
87
|
-
Kernel.srand config.seed
|
88
|
-
=end
|
6
|
+
RSpec.configure do |config|
|
7
|
+
# some (optional) config here
|
89
8
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
document.addEventListener('DOMContentLoaded', () => {
|
2
|
+
let alertMessage = document.getElementById('alert');
|
3
|
+
|
4
|
+
alertMessage.classList.add('alert-message--visible');
|
5
|
+
|
6
|
+
setTimeout((() => {
|
7
|
+
alertMessage.classList.remove('alert-message--visible');
|
8
|
+
}), 10000);
|
9
|
+
|
10
|
+
alertMessage.addEventListener('click', () => {
|
11
|
+
alertMessage.classList.remove('alert-message--visible');
|
12
|
+
});
|
13
|
+
});
|
@@ -4,22 +4,43 @@
|
|
4
4
|
position: fixed;
|
5
5
|
z-index: 9999;
|
6
6
|
top: 0;
|
7
|
-
|
7
|
+
right: 0;
|
8
8
|
|
9
|
+
box-sizing: border-box;
|
9
10
|
width: 100%;
|
11
|
+
padding: 10px;
|
12
|
+
background-color: #444;
|
10
13
|
|
11
|
-
color: #
|
12
|
-
font-size:
|
14
|
+
color: #ffffff;
|
15
|
+
font-size: 13px;
|
13
16
|
text-align: center;
|
14
17
|
|
15
|
-
|
18
|
+
-webkit-transform: translateY(-100%);
|
19
|
+
-moz-transform: translateY(-100%);
|
20
|
+
transform: translateY(-100%);
|
21
|
+
|
22
|
+
-webkit-transition: .2s ease;
|
23
|
+
-moz-transition: .2s ease;
|
24
|
+
transition: .2s ease;
|
16
25
|
}
|
17
26
|
|
18
|
-
.alert-message
|
19
|
-
|
27
|
+
.alert-message--visible {
|
28
|
+
-webkit-transform: translateY(0);
|
29
|
+
-moz-transform: translateY(0);
|
30
|
+
transform: translateY(0);
|
31
|
+
}
|
32
|
+
|
33
|
+
.alert-message-error, .alert-message-danger {
|
34
|
+
background-color: #D33D3D;
|
20
35
|
}
|
21
36
|
|
22
37
|
.alert-message-notice,
|
23
38
|
.alert-message-success {
|
24
|
-
background: #
|
39
|
+
background-color: #67AF72;
|
40
|
+
}
|
41
|
+
|
42
|
+
@media screen and (min-width: 768px) {
|
43
|
+
.alert-message {
|
44
|
+
font-size: 15px;
|
45
|
+
}
|
25
46
|
}
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alert_message
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luiz Picolo
|
8
8
|
- Gabriel Medina
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -17,48 +17,102 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '1
|
20
|
+
version: '2.1'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '1
|
27
|
+
version: '2.1'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: capybara
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 3.0.0
|
35
|
+
- - "~>"
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 3.0.0
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
28
48
|
- !ruby/object:Gem::Dependency
|
29
49
|
name: rake
|
30
50
|
requirement: !ruby/object:Gem::Requirement
|
31
51
|
requirements:
|
32
52
|
- - ">="
|
33
53
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
54
|
+
version: 12.3.3
|
35
55
|
type: :development
|
36
56
|
prerelease: false
|
37
57
|
version_requirements: !ruby/object:Gem::Requirement
|
38
58
|
requirements:
|
39
59
|
- - ">="
|
40
60
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
61
|
+
version: 12.3.3
|
42
62
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
63
|
+
name: rails
|
44
64
|
requirement: !ruby/object:Gem::Requirement
|
45
65
|
requirements:
|
46
66
|
- - ">="
|
47
67
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
68
|
+
version: '6.0'
|
49
69
|
- - "<"
|
50
70
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
52
|
-
type: :
|
71
|
+
version: '7'
|
72
|
+
type: :development
|
53
73
|
prerelease: false
|
54
74
|
version_requirements: !ruby/object:Gem::Requirement
|
55
75
|
requirements:
|
56
76
|
- - ">="
|
57
77
|
- !ruby/object:Gem::Version
|
58
|
-
version: '
|
78
|
+
version: '6.0'
|
59
79
|
- - "<"
|
60
80
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
81
|
+
version: '7'
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: rspec-rails
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '4.0'
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '4.0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: selenium-webdriver
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2.53'
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 2.53.4
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '2.53'
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 2.53.4
|
62
116
|
description: Simple gem for alerts messages
|
63
117
|
email:
|
64
118
|
- luizpicolo@gmail.com
|
@@ -69,6 +123,9 @@ extra_rdoc_files: []
|
|
69
123
|
files:
|
70
124
|
- ".gitignore"
|
71
125
|
- ".rspec"
|
126
|
+
- ".ruby-gemset"
|
127
|
+
- ".ruby-version"
|
128
|
+
- ".travis.yml"
|
72
129
|
- Gemfile
|
73
130
|
- LICENSE
|
74
131
|
- README.md
|
@@ -79,16 +136,14 @@ files:
|
|
79
136
|
- lib/generators/alert_message/install_generator.rb
|
80
137
|
- lib/generators/alert_message/templates/_alerts.html.erb
|
81
138
|
- lib/version/version.rb
|
82
|
-
- spec/alert_message/alert_message_spec.rb
|
83
|
-
- spec/alert_message/version_spec.rb
|
84
139
|
- spec/spec_helper.rb
|
85
|
-
- vendor/assets/javascripts/alert_message.
|
140
|
+
- vendor/assets/javascripts/alert_message.js
|
86
141
|
- vendor/assets/stylesheets/alert_message.scss
|
87
142
|
homepage: https://github.com/luizpicolo/alert_message
|
88
143
|
licenses:
|
89
144
|
- MIT
|
90
145
|
metadata: {}
|
91
|
-
post_install_message:
|
146
|
+
post_install_message:
|
92
147
|
rdoc_options: []
|
93
148
|
require_paths:
|
94
149
|
- lib
|
@@ -103,9 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
158
|
- !ruby/object:Gem::Version
|
104
159
|
version: '0'
|
105
160
|
requirements: []
|
106
|
-
|
107
|
-
|
108
|
-
signing_key:
|
161
|
+
rubygems_version: 3.0.8
|
162
|
+
signing_key:
|
109
163
|
specification_version: 4
|
110
164
|
summary: Alert Message
|
111
165
|
test_files: []
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative '../../lib/version/version'
|
3
|
-
|
4
|
-
describe AlertMessage do
|
5
|
-
|
6
|
-
it "should return version correctly" do
|
7
|
-
expect(AlertMessage::Version::VERSION).to be_a_kind_of(String)
|
8
|
-
expect(AlertMessage::Version::VERSION).to eq '1.1.5.1'
|
9
|
-
end
|
10
|
-
end
|