flash_me 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5a25b97958ca4d078392ceb68e87160c4482094b
4
+ data.tar.gz: b84fc2650f0470438428e8378f54e0152085f6f5
5
+ SHA512:
6
+ metadata.gz: 9576b1acfc0e482a5be1422044db11c8a69bff73bea752106ebd7d5f86933938f1a50420255f0d39bbe851df46bdf44ab41db9ad2a4aabd9098fd1c60da2a9bb
7
+ data.tar.gz: 0479b76ae941ffe79b7e306f6774b49d739807e40a1fce1b87ad3c74a3a10a29e5cdef3b8df9e72902ba27af004b858c93e23e18927edc57cc816395c07fa25c
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2019 Kevin J. Storberg
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # Name
2
+ FlashMe
3
+
4
+
5
+
6
+ # Description
7
+ FlashMe simplifies flash messages by consolidating them into a single module where they can be easily edited and stylized.
8
+
9
+
10
+
11
+ # Usage
12
+ A quick and dirty way to send a message.
13
+
14
+ ## Simple and easy dynamic messages for crud actions
15
+ - FlashMe is smart, and will can automatically build messages for CRUD actions
16
+ - Ex: calling flash_message('alert') will generate a flash message of 'User successfully updated' when called in users#update
17
+
18
+ ## Customize messages for unique circumstances
19
+ - Add a new message to /controllers/concerns/flash_me.rb' by adding a method to the file
20
+ - Name the method using the structure 'flash_name_of_method' so FlashMe can find it
21
+ - This method will return a hash containing all of the information about your message
22
+ - 'text' points to the actual content of the message
23
+ - 'type' points to the category of message (e.g. 'alert' or 'success')
24
+ - 'clear' tells FlashMe whether the message will be available to the next action
25
+
26
+
27
+
28
+ # Installation
29
+ 1. Add this line to your application's Gemfile:
30
+ ```ruby
31
+ gem 'flash_me'
32
+ ```
33
+
34
+ 2. Next execute:
35
+ ```bash
36
+ $ bundle
37
+ ```
38
+
39
+ Or install it yourself as:
40
+ ```bash
41
+ $ gem install flash_me
42
+ ```
43
+
44
+ 3. Then install the FlashMe Controller Concern
45
+ ```bash
46
+ $ rails g flash_me:install
47
+ ```
48
+
49
+ 4. Finally, include FlashMe in your controllers
50
+
51
+
52
+
53
+ # Authors
54
+ - Kevin J. Storberg, Ooftypop Inc.
55
+
56
+
57
+
58
+ # Contributing
59
+ We welcome collaboration on all of our open source projects.
60
+
61
+ When contributing to SnoopDogg, we ask that you:
62
+ - notify us of your intended contribution so we may provide feedback
63
+ - make a PR on Github with a short description of your changes
64
+ - update any relevant documentation
65
+
66
+
67
+
68
+ # License
69
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'FlashMe'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ require 'bundler/gem_tasks'
18
+
19
+ require 'rake/testtask'
20
+
21
+ Rake::TestTask.new(:test) do |t|
22
+ t.libs << 'test'
23
+ t.pattern = 'test/**/*_test.rb'
24
+ t.verbose = false
25
+ end
26
+
27
+ task default: :test
data/lib/flash_me.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "flash_me/railtie"
2
+
3
+ module FlashMe
4
+
5
+ end
@@ -0,0 +1,4 @@
1
+ module FlashMe
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module FlashMe
2
+ VERSION = '0.1.1'
3
+ end
@@ -0,0 +1,9 @@
1
+ module FlashMe
2
+ class InstallGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def copy_flash_me_concern_file
6
+ template "flash_me_concern.rb", "app/controllers/concerns/flash_me.rb"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,95 @@
1
+ module FlashMessages
2
+ extend ActiveSupport::Concern
3
+ private
4
+
5
+ # Authorizations =============================================================
6
+ def flash_user_not_found
7
+ {
8
+ text: "No user was found matching the provided data.",
9
+ type: "alert"
10
+ }
11
+ end
12
+
13
+ # Bulk Data Requests =========================================================
14
+ def flash_everything_up_to_date
15
+ {
16
+ text: "Everything is up to date.",
17
+ type: "success"
18
+ }
19
+ end
20
+
21
+ def flash_fetch_data_success
22
+ {
23
+ text: "Successfully fetched data requested.",
24
+ type: "success"
25
+ }
26
+ end
27
+
28
+ def flash_fetch_data_failed
29
+ {
30
+ text: "Failed to fetch data requested!!",
31
+ type: "alert"
32
+ }
33
+ end
34
+
35
+ def flash_update_data_success
36
+ {
37
+ text: "Successfully updated the data requested.",
38
+ type: "success"
39
+ }
40
+ end
41
+
42
+ def flash_update_data_failed
43
+ {
44
+ text: "Failed to update the requested data!!",
45
+ type: "alert"
46
+ }
47
+ end
48
+
49
+ # CRUD =======================================================================
50
+ def flash_alert
51
+ {
52
+ clear: true,
53
+ text: "Failed to #{action_name} #{flash_object_name}.",
54
+ type: "alert"
55
+ }
56
+ end
57
+
58
+ def flash_success
59
+ {
60
+ clear: false,
61
+ text: "#{flash_object_name} successfully #{flash_action_name}.",
62
+ type: "success"
63
+ }
64
+ end
65
+
66
+ # ============================================================================
67
+ # Flash Builders =============================================================
68
+ # ============================================================================
69
+ included do
70
+ def clear_flash_messages
71
+ flash.clear
72
+ end
73
+
74
+ def flash_message(*messages)
75
+ messages.each do |message|
76
+
77
+ message_params = send("flash_#{message}".to_sym)
78
+
79
+ clear = message_params[:clear]
80
+ text = message_params[:text]
81
+ type = message_params[:type].to_sym
82
+
83
+ clear ? (flash.now[type] = text) : (flash[type] = text)
84
+ end
85
+ end
86
+
87
+ def flash_action_name
88
+ ['destroy', 'publish'].include?(action_name) ? action_name + "ed" : action_name + "d"
89
+ end
90
+
91
+ def flash_object_name
92
+ controller_name.underscore.humanize.split.map {|word| word.singularize }.join(" ")
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :flash_me do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flash_me
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Kevin J. Storberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-03-20 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: 5.1.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 5.1.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A quick and dirty way to send a message
42
+ email:
43
+ - kevin@storberg.net
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - lib/flash_me.rb
52
+ - lib/flash_me/railtie.rb
53
+ - lib/flash_me/version.rb
54
+ - lib/generators/flash_me/install_generator.rb
55
+ - lib/generators/flash_me/templates/flash_me_concern.rb
56
+ - lib/tasks/flash_me_tasks.rake
57
+ homepage: https://github.com/ooftypop/flash_me
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.6.10
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: A quick and dirty way to send a message
81
+ test_files: []