landline 0.9.2 → 0.9.3
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 +4 -4
- data/README.md +1 -1
- data/lib/landline/dsl/constructors_probe.rb +8 -6
- data/lib/landline/dsl/methods_path.rb +3 -1
- data/lib/landline/template/erb.rb +2 -1
- data/lib/landline/template/erubi.rb +5 -7
- data/lib/landline/template.rb +7 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58106097aed53f3fb0edd51bf2d9ecf8ba9d976946ffd7e4570c7f1b5ecdafa7
|
4
|
+
data.tar.gz: 2b1a03b8a2afeb431a9afe0207a7f17a9ea5439372cccd2c7d2e02b50f544ff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9422f97e4310cea957b3c8ee6aed9ecc279bdffbb3e8578263a1f03316881d2833a3e3bdac42816a077702d3501d7c71027d6e7f5d72a8e1cf34ca4e114f66b8
|
7
|
+
data.tar.gz: ea8a961e1a6cbb755a8be74c75288932c736174fdef1a7c04c5ef5f6d5d3e0687f393ff5076a8435c1e6eb57978c4993f0152a38af5e5ec77c99adfdedfffe6c
|
data/README.md
CHANGED
@@ -142,7 +142,7 @@ For things to render correctly, please install the `redcarpet` gem.
|
|
142
142
|
|
143
143
|
```plain
|
144
144
|
Landline - an HTTP request pattern matching system
|
145
|
-
Copyright (C) 2022 yessiest (yessiest@
|
145
|
+
Copyright (C) 2022 yessiest (yessiest@text.512mb.org)
|
146
146
|
|
147
147
|
This program is free software: you can redistribute it and/or modify
|
148
148
|
it under the terms of the GNU General Public License as published by
|
@@ -8,8 +8,9 @@ module Landline
|
|
8
8
|
# @see {Landline::Template#new}
|
9
9
|
def erb(input, vars = {})
|
10
10
|
Landline::Templates::ERB.new(input,
|
11
|
-
|
12
|
-
|
11
|
+
vars,
|
12
|
+
parent: @origin,
|
13
|
+
filename: caller_locations[0].path)
|
13
14
|
end
|
14
15
|
|
15
16
|
# Create a new erb template using Erubi engine
|
@@ -18,10 +19,11 @@ module Landline
|
|
18
19
|
# @param capture [Boolean] whether to enable output capturing
|
19
20
|
def erubi(input, vars = {}, freeze: true, capture: false)
|
20
21
|
Landline::Templates::Erubi.new(input,
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
vars,
|
23
|
+
parent: @origin,
|
24
|
+
freeze: freeze,
|
25
|
+
capture: capture,
|
26
|
+
filename: caller_locations[0].path)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -8,7 +8,7 @@ module Landline
|
|
8
8
|
# ERB Template language adapter
|
9
9
|
class ERB < Landline::Template
|
10
10
|
# @see {Landline::Template#new}
|
11
|
-
def initialize(input, vars = nil, parent:)
|
11
|
+
def initialize(input, vars = nil, parent:, filename:)
|
12
12
|
super
|
13
13
|
varname = "_part_#{SecureRandom.hex(10)}".to_sym
|
14
14
|
while @binding.local_variable_defined? varname
|
@@ -20,6 +20,7 @@ module Landline
|
|
20
20
|
|
21
21
|
# Run the template.
|
22
22
|
def run
|
23
|
+
@template.filename = @filename
|
23
24
|
@template.result @binding
|
24
25
|
end
|
25
26
|
end
|
@@ -10,26 +10,24 @@ module Landline
|
|
10
10
|
# @see {Landline::Template#new}
|
11
11
|
def initialize(input,
|
12
12
|
vars = nil,
|
13
|
-
|
14
|
-
|
15
|
-
capture: false)
|
16
|
-
super(input, vars, parent: parent)
|
13
|
+
**ext)
|
14
|
+
super(input, vars, parent: ext[:parent], filename: ext[:filename])
|
17
15
|
varname = "_part_#{SecureRandom.hex(10)}"
|
18
16
|
while @binding.local_variable_defined? varname.to_sym
|
19
17
|
varname = "_part_#{SecureRandom.hex(10)}"
|
20
18
|
end
|
21
19
|
properties = {
|
22
|
-
filename: input.is_a?(File) ? input.path : "(Inline)",
|
23
20
|
bufvar: varname,
|
24
|
-
freeze: freeze
|
21
|
+
freeze: ext.fetch(:freeze, true)
|
25
22
|
}
|
23
|
+
capture = ext.fetch(:capture, false)
|
26
24
|
engine = capture ? ::Erubi::CaptureEndEngine : ::Erubi::Engine
|
27
25
|
@template = engine.new(@template, properties)
|
28
26
|
end
|
29
27
|
|
30
28
|
# Run the template.
|
31
29
|
def run
|
32
|
-
@binding.eval(@template.src)
|
30
|
+
@binding.eval(@template.src, @filename)
|
33
31
|
end
|
34
32
|
end
|
35
33
|
end
|
data/lib/landline/template.rb
CHANGED
@@ -36,8 +36,13 @@ module Landline
|
|
36
36
|
# @param input [String, File] template text
|
37
37
|
# @param vars [Hash] local variables for tempalte
|
38
38
|
# @param parent [Landline::Node] parent node
|
39
|
-
|
40
|
-
|
39
|
+
# @param filename [String] filename for eval if input is a string
|
40
|
+
def initialize(input, vars = {}, parent:, filename:)
|
41
|
+
@template, @filename = if input.is_a?(File)
|
42
|
+
[input.read, input.path]
|
43
|
+
else
|
44
|
+
[input, filename]
|
45
|
+
end
|
41
46
|
@context = TemplateContext.new(parent, self)
|
42
47
|
@parent = parent
|
43
48
|
input.close if input.is_a? File
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: landline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yessiest
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Landline is a no-hard-dependencies HTTP routing DSL that was made entirely for fun.
|
@@ -71,7 +71,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 3.0.6
|
75
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
77
|
- - ">="
|