flushing-flash 0.2.3 → 0.3.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.
Files changed (73) hide show
  1. data/.rvmrc +1 -0
  2. data/README.rdoc +67 -52
  3. data/Rakefile +6 -6
  4. data/flushing-flash.gemspec +69 -2
  5. data/lib/flushing-flash/action_view_methods.rb +4 -4
  6. data/lib/flushing-flash/version.rb +2 -2
  7. data/test/dummy/.gitignore +5 -0
  8. data/test/dummy/Gemfile +38 -0
  9. data/test/dummy/Gemfile.lock +121 -0
  10. data/test/dummy/README +261 -0
  11. data/test/dummy/Rakefile +7 -0
  12. data/test/dummy/app/assets/images/rails.png +0 -0
  13. data/test/dummy/app/assets/javascripts/application.js +9 -0
  14. data/test/dummy/app/assets/javascripts/posts.js.coffee +3 -0
  15. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  16. data/test/dummy/app/assets/stylesheets/posts.css.scss +3 -0
  17. data/test/dummy/app/assets/stylesheets/scaffolds.css.scss +56 -0
  18. data/test/dummy/app/controllers/application_controller.rb +3 -0
  19. data/test/dummy/app/controllers/posts_controller.rb +98 -0
  20. data/test/dummy/app/helpers/application_helper.rb +2 -0
  21. data/test/dummy/app/helpers/posts_helper.rb +2 -0
  22. data/test/dummy/app/mailers/.gitkeep +0 -0
  23. data/test/dummy/app/models/.gitkeep +0 -0
  24. data/test/dummy/app/models/post.rb +3 -0
  25. data/test/dummy/app/views/layouts/application.html.erb +23 -0
  26. data/test/dummy/app/views/posts/_form.html.erb +29 -0
  27. data/test/dummy/app/views/posts/edit.html.erb +6 -0
  28. data/test/dummy/app/views/posts/index.html.erb +27 -0
  29. data/test/dummy/app/views/posts/new.html.erb +5 -0
  30. data/test/dummy/app/views/posts/show.html.erb +20 -0
  31. data/test/dummy/app/views/shared/_flash_messages.html.erb +5 -0
  32. data/test/dummy/config/application.rb +48 -0
  33. data/test/dummy/config/boot.rb +6 -0
  34. data/test/dummy/config/database.yml +25 -0
  35. data/test/dummy/config/environment.rb +5 -0
  36. data/test/dummy/config/environments/development.rb +30 -0
  37. data/test/dummy/config/environments/production.rb +60 -0
  38. data/test/dummy/config/environments/test.rb +39 -0
  39. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  40. data/test/dummy/config/initializers/inflections.rb +10 -0
  41. data/test/dummy/config/initializers/mime_types.rb +5 -0
  42. data/test/dummy/config/initializers/secret_token.rb +7 -0
  43. data/test/dummy/config/initializers/session_store.rb +8 -0
  44. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  45. data/test/dummy/config/locales/en.yml +14 -0
  46. data/test/dummy/config/routes.rb +60 -0
  47. data/test/dummy/config.ru +4 -0
  48. data/test/dummy/db/migrate/20111105100343_create_posts.rb +11 -0
  49. data/test/dummy/db/schema.rb +24 -0
  50. data/test/dummy/db/seeds.rb +7 -0
  51. data/test/dummy/lib/assets/.gitkeep +0 -0
  52. data/test/dummy/lib/tasks/.gitkeep +0 -0
  53. data/test/dummy/log/.gitkeep +0 -0
  54. data/test/dummy/public/404.html +26 -0
  55. data/test/dummy/public/422.html +26 -0
  56. data/test/dummy/public/500.html +26 -0
  57. data/test/dummy/public/favicon.ico +0 -0
  58. data/test/dummy/public/index.html +241 -0
  59. data/test/dummy/public/robots.txt +5 -0
  60. data/test/dummy/script/rails +6 -0
  61. data/test/dummy/test/fixtures/.gitkeep +0 -0
  62. data/test/dummy/test/fixtures/posts.yml +11 -0
  63. data/test/dummy/test/functional/.gitkeep +0 -0
  64. data/test/dummy/test/functional/posts_controller_test.rb +49 -0
  65. data/test/dummy/test/integration/.gitkeep +0 -0
  66. data/test/dummy/test/performance/browsing_test.rb +12 -0
  67. data/test/dummy/test/test_helper.rb +13 -0
  68. data/test/dummy/test/unit/.gitkeep +0 -0
  69. data/test/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
  70. data/test/dummy/test/unit/post_test.rb +7 -0
  71. data/test/dummy/vendor/assets/stylesheets/.gitkeep +0 -0
  72. data/test/dummy/vendor/plugins/.gitkeep +0 -0
  73. metadata +78 -11
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2-p290@gem-flushing-flash --create
data/README.rdoc CHANGED
@@ -8,75 +8,90 @@ To provide helper methods for handling rails flash messages.
8
8
 
