sinatra-flash 0.1.0 → 0.2.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.
- data/VERSION +1 -1
- data/lib/sinatra/flash.rb +12 -8
- data/sinatra-flash.gemspec +73 -0
- data/spec/base_spec.rb +50 -0
- metadata +6 -5
- data/spec/classic_spec.rb +0 -20
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/sinatra/flash.rb
CHANGED
@@ -6,15 +6,19 @@ require 'sinatra/flash/style'
|
|
6
6
|
module Sinatra
|
7
7
|
module Flash
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
def self.registered(app)
|
10
|
+
app.helpers Flash::Storage
|
11
|
+
app.helpers Flash::Style
|
12
|
+
|
13
|
+
# This callback rotates any flash structure we referenced, placing the 'next' hash into the session
|
14
|
+
# for the next request.
|
15
|
+
app.after do
|
16
|
+
set :sessions, true unless session # If you do not have a session, one will be appointed for you by the court.
|
17
|
+
@flash.each{|key, flash| session[key] = @flash[key].next}
|
18
|
+
end
|
14
19
|
end
|
15
|
-
|
16
|
-
helpers Storage
|
17
|
-
helpers Style
|
20
|
+
|
18
21
|
end
|
22
|
+
|
19
23
|
register Flash
|
20
24
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{sinatra-flash}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Stephen Eley"]
|
12
|
+
s.date = %q{2010-04-28}
|
13
|
+
s.description = %q{A Sinatra extension for setting and showing Rails-like flash messages. This extension improves on the Rack::Flash gem by being simpler to use, providing a full range of hash operations (including iterating through various flash keys, testing the size of the hash, etc.), and offering a 'styled_flash' view helper to render the entire flash hash with sensible CSS classes. The downside is reduced flexibility -- these methods will *only* work in Sinatra.}
|
14
|
+
s.email = %q{sfeley@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.markdown",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE.markdown",
|
23
|
+
"README.markdown",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/sinatra/flash.rb",
|
27
|
+
"lib/sinatra/flash/hash.rb",
|
28
|
+
"lib/sinatra/flash/storage.rb",
|
29
|
+
"lib/sinatra/flash/style.rb",
|
30
|
+
"sinatra-flash.gemspec",
|
31
|
+
"spec/base_spec.rb",
|
32
|
+
"spec/flash/hash_spec.rb",
|
33
|
+
"spec/flash/style_spec.rb",
|
34
|
+
"spec/flash_spec.rb",
|
35
|
+
"spec/spec.opts",
|
36
|
+
"spec/spec_helper.rb"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/SFEley/sinatra-flash}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.3.6}
|
42
|
+
s.summary = %q{Proper flash messages in Sinatra}
|
43
|
+
s.test_files = [
|
44
|
+
"spec/base_spec.rb",
|
45
|
+
"spec/flash/hash_spec.rb",
|
46
|
+
"spec/flash/style_spec.rb",
|
47
|
+
"spec/flash_spec.rb",
|
48
|
+
"spec/spec_helper.rb"
|
49
|
+
]
|
50
|
+
|
51
|
+
if s.respond_to? :specification_version then
|
52
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
53
|
+
s.specification_version = 3
|
54
|
+
|
55
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_runtime_dependency(%q<sinatra>, [">= 1.0.0"])
|
57
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
58
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
59
|
+
s.add_development_dependency(%q<sinatra-sessionography>, [">= 0"])
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<sinatra>, [">= 1.0.0"])
|
62
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
63
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
64
|
+
s.add_dependency(%q<sinatra-sessionography>, [">= 0"])
|
65
|
+
end
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<sinatra>, [">= 1.0.0"])
|
68
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
69
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
70
|
+
s.add_dependency(%q<sinatra-sessionography>, [">= 0"])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
data/spec/base_spec.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require 'sinatra/base'
|
3
|
+
|
4
|
+
class BaseApp < Sinatra::Base
|
5
|
+
helpers Sinatra::Sessionography
|
6
|
+
register Sinatra::Flash
|
7
|
+
|
8
|
+
|
9
|
+
get '/flash' do
|
10
|
+
if params[:key]
|
11
|
+
flash(params[:key]).inspect
|
12
|
+
else
|
13
|
+
flash.inspect
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
post '/flash' do
|
18
|
+
if (key = params.delete('key'))
|
19
|
+
params.each{|k,v| flash(key)[k.to_sym] = v.to_sym}
|
20
|
+
flash(key).inspect
|
21
|
+
else
|
22
|
+
params.each{|k,v| flash[k.to_sym] = v.to_sym}
|
23
|
+
flash.inspect
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "Sinatra::Flash in a Sinatra::Base application" do
|
30
|
+
|
31
|
+
def app
|
32
|
+
BaseApp
|
33
|
+
end
|
34
|
+
|
35
|
+
before(:each) do
|
36
|
+
Sinatra::Sessionography.session = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it "shows nothing when no flash has been set" do
|
40
|
+
get '/flash'
|
41
|
+
last_response.body.should == "{}"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "can set and retrieve the flash" do
|
45
|
+
post '/flash', {:foo => :bar}
|
46
|
+
get '/flash'
|
47
|
+
last_response.body.should == "{:foo=>:bar}"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Stephen Eley
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-28 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -89,7 +89,8 @@ files:
|
|
89
89
|
- lib/sinatra/flash/hash.rb
|
90
90
|
- lib/sinatra/flash/storage.rb
|
91
91
|
- lib/sinatra/flash/style.rb
|
92
|
-
-
|
92
|
+
- sinatra-flash.gemspec
|
93
|
+
- spec/base_spec.rb
|
93
94
|
- spec/flash/hash_spec.rb
|
94
95
|
- spec/flash/style_spec.rb
|
95
96
|
- spec/flash_spec.rb
|
@@ -126,7 +127,7 @@ signing_key:
|
|
126
127
|
specification_version: 3
|
127
128
|
summary: Proper flash messages in Sinatra
|
128
129
|
test_files:
|
129
|
-
- spec/
|
130
|
+
- spec/base_spec.rb
|
130
131
|
- spec/flash/hash_spec.rb
|
131
132
|
- spec/flash/style_spec.rb
|
132
133
|
- spec/flash_spec.rb
|
data/spec/classic_spec.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
#
|
3
|
-
# # Make sure it behaves properly in a top-level 'classic' app
|
4
|
-
#
|
5
|
-
# require 'sinatra'
|
6
|
-
# require 'sinatra/flash'
|
7
|
-
# # set test environment
|
8
|
-
# set :environment, :test
|
9
|
-
# set :run, false
|
10
|
-
# set :raise_errors, true
|
11
|
-
# set :logging, false
|
12
|
-
#
|
13
|
-
# get "/first" do
|
14
|
-
# flash[:info] = 'You should see this on the second page.'
|
15
|
-
# erb "<%= styled_flash%><h1>There should be no flash here!</h1>"
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# describe "A Sinatra classic app" do
|
19
|
-
#
|
20
|
-
# end
|