zorglub 0.1.5 → 0.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abcf28ed3f097126ca87285fb4e856139ea4cd3ee410d3ff294604d5becca95f
4
- data.tar.gz: ecd7ad7f09153e4e847652f448284d559404f6c5682bfd15fcc05a72fe9ffb72
3
+ metadata.gz: 88366b3d9072148ff02475d0c49f01308b4c5b93e44c9c144132d967148fd876
4
+ data.tar.gz: 86e1a4e383f65d05fa80a871e7246b089bc70708475e6123eaadfd0aa82ec26c
5
5
  SHA512:
6
- metadata.gz: eb190cc7abd3bf94341d807491b8432c323674e49ed9d52bf151b926ec8f31efd6f61f9c27bfab17e6d1e27f3f4f6d0c1b63e7263340d5dab9edda97c98ad8e2
7
- data.tar.gz: 52e826f544530e6cdadb65b53fda7ec771ed72621a51a72565507515b931da49b3ac5b1c1af93d35c93596db0b0d00be10cf51054acd935a6be1949c35536a27
6
+ metadata.gz: 2266d5149353d7d1351b944f5f20df05f60425926090cfcb44136f2fa8eb7849317c47c920620654f61e410d17611305f20eaa6aa700ef738a36a9c300b0a3eb
7
+ data.tar.gz: 725d026f3eccc26579d1455de735762e4baef7ba172b1e3caf7611e36a941fb005343b2f09a9b638660e2d20c9907046e9080cbbedff12aefc809043572611ad
data/Changelog CHANGED
@@ -1,3 +1,8 @@
1
+ 2024-08-20 Jérémy Zurcher <jeremy@asynk.ch>
2
+ * release 0.1.6
3
+ * fix specs
4
+ * fix Node#error404
5
+
1
6
  2024-08-14 Jérémy Zurcher <jeremy@asynk.ch>
2
7
  * release 0.1.5