9
9
  Put the following into the Gemfile and run `bundle install`
10
10
 
11
- gem 'flushing_flash'
11
+ gem 'flushing_flash'
12
12
 
13
13
  == Usage
14
14
 
15
- ==== to push a flash message
15
+ ==== 1. To push a flash message
16
16
 
17
- push_flash(message_type, *args)
17
+ push_flash(message_type, *args)
18
18
 
19
- ==== examples:
19
+ examples:
20
20
 
21
- 1.1) push_flash(:success)
22
- { message_type: :success, content: I18n.t("flashes.#{controller_name}.#{action_name}.success", {}) }
23
-
24
- 1.2) push_flash(:failure, "User is not authenticated!") # note that the 2nd param is a **String**!
25
- { message_type: :failure, content: "User is not authenticated!" }
26
-
27
- 1.3) push_flash(:failure, :"users.authenticate") # note that the 2nd param is a **Symbol**!
28
- { message_type: :failure, content: I18n.t("flashes.users.authenticate.failure", {}) }
29
-
30
- 1.4) push_flash(:success, name: "Peter")
31
- { message_type: :success, content: I18n.t("flashes.#{controller_name}.#{action_name}.success", name: "Peter") }
32
-
33
- 1.5) push_flash(:failure, :"users.authenticate", name: "Peter")
34
- { message_type: :success, content: I18nt("flashes.users.authenticate.failure", name: "Peter") }
35
-
36
- 1.6) push_flash(:success, name: "Peter", target: :signin_form)
37
- the target will not be passed to the I18n.t! Instead, it is a keyword for identifying the target receving the message.
38
- see the (2) part.
21
+ 1.1. push_flash(:success)
22
+ { message_type: :success, content: I18n.t("flashes.#{controller_name}.#{action_name}.success", {}) }
23
+
24
+ 1.2. push_flash(:failure, "User is not authenticated!") # note that the 2nd param is a **String**!
25
+ { message_type: :failure, content: "User is not authenticated!" }
26
+
27
+ 1.3. push_flash(:failure, :"users.authenticate") # note that the 2nd param is a **Symbol**!
28
+ { message_type: :failure, content: I18n.t("flashes.users.authenticate.failure", {}) }
29
+
30
+ 1.4. push_flash(:success, name: "Peter")
31
+ { message_type: :success, content: I18n.t("flashes.#{controller_name}.#{action_name}.success", name: "Peter") }
32
+
33
+ 1.5. push_flash(:failure, :"users.authenticate", name: "Peter")
34
+ { message_type: :success, content: I18nt("flashes.users.authenticate.failure", name: "Peter") }
35
+
36
+ 1.6. push_flash(:success, name: "Peter", target: :signin_form)
37
+ the target will not be passed to the I18n.t! Instead, it is a keyword for identifying the target receving the message.
38
+ see the (2) part.
39
39
 
40
- === to pull flash messages from a target
40
+ === 2. To pull flash messages from a target
41
41
 
