flame-flash 1.0.1 → 2.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab31089be121a3137cf52b0fa191fb929293e523
4
- data.tar.gz: b50a7d89e7266fa290ea6e930df99fae77c32389
3
+ metadata.gz: cc6d4eba7a43b4d9f517a88640c0d0d12144f2c6
4
+ data.tar.gz: 2d4afb0d9cea7ee3fc7292ba21297dd2bd50d19b
5
5
  SHA512:
6
- metadata.gz: 9af4b013aa622fefa59b2a86a7bc9833bbade6ff88e4b62130ed846c728b2e21fc32199d59903528ae8dcbbc930923b580146b6627145fb68918b7f5ed6c4eb2
7
- data.tar.gz: d979a528bf3a204ae302080db1a4077fe75e4bb528758cb566593e321e990a07a2470b87372e3b86e0861a8f416c7b30e7ebc8cc7076693c0b0679d0c733482a
6
+ metadata.gz: 448eea08643b3d48a7a071c708d824b362779c0c0ca9703444f43347c06b4b22e3095bd7c20bf7f61a30c7276a30b68f2628fa5d07ce817b8abb2816316f0109
7
+ data.tar.gz: 4e4d0d712ee78590da93426046c3c16c371ba05d320601f642da8ab6b01eb9e875d6819eb9e00fb2eecdfc65acbb6761995daee357422dc8aed6cbdbacb2c044
data/lib/flame/flash.rb CHANGED
@@ -1,16 +1,11 @@
1
- # Dir[File.join(__dir__, 'flash', '*.rb')].each { |file| require file }
1
+ require_relative 'flash_array'
2
2
 
3
3
  module Flame
4
4
  # Module for Flame::Flash extension with helper methods and base class
5
5
  module Flash
6
- def self.mount
7
- proc do
8
- # This callback rotates any flash structure we referenced,
9
- # placing the 'next' hash into the session for the next request.
10
- after do
11
- session[:flash] = flash.next
12
- end
13
- end
6
+ def execute(method)
7
+ super
8
+ session[:flash] = flash.next
14
9
  end
15
10
 
16
11
  private
@@ -22,60 +17,5 @@ module Flame
22
17
  )
23
18
  ).scope(key)
24
19
  end
25
-
26
- # A subclass of Array that "remembers forward" by exactly one action.
27
- # Tastes just like the API of Rails's ActionController::Flash::FlashHash,
28
- # but with fewer calories.
29
- class FlashArray
30
- attr_reader :now, :next
31
-
32
- # Builds a new FlashHash. It takes the hash for this action's values
33
- # as an initialization variable.
34
- def initialize(session, parent = nil, scope = nil)
35
- @now = session || []
36
- @next = []
37
- @parent = parent || self
38
- @scope = scope
39
- end
40
-
41
- def scope(scope = nil)
42
- # p 'scope', scope
43
- return self unless scope
44
- self.class.new(
45
- @now.select { |hash| condition(hash, scope: scope) },
46
- self,
47
- scope
48
- )
49
- end
50
-
51
- # We assign to the _next_ hash, but retrieve values
52
- # from the _now_ hash. Freaky, huh?
53
- def []=(type, text)
54
- hash = { type: type, text: text }
55
- # p @parent == self, @scope
56
- hash.merge!(scope: @scope) if @parent != self
57
- # p hash
58
- @parent.next.push(hash)
59
- # p @parent.next
60
- end
61
-
62
- def [](type = nil)
63
- selected = @parent.now.select do |hash|
64
- condition(hash, type: type, scope: @scope)
65
- end
66
- # p 'flash[]', type, @scope, selected
67
- selected.map { |hash| hash[:text] }
68
- end
69
-
70
- def each(&block)
71
- @now.each(&block)
72
- end
73
-
74
- private
75
-
76
- def condition(hash, options = {}) # kind, section)
77
- options.reject { |key, val| hash[key] == val || val.nil? }.empty?
78
- end
79
- end
80
20
  end
81
21
  end
@@ -0,0 +1,58 @@
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
+ @next = []
14
+ @parent = parent || self
15
+ @scope = scope
16
+ end
17
+
18
+ def scope(scope = nil)
19
+ # p 'scope', scope
20
+ return self unless scope
21
+ self.class.new(
22
+ @now.select { |hash| condition(hash, scope: scope) },
23
+ self,
24
+ scope
25
+ )
26
+ end
27
+
28
+ # We assign to the _next_ hash, but retrieve values
29
+ # from the _now_ hash. Freaky, huh?
30
+ def []=(type, text)
31
+ hash = { type: type, text: text }
32
+ # p @parent == self, @scope
33
+ hash[:scope] = @scope if @parent != self
34
+ # p hash
35
+ @parent.next.push(hash)
36
+ # p @parent.next
37
+ end
38
+
39
+ def [](type = nil)
40
+ selected = @parent.now.select do |hash|
41
+ condition(hash, type: type, scope: @scope)
42
+ end
43
+ # p 'flash[]', type, @scope, selected
44
+ selected.map { |hash| hash[:text] }
45
+ end
46
+
47
+ def each(&block)
48
+ @now.each(&block)
49
+ end
50
+
51
+ private
52
+
53
+ def condition(hash, options = {}) # kind, section)
54
+ options.reject { |key, val| hash[key] == val || val.nil? }.empty?
55
+ end
56
+ end
57
+ end
58
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flame-flash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-10 00:00:00.000000000 Z
11
+ date: 2016-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flame
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.3'
19
+ version: '4.0'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 3.3.4
22
+ version: 4.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '3.3'
29
+ version: '4.0'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 3.3.4
32
+ version: 4.0.0
33
33
  description: Show messages (notifies, errors, warnings) in current or next routes
34
34
  after redirect.
35
35
  email:
@@ -39,6 +39,7 @@ extensions: []
39
39
  extra_rdoc_files: []
40
40
  files:
41
41
  - lib/flame/flash.rb
42
+ - lib/flame/flash_array.rb
42
43
  homepage: https://gitlab.com/AlexWayfer/flame-flash
43
44
  licenses:
44
45
  - MIT
@@ -59,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
60
  version: '0'
60
61
  requirements: []
61
62
  rubyforge_project:
62
- rubygems_version: 2.4.5.1
63
+ rubygems_version: 2.5.1
63
64
  signing_key:
64
65
  specification_version: 4
65
66
  summary: Flash plugin for Flame-framework