kotoshu-server 1.1.1 → 1.2.0

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: bfd8418e06fb8a070347045192c1b3a8e189cc981ad833d9246458b16e5171e5
4
- data.tar.gz: 4a96aa19567eab995cf150a81471056c6b76cd1bd3cbbcf41a16d19294515974
3
+ metadata.gz: 61b089870da33a1434ad652e6274770681b9448fd1d7768b8a9b63d4ff12325d
4
+ data.tar.gz: c70874b9311e0ba3f533e0650d15c58e6c289d0d195003033ee8bd0b06d02db6
5
5
  SHA512:
6
- metadata.gz: ee4aef3288c7f61aee8b46d49584c847c6ac22357be3e8bfd67828b979a4f7ee368d3bc15e1f9e75e920d7a05c4818dc156df128b289d20aea03613a19b10a3e
7
- data.tar.gz: f495ec48ae62deca5df1f4c6d6d596a062f8cc1bd1faea2f96fe79e9997798768b70aa1ca187a4af1e1be0d2af5aae5da30ebe257c9e89e40b97186f2d9ae6ef
6
+ metadata.gz: d810035c9078b9b944da1365da2bac8b81795b31c63575a77e6cb37bc7dcb52bfc7b75849db80ba5d2d71507296e3d09334209cdfbf569ae073e1519b18f4991
7
+ data.tar.gz: e860bc98709ccca4b60f29a5aba34943ec116eb3fc9790d8ba948ef5176ecd6614d1e4f3c2afc3219e25563bfeb600797d2bf55f19d15eb15c459bd9caeddf9d
@@ -325,6 +325,13 @@ module Kotoshu
325
325
  halt_with_error(400, "missing 'text'") unless text.is_a?(String)
326
326
 
327
327
  want = want_model ? %i[spelling model] : %i[spelling]
328
+ # Grammar checks are rule-only and bundled with the gem — no
329
+ # setup step. Soft-gated: kotoshu >= the grammar release; on
330
+ # older gems the flag is simply ignored.
331
+ grammar_errors =
332
+ if body["grammar"] && Kotoshu.respond_to?(:grammar_check)
333
+ Kotoshu.grammar_check(text, language: language)
334
+ end
328
335
  result = with_resource(language, want: want) do |checker, bundle|
329
336
  if want_model && bundle.model.nil?
330
337
  # The gem resolves a nil model for languages that cannot
@@ -341,10 +348,23 @@ module Kotoshu
341
348
  end
342
349
 
343
350
  content_type :json
344
- case format_hint
345
- when "errors" then serialize_errors(result).to_json
346
- else serialize_full(result).to_json
351
+ payload =
352
+ case format_hint
353
+ when "errors" then serialize_errors(result)
354
+ else serialize_full(result)
355
+ end
356
+ if grammar_errors
357
+ payload = payload.merge("grammar_errors" => grammar_errors.map do |e|
358
+ {
359
+ "rule_id" => e[:rule_id],
360
+ "start_offset" => e[:start_offset],
361
+ "end_offset" => e[:end_offset],
362
+ "message" => e[:message],
363
+ "suggestions" => e[:suggestions]
364
+ }
365
+ end)
347
366
  end
367
+ payload.to_json
348
368
  end
349
369
 
350
370
  post "/v1/suggest" do
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kotoshu
4
4
  module Server
5
- VERSION = "1.1.1"
5
+ VERSION = "1.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kotoshu-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-09-29 00:00:00.000000000 Z
11
+ date: 2026-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kotoshu