42
- pull_flash(target=:default)
42
+ pull_flash(target=:default)
43
43
 
44
- ==== examples:
44
+ examples:
45
45
 
46
- 2.1) pull_flash # pull from :default target
47
- [{message_type: ..., content: ...}, { message_type: ..., content: ...}, ...]
48
-
49
- 2.2) pull_flash(:signin_form)
50
- [{message_type: ..., content: ...}, { message_type: ..., content: ...}, ...]
46
+ 2.1. pull_flash # pull from :default target
47
+ [{message_type: ..., content: ...}, { message_type: ..., content: ...}, ...]
48
+
49
+ 2.2. pull_flash(:signin_form)
50
+ [{message_type: ..., content: ...}, { message_type: ..., content: ...}, ...]
51
51
 
52
- === check if a target has flash messages or not
52
+ === 3. To check if a target has flash messages or not
53
53
 
54
- has_flash?(target=:default)
54
+ has_flash?(target=:default)
55
55
 
56
- ==== examples:
56
+ examples:
57
57
 
58
- 3.1) has_flash?
59
- true / false
60
-
61
- 3.2) has_flash?(:signin_form)
62
- true / false
58
+ 3.1. has_flash?
59
+ true / false
60
+
61
+ 3.2. has_flash?(:signin_form)
62
+ true / false
63
63
 
64
- === return currently hard-coded view for the messages in the target
64
+ === 4. To return currently hard-coded view for the messages in the target
65
65
 
66
66
  *** TODO: provide a better way to customize the html output ***
67
67
 
68
- flush_flash(target=:default)
68
+ flush_flash(target=:default)
69
69
 
70
- ==== examples:
70
+ examples:
71
71
 
72
- 4.1) flush_flash
73
- <div class="alert-message #{message_type} fade in">
74
- <a href="#" class="close">x</a>
75
- <p>#{content.html_safe}</p>
76
- </div>
77
-
78
- 4.2) flush_flash(:signin_form)
79
- <div class="alert-message #{message_type} fade in">
80
- <a href="#" class="close">x</a>
81
- <p>#{content.html_safe}</p>
82
- </div>
72
+ 4.1. flush_flash
73
+ <div class="alert-message #{message_type} fade in">
74
+ <a href="#" class="close">x</a>
75
+ <p>#{content.html_safe}</p>
76
+ </div>
77
+
78
+ 4.2. flush_flash(:signin_form)
79
+ <div class="alert-message #{message_type} fade in">
80
+ <a href="#" class="close">x</a>
81
+ <p>#{content.html_safe}</p>
82
+ </div>
83
+
84
+ === 5. To use self-defined partial for rendering the flash messages
85
+
86
+ flush_flash(target=:default, options={})
87
+
88
+ examples:
89
+
90
+ 5.1 flush_flash(using: "shared/flash_messages")
91
+ HTML output for the partial app/views/shared/_flash_messages.html.erb
92
+
93
+ === Change Logs
94
+
95
+ ==== 0.2.3
96
+
97
+ 1. fixed error if passing `:using` to pull `flush_flash` method. Now you could make use of `:using` option to use your own partial for rendering the flash messages.
data/Rakefile CHANGED
@@ -1,13 +1,13 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  # Process of development:
4
- # 1. do the actual coding and update (hopfully with tests)
5
- # 2. commit
6
- # 3. goto 1 if needed :) else goto 4
7
- # 4. update the version in lib/flushing-flash/version.rb
8
- # 5. git commit -am "bump version to 0.1.0" # please update the version number
4
+ # 1. update the version in lib/flushing-flash/version.rb
5
+ # 2. git commit -am "bump version to 0.1.0" # please update the version number
6
+ # 3. do the actual coding and update (hopfully with tests)
7
+ # 4. commit
8
+ # 5. goto 3 if needed :) else goto 6
9
9
  # 6. rake install to install locally (and hopfully test it with test applications)
10
- # 7. rake release
10
+ # 7. rake release # will be automatically git tagged!!!
11
11
 
12
12
  require 'rubygems'
