flash_gordon 0.0.4 → 0.0.5

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.
@@ -21,7 +21,6 @@ module FlashGordon
21
21
  end
22
22
 
23
23
  def self.render(zone=:all, glue="<br/>")
24
- @messages
25
24
  if zone == :all
26
25
  @messages.each_pair do |k,v|
27
26
  @messages[k] = v.join(glue) unless v.empty?
@@ -1,3 +1,3 @@
1
1
  module FlashGordon
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/flash_gordon.rb CHANGED
@@ -1,30 +1,43 @@
1
1
  module FlashGordon
2
2
  mattr_accessor :zones
3
-
3
+ mattr_reader :default_zones
4
4
  @@zones = {}
5
5
 
6
6
  def self.setup
7
7
  yield self
8
8
  end
9
9
 
10
+ def self.set_default_zones
11
+ @@default_zones = Hash[@@zones]
12
+ end
13
+
10
14
  def self.init_zone
11
15
  zone_list = "warning danger info success error"
12
16
  zone_list.split(" ").each{|z| @@zones[z.to_sym] = []}
17
+ self.set_default_zones
13
18
  true
14
19
  end
15
20
 
16
21
  def self.add_zone(zone)
17
22
  @@zones[zone.to_sym] = [] unless @@zones[zone.to_sym]
18
- @@default_zones[zone.to_sym] = [] unless @@zones[zone.to_sym]
19
23
  true
20
24
  end
21
25
 
22
26
  def self.reset_zones
23
- reset_zones = {}
24
27
  @@zones.each_key do |k|
25
- reset_zones[k] = []
28
+ @@zones[k] = []
26
29
  end
27
- self.zones = reset_zones
30
+ @@zones
31
+ end
32
+
33
+ def self.hash_compare(a,b)
34
+ (a.size > b.size ? a.to_a - b.to_a : b.to_a - a.to_a).flatten
35
+ end
36
+
37
+ private_class_method :hash_compare
38
+
39
+ def self.new_zones
40
+ hash_compare(@@zones, @@default_zones)
28
41
  end
29
42
 
30
43
  self.init_zone
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class PagesControllerTest < ActionController::TestCase
4
+
5
+ test "view should have a flash div" do
6
+ get :home
7
+ assert_select ".alert", "success"
8
+ end
9
+
10
+ end
@@ -0,0 +1,5 @@
1
+ class PagesController < ApplicationController
2
+ def home
3
+ FlashGordon::Flash.append("success")
4
+ end
5
+ end
@@ -7,7 +7,7 @@
7
7
  <%= csrf_meta_tags %>
8
8
  </head>
9
9
  <body>
10
-
10
+ <%= render_flash %>
11
11
  <%= yield %>
12
12
 
13
13
  </body>
@@ -0,0 +1 @@
1
+ Pewpewpew
@@ -0,0 +1,3 @@
1
+ FlashGordon.setup do |config|
2
+ config.add_zone(:anger)
3
+ end
@@ -1,56 +1,3 @@
1
1
  Dummy::Application.routes.draw do
2
- # The priority is based upon order of creation: first created -> highest priority.
3
- # See how all your routes lay out with "rake routes".
4
-
5
- # You can have the root of your site routed with "root"
6
- # root 'welcome#index'
7
-
8
- # Example of regular route:
9
- # get 'products/:id' => 'catalog#view'
10
-
11
- # Example of named route that can be invoked with purchase_url(id: product.id)
12
- # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
13
-
14
- # Example resource route (maps HTTP verbs to controller actions automatically):
15
- # resources :products
16
-
17
- # Example resource route with options:
18
- # resources :products do
19
- # member do
20
- # get 'short'
21
- # post 'toggle'
22
- # end
23
- #
24
- # collection do
25
- # get 'sold'
26
- # end
27
- # end
28
-
29
- # Example resource route with sub-resources:
30
- # resources :products do
31
- # resources :comments, :sales
32
- # resource :seller
33
- # end
34
-
35
- # Example resource route with more complex sub-resources:
36
- # resources :products do
37
- # resources :comments
38
- # resources :sales do
39
- # get 'recent', on: :collection
40
- # end
41
- # end
42
-
43
- # Example resource route with concerns:
44
- # concern :toggleable do
45
- # post 'toggle'
46
- # end
47
- # resources :posts, concerns: :toggleable
48
- # resources :photos, concerns: :toggleable
49
-
50
- # Example resource route within a namespace:
51
- # namespace :admin do
52
- # # Directs /admin/products/* to Admin::ProductsController
53
- # # (app/controllers/admin/products_controller.rb)
54
- # resources :products
55
- # end
2
+ root 'pages#home'
56
3
  end
File without changes