flame-flash 2.3.3 → 3.0.1.rc1
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 +5 -5
- data/CHANGELOG.md +79 -0
- data/LICENSE.txt +21 -0
- data/README.md +91 -0
- data/lib/flame/flash.rb +57 -22
- data/lib/flame/flash/flash_array.rb +64 -0
- data/lib/flame/flash/flash_object.rb +37 -0
- data/lib/flame/flash/version.rb +7 -0
- metadata +205 -19
- data/lib/flame/flash_array.rb +0 -73
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 770daf991964e0a25952e4af521a31a2830dccd7ea1d363c4b19dca4bd61889e
|
|
4
|
+
data.tar.gz: 9b1bb4bcce4b6b9d67332e265b7b11ff03d5199320a194536c60ae591a42cc10
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9cc0dbd38c1de71cb1089342371cd8cf329b49e25d7bea25cf3b005ded22a783fd85b26aa5aa5d33214b5e7d798a9edfcc2c0bbea7c66eac8ced81fb567f516
|
|
7
|
+
data.tar.gz: 24d38202f36ac1c08d34d165e3e9f870f936aceb68cfdaf37e26a9a9c426baf297665d51305f505907f82c05587582217109fb5851d8f6746f6677aa2a3eedb2
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## master (unreleased)
|
|
4
|
+
|
|
5
|
+
## 3.0.1.rc1 (2021-04-16)
|
|
6
|
+
|
|
7
|
+
* Support Flame 5
|
|
8
|
+
* Forward flashes on redirect
|
|
9
|
+
* Replace `Array` check with `Enumerable`
|
|
10
|
+
* Take flashes only from reserved keys (error, warning, notice) or `flash` key
|
|
11
|
+
Don't extract parameters for controller's path as flashes.
|
|
12
|
+
Reference: <http://guides.rubyonrails.org/action_controller_overview.html#the-flash>
|
|
13
|
+
* Change `FlashArray` to `FlashObject` with `now` and `next` as `FlashArray`
|
|
14
|
+
* Add `FlashArray#delete` method
|
|
15
|
+
* Fix calls of redefined `view` without parameters
|
|
16
|
+
* Make `execute` and methods below `protected`
|
|
17
|
+
* Make `FlashObject` private, test `Flame::Flash` better.
|
|
18
|
+
* Remove `flash.scope` method.
|
|
19
|
+
It was taken not from Rails, but from (abandoned) `sinatra-flash`.
|
|
20
|
+
But we can add it later in more correct way if somebody's needing!
|
|
21
|
+
* Fix requiring by `path` in `Gemfile`
|
|
22
|
+
* Drop Ruby 2.3 and 2.4 support (after Flame)
|
|
23
|
+
* Support Ruby 3.
|
|
24
|
+
* Add MIT license file
|
|
25
|
+
* Add tests, 100% coverage
|
|
26
|
+
* Fix RuboCop warnings, and RuboCop configuration file
|
|
27
|
+
With `rubocop-performance` and `rubocop-rspec`.
|
|
28
|
+
* Improve documentation of methods
|
|
29
|
+
* Add Cirrus CI
|
|
30
|
+
* Add `remark` CI task.
|
|
31
|
+
* Replace `rake` with `toys`.
|
|
32
|
+
* Update development dependencies.
|
|
33
|
+
* Add more meta-information to gem specs.
|
|
34
|
+
* Add "Development", "Contributing" and "License" sections to README.
|
|
35
|
+
* Add CHANGELOG file.
|
|
36
|
+
* Move gem version to a separate file (and constant).
|
|
37
|
+
|
|
38
|
+
## 2.3.3 (2016-11-16)
|
|
39
|
+
|
|
40
|
+
* Flashes extracting fixed for `params` key
|
|
41
|
+
* Migrate from GitLab to GitHub
|
|
42
|
+
|
|
43
|
+
## 2.3.2 (2016-08-09)
|
|
44
|
+
|
|
45
|
+
* Fixed `fix_messages_as_array` method
|
|
46
|
+
|
|
47
|
+
## 2.3.1 (2016-03-11)
|
|
48
|
+
|
|
49
|
+
* Trying to fix messages as `Array`
|
|
50
|
+
|
|
51
|
+
## 2.3.0 (2016-03-11)
|
|
52
|
+
|
|
53
|
+
* Capture `halt` method and take out flash-recording to private method
|
|
54
|
+
* Adding ability to add `Array` as many flashes
|
|
55
|
+
|
|
56
|
+
## 2.2.0 (2016-02-11)
|
|
57
|
+
|
|
58
|
+
* Allowing assign array to `FlashArray`
|
|
59
|
+
|
|
60
|
+
## 2.1.1 (2016-02-04)
|
|
61
|
+
|
|
62
|
+
* Support `String` redirects
|
|
63
|
+
|
|
64
|
+
## 2.1.0 (2016-02-02)
|
|
65
|
+
|
|
66
|
+
* Add flash-options for redirect method of controller
|
|
67
|
+
|
|
68
|
+
## 2.0.0 (2016-01-29)
|
|
69
|
+
|
|
70
|
+
* Support Flame 4.0
|
|
71
|
+
|
|
72
|
+
## 1.0.1 (2015-12-10)
|
|
73
|
+
|
|
74
|
+
* Add `flame` as runtime dependency
|
|
75
|
+
* Update after-hook for Flame 3.3.4
|
|
76
|
+
|
|
77
|
+
## 1.0.0 (2015-12-07)
|
|
78
|
+
|
|
79
|
+
* Initial release.
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Alexander Popov
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Flame Flash
|
|
2
|
+
|
|
3
|
+
[](https://cirrus-ci.com/github/AlexWayfer/flame-flash)
|
|
4
|
+
[](https://codecov.io/gh/AlexWayfer/flame-flash)
|
|
5
|
+
[](https://codeclimate.com/github/AlexWayfer/flame-flash)
|
|
6
|
+

|
|
7
|
+
[](https://inch-ci.org/github/AlexWayfer/flame-flash)
|
|
8
|
+
[](https://github.com/AlexWayfer/flame-flash/blob/master/LICENSE.txt)
|
|
9
|
+
[](https://rubygems.org/gems/flame-flash)
|
|
10
|
+
|
|
11
|
+
[Flashes](http://guides.rubyonrails.org/action_controller_overview.html#the-flash)
|
|
12
|
+
for [Flame](https://github.com/AlexWayfer/flame).
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ruby
|
|
17
|
+
# Gemfile
|
|
18
|
+
gem 'flame-flash'
|
|
19
|
+
|
|
20
|
+
# config.ru
|
|
21
|
+
require 'flame-flash' # or `Bundler.require`
|
|
22
|
+
|
|
23
|
+
# _controller.rb
|
|
24
|
+
include Flame::Flash
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```erb
|
|
28
|
+
<!-- layout.html.erb -->
|
|
29
|
+
|
|
30
|
+
<%
|
|
31
|
+
%i[error warning notice].each do |type|
|
|
32
|
+
flash[type].each do |text|
|
|
33
|
+
%>
|
|
34
|
+
<p class="flash <%= type %>">
|
|
35
|
+
<%= text %>
|
|
36
|
+
</p>
|
|
37
|
+
<%
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
%>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Examples
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
class PostsController < Flame::Controller
|
|
47
|
+
def update
|
|
48
|
+
flash[:error] = "You don't have permissions"
|
|
49
|
+
redirect :show
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def delete
|
|
53
|
+
redirect :show, notice: 'Deleted'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def move
|
|
57
|
+
redirect :index, flash: { success: 'Moved' }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def create
|
|
61
|
+
flash.now[:error] = 'Not enought permissions'
|
|
62
|
+
view :new
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Reserved keys
|
|
68
|
+
|
|
69
|
+
* `error`
|
|
70
|
+
* `warning`
|
|
71
|
+
* `notice`
|
|
72
|
+
|
|
73
|
+
## Development
|
|
74
|
+
|
|
75
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
|
76
|
+
|
|
77
|
+
Then, run `toys rspec` to run the tests.
|
|
78
|
+
|
|
79
|
+
To install this gem onto your local machine, run `toys gem install`.
|
|
80
|
+
|
|
81
|
+
To release a new version, run `toys gem release %version%`.
|
|
82
|
+
See how it works [here](https://github.com/AlexWayfer/gem_toys#release).
|
|
83
|
+
|
|
84
|
+
## Contributing
|
|
85
|
+
|
|
86
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/AlexWayfer/flame-flash).
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
The gem is available as open source under the terms of the
|
|
91
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
data/lib/flame/flash.rb
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'gorilla_patch/deep_dup'
|
|
4
|
+
require 'gorilla_patch/slice'
|
|
5
|
+
|
|
6
|
+
require_relative 'flash/version'
|
|
7
|
+
|
|
8
|
+
require_relative 'flash/flash_object'
|
|
2
9
|
|
|
3
10
|
module Flame
|
|
4
11
|
# Module for Flame::Flash extension with helper methods and base class
|
|
5
12
|
module Flash
|
|
13
|
+
protected
|
|
14
|
+
|
|
6
15
|
## After hook
|
|
7
16
|
def execute(method)
|
|
8
17
|
super
|
|
@@ -10,21 +19,32 @@ module Flame
|
|
|
10
19
|
end
|
|
11
20
|
|
|
12
21
|
## Upgrade redirect method
|
|
22
|
+
## TODO: write `@see`
|
|
13
23
|
## @example Redirect to show method of Articles controller with error
|
|
14
24
|
## redirect ArticlesController, :show, id: 2, error: 'Access required'
|
|
15
25
|
def redirect(*args)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
args, flashes = extract_flashes_for_redirect(args)
|
|
27
|
+
flash.merge flashes
|
|
28
|
+
flash.next.concat(flash.now) ## for multiple redirects
|
|
29
|
+
super(*args)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
## Upgrade view method
|
|
33
|
+
## TODO: write `@see`
|
|
34
|
+
## @example Render view with error
|
|
35
|
+
## view :show, error: 'Access required'
|
|
36
|
+
def view(path = nil, options = {}, &block)
|
|
37
|
+
options, flashes = extract_flashes(options)
|
|
38
|
+
flash.now.merge flashes
|
|
39
|
+
super(
|
|
40
|
+
path || caller_locations(1, 1)[0].label.to_sym,
|
|
41
|
+
options,
|
|
42
|
+
&block
|
|
43
|
+
)
|
|
25
44
|
end
|
|
26
45
|
|
|
27
|
-
##
|
|
46
|
+
## Record flashes before halting
|
|
47
|
+
## TODO: write `@see`
|
|
28
48
|
def halt(*args)
|
|
29
49
|
record_flashes
|
|
30
50
|
super
|
|
@@ -33,21 +53,36 @@ module Flame
|
|
|
33
53
|
private
|
|
34
54
|
|
|
35
55
|
## Main helper method
|
|
36
|
-
def flash
|
|
37
|
-
(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
41
|
-
).scope(key)
|
|
56
|
+
def flash
|
|
57
|
+
@flash ||= FlashObject.new(
|
|
58
|
+
(session ? session[:flash] : [])
|
|
59
|
+
)
|
|
42
60
|
end
|
|
43
61
|
|
|
62
|
+
RESERVED_FLASH_KEYS = %i[error warning notice].freeze
|
|
63
|
+
|
|
64
|
+
using GorillaPatch::DeepDup
|
|
65
|
+
using GorillaPatch::Slice
|
|
66
|
+
|
|
44
67
|
## Split Hash-argument to parameters and flashes
|
|
45
|
-
def extract_flashes(
|
|
68
|
+
def extract_flashes(options)
|
|
69
|
+
options = options.deep_dup
|
|
70
|
+
flashes = options.delete(:flash) { {} }
|
|
71
|
+
## Yeah, `RESERVED_FLASH_KEYS` will be deleted from `options`
|
|
72
|
+
## and will not be passed into parent's `redirect` or `view`.
|
|
73
|
+
## But I don't see a problem cause of it for now.
|
|
74
|
+
## If you see - please, send a PR, or create an issue.
|
|
75
|
+
flashes.merge! options.slice_reverse!(*RESERVED_FLASH_KEYS)
|
|
76
|
+
[options, flashes]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def extract_flashes_for_redirect(args)
|
|
80
|
+
return [args, {}] unless args.last.is_a? Hash
|
|
81
|
+
return [args, args.pop] if args.first.is_a?(String)
|
|
82
|
+
|
|
46
83
|
add_controller_class(args)
|
|
47
|
-
|
|
48
|
-
args.
|
|
49
|
-
parameters.include?(key) || key == :params
|
|
50
|
-
end.map(&:to_h)
|
|
84
|
+
options, flashes = extract_flashes(args.last)
|
|
85
|
+
[args[0..-2].push(options), flashes]
|
|
51
86
|
end
|
|
52
87
|
|
|
53
88
|
## Move flash.next to session
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flame
|
|
4
|
+
## https://github.com/bbatsov/rubocop/issues/5831
|
|
5
|
+
module Flash
|
|
6
|
+
## Just contains flashes
|
|
7
|
+
class FlashArray
|
|
8
|
+
## Initialize Flash Array from regular Array
|
|
9
|
+
## @param array [Array<Hash>] initial Array with raw data
|
|
10
|
+
def initialize(array = [])
|
|
11
|
+
@array = []
|
|
12
|
+
concat(array)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
## Go through internal Array
|
|
16
|
+
def each(&block)
|
|
17
|
+
@array.each(&block)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
## Write text by type
|
|
21
|
+
def push(type, text)
|
|
22
|
+
if text.is_a?(Enumerable)
|
|
23
|
+
text.each { |el| push(type, el) }
|
|
24
|
+
return
|
|
25
|
+
end
|
|
26
|
+
hash = { type: type, text: text }
|
|
27
|
+
@array.push(hash)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
alias []= push
|
|
31
|
+
|
|
32
|
+
## Delete text in type
|
|
33
|
+
def delete(type, text)
|
|
34
|
+
@array.delete(type: type, text: text)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
## Select values by text or type
|
|
38
|
+
def select(**options)
|
|
39
|
+
@array.select do |hash|
|
|
40
|
+
options.reject { |key, val| hash[key] == val || val.nil? }.empty?
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
## Concat with other Array-like
|
|
45
|
+
def concat(array)
|
|
46
|
+
array.each do |hash|
|
|
47
|
+
push(hash[:type], hash[:text])
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
## Merge with other Hash-like
|
|
52
|
+
def merge(hash)
|
|
53
|
+
hash.each { |type, text| self[type] = text }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
## Return internal Array
|
|
57
|
+
def to_a
|
|
58
|
+
@array
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private_constant :FlashArray
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'flash_array'
|
|
4
|
+
|
|
5
|
+
module Flame
|
|
6
|
+
## https://github.com/bbatsov/rubocop/issues/5831
|
|
7
|
+
module Flash
|
|
8
|
+
## Contains info about current and next flashes
|
|
9
|
+
class FlashObject
|
|
10
|
+
attr_reader :now, :next
|
|
11
|
+
|
|
12
|
+
## Initialize Flash Object with specific session
|
|
13
|
+
## @param session [Rack::Session::Abstract::Persisted] Rack's session convertible to an Array
|
|
14
|
+
def initialize(session)
|
|
15
|
+
@now = FlashArray.new(session.to_a)
|
|
16
|
+
@next = FlashArray.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
## Add entry with type and text
|
|
20
|
+
def []=(type, text)
|
|
21
|
+
self.next.push type, text
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
## Get entries by type
|
|
25
|
+
def [](type = nil)
|
|
26
|
+
now.select(type: type).map { |hash| hash[:text] }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
## Mass adding to next
|
|
30
|
+
def merge(hash)
|
|
31
|
+
hash.each { |type, text| self[type] = text }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private_constant :FlashObject
|
|
36
|
+
end
|
|
37
|
+
end
|
metadata
CHANGED
|
@@ -1,50 +1,234 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flame-flash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.1.rc1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Popov
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-04-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: flame
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 5.0.0.rc6
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '6'
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: 5.0.0.rc6
|
|
30
|
+
- - "<"
|
|
18
31
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
32
|
+
version: '6'
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: gorilla_patch
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
20
37
|
- - ">="
|
|
21
38
|
- !ruby/object:Gem::Version
|
|
22
|
-
version:
|
|
39
|
+
version: '1'
|
|
40
|
+
- - "<"
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '5'
|
|
23
43
|
type: :runtime
|
|
24
44
|
prerelease: false
|
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '1'
|
|
50
|
+
- - "<"
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '5'
|
|
53
|
+
- !ruby/object:Gem::Dependency
|
|
54
|
+
name: pry-byebug
|
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - "~>"
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '3.9'
|
|
60
|
+
type: :development
|
|
61
|
+
prerelease: false
|
|
25
62
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
63
|
requirements:
|
|
27
64
|
- - "~>"
|
|
28
65
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '
|
|
30
|
-
|
|
66
|
+
version: '3.9'
|
|
67
|
+
- !ruby/object:Gem::Dependency
|
|
68
|
+
name: bundler
|
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - "~>"
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '2.0'
|
|
74
|
+
type: :development
|
|
75
|
+
prerelease: false
|
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - "~>"
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '2.0'
|
|
81
|
+
- !ruby/object:Gem::Dependency
|
|
82
|
+
name: gem_toys
|
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - "~>"
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: 0.8.0
|
|
88
|
+
type: :development
|
|
89
|
+
prerelease: false
|
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - "~>"
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: 0.8.0
|
|
95
|
+
- !ruby/object:Gem::Dependency
|
|
96
|
+
name: toys
|
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - "~>"
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: 0.11.4
|
|
102
|
+
type: :development
|
|
103
|
+
prerelease: false
|
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
+
requirements:
|
|
106
|
+
- - "~>"
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: 0.11.4
|
|
109
|
+
- !ruby/object:Gem::Dependency
|
|
110
|
+
name: codecov
|
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - "~>"
|
|
31
114
|
- !ruby/object:Gem::Version
|
|
32
|
-
version:
|
|
33
|
-
|
|
115
|
+
version: 0.5.0
|
|
116
|
+
type: :development
|
|
117
|
+
prerelease: false
|
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
120
|
+
- - "~>"
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: 0.5.0
|
|
123
|
+
- !ruby/object:Gem::Dependency
|
|
124
|
+
name: rack-test
|
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - "~>"
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: '1.0'
|
|
130
|
+
type: :development
|
|
131
|
+
prerelease: false
|
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
133
|
+
requirements:
|
|
134
|
+
- - "~>"
|
|
135
|
+
- !ruby/object:Gem::Version
|
|
136
|
+
version: '1.0'
|
|
137
|
+
- !ruby/object:Gem::Dependency
|
|
138
|
+
name: rspec
|
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
|
140
|
+
requirements:
|
|
141
|
+
- - "~>"
|
|
142
|
+
- !ruby/object:Gem::Version
|
|
143
|
+
version: '3.9'
|
|
144
|
+
type: :development
|
|
145
|
+
prerelease: false
|
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
147
|
+
requirements:
|
|
148
|
+
- - "~>"
|
|
149
|
+
- !ruby/object:Gem::Version
|
|
150
|
+
version: '3.9'
|
|
151
|
+
- !ruby/object:Gem::Dependency
|
|
152
|
+
name: simplecov
|
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
|
154
|
+
requirements:
|
|
155
|
+
- - "~>"
|
|
156
|
+
- !ruby/object:Gem::Version
|
|
157
|
+
version: 0.21.2
|
|
158
|
+
type: :development
|
|
159
|
+
prerelease: false
|
|
160
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
161
|
+
requirements:
|
|
162
|
+
- - "~>"
|
|
163
|
+
- !ruby/object:Gem::Version
|
|
164
|
+
version: 0.21.2
|
|
165
|
+
- !ruby/object:Gem::Dependency
|
|
166
|
+
name: rubocop
|
|
167
|
+
requirement: !ruby/object:Gem::Requirement
|
|
168
|
+
requirements:
|
|
169
|
+
- - "~>"
|
|
170
|
+
- !ruby/object:Gem::Version
|
|
171
|
+
version: '1.4'
|
|
172
|
+
type: :development
|
|
173
|
+
prerelease: false
|
|
174
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
175
|
+
requirements:
|
|
176
|
+
- - "~>"
|
|
177
|
+
- !ruby/object:Gem::Version
|
|
178
|
+
version: '1.4'
|
|
179
|
+
- !ruby/object:Gem::Dependency
|
|
180
|
+
name: rubocop-performance
|
|
181
|
+
requirement: !ruby/object:Gem::Requirement
|
|
182
|
+
requirements:
|
|
183
|
+
- - "~>"
|
|
184
|
+
- !ruby/object:Gem::Version
|
|
185
|
+
version: '1.0'
|
|
186
|
+
type: :development
|
|
187
|
+
prerelease: false
|
|
188
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
189
|
+
requirements:
|
|
190
|
+
- - "~>"
|
|
191
|
+
- !ruby/object:Gem::Version
|
|
192
|
+
version: '1.0'
|
|
193
|
+
- !ruby/object:Gem::Dependency
|
|
194
|
+
name: rubocop-rspec
|
|
195
|
+
requirement: !ruby/object:Gem::Requirement
|
|
196
|
+
requirements:
|
|
197
|
+
- - "~>"
|
|
198
|
+
- !ruby/object:Gem::Version
|
|
199
|
+
version: '2.0'
|
|
200
|
+
type: :development
|
|
201
|
+
prerelease: false
|
|
202
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
203
|
+
requirements:
|
|
204
|
+
- - "~>"
|
|
205
|
+
- !ruby/object:Gem::Version
|
|
206
|
+
version: '2.0'
|
|
207
|
+
description: 'Show messages (notifies, errors, warnings) in current or next routes
|
|
34
208
|
after redirect.
|
|
209
|
+
|
|
210
|
+
'
|
|
35
211
|
email:
|
|
36
212
|
- alex.wayfer@gmail.com
|
|
37
213
|
executables: []
|
|
38
214
|
extensions: []
|
|
39
215
|
extra_rdoc_files: []
|
|
40
216
|
files:
|
|
217
|
+
- CHANGELOG.md
|
|
218
|
+
- LICENSE.txt
|
|
219
|
+
- README.md
|
|
41
220
|
- lib/flame/flash.rb
|
|
42
|
-
- lib/flame/flash_array.rb
|
|
221
|
+
- lib/flame/flash/flash_array.rb
|
|
222
|
+
- lib/flame/flash/flash_object.rb
|
|
223
|
+
- lib/flame/flash/version.rb
|
|
43
224
|
homepage: https://github.com/AlexWayfer/flame-flash
|
|
44
225
|
licenses:
|
|
45
226
|
- MIT
|
|
46
|
-
metadata:
|
|
47
|
-
|
|
227
|
+
metadata:
|
|
228
|
+
source_code_uri: https://github.com/AlexWayfer/flame-flash
|
|
229
|
+
homepage_uri: https://github.com/AlexWayfer/flame-flash
|
|
230
|
+
changelog_uri: https://github.com/AlexWayfer/flame-flash/blob/master/CHANGELOG.md
|
|
231
|
+
post_install_message:
|
|
48
232
|
rdoc_options: []
|
|
49
233
|
require_paths:
|
|
50
234
|
- lib
|
|
@@ -52,16 +236,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
52
236
|
requirements:
|
|
53
237
|
- - ">="
|
|
54
238
|
- !ruby/object:Gem::Version
|
|
55
|
-
version: '
|
|
239
|
+
version: '2.5'
|
|
240
|
+
- - "<"
|
|
241
|
+
- !ruby/object:Gem::Version
|
|
242
|
+
version: '4'
|
|
56
243
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
244
|
requirements:
|
|
58
|
-
- - "
|
|
245
|
+
- - ">"
|
|
59
246
|
- !ruby/object:Gem::Version
|
|
60
|
-
version:
|
|
247
|
+
version: 1.3.1
|
|
61
248
|
requirements: []
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
signing_key:
|
|
249
|
+
rubygems_version: 3.2.15
|
|
250
|
+
signing_key:
|
|
65
251
|
specification_version: 4
|
|
66
252
|
summary: Flash plugin for Flame-framework
|
|
67
253
|
test_files: []
|
data/lib/flame/flash_array.rb
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
module Flame
|
|
2
|
-
module Flash
|
|
3
|
-
# A subclass of Array that "remembers forward" by exactly one action.
|
|
4
|
-
# Tastes just like the API of Rails's ActionController::Flash::FlashHash,
|
|
5
|
-
# but with fewer calories.
|
|
6
|
-
class FlashArray
|
|
7
|
-
attr_reader :now, :next
|
|
8
|
-
|
|
9
|
-
# Builds a new FlashHash. It takes the hash for this action's values
|
|
10
|
-
# as an initialization variable.
|
|
11
|
-
def initialize(session, parent = nil, scope = nil)
|
|
12
|
-
@now = session || []
|
|
13
|
-
fix_messages_as_array
|
|
14
|
-
@next = []
|
|
15
|
-
@parent = parent || self
|
|
16
|
-
@scope = scope
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def scope(scope = nil)
|
|
20
|
-
# p 'scope', scope
|
|
21
|
-
return self unless scope
|
|
22
|
-
self.class.new(
|
|
23
|
-
@now.select { |hash| condition(hash, scope: scope) },
|
|
24
|
-
self,
|
|
25
|
-
scope
|
|
26
|
-
)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# We assign to the _next_ hash, but retrieve values
|
|
30
|
-
# from the _now_ hash. Freaky, huh?
|
|
31
|
-
def []=(type, text)
|
|
32
|
-
return text.each { |el| self[type] = el } if text.is_a?(Array)
|
|
33
|
-
hash = { type: type, text: text }
|
|
34
|
-
# p @parent == self, @scope
|
|
35
|
-
hash[:scope] = @scope if @parent != self
|
|
36
|
-
# p hash
|
|
37
|
-
@parent.next.push(hash)
|
|
38
|
-
# p @parent.next
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def [](type = nil)
|
|
42
|
-
selected = @parent.now.select do |hash|
|
|
43
|
-
condition(hash, type: type, scope: @scope)
|
|
44
|
-
end
|
|
45
|
-
# p 'flash[]', type, @scope, selected
|
|
46
|
-
selected.map { |hash| hash[:text] }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def each(&block)
|
|
50
|
-
@now.each(&block)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
## Mass adding to next
|
|
54
|
-
def merge(hash)
|
|
55
|
-
hash.each { |type, text| self[type] = text }
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
private
|
|
59
|
-
|
|
60
|
-
def condition(hash, options = {}) # kind, section)
|
|
61
|
-
options.reject { |key, val| hash[key] == val || val.nil? }.empty?
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def fix_messages_as_array
|
|
65
|
-
@now.each_with_index do |hash, ind|
|
|
66
|
-
next unless hash[:text].is_a?(Array)
|
|
67
|
-
hash = @now.delete(hash)
|
|
68
|
-
@now.insert(ind, hash[:text].map { |text| hash.merge(text: text) })
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|