lunetas 0.1.0 → 0.1.1
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/examples/redirect.rb +10 -0
- data/lib/lunetas/candy/request_wrapper.rb +8 -0
- data/lib/lunetas/candy/response_handler.rb +5 -1
- data/spec/lunetas/candy_spec.rb +8 -0
- data/spec/spec_helper.rb +5 -0
- metadata +5 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -26,6 +26,14 @@ module Lunetas::Candy::RequestWrapper
|
|
26
26
|
@req.session
|
27
27
|
end
|
28
28
|
|
29
|
+
# Redirects to some location.
|
30
|
+
# @param [String] target the location to redirect to.
|
31
|
+
# @param [Fixnum] status the redirect status.
|
32
|
+
# @return [nil]
|
33
|
+
def redirect(target, status = 302)
|
34
|
+
@lunetas_redirect = [status, {'Content-Type' => 'text/plain', 'Location' => target}, []]
|
35
|
+
end
|
36
|
+
|
29
37
|
# Is lunetas running in development?
|
30
38
|
# @return [true, false]
|
31
39
|
def development?
|
@@ -60,7 +60,11 @@ module Lunetas::Candy::ResponseHandler
|
|
60
60
|
# @param [Fixnum] code the response code.
|
61
61
|
# @return [Array] a Rack::Request response.
|
62
62
|
def response(object, code = 200)
|
63
|
-
|
63
|
+
if @lunetas_redirect && @lunetas_redirect.is_a?(Array)
|
64
|
+
@lunetas_redirect
|
65
|
+
else
|
66
|
+
[code, {'Content-Type' => self.class.lunetas_content_type}, [object.to_s]]
|
67
|
+
end
|
64
68
|
end
|
65
69
|
end
|
66
70
|
|
data/spec/lunetas/candy_spec.rb
CHANGED
@@ -73,6 +73,14 @@ describe Lunetas::Candy do
|
|
73
73
|
@instance.bite[1]["Content-Type"].should == "text/plain"
|
74
74
|
end
|
75
75
|
|
76
|
+
it 'should be able to redirect' do
|
77
|
+
mock_env = mock_env('/just_a_test')
|
78
|
+
mock_env['REQUEST_METHOD'] = 'REDIRECT'
|
79
|
+
@instance = TestClass.new(mock_env, ['/just_a_test'])
|
80
|
+
@instance.bite[1].keys.should include('Location')
|
81
|
+
@instance.bite[1].values.should include('http://example.com')
|
82
|
+
end
|
83
|
+
|
76
84
|
%w{post put delete head trace options}.each do |verb|
|
77
85
|
it 'should call to the #{verb} method if called with #{verb.upcase}' do
|
78
86
|
mock_env = mock_env('/just_a_test')
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lunetas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Iv\xC3\xA1n Vald\xC3\xA9s (@ivanvc)"
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- VERSION
|
95
95
|
- examples/config.ru
|
96
96
|
- examples/jay_son.rb
|
97
|
+
- examples/redirect.rb
|
97
98
|
- examples/testing.rb
|
98
99
|
- lib/lunetas.rb
|
99
100
|
- lib/lunetas/bag.rb
|
@@ -146,4 +147,5 @@ test_files:
|
|
146
147
|
- spec/lunetas/candy_spec.rb
|
147
148
|
- spec/spec_helper.rb
|
148
149
|
- examples/jay_son.rb
|
150
|
+
- examples/redirect.rb
|
149
151
|
- examples/testing.rb
|