flash-message-conductor 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .rvmrc
19
+ .rbenv-version
20
+ .rbenv-gemsets
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in flash-message-conductor.gemspec
4
+ gemspec
@@ -1,4 +1,6 @@
1
- Copyright (c) 2008 Planet Argon
1
+ Copyright (c) 2008-2012 Planet Argon
2
+
3
+ MIT License
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
@@ -17,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # Flash Message Conductor
2
+
3
+ A simple pattern for managing flash messages in your Ruby on Rails application.
4
+
5
+ ## Installation
6
+
7
+ ***This branch is considered an Alpha release.***
8
+
9
+ ***This branch is only used for Rails 3. Still using Rails 2? Use [https://github.com/planetargon/flash-message-conductor/tree/rails2](https://github.com/planetargon/flash-message-conductor/tree/rails2) instead.***
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem "flash-message-conductor", "~> 2.0"
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ gem install flash-message-conductor
22
+
23
+ ## Usage
24
+
25
+ ### Controller helpers
26
+
27
+ ```
28
+ add_message('foo')
29
+ ```
30
+
31
+ **Is the equivalent of:**
32
+
33
+ ```
34
+ flash[:message] = 'foo'
35
+ ```
36
+
37
+ **Rails Controller helpers included:**
38
+
39
+ ```
40
+ add_message(message)
41
+ add_notice(message)
42
+ add_error(message)
43
+ ```
44
+
45
+ ### View helpers
46
+
47
+ ```
48
+ <%= render_flash_messages %>
49
+ ```
50
+
51
+ **Produces:**
52
+
53
+ ```
54
+ <div id="flash_messages">
55
+ <p class="message">You have successfully done XYZ...</p>
56
+ </div>
57
+ ```
58
+
59
+ **Or... if you set an error:**
60
+
61
+ ```
62
+ <div id="flash_messages">
63
+ <p class="error">Oops! Something went bonkers!<p>
64
+ </div>
65
+ ```
66
+
67
+ **Or:**
68
+
69
+ ```
70
+ <% if flash_message_set? -%>
71
+ # do something
72
+ <% end -%>
73
+ ```
74
+
75
+ Copyright (c) 2008-2012 Planet Argon, released under the MIT license
76
+
77
+ ### Contributing
78
+
79
+ 1. Fork it
80
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
81
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
82
+ 4. Push to the branch (`git push origin my-new-feature`)
83
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,27 @@
1
+ /*------------------------------------------------------------------------
2
+ =Flash Messages
3
+ ------------------------------------------------------------------------*/
4
+
5
+ #flash_messages {
6
+ padding: 8px;
7
+ margin-bottom: 18px;
8
+ }
9
+
10
+ #flash_messages p {
11
+ margin-bottom: 0;
12
+ }
13
+
14
+ #flash_messages p.error {
15
+ background: #fcc;
16
+ border: 1px solid #f00;
17
+ }
18
+
19
+ #flash_messages p.notice {
20
+ background: #fee37a;
21
+ border: 1px solid #fd9b5b;
22
+ }
23
+
24
+ #flash_messages p.message {
25
+ background: #cbf285;
26
+ border: 1px solid #3cab09;
27
+ }
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'flash-message-conductor/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "flash-message-conductor"
8
+ gem.version = FlashMessageConductor::VERSION
9
+ gem.authors = ["Robby Russell", "Carlos Rodriguez"]
10
+ gem.email = ["robbyrussell@planetargon.com", "carlos@planetargon.com"]
11
+ gem.description = %q{A simple pattern for managing flash messages in your Ruby on Rails application}
12
+ gem.summary = %q{Conduct your Flash Messages in Rails}
13
+ gem.homepage = %q{http://github.com/planetargon/flash-message-conductor}
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,2 @@
1
+ require "flash-message-conductor/version"
2
+ require "flash-message-conductor/railtie" if defined?(Rails)
@@ -0,0 +1,25 @@
1
+ module FlashMessageConductor
2
+ FLASH_MESSAGE_TYPES = [ :error, :notice, :message ]
3
+
4
+ module ControllerHelpers
5
+ def add_error(msg)
6
+ flash[:error] = msg
7
+ end
8
+
9
+ def add_notice(msg)
10
+ flash[:notice] = msg
11
+ end
12
+
13
+ def add_message(msg)
14
+ flash[:message] = msg
15
+ end
16
+
17
+ def flash_message_set?
18
+ flash_set = false
19
+ FLASH_MESSAGE_TYPES.each do |key|
20
+ flash_set = true unless flash[key].blank?
21
+ end
22
+ return flash_set
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ require 'flash-message-conductor/view_helpers'
2
+ require 'flash-message-conductor/controller_helpers'
3
+
4
+ module FlashMessageConductor
5
+ class Railtie < Rails::Railtie
6
+ initializer "flash_message_conductor.view_helpers" do
7
+ ActionView::Base.send :include, FlashMessageConductor::ViewHelpers
8
+ end
9
+
10
+ initializer "flash_message_conductor.controller_helpers" do
11
+ ActionController::Base.send :include, FlashMessageConductor::ControllerHelpers
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module FlashMessageConductor
2
+ VERSION = "2.0.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ module FlashMessageConductor
2
+ module ViewHelpers
3
+ def render_flash_message(css_class, message = "")
4
+ return "" if message.nil? or message.blank?
5
+ content_tag("p", message.html_safe, :class => "#{css_class}")
6
+ end
7
+
8
+ def render_flash_messages(div_id = "flash_messages", div_class = "")
9
+ div_content = ''
10
+ FLASH_MESSAGE_TYPES.each do |key|
11
+ div_content << render_flash_message(key.to_s, flash[key]) unless flash[key].blank?
12
+ end
13
+ if div_content.blank?
14
+ return ""
15
+ else
16
+ return content_tag('div', div_content.html_safe, :id => div_id, :class => div_class)
17
+ end
18
+ end
19
+
20
+ def flash_message_set?
21
+ flash_set = false
22
+ FLASH_MESSAGE_TYPES.each do |key|
23
+ flash_set = true unless flash[key].blank?
24
+ end
25
+ return flash_set
26
+ end
27
+ end
28
+ end
metadata CHANGED
@@ -1,72 +1,59 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: flash-message-conductor
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 2
10
- version: 1.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Robby Russell
9
+ - Carlos Rodriguez
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
-
18
- date: 2011-05-06 00:00:00 +02:00
19
- default_executable:
13
+ date: 2012-12-12 00:00:00.000000000 Z
20
14
  dependencies: []
21
-
22
15
  description: A simple pattern for managing flash messages in your Ruby on Rails application
23
- email: robby@planetargon.com
16
+ email:
17
+ - robbyrussell@planetargon.com
18
+ - carlos@planetargon.com
24
19
  executables: []
25
-
26
20
  extensions: []
27
-
28
21
  extra_rdoc_files: []
29
-
30
- files:
31
- - VERSION.yml
32
- - lib/flash_message_conductor.rb
33
- - rails/init.rb
34
- - README
35
- - MIT-LICENSE
36
- has_rdoc: true
22
+ files:
23
+ - .gitignore
24
+ - Gemfile
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - examples/example.css
29
+ - flash-message-conductor.gemspec
30
+ - lib/flash-message-conductor.rb
31
+ - lib/flash-message-conductor/controller_helpers.rb
32
+ - lib/flash-message-conductor/railtie.rb
33
+ - lib/flash-message-conductor/version.rb
34
+ - lib/flash-message-conductor/view_helpers.rb
37
35
  homepage: http://github.com/planetargon/flash-message-conductor
38
36
  licenses: []
39
-
40
37
  post_install_message:
41
- rdoc_options:
42
- - --inline-source
43
- - --charset=UTF-8
44
- require_paths:
38
+ rdoc_options: []
39
+ require_paths:
45
40
  - lib
46
- required_ruby_version: !ruby/object:Gem::Requirement
41
+ required_ruby_version: !ruby/object:Gem::Requirement
47
42
  none: false
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- hash: 3
52
- segments:
53
- - 0
54
- version: "0"
55
- required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
48
  none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 0
63
- version: "0"
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
64
53
  requirements: []
65
-
66
54
  rubyforge_project:
67
- rubygems_version: 1.6.2
55
+ rubygems_version: 1.8.23
68
56
  signing_key:
69
57
  specification_version: 3
70
58
  summary: Conduct your Flash Messages in Rails
71
59
  test_files: []
72
-
data/README DELETED
@@ -1,47 +0,0 @@
1
- Flash Message Conductor
2
- ============
3
-
4
- A simple pattern for managing flash messages in your Ruby on Rails application.
5
-
6
-
7
- Example
8
- =======
9
-
10
- # Controller helpers
11
-
12
- add_message( 'foo' )
13
-
14
- is the equivalent of
15
-
16
- flash[:message] = 'foo'
17
-
18
- Controller helpers included:
19
-
20
- add_message( message )
21
- add_notice( message )
22
- add_error( message )
23
-
24
- # View helpers
25
-
26
- <%= render_flash_messages %>
27
-
28
- produces:
29
-
30
- <div id="flash_messages">
31
- <p class="message">You have successfully done XYZ...</p>
32
- </div>
33
-
34
- # or... if you set an error
35
-
36
- <div id="flash_messages">
37
- <p class="error">Oops! Something went bonkers!</p>
38
- </div>
39
-
40
- # or...
41
-
42
- <% if flash_message_set? -%>
43
- # do something
44
- <% end -%>
45
-
46
-
47
- Copyright (c) 2011 Planet Argon, released under the MIT license
data/VERSION.yml DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- :minor: 0
3
- :patch: 1
4
- :major: 1
@@ -1,56 +0,0 @@
1
- # ArgonHelpers
2
-
3
- module PlanetArgon
4
- module FlashMessageConductor
5
- FLASH_MESSAGE_TYPES = [ :error, :notice, :message ]
6
-
7
- module ControllerHelpers
8
- def add_error(msg)
9
- flash[:error] = msg
10
- end
11
-
12
- def add_notice(msg)
13
- flash[:notice] = msg
14
- end
15
-
16
- def add_message(msg)
17
- flash[:message] = msg
18
- end
19
-
20
- def flash_message_set?
21
- flash_set = false
22
- FLASH_MESSAGE_TYPES.each do |key|
23
- flash_set = true unless flash[key].blank?
24
- end
25
- return flash_set
26
- end
27
- end
28
-
29
- module ViewHelpers
30
- def render_flash_message( css_class, message = "" )
31
- return "" if message.nil? or message.blank?
32
- content_tag( "p", message, :class => "#{css_class}" )
33
- end
34
-
35
- def render_flash_messages( div_id = "flash_messages", div_class = "" )
36
- div_content = ''
37
- FLASH_MESSAGE_TYPES.each do |key|
38
- div_content << render_flash_message( key.to_s, flash[key] ) unless flash[key].blank?
39
- end
40
- if div_content.blank?
41
- return ""
42
- else
43
- return content_tag( 'div', div_content, :id => div_id, :class => div_class )
44
- end
45
- end
46
-
47
- def flash_message_set?
48
- flash_set = false
49
- FLASH_MESSAGE_TYPES.each do |key|
50
- flash_set = true unless flash[key].blank?
51
- end
52
- return flash_set
53
- end
54
- end
55
- end
56
- end
data/rails/init.rb DELETED
@@ -1,4 +0,0 @@
1
- require 'flash_message_conductor'
2
-
3
- ActionController::Base.send( :include, PlanetArgon::FlashMessageConductor::ControllerHelpers )
4
- ActionView::Base.send( :include, PlanetArgon::FlashMessageConductor::ViewHelpers )