lunetas 0.0.0 → 0.0.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/.gitignore +3 -0
- data/VERSION +1 -1
- data/examples/jay_son.rb +12 -0
- data/examples/testing.rb +5 -1
- data/lib/lunetas/candy.rb +9 -1
- data/spec/lunetas/candy_spec.rb +9 -0
- metadata +6 -4
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
data/examples/jay_son.rb
ADDED
data/examples/testing.rb
CHANGED
data/lib/lunetas/candy.rb
CHANGED
@@ -97,7 +97,7 @@ module Lunetas::Candy
|
|
97
97
|
# end
|
98
98
|
|
99
99
|
def response(object, code = 200)
|
100
|
-
[code, {'Content-Type' =>
|
100
|
+
[code, {'Content-Type' => self.class.content_type}, [object.to_s]]
|
101
101
|
end
|
102
102
|
|
103
103
|
# The following methods should be overwritten by the including class
|
@@ -140,6 +140,7 @@ module Lunetas::Candy
|
|
140
140
|
|
141
141
|
module ClassMethods
|
142
142
|
attr_reader :_url_params
|
143
|
+
attr_reader :content_type
|
143
144
|
|
144
145
|
# Support to be runned as a Rails Metal.
|
145
146
|
# @param [Hash] env the Rack env.
|
@@ -170,6 +171,7 @@ module Lunetas::Candy
|
|
170
171
|
# @param [Array<Symbol, String>] url_params the instance variables that will
|
171
172
|
# be set for the captures from the regex.
|
172
173
|
def matches(regex, *url_params)
|
174
|
+
@content_type = 'text/html'
|
173
175
|
@_regex = regex
|
174
176
|
unless Regexp === @_regex
|
175
177
|
@_regex = Regexp.new(@_regex)
|
@@ -177,6 +179,12 @@ module Lunetas::Candy
|
|
177
179
|
@_url_params = url_params
|
178
180
|
Lunetas::Bag.register(@_regex, self)
|
179
181
|
end
|
182
|
+
|
183
|
+
# Sets the Content Type for this URL. Defaults to text/html.
|
184
|
+
# @param [String] content_type the ContentType for the response.
|
185
|
+
def set_content_type(content_type)
|
186
|
+
@content_type = content_type
|
187
|
+
end
|
180
188
|
end
|
181
189
|
|
182
190
|
def self.included(receiver)
|
data/spec/lunetas/candy_spec.rb
CHANGED
@@ -59,6 +59,15 @@ describe Lunetas::Candy::InstanceMethods do
|
|
59
59
|
@instance.bite.last.should == ['Chunky Bacon']
|
60
60
|
end
|
61
61
|
|
62
|
+
it 'should have the default ContentType if not set' do
|
63
|
+
@instance.bite[1]["Content-Type"].should == "text/html"
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should set another ContentType' do
|
67
|
+
TestClass.send(:set_content_type, 'text/plain')
|
68
|
+
@instance.bite[1]["Content-Type"].should == "text/plain"
|
69
|
+
end
|
70
|
+
|
62
71
|
%w{post put delete head trace options}.each do |verb|
|
63
72
|
it 'should call to the #{verb} method if called with #{verb.upcase}' do
|
64
73
|
mock_env = mock_env('/just_a_test')
|
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: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Iv\xC3\xA1n Vald\xC3\xA9s (@ivanvc)"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-24 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- Rakefile
|
94
94
|
- VERSION
|
95
95
|
- examples/config.ru
|
96
|
+
- examples/jay_son.rb
|
96
97
|
- examples/testing.rb
|
97
98
|
- lib/lunetas.rb
|
98
99
|
- lib/lunetas/bag.rb
|
@@ -140,4 +141,5 @@ test_files:
|
|
140
141
|
- spec/lunetas/bag_spec.rb
|
141
142
|
- spec/lunetas/candy_spec.rb
|
142
143
|
- spec/spec_helper.rb
|
144
|
+
- examples/jay_son.rb
|
143
145
|
- examples/testing.rb
|