tina4ruby 0.4.0 → 0.5.1

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: 21e81c7d2b4f653ae64aa9a56e45534a48432c9914ef70b7e41d11d41ac83a40
4
- data.tar.gz: 38a0c3ea03aafc8593bdb49a217026592017816ecef416fac96e352e1f0899f6
3
+ metadata.gz: 6990765547b19aefdc010ea9e3ce13a00255166ff5eba52963422a2d5e493ff4
4
+ data.tar.gz: 33f2417c218fe03148b96c9e7f0a63e8e69f2dd1c9046aee0a9c1fd64e9c93cf
5
5
  SHA512:
6
- metadata.gz: c4ff78f4cfddafab5cd3dedf8393e1ed3f25b973cf22113ebd73c780b0b10fc04a84991c9a6b98b3cac2533d372be2c80f4f93cb8cec006e0394e1e1758e70dc
7
- data.tar.gz: c3d340186e084c3166266af6c7a5155e837dc69f27bd7ebb85f9d4e70c3e428e1b71691e7a788f3f347deafaedb4f3a4c995b55ae55764f39912b04623c18da6
6
+ metadata.gz: 6a100277f5e4ab408ac2a8a536fd5e59f3611276623cb0af76599e05eb3a0f872a6ee5f420558d10bff41dac913f07df91e11812df33bb781fcc23f79595462b
7
+ data.tar.gz: 4f8e0599f8985544ebad7ab96e867a616aef01b56c3d52b7d167a7a042ec9626efac25eced5c03e94908bda9325b9e54148297fd4df4fc5c690fb268cf259490
@@ -125,8 +125,8 @@ module Tina4
125
125
  end
126
126
 
127
127
  def serve_openapi_json
128
- spec = Tina4::Swagger.generate
129
- [200, { "content-type" => "application/json; charset=utf-8" }, [JSON.generate(spec)]]
128
+ @openapi_json ||= JSON.generate(Tina4::Swagger.generate)
129
+ [200, { "content-type" => "application/json; charset=utf-8" }, [@openapi_json]]
130
130
  end
131
131
 
132
132
  def handle_403
@@ -125,9 +125,11 @@ module Tina4
125
125
  content
126
126
  end
127
127
 
128
+ HTML_ESCAPE = { "&" => "&amp;", "<" => "&lt;", ">" => "&gt;", '"' => "&quot;", "'" => "&#39;" }.freeze
129
+ HTML_ESCAPE_PATTERN = /[&<>"']/
130
+
128
131
  def self.escape_html(str)
129
- str.gsub("&", "&amp;").gsub("<", "&lt;").gsub(">", "&gt;")
130
- .gsub('"', "&quot;").gsub("'", "&#39;")
132
+ str.gsub(HTML_ESCAPE_PATTERN, HTML_ESCAPE)
131
133
  end
132
134
 
133
135
  def self.format_date(value, fmt)
@@ -186,7 +188,7 @@ module Tina4
186
188
  collection_expr = Regexp.last_match(3)
187
189
  body = Regexp.last_match(4)
188
190
  collection = evaluate_expression(collection_expr)
189
- output = ""
191
+ output = +""
190
192
  items = case collection
191
193
  when Array then collection
192
194
  when Hash then collection.to_a
@@ -210,7 +212,7 @@ module Tina4
210
212
  loop_context[key_or_val] = item
211
213
  end
212
214
  sub_engine = TwigEngine.new(loop_context, @base_dir)
213
- output += sub_engine.render(body)
215
+ output << sub_engine.render(body)
214
216
  end
215
217
  output
216
218
  end
@@ -292,24 +294,24 @@ module Tina4
292
294
 
293
295
  def parse_filter_args(args_str)
294
296
  args = []
295
- current = ""
297
+ current = +""
296
298
  in_quote = nil
297
299
  args_str.each_char do |ch|
298
300
  if in_quote
299
301
  if ch == in_quote
300
- current += ch
302
+ current << ch
301
303
  in_quote = nil
302
304
  else
303
- current += ch
305
+ current << ch
304
306
  end
305
307
  elsif ch == '"' || ch == "'"
306
308
  in_quote = ch
307
- current += ch
309
+ current << ch
308
310
  elsif ch == ","
309
311
  args << current.strip
310
- current = ""
312
+ current = +""
311
313
  else
312
- current += ch
314
+ current << ch
313
315
  end
314
316
  end
315
317
  args << current.strip unless current.strip.empty?
data/lib/tina4/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tina4
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.1"
5
5
  end
data/lib/tina4.rb CHANGED
@@ -1,5 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # ── Fast JSON: use oj if available, fall back to stdlib json ──────────
4
+ begin
5
+ require "oj"
6
+ Oj.default_options = { mode: :compat, symbol_keys: false }
7
+ rescue LoadError
8
+ # oj not installed — stdlib json is fine
9
+ end
10
+
3
11
  # ── Core (always loaded) ──────────────────────────────────────────────
4
12
  require_relative "tina4/version"
5
13
  require_relative "tina4/debug"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tina4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tina4 Team
@@ -121,6 +121,20 @@ dependencies:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
123
  version: '2.7'
124
+ - !ruby/object:Gem::Dependency
125
+ name: oj
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '3.16'
131
+ type: :runtime
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '3.16'
124
138
  - !ruby/object:Gem::Dependency
125
139
  name: webrick
126
140
  requirement: !ruby/object:Gem::Requirement