13
13
  require 'bundler'
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{flushing-flash}
8
- s.version = "0.2.3"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{PeterWong}]
12
- s.date = %q{2011-11-04}
12
+ s.date = %q{2011-11-05}
13
13
  s.description = %q{To provide helper methods for handling rails flash messages.}
14
14
  s.email = %q{peter@peterwongpp.com}
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
+ ".rvmrc",
21
22
  "Gemfile",
22
23
  "Gemfile.lock",
23
24
  "LICENSE.txt",
@@ -28,6 +29,72 @@ Gem::Specification.new do |s|
28
29
  "lib/flushing-flash/action_controller_methods.rb",
29
30
  "lib/flushing-flash/action_view_methods.rb",
30
31
  "lib/flushing-flash/version.rb",
32
+ "test/dummy/.gitignore",
33
+ "test/dummy/Gemfile",
34
+ "test/dummy/Gemfile.lock",
35
+ "test/dummy/README",
36
+ "test/dummy/Rakefile",
37
+ "test/dummy/app/assets/images/rails.png",
38
+ "test/dummy/app/assets/javascripts/application.js",
39
+ "test/dummy/app/assets/javascripts/posts.js.coffee",
40
+ "test/dummy/app/assets/stylesheets/application.css",
41
+ "test/dummy/app/assets/stylesheets/posts.css.scss",
42
+ "test/dummy/app/assets/stylesheets/scaffolds.css.scss",
43
+ "test/dummy/app/controllers/application_controller.rb",
44
+ "test/dummy/app/controllers/posts_controller.rb",
45
+ "test/dummy/app/helpers/application_helper.rb",
46
+ "test/dummy/app/helpers/posts_helper.rb",
47
+ "test/dummy/app/mailers/.gitkeep",
48
+ "test/dummy/app/models/.gitkeep",
49
+ "test/dummy/app/models/post.rb",
50
+ "test/dummy/app/views/layouts/application.html.erb",
51
+ "test/dummy/app/views/posts/_form.html.erb",
52
+ "test/dummy/app/views/posts/edit.html.erb",
53
+ "test/dummy/app/views/posts/index.html.erb",
54
+ "test/dummy/app/views/posts/new.html.erb",
55
+ "test/dummy/app/views/posts/show.html.erb",
56
+ "test/dummy/app/views/shared/_flash_messages.html.erb",
57
+ "test/dummy/config.ru",
58
+ "test/dummy/config/application.rb",
59
+ "test/dummy/config/boot.rb",
60
+ "test/dummy/config/database.yml",
61
+ "test/dummy/config/environment.rb",
62
+ "test/dummy/config/environments/development.rb",
63
+ "test/dummy/config/environments/production.rb",
64
+ "test/dummy/config/environments/test.rb",
65
+ "test/dummy/config/initializers/backtrace_silencers.rb",
66
+ "test/dummy/config/initializers/inflections.rb",
67
+ "test/dummy/config/initializers/mime_types.rb",
68
+ "test/dummy/config/initializers/secret_token.rb",
69
+ "test/dummy/config/initializers/session_store.rb",
70
+ "test/dummy/config/initializers/wrap_parameters.rb",
71
+ "test/dummy/config/locales/en.yml",
72
+ "test/dummy/config/routes.rb",
73
+ "test/dummy/db/migrate/20111105100343_create_posts.rb",
74
+ "test/dummy/db/schema.rb",
75
+ "test/dummy/db/seeds.rb",
76
+ "test/dummy/lib/assets/.gitkeep",
77
+ "test/dummy/lib/tasks/.gitkeep",
78
+ "test/dummy/log/.gitkeep",
79
+ "test/dummy/public/404.html",
80
+ "test/dummy/public/422.html",
81
+ "test/dummy/public/500.html",
82
+ "test/dummy/public/favicon.ico",
83
+ "test/dummy/public/index.html",
84
+ "test/dummy/public/robots.txt",
85
+ "test/dummy/script/rails",
86
+ "test/dummy/test/fixtures/.gitkeep",
87
+ "test/dummy/test/fixtures/posts.yml",
88
+ "test/dummy/test/functional/.gitkeep",
89
+ "test/dummy/test/functional/posts_controller_test.rb",
90
+ "test/dummy/test/integration/.gitkeep",
91
+ "test/dummy/test/performance/browsing_test.rb",
92
+ "test/dummy/test/test_helper.rb",
93
+ "test/dummy/test/unit/.gitkeep",
94
+ "test/dummy/test/unit/helpers/posts_helper_test.rb",
95
+ "test/dummy/test/unit/post_test.rb",
96
+ "test/dummy/vendor/assets/stylesheets/.gitkeep",
97
+ "test/dummy/vendor/plugins/.gitkeep",
31
98
  "test/helper.rb",
