rackr 0.0.48 → 0.0.49

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rackr/action.rb +40 -35
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17ea0ba90cd0ee285862c06535ce35a2965a475e0e46994057c40af7631fd082
4
- data.tar.gz: 858b1c9b70af9a250ecf46cb7bc7020735bccf6d2c9da9948dc2b60038ce939d
3
+ metadata.gz: f92461b0ae4b6cab185bc30a250bc4155995b75509c66303abdf4cc1448770aa
4
+ data.tar.gz: d5e3ac4c8555803763a3dcb9b1db3f0d6659e5b5be63dc23624cab75b15d8bb5
5
5
  SHA512:
6
- metadata.gz: e3ac8005daa702a46140afeec59bb7cd2f339c6a12dce1468ca8e3c4b447b68ac00068b76807594365db54bc32a0d7ca219d42389098c0fac7d3b53346eb4856
7
- data.tar.gz: 57059e5130445514fc26f7972ed9c972835798e666a262372b2f5e1797e938ba01aa5a68649ebcff431afa149e2069b7646212eb6a4ba1a939e35e347b2aca2f
6
+ metadata.gz: 37a468ee044c2628c810e783735d19bef979ed8ddbe1b62c52e856f992a9cf731b4e25f0785eb2570f47438ab43f4ed1842011aa570b85a5d786f65f1b0cfe7e
7
+ data.tar.gz: 253aff88e9aa466796f7657477c1fef6fe43c2b743a8400e9fca31a66667144c52eca7a981b65fb07f58f4ff89e67ee79f569a6ac8f7ea535c774806d187152b
data/lib/rackr/action.rb CHANGED
@@ -16,11 +16,12 @@ class Rackr
16
16
  @db = config[:db]
17
17
  end
18
18
 
19
- def view_response(a_path, a_view_params = {}, status: 200)
19
+ def view_response(a_path, a_view_params = {}, status: 200, headers: {})
20
20
  Rackr::Action.view_response(
21
21
  a_path,
22
22
  a_view_params,
23
23
  status: status,
24
+ headers: headers,
24
25
  config: config,
25
26
  routes: routes,
26
27
  db: db
@@ -28,12 +29,13 @@ class Rackr
28
29
  end
29
30
 
30
31
  def view(
31
- a_path, a_view_params = {}, status: 200, response_instance: false
32
+ a_path, a_view_params = {}, status: 200, response_instance: false, headers: {}
32
33
  )
33
34
  Rackr::Action.view(
34
35
  a_path,
35
36
  a_view_params,
36
37
  status: status,
38
+ headers: headers,
37
39
  config: config,
38
40
  routes: routes,
39
41
  db: db,
@@ -47,40 +49,40 @@ class Rackr
47
49
  Rackr::Action.layout(layout_path, file_path)
48
50
  end
49
51
 
50
- def html(content, status: 200)
51
- Rackr::Action.html(content, status: status)
52
+ def html(content, status: 200, headers: {})
53
+ Rackr::Action.html(content, status: status, headers: headers)
52
54
  end
53
55
 
54
56
  def html_response(content, status: 200)
55
- Rackr::Action.html_response(content, status: status)
57
+ Rackr::Action.html_response(content, status: status, headers: headers)
56
58
  end
57
59
 
58
- def json(content = {}, status: 200)
59
- Rackr::Action.json(content, status: status)
60
+ def json(content = {}, status: 200, headers: {})
61
+ Rackr::Action.json(content, status: status, headers: headers)
60
62
  end
61
63
 
62
- def json_response(content = {}, status: 200)
63
- Rackr::Action.json_response(content, status: status)
64
+ def json_response(content = {}, status: 200, headers: {})
65
+ Rackr::Action.json_response(content, status: status, headers: headers)
64
66
  end
65
67
 
66
- def text(content, status: 200)
67
- Rackr::Action.text(content, status: status)
68
+ def text(content, status: 200, headers: {})
69
+ Rackr::Action.text(content, status: status, headers: headers)
68
70
  end
69
71
 
70
- def text_response(content, status: 200)
71
- Rackr::Action.text_response(content, status: status)
72
+ def text_response(content, status: 200, headers: {})
73
+ Rackr::Action.text_response(content, status: status, headers: headers)
72
74
  end
73
75
 
74
76
  def erb(content, view_params = {})
75
77
  Rackr::Action.erb(content, view_params)
76
78
  end
77
79
 
78
- def redirect_response(url)
79
- Rackr::Action.redirect_response(url)
80
+ def redirect_response(url, headers: {})
81
+ Rackr::Action.redirect_response(url, headers: headers, headers: headers)
80
82
  end
81
83
 
82
- def redirect_to(url)
83
- Rackr::Action.redirect_to(url)
84
+ def redirect_to(url, headers: {})
85
+ Rackr::Action.redirect_to(url, headers: headers, headers: headers)
84
86
  end
85
87
 
86
88
  def response(body = nil, status = 200, headers = {})
@@ -92,6 +94,7 @@ class Rackr
92
94
  paths,
93
95
  view_params = {},
94
96
  status: 200,
97
+ headers: {},
95
98
  config: {},
96
99
  routes: nil,
97
100
  db: nil
@@ -102,6 +105,7 @@ class Rackr
102
105
  status: status,
103
106
  config: config,
104
107
  routes: routes,
108
+ headers: headers,
105
109
  db: db,
106
110
  response_instance: true
107
111
  )
@@ -111,6 +115,7 @@ class Rackr
111
115
  paths,
112
116
  view_params = {},
113
117
  status: 200,
118
+ headers: {},
114
119
  config: {},
115
120
  routes: nil,
116
121
  db: nil,
@@ -146,11 +151,11 @@ class Rackr
146
151
  return Rack::Response.new(
147
152
  erb,
148
153
  status,
149
- { 'Content-Type' => 'text/html' }
154
+ { 'Content-Type' => 'text/html' }.merge(headers)
150
155
  )
151
156
  end
152
157
 
153
- [status, { 'Content-Type' => 'text/html' }, [erb]]
158
+ [status, { 'Content-Type' => 'text/html' }.merge(headers), [erb]]
154
159
  end
155
160
 
156
161
  def layout(layout_path, file_path)
@@ -161,35 +166,35 @@ class Rackr
161
166
  ]
