flash_hash_request_uuid 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in flash_hash.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Adam Vaughan
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.
@@ -0,0 +1,43 @@
1
+ # Flash with Request UUID
2
+
3
+ This gem hijacks the `flash[:blah]` calls in your application and instead of storing just the string message
4
+ you send it, it stores a hash that includes your message and the request UUID.
5
+
6
+ Example:
7
+
8
+ flash[:error] = 'An error occurred!'
9
+ flash[:error] # => { :message => 'An error occurred!', :request_uuid => 'sjdf89u39n23f2p9fapwc938pawr' }
10
+
11
+ ## Why?
12
+
13
+ In order to assist our operations team in tracking down errors from customers, we wanted to include the
14
+ request UUID in the error message we present to user so we can track down their request in our logs
15
+ and see what went wrong.
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ gem 'flash_hash_request_uuid'
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install flash_hash_request_uuid
30
+
31
+ ## Usage
32
+
33
+ Inside your `ApplicationController`, do this:
34
+
35
+ include FlashHashRequestUuid::Flash
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'flash_hash_request_uuid/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "flash_hash_request_uuid"
8
+ gem.version = FlashHashRequestUuid::VERSION
9
+ gem.authors = ["Adam Vaughan"]
10
+ gem.email = ["avaughan@decisiv.net"]
11
+ gem.description = %q{Overrides setting flash messages to automatically wrap them in a hash. The original message is stored in the :message key and the request UUID is stored in the :request_uuid key. }
12
+ gem.summary = %q{Overrides setting flash messages to automatically wrap them in a hash. The original message is stored in the :message key and the request UUID is stored in the :request_uuid key. }
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.require_paths = ["lib"]
17
+ end
@@ -0,0 +1,3 @@
1
+ require "flash_hash_request_uuid/flash"
2
+ require "flash_hash_request_uuid/flash_hash"
3
+ require "flash_hash_request_uuid/version"
@@ -0,0 +1,19 @@
1
+ module FlashHashRequestUuid
2
+ module Flash
3
+ extend ActiveSupport::Concern
4
+
5
+ def flash
6
+ unless request.env[ActionDispatch::Flash::KEY]
7
+ if session['flash']
8
+ request.env[ActionDispatch::Flash::KEY] = session['flash']
9
+ else
10
+ flash_hash = FlashHashRequestUuid::FlashHash.new
11
+ flash_hash.request_uuid = request.uuid
12
+ request.env[ActionDispatch::Flash::KEY] = flash_hash
13
+ end
14
+ end
15
+
16
+ request.env[ActionDispatch::Flash::KEY]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ module FlashHashRequestUuid
2
+ class FlashHash < ActionDispatch::Flash::FlashHash
3
+ attr_accessor :request_uuid
4
+
5
+ def []=(k, v)
6
+ super k, { :message => v, :request_uuid => request_uuid }
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module FlashHashRequestUuid
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flash_hash_request_uuid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adam Vaughan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-08 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: ! 'Overrides setting flash messages to automatically wrap them in a hash.
15
+ The original message is stored in the :message key and the request UUID is stored
16
+ in the :request_uuid key. '
17
+ email:
18
+ - avaughan@decisiv.net
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - .gitignore
24
+ - Gemfile
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - flash_hash_request_uuid.gemspec
29
+ - lib/flash_hash_request_uuid.rb
30
+ - lib/flash_hash_request_uuid/flash.rb
31
+ - lib/flash_hash_request_uuid/flash_hash.rb
32
+ - lib/flash_hash_request_uuid/version.rb
33
+ homepage: ''
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 1.8.23
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: Overrides setting flash messages to automatically wrap them in a hash. The
57
+ original message is stored in the :message key and the request UUID is stored in
58
+ the :request_uuid key.
59
+ test_files: []
60
+ has_rdoc: