zorglub 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog +8 -0
- data/Gemfile.lock +1 -1
- data/lib/zorglub/node.rb +15 -16
- data/lib/zorglub.rb +1 -1
- data/spec/node_spec.rb +6 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be6b53fccd29ce596c15253af31b7c4b7470e1a55075aa34cd541edd54144f57
|
4
|
+
data.tar.gz: cda16f4674a73d6ce3659db5e5cf7f51eea5fe0779324990b406046a341b6a04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10c3739c48de2eed8c53c32d703f198ec5fc4a752ce32a36de12c5964664d057ad04f81eeb6ce95b16bd4ae0236e4cd4f02d00c27327372a4479078b1c822e28
|
7
|
+
data.tar.gz: 109e27aa1526edff83bd67681f61aced077b2f55a23e13d3b3aaa8ec0962ccf61a8218e0f6f0bcd405cd4c3680e3e370e515ce46718b7d758f86f0322fc1e0bc
|
data/Changelog
CHANGED
data/Gemfile.lock
CHANGED
data/lib/zorglub/node.rb
CHANGED
@@ -229,7 +229,7 @@ module Zorglub
|
|
229
229
|
def call(env)
|
230
230
|
meth, *args = env['PATH_INFO'].sub(%r{^/+}, '').split(%r{/})
|
231
231
|
meth ||= 'index'
|
232
|
-
$
|
232
|
+
$stdout << "=> #{meth}(#{args.join ','})\n" if app.opt :debug
|
233
233
|
node = new(env, meth, args)
|
234
234
|
return error404 node, meth unless node.respond_to? meth
|
235
235
|
|
@@ -237,26 +237,26 @@ module Zorglub
|
|
237
237
|
end
|
238
238
|
|
239
239
|
def partial(env, meth, *args)
|
240
|
-
node = new
|
240
|
+
node = new(env, meth.to_s, args, partial: true)
|
241
241
|
return error404 node, meth unless node.respond_to? meth
|
242
242
|
|
243
|
-
node.feed! env[:no_hooks]
|
243
|
+
node.feed!(no_hooks: env[:no_hooks])
|
244
244
|
node.content
|
245
245
|
end
|
246
246
|
|
247
247
|
def error404(node, meth)
|
248
|
-
$
|
248
|
+
$stdout << " !! #{node.class.name}::#{meth} not found\n" if app.opt :debug
|
249
249
|
resp = node.response
|
250
250
|
resp.status = 404
|
251
251
|
resp['content-type'] = 'text/plain'
|
252
|
-
resp.write "
|
252
|
+
resp.write "#{node.class.name} mapped at #{node.map} can't respond to : #{node.meth}"
|
253
253
|
resp.finish
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
257
|
attr_reader :request, :response, :content, :mime, :state, :engine, :meth, :args
|
258
258
|
|
259
|
-
def initialize(env, meth, args, partial
|
259
|
+
def initialize(env, meth, args, partial: false)
|
260
260
|
@meth = meth
|
261
261
|
@args = args
|
262
262
|
@partial = partial
|
@@ -281,16 +281,15 @@ module Zorglub
|
|
281
281
|
end.finish
|
282
282
|
end
|
283
283
|
|
284
|
-
def feed!(no_hooks
|
284
|
+
def feed!(no_hooks: false)
|
285
285
|
@state = :pre_cb
|
286
286
|
self.class.call_before_hooks self unless no_hooks
|
287
287
|
@state = :meth
|
288
288
|
@content = send @meth, *@args
|
289
|
-
static_path = static
|
290
|
-
if static_path.nil?
|
291
|
-
compile_page!
|
292
|
-
else
|
289
|
+
if (static_path = static)
|
293
290
|
static_page! static_path
|
291
|
+
else
|
292
|
+
compile_page!
|
294
293
|
end
|
295
294
|
@state = :post_cb
|
296
295
|
self.class.call_after_hooks self unless no_hooks
|
@@ -301,7 +300,7 @@ module Zorglub
|
|
301
300
|
def static_page!(path)
|
302
301
|
if File.exist?(path) && (@cache_lifetime.nil? || @cache_lifetime.zero? ||
|
303
302
|
(Time.now - File.stat(path).mtime) < @cache_lifetime)
|
304
|
-
$
|
303
|
+
$stdout << " * use cache file : #{path}\n" if @debug
|
305
304
|
content = File.read(path)
|
306
305
|
@content = content.sub(/^@mime:(.*)\n/, '')
|
307
306
|
@mime = ::Regexp.last_match(1)
|
@@ -309,7 +308,7 @@ module Zorglub
|
|
309
308
|
compile_page!
|
310
309
|
FileUtils.mkdir_p File.dirname(path)
|
311
310
|
File.open(path, 'w') { |f| f.write("@mime:#{@mime}\n#{@content}") }
|
312
|
-
$
|
311
|
+
$stdout << " * cache file created : #{path}\n" if @debug
|
313
312
|
end
|
314
313
|
end
|
315
314
|
|
@@ -318,9 +317,9 @@ module Zorglub
|
|
318
317
|
v = view
|
319
318
|
l = layout
|
320
319
|
if @debug
|
321
|
-
$
|
322
|
-
$
|
323
|
-
$
|
320
|
+
$stdout << " * #{e ? 'use engine' : 'no engine '} : #{e ? e.to_s : ''}\n"
|
321
|
+
$stdout << " * #{l && File.exist?(l) ? 'use layout' : 'no layout '} : #{l || ''}\n"
|
322
|
+
$stdout << " * #{v && File.exist?(v) ? 'use view ' : 'no view '} : #{v || ''}\n"
|
324
323
|
end
|
325
324
|
@state = @partial ? :partial : :view
|
326
325
|
@content, mime = e.call(v, self) if e && v && File.exist?(v)
|
data/lib/zorglub.rb
CHANGED
data/spec/node_spec.rb
CHANGED
@@ -56,6 +56,7 @@ describe Zorglub do
|
|
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[2][0]).to eq "Node0 mapped at /node0 can't respond to : noresponse"
|
59
60
|
expect(r[0]).to eq 404
|
60
61
|
end
|
61
62
|
|
@@ -294,16 +295,16 @@ describe Zorglub do
|
|
294
295
|
end
|
295
296
|
|
296
297
|
it 'debug out should work' do
|
297
|
-
|
298
|
-
|
299
|
-
$
|
298
|
+
stdout0 = $stdout.dup
|
299
|
+
stdouts = StringIO.new
|
300
|
+
$stdout = stdouts
|
300
301
|
begin
|
301
302
|
APP.opt! :debug, true
|
302
303
|
Node0.my_call '/hello'
|
303
304
|
ensure
|
304
|
-
$
|
305
|
+
$stdout = stdout0
|
305
306
|
end
|
306
|
-
expect(
|
307
|
+
expect(stdouts.string.include?('spec/data/view/node0/hello')).to be true
|
307
308
|
end
|
308
309
|
end
|
309
310
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zorglub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
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-
|
11
|
+
date: 2024-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A very stripped down version of innate.
|
14
14
|
email:
|