show_message 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-18mode # JRuby in 1.8 mode
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+ - rbx-18mode
7
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in show_message.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jarrett Lusso
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # ShowMessage
2
+
3
+ [![Build Status](https://travis-ci.org/jclusso/show_message.png?branch=master)](https://travis-ci.org/jclusso/show_message)
4
+ [![Code Climate](https://codeclimate.com/repos/51df6c497e00a4660f0070ea/badges/8965c37137b1ddcf785f/gpa.png)](https://codeclimate.com/repos/51df6c497e00a4660f0070ea/feed)
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'show_message'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install show_message
19
+
20
+ ## Usage
21
+
22
+ TODO: Write usage instructions here
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default do; end
@@ -0,0 +1,7 @@
1
+ <% data.each do |m| %>
2
+ <div class="alert-box <%= m[:class] %> <%= "autohide" if options[:autohide] %>" style= "<%= (m != data.last) ? "margin-bottom:5px;" : "" %>">
3
+ <div class="message">
4
+ <%= raw m[:message] %>
5
+ </div>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,4 @@
1
+ module ShowMessage
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ require 'show_message/view_helpers'
2
+
3
+ module ShowMessage
4
+ class Railtie < Rails::Railtie
5
+ ActiveSupport.on_load(:action_view) do
6
+ ::ActionView::Base.send :include, ShowMessage::ViewHelpers
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module ShowMessage
2
+ VERSION = [0, 0, 1].join "."
3
+ end
@@ -0,0 +1,43 @@
1
+ module ShowMessage
2
+ module ViewHelpers
3
+
4
+ def show_message(options = {}, *args)
5
+
6
+ options = {autohide: false}.merge!(options)
7
+ if options[:id].present?
8
+ class_mappings = {"success_#{options[:id]}".to_sym => "success", "error_#{options[:id]}".to_sym => "error", "warning_#{options[:id]}".to_sym => "warning", "info_#{options[:id]}".to_sym => "info"}
9
+ flash_is_empty = false
10
+ class_mappings.each_key do |k|
11
+ flash_is_empty = false unless flash[k].nil?
12
+ end
13
+ return if flash_is_empty
14
+ else
15
+ class_mappings = {:success => "success", :error => "error", :warning => "warning", :info => "info"}
16
+ end
17
+
18
+ data = []
19
+
20
+ class_mappings.each_key do |k|
21
+ if flash[k].kind_of?(Array)
22
+ if flash[k]
23
+ flash[k].each do |m|
24
+ data << {:message => m, :class => class_mappings[k]}
25
+ end
26
+ end
27
+ else
28
+ if flash[k]
29
+ data << {:message => flash[k], :class => class_mappings[k]}
30
+ end
31
+ end
32
+ end
33
+ args.each do |k|
34
+ data << k
35
+ end
36
+ class_mappings.each_key { |k| flash[k] = nil }
37
+
38
+ render partial: "show_message/show_message", locals: {data: data, options: options}
39
+
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ require 'show_message/view_helpers'
2
+ if defined? Rails
3
+ require 'show_message/railtie'
4
+ require 'show_message/engine'
5
+ end
@@ -0,0 +1,22 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'show_message/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "show_message"
7
+ spec.version = ShowMessage::VERSION
8
+ spec.authors = ["Jarrett Lusso"]
9
+ spec.email = ["jarrett@graphicflash.com"]
10
+ spec.description = %q{show-message makes it easy to output your flash[:success], flash[:error] or flash[:whatever] to the view using one simple helper.}
11
+ spec.summary = %q{show-message makes it easy to output your flash[:success], flash[:error] or flash[:whatever] to the view using one simple helper.}
12
+ spec.homepage = "http://github.com/jclusso/show_message"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler"
21
+ spec.add_development_dependency "rake"
22
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: show_message
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jarrett Lusso
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: show-message makes it easy to output your flash[:success], flash[:error]
47
+ or flash[:whatever] to the view using one simple helper.
48
+ email:
49
+ - jarrett@graphicflash.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - .travis.yml
56
+ - Gemfile
57
+ - LICENSE.txt
58
+ - README.md
59
+ - Rakefile
60
+ - app/views/show_message/_show_message.html.erb
61
+ - lib/show_message.rb
62
+ - lib/show_message/engine.rb
63
+ - lib/show_message/railtie.rb
64
+ - lib/show_message/version.rb
65
+ - lib/show_message/view_helpers.rb
66
+ - show_message.gemspec
67
+ homepage: http://github.com/jclusso/show_message
68
+ licenses:
69
+ - MIT
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 1.8.25
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: show-message makes it easy to output your flash[:success], flash[:error]
92
+ or flash[:whatever] to the view using one simple helper.
93
+ test_files: []