flash_notifier 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 05db456c676cb2f9f3f74e42965c8f1186b03a9cf75e1aca494565d00f2df7c4
4
+ data.tar.gz: 6f2037288205cbac034cf63d5b675cc9524d4d873043daa43c284aa53ba62da9
5
+ SHA512:
6
+ metadata.gz: ed92d06a66c5e41214ee9a970c3c526077fbc881f7e797da40bb2335f61474356e5a8c409e004f49bc8925e1bc763d613d2b4a4c82c7822dd28f5dca6333cf54
7
+ data.tar.gz: 8eee344a6301f5e16b45b9e3c290e80679f93c53cdb02b574c35c4ea3771ef0ae8e72f7c97a79fa17751bfb0927076d485cbb31698d3e44d193cd7f94402c5b1
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ .idea/
2
+ *.gem
3
+ /bin
4
+ /.bundle/
5
+ /.yardoc
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at fakhir.shad@virtual-force.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in flash_notifier.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 fakhir-shad
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # FlashNotifier
2
+
3
+ If you are tired of integrating flash messages in your rails application over and over again then this gem is for you!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'flash_notifier'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install flash_notifier
20
+
21
+ ## Usage
22
+
23
+ ### For Bootstrap Flash Messages
24
+
25
+ Add this helper method in your layout and leave rest to the gem!
26
+
27
+ <%= build_bootstrap_flash %>
28
+
29
+ ### For other two libraries follow following steps
30
+
31
+ #### Step 1: Choose a Library Noty JS or Toastr JS
32
+
33
+ #### For Noty JS 3.1.4 ([Official Website](https://ned.im/noty/#/))
34
+
35
+ Import noty library in your application.js
36
+
37
+ //= require noty_lib
38
+
39
+ Add noty stylesheet in your application.scss
40
+
41
+ @import "noty";
42
+
43
+ #### For Toastr JS 2.1.4 ([Official Website](https://codeseven.github.io/toastr/))
44
+
45
+ Import noty library in your application.js
46
+
47
+ //= require toastr_lib
48
+
49
+ Add noty stylesheet in your application.scss
50
+
51
+ @import "toastr.min";
52
+
53
+ ### Step 2
54
+
55
+ In your layout add this helper method
56
+
57
+ <%= build_flash %>
58
+
59
+ ### Optional Step 3: Pass options to helper method
60
+
61
+ For Onscreen positioning of flash message pass param
62
+
63
+ <%= build_flash placement: 'topRight' %>
64
+
65
+ To manage progress bar pass param
66
+
67
+ <%= build_flash progress_bar: true %>
68
+
69
+ To set auto hide timeout pass param
70
+
71
+ <%= build_flash timeout: 3500 %>
72
+
73
+ To set default theme pass param (Note this param works only for Noty JS)
74
+
75
+ <%= build_flash theme: 'mint' %>
76
+
77
+ ##### Values for these params can be found here [Noty JS](https://ned.im/noty/#/options), [Toastr JS](https://codeseven.github.io/toastr/demo.html)
78
+
79
+ ## Development
80
+
81
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
82
+
83
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
84
+
85
+ ## Contributing
86
+
87
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/fakhir-shad/flash_notifier](https://github.com/fakhir-shad/flash_notifier). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
88
+
89
+ ## License
90
+
91
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
92
+
93
+ ## Code of Conduct
94
+
95
+ Everyone interacting in the FlashNotifier project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/flash_notifier/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "flash_notifier"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "flash_notifier/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "flash_notifier"
8
+ spec.version = FlashNotifier::VERSION
9
+ spec.authors = ["fakhir-shad"]
10
+ spec.email = ["fakhir.shad@virtual-force.com"]
11
+
12
+ spec.summary = %q{Integrate Flash Messages with ease using Noty JS, Toastr JS or Bootstrap}
13
+ spec.description = %q{A simple Gem that allows you to integrate flash messages using Noty JS, Toastr JS or Bootstrap }
14
+ spec.homepage = "https://github.com/fakhir-shad/flash_notifier"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.16"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ end
@@ -0,0 +1,29 @@
1
+ module FlashHelper
2
+ def build_flash *args
3
+ options = args.last.is_a?(::Hash) ? args.pop.with_indifferent_access : {}
4
+ html = content_tag(:div, '', data: { flash_notifier_options: options })
5
+ flash.each do |type, message|
6
+ flash_type = (%w(notice success).include?(type)) ? 'success' : (( %w(alert error).include?(type)) ? 'error' : (%w(warning info).include?(type) ? type : 'info' ))
7
+ html += content_tag(:div, '' , data: { flash_notifier: 'inside gem', flash_type: flash_type, flash_msg: message })
8
+ end
9
+ html.html_safe
10
+ end
11
+
12
+ def build_bootstrap_flash
13
+ alert_klasses = {
14
+ success: 'alert-success',
15
+ error: 'alert-danger',
16
+ alert: 'alert-warning',
17
+ notice: 'alert-info'
18
+ }
19
+ html = ''
20
+ flash.each do |type, message|
21
+ html += content_tag :div, class: "alert #{alert_klasses[type.to_sym] || type.to_s} alert-dismissible fade in", role: 'alert' do
22
+ inner_html = link_to 'x', '#', class: 'close', data: {dismiss: 'alert'}, aria_label: 'close', title: 'close'
23
+ inner_html += content_tag :div, message, class: 'text'
24
+ inner_html.html_safe
25
+ end
26
+ end
27
+ html.html_safe
28
+ end
29
+ end
@@ -0,0 +1,12 @@
1
+ require 'flash_notifier/flash_helper'
2
+
3
+ module FlashNotifier
4
+ class Railtie < Rails::Railtie
5
+ initializer 'build_flash.helper' do |app|
6
+ ActionView::Base.send :include, FlashHelper
7
+ end
8
+ initializer 'build_bootstrap_flash.helper' do |app|
9
+ ActionView::Base.send :include, FlashHelper
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module FlashNotifier
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "flash_notifier/version"
2
+
3
+ module FlashNotifier
4
+ require 'flash_notifier/railtie' if defined?(Rails)
5
+ class Engine < ::Rails::Engine; end
6
+ end
@@ -0,0 +1,11 @@
1
+ window.fetchFlashOption = (attribute, defaultValue) ->
2
+ options = $('[data-flash-notifier-options]').data('flash-notifier-options')
3
+ option = eval("options.#{attribute}")
4
+ if option == undefined then defaultValue else option
5
+
6
+ window.initializeFlashNotifier = (method) ->
7
+ try
8
+ Turbolinks.supported
9
+ $(document).on 'turbolinks:load', -> method()
10
+ catch e
11
+ $(document).ready -> method()