162
167
  end
163
168
 
164
- def html(content, status: 200)
165
- [status, { 'Content-Type' => 'text/html' }, [content]]
169
+ def html(content, status: 200, headers: {})
170
+ [status, { 'Content-Type' => 'text/html' }.merge(headers), [content]]
166
171
  end
167
172
 
168
- def html_response(content, status: 200)
169
- Rack::Response.new(content, status, { 'Content-Type' => 'text/html' })
173
+ def html_response(content, status: 200, headers: {})
174
+ Rack::Response.new(content, status, { 'Content-Type' => 'text/html' }.merge(headers))
170
175
  end
171
176
 
172
- def json(content = {}, status: 200)
173
- [status, { 'Content-Type' => 'application/json' }, [Oj.dump(content, mode: :compat)]]
177
+ def json(content = {}, status: 200, headers: {})
178
+ [status, { 'Content-Type' => 'application/json' }.merge(headers), [Oj.dump(content, mode: :compat)]]
174
179
  end
175
180
 
176
- def json_response(content = {}, status: 200)
181
+ def json_response(content = {}, status: 200, headers: {})
177
182
  Rack::Response.new(
178
183
  Oj.dump(content, mode: :compat),
179
184
  status,
180
- { 'Content-Type' => 'application/json' }
185
+ { 'Content-Type' => 'application/json' }.merge(headers)
181
186
  )
182
187
  end
183
188
 
184
- def text(content, status: 200)
185
- [status, { 'Content-Type' => 'text/plain' }, [content]]
189
+ def text(content, status: 200, headers: {})
190
+ [status, { 'Content-Type' => 'text/plain' }.merge(headers), [content]]
186
191
  end
187
192
 
188
- def text_response(content, status: 200)
193
+ def text_response(content, status: 200, headers: {})
189
194
  Rack::Response.new(
190
195
  content,
191
196
  status,
192
- { 'Content-Type' => 'text/plain' }
197
+ { 'Content-Type' => 'text/plain' }.merge(headers)
193
198
  )
194
199
  end
195
200
 
@@ -201,16 +206,16 @@ class Rackr
201
206
  end
202
207
  # rubocop:enable Lint/UnusedMethodArgument
203
208
 
204
- def redirect_response(url)
209
+ def redirect_response(url, headers: {})
205
210
  Rack::Response.new(
206
211
  nil,
207
212
  302,
208
- { 'Location' => url }
213
+ { 'Location' => url }.merge(headers)
209
214
  )
210
215
  end
211
216
 
212
- def redirect_to(url)
213
- [302, { 'Location' => url }, []]
217
+ def redirect_to(url, headers: {})
218
+ [302, { 'Location' => url }.merge(headers), []]
214
219
  end
215
220
 
216
221
  def response(body = nil, status = 200, headers = {})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rackr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.48
4
+ version: 0.0.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrique F. Teixeira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-07 00:00:00.000000000 Z
11
+ date: 2024-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubi