merb-flash 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +5 -12
- data/Rakefile +6 -3
- data/VERSION +1 -1
- data/lib/merb-flash.rb +15 -6
- data/merb-flash.gemspec +11 -9
- data/spec/merb-flash_spec.rb +22 -9
- metadata +21 -10
data/README.markdown
CHANGED
@@ -6,11 +6,10 @@ A plugin for the Merb framework that provides rails-like flash messages
|
|
6
6
|
Instalation
|
7
7
|
-----------
|
8
8
|
|
9
|
-
gem
|
10
|
-
sudo gem install merb-flash
|
9
|
+
gem install merb-flash
|
11
10
|
|
12
|
-
#
|
13
|
-
|
11
|
+
# Gemfile
|
12
|
+
gem "merb-flash", "1.1.0"
|
14
13
|
|
15
14
|
Usage
|
16
15
|
-----
|
@@ -20,16 +19,10 @@ _in controller:_
|
|
20
19
|
redirect url(:homepage), :message => {:notice => "Merb is awesome"}
|
21
20
|
redirect url(:homepage), :message => {:error => "PHP sux"}
|
22
21
|
redirect url(:homepage), :message => {:whatever => "you like"}
|
22
|
+
redirect url(:homepage), :success => "Huray!"
|
23
23
|
|
24
24
|
_in view:_
|
25
25
|
|
26
26
|
= message[:notice]
|
27
27
|
= message[:error]
|
28
|
-
|
29
|
-
one more...
|
30
|
-
-----------
|
31
|
-
redirect url(:homepage), :message => "Merb is awesome"
|
32
|
-
|
33
|
-
is a shortcut for
|
34
|
-
|
35
|
-
redirect url(:homepage), :message => {:notice => "Merb is awesome"}
|
28
|
+
= message[:success]
|
data/Rakefile
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
1
4
|
begin
|
2
5
|
require 'jeweler'
|
3
6
|
Jeweler::Tasks.new do |gemspec|
|
@@ -6,14 +9,14 @@ begin
|
|
6
9
|
gemspec.email = "i@teamon.eu"
|
7
10
|
gemspec.homepage = "http://github.com/teamon/merb-flash"
|
8
11
|
gemspec.authors = ["Tymon Tobolski"]
|
9
|
-
gemspec.add_dependency('merb-core', '>= 1.
|
12
|
+
gemspec.add_dependency('merb-core', '>= 1.1')
|
10
13
|
end
|
11
14
|
Jeweler::GemcutterTasks.new
|
12
15
|
rescue LoadError
|
13
|
-
puts "Jeweler not available. Install it with:
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
14
17
|
end
|
15
18
|
|
16
19
|
desc "Run specs"
|
17
20
|
task :spec do
|
18
21
|
system("spec -O spec/spec.opts spec")
|
19
|
-
end
|
22
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/merb-flash.rb
CHANGED
@@ -15,15 +15,24 @@ if defined?(Merb::Plugins)
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
module Merb::RedirectWithSessionFlash
|
19
|
-
def
|
18
|
+
module Merb::RedirectWithSessionFlash
|
19
|
+
def handle_redirect_messages(url, opts={})
|
20
|
+
opts = opts.dup
|
21
|
+
|
22
|
+
# check opts for message shortcut keys (and assign them to message)
|
23
|
+
[:notice, :error, :success].each do |message_key|
|
24
|
+
if opts[message_key]
|
25
|
+
opts[:message] ||= {}
|
26
|
+
opts[:message][message_key] = opts[message_key]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# append message query param if message is passed
|
20
31
|
if opts[:message]
|
21
|
-
|
22
|
-
msg = Mash.new(:notice => msg.to_s) unless msg.is_a?(Hash)
|
23
|
-
session[:flash] = msg
|
32
|
+
session[:flash] = opts[:message]
|
24
33
|
end
|
25
34
|
|
26
|
-
|
35
|
+
url
|
27
36
|
end
|
28
37
|
end
|
29
38
|
|
data/merb-flash.gemspec
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{merb-flash}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Tymon Tobolski"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2010-05-01}
|
13
13
|
s.description = %q{Merb plugin that provides rails-like flash messages}
|
14
14
|
s.email = %q{i@teamon.eu}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
"README.markdown"
|
17
|
+
"README.markdown",
|
18
|
+
"TODO"
|
18
19
|
]
|
19
20
|
s.files = [
|
20
21
|
".gitignore",
|
@@ -32,7 +33,7 @@ Gem::Specification.new do |s|
|
|
32
33
|
s.homepage = %q{http://github.com/teamon/merb-flash}
|
33
34
|
s.rdoc_options = ["--charset=UTF-8"]
|
34
35
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.
|
36
|
+
s.rubygems_version = %q{1.3.6}
|
36
37
|
s.summary = %q{Merb plugin that provides rails-like flash messages}
|
37
38
|
s.test_files = [
|
38
39
|
"spec/merb-flash_spec.rb",
|
@@ -44,11 +45,12 @@ Gem::Specification.new do |s|
|
|
44
45
|
s.specification_version = 3
|
45
46
|
|
46
47
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
47
|
-
s.add_runtime_dependency(%q<merb-core>, [">= 1.
|
48
|
+
s.add_runtime_dependency(%q<merb-core>, [">= 1.1"])
|
48
49
|
else
|
49
|
-
s.add_dependency(%q<merb-core>, [">= 1.
|
50
|
+
s.add_dependency(%q<merb-core>, [">= 1.1"])
|
50
51
|
end
|
51
52
|
else
|
52
|
-
s.add_dependency(%q<merb-core>, [">= 1.
|
53
|
+
s.add_dependency(%q<merb-core>, [">= 1.1"])
|
53
54
|
end
|
54
55
|
end
|
56
|
+
|
data/spec/merb-flash_spec.rb
CHANGED
@@ -8,24 +8,37 @@ class FlashTestController < Merb::Controller
|
|
8
8
|
redirect "/", :message => {:notice => "Chunky bacon!"}
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
redirect "/", :
|
11
|
+
def shortcut_notice
|
12
|
+
redirect "/", :notice => "Chunky notice?"
|
13
|
+
end
|
14
|
+
|
15
|
+
def shortcut_error
|
16
|
+
redirect "/", :error => "Chunky error?"
|
17
|
+
end
|
18
|
+
|
19
|
+
def shortcut_success
|
20
|
+
redirect "/", :success => "Chunky success?"
|
13
21
|
end
|
14
22
|
end
|
15
23
|
|
16
24
|
describe "merb-flash" do
|
17
25
|
it "shouldn`t have message in url" do
|
18
|
-
|
19
|
-
@controller.headers["Location"].should == "/"
|
26
|
+
dispatch_to(FlashTestController, :standard).headers["Location"].should == "/"
|
20
27
|
end
|
21
28
|
|
22
29
|
it "should have message in session" do
|
23
|
-
|
24
|
-
@controller.session.should == Mash.new(:flash => {:notice => "Chunky bacon!"})
|
30
|
+
dispatch_to(FlashTestController, :standard).session.should == Mash.new(:flash => {:notice => "Chunky bacon!"})
|
25
31
|
end
|
26
32
|
|
27
|
-
it "should use shortcut :
|
28
|
-
|
29
|
-
|
33
|
+
it "should use shortcut :notice => 'foo' as :message => {:notice => 'foo'}" do
|
34
|
+
dispatch_to(FlashTestController, :shortcut_notice).session.should == Mash.new(:flash => {:notice => "Chunky notice?"})
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should use shortcut :error => 'foo' as :message => {:error => 'foo'}" do
|
38
|
+
dispatch_to(FlashTestController, :shortcut_error).session.should == Mash.new(:flash => {:error => "Chunky error?"})
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should use shortcut :success => 'foo' as :message => {:success => 'foo'}" do
|
42
|
+
dispatch_to(FlashTestController, :shortcut_success).session.should == Mash.new(:flash => {:success => "Chunky success?"})
|
30
43
|
end
|
31
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb-flash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Tymon Tobolski
|
@@ -9,19 +14,22 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-05-01 00:00:00 +02:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: merb-core
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 1
|
30
|
+
version: "1.1"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
25
33
|
description: Merb plugin that provides rails-like flash messages
|
26
34
|
email: i@teamon.eu
|
27
35
|
executables: []
|
@@ -31,6 +39,7 @@ extensions: []
|
|
31
39
|
extra_rdoc_files:
|
32
40
|
- LICENSE
|
33
41
|
- README.markdown
|
42
|
+
- TODO
|
34
43
|
files:
|
35
44
|
- .gitignore
|
36
45
|
- LICENSE
|
@@ -56,18 +65,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
65
|
requirements:
|
57
66
|
- - ">="
|
58
67
|
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
59
70
|
version: "0"
|
60
|
-
version:
|
61
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
73
|
- - ">="
|
64
74
|
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
65
77
|
version: "0"
|
66
|
-
version:
|
67
78
|
requirements: []
|
68
79
|
|
69
80
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.3.
|
81
|
+
rubygems_version: 1.3.6
|
71
82
|
signing_key:
|
72
83
|
specification_version: 3
|
73
84
|
summary: Merb plugin that provides rails-like flash messages
|