alert_message 1.1.6 → 2.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
- SHA1:
3
- metadata.gz: 6be83af0acde1a7a31906ec4440fe0beab034132
4
- data.tar.gz: 29478703037b98dd39e124ae879b2c65ccec1056
2
+ SHA256:
3
+ metadata.gz: 9372dff7cb083d75a74e0f6dedd31d88920b304abd5535d6beba42e647e34686
4
+ data.tar.gz: 473a8fe31b5a9ce7d7db38804751a5cb4dadeaf80506c36cf30379380aa718d4
5
5
  SHA512:
6
- metadata.gz: 06827eb3cfb541fb9b156f9a969a9a79edb00bfcebc600666ae350c695a9d1afbfb9b289e55c42978b12e46d2fa704c8ffe1d85d8e528ce580cad3bd8bc069fd
7
- data.tar.gz: 83a146e033dc4336770760bd1fa173f85afbfca93156a3b68429c21068867e8a3fb5a954205fae28e58456dbe43ace6face68f7e6ace85964256e57aab295e57
6
+ metadata.gz: a1dfb76a0a94ef04a2585bbeadeb5b76440e5ba6777220f846853d6e62b788e94bbe5d33c08523885252fdd00cbd4916bc301cc33ac2503a467b38e597a641dc
7
+ data.tar.gz: 46310062eda75518711cdc4d526fc7749723ce53ca879abe0eb6684063f8d41f974b88e0ea73ba7a1596809c8bd2b987f78cbafcf48c91cdaed817c54c7313c1
data/.gitignore CHANGED
@@ -20,3 +20,5 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ spec/dummy/db/test.sqlite3
24
+ spec/dummy/log/test.log
data/.rspec CHANGED
@@ -1,2 +1,4 @@
1
1
  --color
2
- --require spec_helper
2
+ --order=random
3
+ --drb
4
+ --format Fuubar
@@ -0,0 +1 @@
1
+ alert_message
@@ -0,0 +1 @@
1
+ 2.6.5
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.6.5
4
+ before_install: gem install bundler -v 2.1
5
+ notifications:
6
+ email:
7
+ - luizpicolo@gmail.com
data/Gemfile CHANGED
@@ -1,10 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'jquery-rails'
4
3
  gem 'sass-rails'
4
+ gem 'sqlite3'
5
5
 
6
6
  gemspec
7
7
 
8
8
  group :test do
9
9
  gem 'rspec'
10
+ gem 'fuubar'
10
11
  end
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
- *= require alert_message
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
- //= require alert_message
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
- <%= render "layouts/alerts" %>
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
- ## Custom message to Devise
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
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
2
3
 
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -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 "bundler", "~> 1.6"
24
- s.add_development_dependency "rake"
25
- s.add_dependency 'jquery-rails', ['>= 3.0', '< 5']
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
@@ -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
- if key != 'success' && key != 'danger' && key != 'notice'
4
- key = 'danger'
3
+ unless ['success', 'danger', 'error'].include?(key)
4
+ key = 'notice'
5
5
  end
6
6
  %>
7
- <div class="alert-message alert-message-<%= key %>">
8
- <%= value.html_safe %>
9
- </div>
7
+ <div id="alert" role="alert" class="alert-message alert-message-<%= key %>">
8
+ <%= value.to_s.html_safe %>
9
+ </div>
10
10
  <% end %>
@@ -1,5 +1,5 @@
1
1
  module AlertMessage
2
2
  module Version
3
- VERSION = '1.1.6'
3
+ VERSION = '2.0.2'
4
4
  end
5
5
  end
@@ -1,89 +1,8 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
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
- # This setting enables warnings. It's recommended, but in some cases may
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
- # Many RSpec users commonly either run the entire suite or an individual
63
- # file, and it's useful to allow more verbose output when running an
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
- left: 0;
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: #fff;
12
- font-size: 1em;
14
+ color: #ffffff;
15
+ font-size: 13px;
13
16
  text-align: center;
14
17
 
15
- padding: 10px;
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-danger {
19
- background: #e74c3c;
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: #27ae60;
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: 1.1.6
4
+ version: 2.0.2
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: 2016-04-15 00:00:00.000000000 Z
12
+ date: 2020-10-31 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.6'
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.6'
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: '0'
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: '0'
61
+ version: 12.3.3
42
62
  - !ruby/object:Gem::Dependency
43
- name: jquery-rails
63
+ name: rails
44
64
  requirement: !ruby/object:Gem::Requirement
45
65
  requirements:
46
66
  - - ">="
47
67
  - !ruby/object:Gem::Version
48
- version: '3.0'
68
+ version: '6.0'
49
69
  - - "<"
50
70
  - !ruby/object:Gem::Version
51
- version: '5'
52
- type: :runtime
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: '3.0'
78
+ version: '6.0'
59
79
  - - "<"
60
80
  - !ruby/object:Gem::Version
61
- version: '5'
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.coffee
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
- rubyforge_project:
107
- rubygems_version: 2.4.8
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
-
3
- describe AlertMessage do
4
-
5
- path = 'lib/generators/alert_message/templates/'
6
-
7
- it 'should return true if template exist' do
8
- expect(File.exist?("#{path}_alerts.html.erb")).to be_truthy
9
- end
10
- end
@@ -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
@@ -1,10 +0,0 @@
1
- $ ->
2
- alerts = $('.alert-message')
3
- setTimeout (->
4
- alerts.fadeOut 400
5
- return
6
- ), 4000
7
- alerts.click ->
8
- alerts.fadeOut 400
9
- return
10
- return