3
8
  * fix Node#redirect
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zorglub (0.1.5)
4
+ zorglub (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/lib/zorglub/node.rb CHANGED
@@ -154,7 +154,7 @@ module Zorglub
154
154
  status = options[:status] || 302
155
155
  body = options[:body] || redirect_body(target)
156
156
  header = response.headers.merge('Location' => target.to_s)
157
- throw :stop_realize, Rack::Response.new(body, status, header, &block).finish
157
+ throw :stop_realize, Rack::Response.new(body, status, header, &block)
158
158
  end
159
159
 
160
160
  def redirect_body(target)
@@ -250,7 +250,7 @@ module Zorglub
250
250
  resp.status = 404
251
251
  resp['content-type'] = 'text/plain'
252
252
  resp.write "%<node.class.name>s mapped at %<node.map>p can't respond to : %<node.meth>p"
253
- resp
253
+ resp.finish
254
254
  end
255
255
  end
256
256
 
@@ -277,8 +277,8 @@ module Zorglub
277
277
  feed!
278
278
  response.write @content
279
279
  response.headers['content-type'] ||= @mime || 'text/html'
280
- response.finish
281
- end
280
+ response
281
+ end.finish
282
282
  end
283
283
 
284
284
  def feed!(no_hooks = false)
data/lib/zorglub.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
3
  module Zorglub
4
- VERSION = '0.1.5'.freeze
4
+ VERSION = '0.1.6'.freeze
5
5
  end
6
6
 
7
7
  require 'zorglub/node'
data/spec/node_spec.rb CHANGED
@@ -49,25 +49,25 @@ describe Zorglub do
49
49
 
50
50
  it 'instance level map should work' do
51
51
  r = Node0.my_call '/with_2args/1/2'
52
- h = YAML.load r.body[0]
52
+ h = YAML.load r[2][0]
53
53
  expect(h[:map]).to eq '/node0'
54
54
  end
55
55
 
56
56
  it 'should return err404 response when no method found' do
57
57
  expect(Node0.respond_to?('noresponse')).to be_falsey
58
58
  r = Node0.my_call '/noresponse'
59
- expect(r.status).to eq 404
59
+ expect(r[0]).to eq 404
60
60
  end
61
61
 
62
62
  it 'simple method should respond' do
63
63
  r = Node0.my_call '/hello'
64
- expect(r.status).to eq 200
65
- expect(r.body[0]).to eq 'world'
64
+ expect(r[0]).to eq 200
65
+ expect(r[2][0]).to eq 'world'
66
66
  end
67
67
 
68
68
  it 'instance level args should work' do
69
69
  r = Node0.my_call '/with_2args/1/2'
70
- h = YAML.load r.body[0]
70
+ h = YAML.load r[2][0]
71
71
  expect(h[:args][0]).to eq '1'
72
72
  expect(h[:args][1]).to eq '2'
73
73
  end
@@ -78,8 +78,8 @@ describe Zorglub do
78
78
 
79
79
  it 'layout proc, method level layout and engine definitions should work' do
80
80
  r = Node0.my_call '/index'
81
- expect(r.status).to eq 200
82
- h = YAML.load r.body[0]
81
+ expect(r[0]).to eq 200
82
+ h = YAML.load r[2][0]
83
83
  ly = File.join Node0.app.layout_base_path, Node0.layout
84
84
  vu = File.join Node0.app.view_base_path, Node0.r, 'index'
85
85
  expect(h[:path]).to eq ly
@@ -89,8 +89,8 @@ describe Zorglub do
89
89
 
90
90
  it 'layout proc, method level layout and engine definitions should work' do
91
91
  r = Node1.my_call '/index'
92
- expect(r.status).to eq 200
93
- h = YAML.load r.body[0]
92
+ expect(r[0]).to eq 200
93
+ h = YAML.load r[2][0]
94
94
  ly = File.join Node1.app.layout_base_path, 'main.spec'
95
95
  vu = File.join Node1.app.view_base_path, Node1.r, 'index.spec'
96
96
  expect(h[:path]).to eq ly
@@ -148,23 +148,23 @@ describe Zorglub do
148
148
 
149
149
  it 'should find view and layout and render them' do
150
150
  r = Node0.my_call '/do_render'
151
- expect(r.status).to eq 200
152
- expect(r.body[0]).to eq 'layout_start view_content layout_end'
151
+ expect(r[0]).to eq 200
152
+ expect(r[2][0]).to eq 'layout_start view_content layout_end'
153
153
  end
154
154
 
155
155
  it 'default mime-type should be text/html' do
156
156
  r = Node0.my_call '/index'
157
- expect(r.headers['Content-type']).to eq 'text/html'
157
+ expect(r[1]['Content-type']).to eq 'text/html'
158
158
  end
159
159
 
160
160
  it 'should be able to override mime-type' do
161
161
  r = Node0.my_call '/do_render'
162
- expect(r.headers['Content-type']).to eq 'text/view'
162
+ expect(r[1]['Content-type']).to eq 'text/view'
163
163
  end
164
164
 
165
165
  it 'should be able to override through rack response mime-type' do
166
166
  r = Node0.my_call '/do_content_type'
167
- expect(r.headers['Content-type']).to eq 'text/mine'
167
+ expect(r[1]['Content-type']).to eq 'text/mine'
168
168
  end
169
169
 
170
170
  it 'partial should render correctly' do
@@ -193,31 +193,31 @@ describe Zorglub do
193
193
 
194
194
  it 'static pages should be generated' do
195
195
  r = Node6.my_call '/do_static'
196
- expect(r.body[0]).to eq 'VAL 1'
197
- expect(r.headers['Content-type']).to eq 'text/static'
196
+ expect(r[2][0]).to eq 'VAL 1'
197
+ expect(r[1]['Content-type']).to eq 'text/static'
198
198
  r = Node6.my_call '/do_static'
199
- expect(r.body[0]).to eq 'VAL 1'
200
- expect(r.headers['Content-type']).to eq 'text/static'
199
+ expect(r[2][0]).to eq 'VAL 1'
200
+ expect(r[1]['Content-type']).to eq 'text/static'
201
201
  r = Node6.my_call '/do_static'
202
- expect(r.body[0]).to eq 'VAL 1'
203
- expect(r.headers['Content-type']).to eq 'text/static'
202
+ expect(r[2][0]).to eq 'VAL 1'
203
+ expect(r[1]['Content-type']).to eq 'text/static'
204
204
  r = Node6.my_call '/no_static'
205
- expect(r.body[0]).to eq 'VAL 4'
206
- expect(r.headers['Content-type']).to eq 'text/static'
205
+ expect(r[2][0]).to eq 'VAL 4'
206
+ expect(r[1]['Content-type']).to eq 'text/static'
207
207
  r = Node6.my_call '/do_static'
208
- expect(r.body[0]).to eq 'VAL 1'
209
- expect(r.headers['Content-type']).to eq 'text/static'
208
+ expect(r[2][0]).to eq 'VAL 1'
209
+ expect(r[1]['Content-type']).to eq 'text/static'
210
210
  Node6.static! true, 0.000001
211
211
  sleep 0.0001
212
212
  r = Node6.my_call '/do_static'
213
- expect(r.body[0]).to eq 'VAL 6'
214
- expect(r.headers['Content-type']).to eq 'text/static'
213
+ expect(r[2][0]).to eq 'VAL 6'
214
+ expect(r[1]['Content-type']).to eq 'text/static'
215
215
  end
216
216
 
217
217
  it 'redirect should work' do
218
218
  r = Node0.my_call '/do_redirect'
219
- expect(r.status).to eq 302
220
- expect(r.headers['location']).to eq Node0.r(:do_partial, 1, 2, 3)
219
+ expect(r[0]).to eq 302
220
+ expect(r[1]['location']).to eq Node0.r(:do_partial, 1, 2, 3)
221
221
  end
222
222
 
223
223
  it 'no_layout! should be inherited' do
@@ -226,70 +226,70 @@ describe Zorglub do
226
226
 
227
227
  it 'cli_vals should be inherited and extended' do
228
228
  r = Node5.my_call '/index'
229
- vars = YAML.load r.body[0]
229
+ vars = YAML.load r[2][0]
230
230
  expect(vars).to eq %w[js0 js1 js3 jsx css0 css1 css2]
231
231
  expect(vars[7]).to be_nil
232
232
  end
233
233
 
234
234
  it 'cli_vals should be extended at method level' do
235
235
  r = Node4.my_call '/more'
236
- vars = YAML.load r.body[0]
236
+ vars = YAML.load r[2][0]
237
237
  expect(vars).to eq %w[js0 js1 js2]
238
238
  expect(vars[3]).to be_nil
239
239
  end
240
240
 
241
241
  it 'cli_vals should be untouched' do
242
242
  r = Node4.my_call '/index'
243
- vars = YAML.load r.body[0]
243
+ vars = YAML.load r[2][0]
244
244
  expect(vars).to eq %w[js0 js1]
245
245
  expect(vars[2]).to be_nil
246
246
  r = Node5.my_call '/index'
247
- vars = YAML.load r.body[0]
247
+ vars = YAML.load r[2][0]
248
248
  expect(vars).to eq %w[js0 js1 js3 jsx css0 css1 css2]
249
249
  expect(vars[7]).to be_nil
250
250
  end
251
251
 
252
252
  it 'ext definition and file engine should work' do
253
253
  r = Node0.my_call '/xml_file'
254
- expect(r.body[0]).to eq "<xml>file<\/xml>\n"
255
- expect(r.headers['Content-type']).to eq 'application/xml'
254
+ expect(r[2][0]).to eq "<xml>file<\/xml>\n"
255
+ expect(r[1]['Content-type']).to eq 'application/xml'
256
256
  r = Node0.my_call '/plain_file'
257
- expect(r.body[0]).to eq "plain file\n"
258
- expect(r.headers['Content-type']).to eq 'text/plain'
257
+ expect(r[2][0]).to eq "plain file\n"
258
+ expect(r[1]['Content-type']).to eq 'text/plain'
259
259
  end
260
260
 
261
261
  it 'no view no layout should work as well' do
262
262
  r = Node0.my_call '/no_view_no_layout'
263
- expect(r.body[0]).to eq 'hello world'
263
+ expect(r[2][0]).to eq 'hello world'
264
264
  end
265
265
 
266
266
  it 'haml engine should work' do
267
267
  Node0.app.opt! :engines_cache_enabled, false
268
268
  r = Node0.my_call '/engines/haml'
269
- expect(r.body[0]).to eq "<h1>Hello <i>world</i></h1>\n"
269
+ expect(r[2][0]).to eq "<h1>Hello <i>world</i></h1>\n"
270
270
  Node0.app.opt! :engines_cache_enabled, true
271
271
  r = Node0.my_call '/engines/haml'
272
- expect(r.body[0]).to eq "<h1>Hello <i>world</i></h1>\n"
272
+ expect(r[2][0]).to eq "<h1>Hello <i>world</i></h1>\n"
273
273
  end
274
274
 
275
275
  it 'sass engine should work' do
276
276
  Node0.app.opt! :engines_cache_enabled, true
277
277
  r = Node0.my_call '/engines/sass'
278
- expect(r.body[0]).to eq "vbar{width:80%;height:23px}vbar ul{list-style-type:none}vbar li{float:left}vbar li a{font-weight:bold}\n"
278
+ expect(r[2][0]).to eq "vbar{width:80%;height:23px}vbar ul{list-style-type:none}vbar li{float:left}vbar li a{font-weight:bold}\n"
279
279
  Node0.app.opt! :engines_cache_enabled, false
280
280
  r = Node0.my_call '/engines/sass'
281
- expect(r.body[0]).to eq "vbar{width:80%;height:23px}vbar ul{list-style-type:none}vbar li{float:left}vbar li a{font-weight:bold}\n"
281
+ expect(r[2][0]).to eq "vbar{width:80%;height:23px}vbar ul{list-style-type:none}vbar li{float:left}vbar li a{font-weight:bold}\n"
282
282
  end
283
283
 
284
284
  it 'view_base_path! should work' do
285
285
  r = Node7.my_call '/view_path'
286
- h = YAML.load r.body[0]
286
+ h = YAML.load r[2][0]
287
287
  expect(h[:view]).to eq File.join(Node7.app.opt(:root), 'alt', 'do_render')
288
288
  end
289
289
 
290
290
  it 'layout_base_path! should work' do
291
291
  r = Node7.my_call '/view_path'
292
- h = YAML.load r.body[0]
292
+ h = YAML.load r[2][0]
293
293
  expect(h[:layout]).to eq File.join(Node7.app.opt(:root), 'alt', 'layout', 'default')
294
294
  end
295
295
 
data/spec/spec_helper.rb CHANGED
@@ -46,7 +46,7 @@ class Zorglub::Node
46
46
  end
47
47
 
48
48
  def self.my_call_i(uri)
49
- call({ 'PATH_INFO' => uri }).body[0].to_i
49
+ call({ 'PATH_INFO' => uri })[2][0].to_i
50
50
  end
51
51
  end
52
52
 
data/zorglub.gemspec CHANGED
@@ -1,26 +1,23 @@
1
1
  #! /usr/bin/env ruby
2
- # -*- coding: UTF-8 -*-
3
2
 
4
- $:.push File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.push File.expand_path("../lib", __FILE__)
5
4
 
6
5
  begin
7
- require 'zorglub'
6
+ require 'zorglub'
8
7
  rescue LoadError
9
8
  end
10
9
 
11
10
  Gem::Specification.new do |s|
12
- s.name = "zorglub"
13
- s.version = Zorglub::VERSION
14
- s.authors = ["Jérémy Zurcher"]
15
- s.email = ["jeremy@asynk.ch"]
16
- s.homepage = "http://github.com/jeremyz/zorglub"
17
- s.summary = %q{a nano web application framework based on rack }
18
- s.description = %q{This is a very stripped down version of innate.}
11
+ s.name = 'zorglub'
12
+ s.version = Zorglub::VERSION
13
+ s.authors = ['Jérémy Zurcher']
14
+ s.email = ['jeremy@asynk.ch']
15
+ s.homepage = 'http://github.com/jeremyz/zorglub'
16
+ s.summary = %s(a rack based nano web application framework)
17
+ s.description = %s(A very stripped down version of innate.)
19
18
 
20
- s.files = `git ls-files`.split("\n")
21
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
- s.require_paths = ["lib"]
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
22
+ s.require_paths = ['lib']
24
23
  end
25
-
26
- # EOF
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zorglub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jérémy Zurcher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-14 00:00:00.000000000 Z
11
+ date: 2024-08-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: This is a very stripped down version of innate.
13
+ description: A very stripped down version of innate.
14
14
  email:
15
15
  - jeremy@asynk.ch
16
16
  executables: []
@@ -77,7 +77,7 @@ requirements: []
77
77
  rubygems_version: 3.4.19
78
78
  signing_key:
79
79
  specification_version: 4
80
- summary: a nano web application framework based on rack
80
+ summary: a rack based nano web application framework
81
81
  test_files:
82
82
  - spec/app_spec.rb
83
83
  - spec/data/alt/do_render