sinatra-redirect-with-flash 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6be62868cd48545bdd988ef376dfe8340787ed0c
4
+ data.tar.gz: 833965baee3cf3dbaec70a8d6969b6ea6b2ddd86
5
+ SHA512:
6
+ metadata.gz: 14d6184da877471da6a60a2df623fc141f103aea00460bcec9d01ff60bca71c884d018613e3294bdfd0df94994334fad2e35dacb965e15d76a4afae17f05e5f5
7
+ data.tar.gz: e387466a2d552a408bbecf6bf06bb3584506265f4c2332017a2bfcde14b48ab003ad519d305d25c3306194860c3525a38e51616df0526f7793185c7e0408f132
data/README.md CHANGED
@@ -1,24 +1,28 @@
1
1
  #Sinatra Extension: redirect with flash
2
2
 
3
3
  Shortly: sinatra-redirect-with-flash provides `redirect` helper that can
4
- set proper flash (rack-flash or sinatra-flash) before the redirection.
4
+ set proper flash (rack-flash3 or sinatra-flash) before the redirection.
5
5
 
6
6
  In fact, every time you set a flash parameter the very next step is often to
7
7
  perform your redirect:
8
8
 
9
- post '/posts/?' do
10
- @post = Post.create(params)
11
- flash[:notice] = 'The post was successfully created'
12
- redirect "/posts/#{@post.id}"
13
- end
9
+ ```ruby
10
+ post '/posts/?' do
11
+ @post = Post.create(params)
12
+ flash[:notice] = 'The post was successfully created'
13
+ redirect "/posts/#{@post.id}"
14
+ end
15
+ ```
14
16
 
15
17
  With sinatra-redirect-with-flash you can do one-line redirects. For instance,
16
18
  to rewrite the above example:
17
19
 
18
- post '/posts/?' do
19
- @post = Post.create(params)
20
- redirect "/posts/#{@post.id}", :notice => 'The post was successfully created'
21
- end
20
+ ```ruby
21
+ post '/posts/?' do
22
+ @post = Post.create(params)
23
+ redirect "/posts/#{@post.id}", :notice => 'The post was successfully created'
24
+ end
25
+ ```
22
26
 
23
27
 
24
28
  ##Installation
