zorglub 0.1.6 → 0.1.8

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: 88366b3d9072148ff02475d0c49f01308b4c5b93e44c9c144132d967148fd876
4
- data.tar.gz: 86e1a4e383f65d05fa80a871e7246b089bc70708475e6123eaadfd0aa82ec26c
3
+ metadata.gz: 8d89d17dda2afc40f6e680136dcf4562b2dd5bc04660b7b5287ddde1cf92a7dd
4
+ data.tar.gz: b18816ab21c0a4635a1e3c0584d7ecc0bba355789304c57d15798b883a729ff1
5
5
  SHA512:
6
- metadata.gz: 2266d5149353d7d1351b944f5f20df05f60425926090cfcb44136f2fa8eb7849317c47c920620654f61e410d17611305f20eaa6aa700ef738a36a9c300b0a3eb
7
- data.tar.gz: 725d026f3eccc26579d1455de735762e4baef7ba172b1e3caf7611e36a941fb005343b2f09a9b638660e2d20c9907046e9080cbbedff12aefc809043572611ad
6
+ metadata.gz: 23185e5cb71d2de61692d6a0345f36cc9f4e825405fe995b1750f1ea376adb39cc946039e30058bd30889bb91d6263d0618c0dff622955aa88b616dcaa4cde09
7
+ data.tar.gz: 31a2709c3daca4485320edd49d288109edaab0b0c5690d1d73511904293990aeae86db871991a0fb81f39d47acf56c5a33e983984b1a472ef8289d192c63bb66
data/Changelog CHANGED
@@ -1,3 +1,11 @@
1
+ 2024-10-01 Jérémy Zurcher <jeremy@asynk.ch>
2
+ * release 0.1.7
3
+ * debug to stdout
4
+ * simplify static code path
5
+ * fix error404 msg
6
+ * use keyword arguments
7
+
8
+
1
9
  2024-08-20 Jérémy Zurcher <jeremy@asynk.ch>
2
10
  * release 0.1.6
3
11
  * fix specs
data/Gemfile.lock CHANGED
@@ -1,41 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zorglub (0.1.6)
4
+ zorglub (0.1.8)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- bigdecimal (3.1.8)
9
+ bigdecimal (3.1.9)
10
10
  coveralls (0.8.23)
11
11
  json (>= 1.8, < 3)
12
12
  simplecov (~> 0.16.1)
13
13
  term-ansicolor (~> 1.3)
14
14
  thor (>= 0.19.4, < 2.0)
15
15
  tins (~> 1.6)
16
- diff-lcs (1.5.1)
16
+ diff-lcs (1.6.1)
17
17
  docile (1.4.1)
18
- ffi (1.17.0)
18
+ ffi (1.17.1)
19
19
  haml (6.3.0)
20
20
  temple (>= 0.8.2)
21
21
  thor
22
22
  tilt
23
- json (2.7.2)
24
- rack (3.1.7)
23
+ json (2.10.2)
24
+ rack (3.1.12)
25
25
  rake (13.2.1)
26
26
  rspec (3.13.0)
27
27
  rspec-core (~> 3.13.0)
28
28
  rspec-expectations (~> 3.13.0)
29
29
  rspec-mocks (~> 3.13.0)
30
- rspec-core (3.13.0)
30
+ rspec-core (3.13.3)
31
31
  rspec-support (~> 3.13.0)
32
- rspec-expectations (3.13.1)
32
+ rspec-expectations (3.13.3)
33
33
  diff-lcs (>= 1.2.0, < 2.0)
34
34
  rspec-support (~> 3.13.0)
35
- rspec-mocks (3.13.1)
35
+ rspec-mocks (3.13.2)
36
36
  diff-lcs (>= 1.2.0, < 2.0)
37
37
  rspec-support (~> 3.13.0)
38
- rspec-support (3.13.1)
38
+ rspec-support (3.13.2)
39
39
  sassc (2.4.0)
40
40
  ffi (~> 1.9)
41
41
  simplecov (0.16.1)
@@ -47,9 +47,9 @@ GEM
47
47
  temple (0.10.3)
48
48
  term-ansicolor (1.11.2)
49
49
  tins (~> 1.0)
50
- thor (1.3.1)
51
- tilt (2.4.0)
52
- tins (1.33.0)
50
+ thor (1.3.2)
51
+ tilt (2.6.0)
52
+ tins (1.38.0)
53
53
  bigdecimal
54
54
  sync
55
55
 
@@ -66,4 +66,4 @@ DEPENDENCIES
66
66
  zorglub!
67
67
 
68
68
  BUNDLED WITH
69
- 2.5.17
69
+ 2.6.7
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
- $stderr << "=> #{meth}(#{args.join ','})\n" if app.opt :debug
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 env, meth.to_s, args, true
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
- $stderr << " !! #{node.class.name}::#{meth} not found\n" if app.opt :debug
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 "%<node.class.name>s mapped at %<node.map>p can't respond to : %<node.meth>p"
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 = false)
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 = false)
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
- $stderr << " * use cache file : #{path}\n" if @debug
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
- $stderr << " * cache file created : #{path}\n" if @debug
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
- $stderr << " * #{e ? 'use engine' : 'no engine '} : #{e ? e.to_s : ''}\n"
322
- $stderr << " * #{l && File.exist?(l) ? 'use layout' : 'no layout '} : #{l || ''}\n"
323
- $stderr << " * #{v && File.exist?(v) ? 'use view ' : 'no view '} : #{v || ''}\n"
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
@@ -1,7 +1,7 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
3
  module Zorglub
4
- VERSION = '0.1.6'.freeze
4
+ VERSION = '0.1.8'.freeze
5
5
  end
6
6
 
7
7
  require 'zorglub/node'
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
- stderr0 = $stderr.dup
298
- stderrs = StringIO.new
299
- $stderr = stderrs
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
- $stderr = stderr0
305
+ $stdout = stdout0
305
306
  end
306
- expect(stderrs.string.include?('spec/data/view/node0/hello')).to be true
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.6
4
+ version: 0.1.8
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-20 00:00:00.000000000 Z
11
+ date: 2025-04-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A very stripped down version of innate.
14
14
  email:
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 3.4.19
77
+ rubygems_version: 3.5.22
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: a rack based nano web application framework