32
99
  "test/test_flushing-flash.rb"
33
100
  ]
@@ -15,16 +15,16 @@ module FlushingFlash
15
15
 
16
16
  def flush_flash(target=:default, options={})
17
17
  msgs = pull_flash(target)
18
- using_template = options[:using]
18
+ using_template = options[:using] || nil
19
+ html_safe = options[:html_safe] || false
19
20
 
20
21
  if msgs.any?
21
22
  if using_template
22
23
  render partial: using_template, locals: { messages: msgs }
23
24
  else
24
25
  msgs.collect do |msg|
25
- content_tag :div, class: "alert-message #{msg[:message_type]} fade in" do
26
- concat link_to("x", "#", class: "close")
27
- concat content_tag(:p, msg[:content].html_safe)
26
+ content_tag :div, class: "flash-message #{msg[:message_type]}" do
27
+ concat content_tag(:p, (html_safe ? msg[:content].html_safe : msg[:content]))
28
28
  end
29
29
  end.join.html_safe
30
30
  end
@@ -1,8 +1,8 @@
1
1
  module FlushingFlash
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 2
5
- PATCH = 3
4
+ MINOR = 3
5
+ PATCH = 0
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -0,0 +1,5 @@
1
+ .bundle
2
+ db/*.sqlite3
3
+ log/*.log
4
+ tmp/
5
+ .sass-cache/
@@ -0,0 +1,38 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '3.1.1'
4
+
5
+ # Bundle edge Rails instead:
6
+ # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
+
8
+ gem 'sqlite3'
9
+
10
+
11
+ # Gems used only for assets and not required
12
+ # in production environments by default.
13
+ group :assets do
14
+ gem 'sass-rails', '~> 3.1.4'
15
+ gem 'coffee-rails', '~> 3.1.1'
16
+ gem 'uglifier', '>= 1.0.3'
17
+ end
18
+
19
+ gem 'jquery-rails'
20
+
21
+ # To use ActiveModel has_secure_password
22
+ # gem 'bcrypt-ruby', '~> 3.0.0'
23
+
24
+ # Use unicorn as the web server
25
+ # gem 'unicorn'
26
+
27
+ # Deploy with Capistrano
28
+ # gem 'capistrano'
29
+
30
+ # To use debugger
31
+ # gem 'ruby-debug19', :require => 'ruby-debug'
32
+
33
+ group :test do
34
+ # Pretty printed test output
35
+ gem 'turn', :require => false
36
+ end
37
+
38
+ gem 'flushing-flash'
@@ -0,0 +1,121 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.1.1)
5
+ actionpack (= 3.1.1)
6
+ mail (~> 2.3.0)
7
+ actionpack (3.1.1)
8
+ activemodel (= 3.1.1)
9
+ activesupport (= 3.1.1)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ i18n (~> 0.6)
13
+ rack (~> 1.3.2)
14
+ rack-cache (~> 1.1)
15
+ rack-mount (~> 0.8.2)
16
+ rack-test (~> 0.6.1)
17
+ sprockets (~> 2.0.2)
18
+ activemodel (3.1.1)
19
+ activesupport (= 3.1.1)
20
+ builder (~> 3.0.0)
21
+ i18n (~> 0.6)
22
+ activerecord (3.1.1)
23
+ activemodel (= 3.1.1)
24
+ activesupport (= 3.1.1)
25
+ arel (~> 2.2.1)
26
+ tzinfo (~> 0.3.29)
27
+ activeresource (3.1.1)
28
+ activemodel (= 3.1.1)
29
+ activesupport (= 3.1.1)
30
+ activesupport (3.1.1)
31
+ multi_json (~> 1.0)
32
+ ansi (1.3.0)
33
+ arel (2.2.1)
34
+ builder (3.0.0)
35
+ coffee-rails (3.1.1)
36
+ coffee-script (>= 2.2.0)
37
+ railties (~> 3.1.0)
38
+ coffee-script (2.2.0)
39
+ coffee-script-source
40
+ execjs
41
+ coffee-script-source (1.1.2)
42
+ erubis (2.7.0)
43
+ execjs (1.2.9)
44
+ multi_json (~> 1.0)
45
+ flushing-flash (0.3.0)
46
+ hike (1.2.1)
47
+ i18n (0.6.0)
48
+ jquery-rails (1.0.16)
49
+ railties (~> 3.0)
50
+ thor (~> 0.14)
51
+ json (1.6.1)
52
+ mail (2.3.0)
53
+ i18n (>= 0.4.0)
54
+ mime-types (~> 1.16)
55
+ treetop (~> 1.4.8)
56
+ mime-types (1.17.2)
57
+ multi_json (1.0.3)
58
+ polyglot (0.3.3)
59
+ rack (1.3.5)
60
+ rack-cache (1.1)
61
+ rack (>= 0.4)
62
+ rack-mount (0.8.3)
63
+ rack (>= 1.0.0)
64
+ rack-ssl (1.3.2)
65
+ rack
66
+ rack-test (0.6.1)
67
+ rack (>= 1.0)
68
+ rails (3.1.1)
69
+ actionmailer (= 3.1.1)
70
+ actionpack (= 3.1.1)
71
+ activerecord (= 3.1.1)
72
+ activeresource (= 3.1.1)
73
+ activesupport (= 3.1.1)
74
+ bundler (~> 1.0)
75
+ railties (= 3.1.1)
76
+ railties (3.1.1)
77
+ actionpack (= 3.1.1)
78
+ activesupport (= 3.1.1)
79
+ rack-ssl (~> 1.3.2)
80
+ rake (>= 0.8.7)
81
+ rdoc (~> 3.4)
82
+ thor (~> 0.14.6)
83
+ rake (0.9.2.2)
84
+ rdoc (3.11)
85
+ json (~> 1.4)
86
+ sass (3.1.10)
87
+ sass-rails (3.1.4)
88
+ actionpack (~> 3.1.0)
89
+ railties (~> 3.1.0)
90
+ sass (>= 3.1.4)
91
+ sprockets (~> 2.0.0)
92
+ tilt (~> 1.3.2)
93
+ sprockets (2.0.3)
94
+ hike (~> 1.2)
95
+ rack (~> 1.0)
96
+ tilt (!= 1.3.0, ~> 1.1)
97
+ sqlite3 (1.3.4)
98
+ thor (0.14.6)
99
+ tilt (1.3.3)
100
+ treetop (1.4.10)
101
+ polyglot
102
+ polyglot (>= 0.3.1)
103
+ turn (0.8.3)
104
+ ansi
105
+ tzinfo (0.3.30)
106
+ uglifier (1.0.4)
107
+ execjs (>= 0.3.0)
108
+ multi_json (>= 1.0.2)
109
+
110
+ PLATFORMS
111
+ ruby
112
+
113
+ DEPENDENCIES
114
+ coffee-rails (~> 3.1.1)
115
+ flushing-flash
116
+ jquery-rails
117
+ rails (= 3.1.1)
118
+ sass-rails (~> 3.1.4)
119
+ sqlite3
120
+ turn
121
+ uglifier (>= 1.0.3)