flash_gordon 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/flash_gordon/flash.rb +5 -4
- data/lib/flash_gordon/version.rb +1 -1
- data/lib/flash_gordon.rb +32 -0
- metadata +2 -2
data/lib/flash_gordon/flash.rb
CHANGED
@@ -3,7 +3,7 @@ module FlashGordon
|
|
3
3
|
# Messages fall under different message zones, for now zones are hardcoded
|
4
4
|
# eventually we can add custom ones via initializers
|
5
5
|
|
6
|
-
@messages =
|
6
|
+
@messages = FlashGordon.zones
|
7
7
|
|
8
8
|
def self.append(message,zone=:warning, options={})
|
9
9
|
# Added options for future use
|
@@ -16,11 +16,12 @@ module FlashGordon
|
|
16
16
|
@messages[zone] << message
|
17
17
|
end
|
18
18
|
else
|
19
|
-
raise "Zone does not exist, please use the following zones -
|
19
|
+
raise "Zone does not exist, please use the following zones - #{@messages.map{|k| ":#{k[0]}"}.join(", ") } or add it to the initializer."
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.render(zone=:all, glue="
|
23
|
+
def self.render(zone=:all, glue="<br/>")
|
24
|
+
@messages
|
24
25
|
if zone == :all
|
25
26
|
@messages.each_pair do |k,v|
|
26
27
|
@messages[k] = v.join(glue) unless v.empty?
|
@@ -32,7 +33,7 @@ module FlashGordon
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def self.reset
|
35
|
-
@messages =
|
36
|
+
@messages = FlashGordon.reset_zones
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
data/lib/flash_gordon/version.rb
CHANGED
data/lib/flash_gordon.rb
CHANGED
@@ -1 +1,33 @@
|
|
1
|
+
module FlashGordon
|
2
|
+
mattr_accessor :zones
|
3
|
+
|
4
|
+
@@zones = {}
|
5
|
+
|
6
|
+
def self.setup
|
7
|
+
yield self
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.init_zone
|
11
|
+
zone_list = "warning danger info success error"
|
12
|
+
zone_list.split(" ").each{|z| @@zones[z.to_sym] = []}
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.add_zone(zone)
|
17
|
+
@@zones[zone.to_sym] = [] unless @@zones[zone.to_sym]
|
18
|
+
@@default_zones[zone.to_sym] = [] unless @@zones[zone.to_sym]
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.reset_zones
|
23
|
+
reset_zones = {}
|
24
|
+
@@zones.each_key do |k|
|
25
|
+
reset_zones[k] = []
|
26
|
+
end
|
27
|
+
self.zones = reset_zones
|
28
|
+
end
|
29
|
+
|
30
|
+
self.init_zone
|
31
|
+
end
|
32
|
+
|
1
33
|
require 'flash_gordon/railtie' if defined? Rails
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: flash_gordon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ernest Sim
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|