@@ -27,8 +31,10 @@ If you use [bundler](http://gembundler.com/), simply specify
27
31
  `sinatra-redirect-with-flash` as a dependency in a Gemfile
28
32
  in your project's root:
29
33
 
30
- gem 'sinatra-flash' # or `gem 'rack-flash'`
31
- gem 'sinatra-redirect-with-flash'
34
+ ```ruby
35
+ gem 'rack-flash3'
36
+ gem 'sinatra-redirect-with-flash'
37
+ ```
32
38
 
33
39
  and run `bundle install`.
34
40
 
@@ -41,33 +47,37 @@ Otherwise install the gem as usual:
41
47
 
42
48
  ##Example
43
49
 
44
- require 'rubygems'
45
- require 'sinatra'
46
- require 'sinatra/flash' # or `require 'rack-flash'`
47
- require 'sinatra/redirect_with_flash'
50
+ ```ruby
51
+ require 'rubygems'
52
+ require 'sinatra'
53
+ require 'rack-flash'
54
+ require 'sinatra/redirect_with_flash'
48
55
 
49
- enable :sessions
56
+ enable :sessions
50
57
 
51
- post '/sessions/new' do
52
- redirect '/secret', :notice => 'Logged in'
53
- # predefined keys are: :notice, :error, :warning, :alert, :info, :success
54
- end
58
+ post '/sessions/new' do
59
+ redirect '/secret', :notice => 'Logged in'
60
+ # predefined keys are: :notice, :error, :warning, :alert, :info, :success
61
+ end
55
62
 
56
- get '/foo' do
57
- redirect '/bar', 301, :notice => 'redirect with 301 code'
58
- end
63
+ get '/foo' do
64
+ redirect '/bar', 301, :notice => 'redirect with 301 code'
65
+ end
59
66
 
60
- get '/archive' do
61
- redirect '/posts/', :flash => {:my_msg => 'Moving on!'}
62
- end
67
+ get '/archive' do
68
+ redirect '/posts/', :flash => {:my_msg => 'Moving on!'}
69
+ end
70
+ ```
63
71
 
64
72
  *Note* that if your application subclasses `Sinatra::Base` (modular app),
65
73
  you have to register the extension in your subclass:
66
74
 
67
- helpers Sinatra::RedirectWithFlash
75
+ ```ruby
76
+ helpers Sinatra::RedirectWithFlash
77
+ ```
68
78
 
69
79
 
70
80
  ##Requirements
71
81
 
72
- Either [rack-flash](http://nakajima.github.com/rack-flash/) or
82
+ Either [rack-flash3](https://github.com/treeder/rack-flash) or
73
83
  [sinatra-flash](https://github.com/SFEley/sinatra-flash).
data/Rakefile CHANGED
@@ -1,34 +1,11 @@
1
- require 'rubygems'
2
1
  require 'rake/testtask'
3
- require 'rake/gempackagetask'
2
+ require 'bundler'
3
+ Bundler::GemHelper.install_tasks
4
4
 
5
5
  task :default => :test
6
6
 
7
- begin
8
- require 'jeweler'
9
- Jeweler::Tasks.new do |gemspec|
10
- gemspec.name = "sinatra-redirect-with-flash"
11
- gemspec.version = "0.2.0"
12
- gemspec.summary = gemspec.description = "redirect with flash helper for Sinatra"
13
- gemspec.email = "vasily@polovnyov.ru"
14
- gemspec.homepage = "http://github.com/vast/sinatra-redirect-with-flash"
15
- gemspec.authors = ["Vasily Polovnyov"]
16
-
17
- gemspec.add_dependency 'sinatra', '>=1.0.0'
18
-
19
- gemspec.add_development_dependency 'rack-test', '>=0.3.0'
20
- gemspec.add_development_dependency 'sinatra-flash', '>=0.3.0'
21
-
22
- gemspec.test_files = Dir.glob('test/*')
23
- gemspec.files = ["LICENSE", "README.md", "Rakefile"] + Dir.glob('lib/**/*') + gemspec.test_files
24
-
25
- end
26
- rescue LoadError
27
- puts "Jeweler not available. Install it with: sudo gem install jeweler"
28
- end
29
-
30
7
  Rake::TestTask.new do |t|
31
8
  t.libs << "test"
32
9
  t.test_files = FileList['test/*_test.rb']
33
10
  t.verbose = true
34
- end
11
+ end
@@ -3,17 +3,17 @@ require 'sinatra/base'
3
3
  module Sinatra
4
4
  module RedirectWithFlash
5
5
  COMMON_FLASH_NAMES = [:notice, :alert, :warning, :error, :info, :success]
6
-
6
+
7
7
  def redirect(uri, *args)
8
8
  flash_opts = args.last
9
-
9
+
10
10
  if flash_opts && flash_opts.is_a?(Hash)
11
11
  COMMON_FLASH_NAMES.each do |name|
12
12
  if val = flash_opts.delete(name)
13
13
  flash[name] = val
14
14
  end
15
15
  end
16
-
16
+
17
17
  if other_flashes = flash_opts.delete(:flash)
18
18
  other_flashes.each {|k, v| flash[k] = v}
19
19
  end
@@ -25,4 +25,4 @@ module Sinatra
25
25
  end
26
26
 
27
27
  helpers RedirectWithFlash
28
- end
28
+ end
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'sinatra'
3
3
  require 'sinatra/flash'
4
- require 'lib/sinatra/redirect_with_flash'
4
+ require './lib/sinatra/redirect_with_flash'
5
5
 
6
6
  enable :sessions
7
7
 
@@ -25,4 +25,4 @@ end
25
25
 
26
26
  get '/old-school-redirect-with-code' do
27
27
  redirect '/aaa', 301
28
- end
28
+ end
metadata CHANGED
@@ -1,110 +1,95 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sinatra-redirect-with-flash
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Vasily Polovnyov
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2012-02-13 00:00:00 +04:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2014-01-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: sinatra
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 0
30
- - 0
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
31
19
  version: 1.0.0
32
20
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: rack-test
36
21
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- - 3
44
- - 0
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack-test
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
45
33
  version: 0.3.0
46
34
  type: :development
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: sinatra-flash
50
35
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
- - 3
58
- - 0
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: sinatra-flash
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
59
47
  version: 0.3.0
60
48
  type: :development
61
- version_requirements: *id003
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.0
62
55
  description: redirect with flash helper for Sinatra
63
56
  email: vasily@polovnyov.ru
64
57
  executables: []
65
-
66
58
  extensions: []
67
-
68
- extra_rdoc_files:
59
+ extra_rdoc_files:
69
60
  - LICENSE
70
61
  - README.md
71
- files:
62
+ files:
72
63
  - LICENSE
73
64
  - README.md
74
65
  - Rakefile
75
66
  - lib/sinatra/redirect_with_flash.rb
76
67
  - test/sinatra_app.rb
77
68
  - test/sinatra_redirect_with_flash_test.rb
78
- has_rdoc: true
79
69
  homepage: http://github.com/vast/sinatra-redirect-with-flash
80
- licenses: []
81
-
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
82
73
  post_install_message:
83
74
  rdoc_options: []
84
-
85
- require_paths:
75
+ require_paths:
86
76
  - lib
87
- required_ruby_version: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- segments:
92
- - 0
93
- version: "0"
94
- required_rubygems_version: !ruby/object:Gem::Requirement
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- segments:
99
- - 0
100
- version: "0"
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
101
87
  requirements: []
102
-
103
88
  rubyforge_project:
104
- rubygems_version: 1.3.6
89
+ rubygems_version: 2.1.8
105
90
  signing_key:
106
- specification_version: 3
91
+ specification_version: 4
107
92
  summary: redirect with flash helper for Sinatra
108
- test_files:
93
+ test_files:
109
94
  - test/sinatra_app.rb
110
95
  - test/sinatra_redirect_with_flash_test.rb