that_language-service 0.1.3 → 0.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 +5 -5
- data/.github/workflows/ci.yml +35 -0
- data/.rubocop.yml +25 -0
- data/.rubocop_todo.yml +159 -0
- data/.ruby-version +1 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +33 -0
- data/README.md +88 -16
- data/lib/that_language/service/application.rb +18 -2
- data/lib/that_language/service/version.rb +1 -3
- data/that_language-service.gemspec +25 -17
- metadata +57 -51
- data/.travis.yml +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f066cb0d03b085415f75ce98baa6ccfd855e64651f848626cccba449cb35a8ae
|
|
4
|
+
data.tar.gz: c2199ad48689b99bee525479d8db872d7e2c4278b7894df0f7e80326c4670862
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 36e4f781eea5808201beed8d6006d665132c91d4c7eb4ac237edd18da8b6fe3ddbab1af611da246b2636afaa51b03f8baab026d7cf16977522221e91d59fd4ef
|
|
7
|
+
data.tar.gz: 24122e0413446e3acac602df6d05124e46b23b2cda1163c137343a29789b8ebd82525047a04d9a4022126b9fe36074e65578c09efba4339a9f3ade431a90d63a
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [master]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
rspec:
|
|
12
|
+
name: rspec (ruby ${{ matrix.ruby }})
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
ruby: ["3.1", "3.2", "3.3", "3.4", "4.0"]
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v7
|
|
20
|
+
- uses: ruby/setup-ruby@v1
|
|
21
|
+
with:
|
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
|
23
|
+
bundler-cache: true
|
|
24
|
+
- run: bundle exec rspec
|
|
25
|
+
|
|
26
|
+
rubocop:
|
|
27
|
+
name: rubocop
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v7
|
|
31
|
+
- uses: ruby/setup-ruby@v1
|
|
32
|
+
with:
|
|
33
|
+
ruby-version: "4.0"
|
|
34
|
+
bundler-cache: true
|
|
35
|
+
- run: bundle exec rubocop
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
|
2
|
+
|
|
3
|
+
AllCops:
|
|
4
|
+
# TargetRubyVersion is deliberately not set here. RuboCop derives it from
|
|
5
|
+
# required_ruby_version in the gemspec (currently ">= 3.1"), which takes
|
|
6
|
+
# precedence over .ruby-version, so the oldest supported Ruby is stated in
|
|
7
|
+
# exactly one place. It is the *minimum* supported version, not the version
|
|
8
|
+
# used for development -- raising it means dropping support for users.
|
|
9
|
+
NewCops: enable
|
|
10
|
+
SuggestExtensions: false
|
|
11
|
+
Exclude:
|
|
12
|
+
- "bin/**/*"
|
|
13
|
+
- "vendor/**/*"
|
|
14
|
+
- "tmp/**/*"
|
|
15
|
+
|
|
16
|
+
# Sinatra route definitions are long blocks by nature, and the spec suite is
|
|
17
|
+
# built from a describe_endpoint macro; block length is not a useful signal
|
|
18
|
+
# in either place.
|
|
19
|
+
Metrics/BlockLength:
|
|
20
|
+
Exclude:
|
|
21
|
+
- "spec/**/*"
|
|
22
|
+
|
|
23
|
+
# Specs read better without a documentation comment on every describe block.
|
|
24
|
+
Style/Documentation:
|
|
25
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2026-07-20 01:51:22 UTC using RuboCop version 1.88.2.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 7
|
|
10
|
+
# Configuration parameters: EnforcedStyle, AllowedGems.
|
|
11
|
+
# SupportedStyles: Gemfile, gems.rb, gemspec
|
|
12
|
+
Gemspec/DevelopmentDependencies:
|
|
13
|
+
Exclude:
|
|
14
|
+
- 'that_language-service.gemspec'
|
|
15
|
+
|
|
16
|
+
# Offense count: 1
|
|
17
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
18
|
+
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation.
|
|
19
|
+
Gemspec/OrderedDependencies:
|
|
20
|
+
Exclude:
|
|
21
|
+
- 'that_language-service.gemspec'
|
|
22
|
+
|
|
23
|
+
# Offense count: 1
|
|
24
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
25
|
+
# Configuration parameters: IndentationWidth.
|
|
26
|
+
# SupportedStyles: outdent, indent
|
|
27
|
+
Layout/AccessModifierIndentation:
|
|
28
|
+
EnforcedStyle: outdent
|
|
29
|
+
|
|
30
|
+
# Offense count: 1
|
|
31
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
32
|
+
Layout/EmptyLineAfterMagicComment:
|
|
33
|
+
Exclude:
|
|
34
|
+
- 'that_language-service.gemspec'
|
|
35
|
+
|
|
36
|
+
# Offense count: 6
|
|
37
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
38
|
+
# Configuration parameters: IndentationWidth.
|
|
39
|
+
# SupportedStyles: special_inside_parentheses, consistent, align_braces
|
|
40
|
+
Layout/FirstHashElementIndentation:
|
|
41
|
+
EnforcedStyle: consistent
|
|
42
|
+
|
|
43
|
+
# Offense count: 3
|
|
44
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
45
|
+
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
|
46
|
+
# SupportedHashRocketStyles: key, separator, table
|
|
47
|
+
# SupportedColonStyles: key, separator, table
|
|
48
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
|
49
|
+
Layout/HashAlignment:
|
|
50
|
+
Exclude:
|
|
51
|
+
- 'that_language-service.gemspec'
|
|
52
|
+
|
|
53
|
+
# Offense count: 1
|
|
54
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
55
|
+
Metrics/AbcSize:
|
|
56
|
+
Max: 32
|
|
57
|
+
|
|
58
|
+
# Offense count: 1
|
|
59
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
60
|
+
# AllowedMethods: refine
|
|
61
|
+
Metrics/BlockLength:
|
|
62
|
+
Max: 29
|
|
63
|
+
|
|
64
|
+
# Offense count: 1
|
|
65
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
66
|
+
Metrics/MethodLength:
|
|
67
|
+
Max: 20
|
|
68
|
+
|
|
69
|
+
# Offense count: 1
|
|
70
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
71
|
+
Style/Encoding:
|
|
72
|
+
Exclude:
|
|
73
|
+
- 'that_language-service.gemspec'
|
|
74
|
+
|
|
75
|
+
# Offense count: 2
|
|
76
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
77
|
+
Style/ExpandPathArguments:
|
|
78
|
+
Exclude:
|
|
79
|
+
- 'spec/spec_helper.rb'
|
|
80
|
+
- 'that_language-service.gemspec'
|
|
81
|
+
|
|
82
|
+
# Offense count: 11
|
|
83
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
84
|
+
# Configuration parameters: EnforcedStyle.
|
|
85
|
+
# SupportedStyles: always, always_true, never
|
|
86
|
+
Style/FrozenStringLiteralComment:
|
|
87
|
+
Exclude:
|
|
88
|
+
- '**/*.arb'
|
|
89
|
+
- 'Gemfile'
|
|
90
|
+
- 'Rakefile'
|
|
91
|
+
- 'config.ru'
|
|
92
|
+
- 'lib/that_language/service.rb'
|
|
93
|
+
- 'lib/that_language/service/application.rb'
|
|
94
|
+
- 'lib/that_language/service/version.rb'
|
|
95
|
+
- 'spec/spec_helper.rb'
|
|
96
|
+
- 'spec/support/that_language_service_spec_helper.rb'
|
|
97
|
+
- 'spec/that_language/service/application_spec.rb'
|
|
98
|
+
- 'spec/that_language/service_spec.rb'
|
|
99
|
+
- 'that_language-service.gemspec'
|
|
100
|
+
|
|
101
|
+
# Offense count: 1
|
|
102
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
103
|
+
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
|
104
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
|
105
|
+
# SupportedShorthandSyntax: always, never, either, consistent, either_consistent
|
|
106
|
+
Style/HashSyntax:
|
|
107
|
+
Exclude:
|
|
108
|
+
- 'Rakefile'
|
|
109
|
+
|
|
110
|
+
# Offense count: 1
|
|
111
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
112
|
+
# Configuration parameters: EnforcedStyle, Recursive.
|
|
113
|
+
# SupportedStyles: literals, strict
|
|
114
|
+
Style/MutableConstant:
|
|
115
|
+
Exclude:
|
|
116
|
+
- 'lib/that_language/service/version.rb'
|
|
117
|
+
|
|
118
|
+
# Offense count: 2
|
|
119
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
120
|
+
# Configuration parameters: PreferredDelimiters.
|
|
121
|
+
Style/PercentLiteralDelimiters:
|
|
122
|
+
Exclude:
|
|
123
|
+
- 'that_language-service.gemspec'
|
|
124
|
+
|
|
125
|
+
# Offense count: 2
|
|
126
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
127
|
+
Style/RedundantPercentQ:
|
|
128
|
+
Exclude:
|
|
129
|
+
- 'that_language-service.gemspec'
|
|
130
|
+
|
|
131
|
+
# Offense count: 130
|
|
132
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
133
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
|
134
|
+
# SupportedStyles: single_quotes, double_quotes
|
|
135
|
+
Style/StringLiterals:
|
|
136
|
+
Exclude:
|
|
137
|
+
- 'Gemfile'
|
|
138
|
+
- 'Rakefile'
|
|
139
|
+
- 'lib/that_language/service.rb'
|
|
140
|
+
- 'lib/that_language/service/application.rb'
|
|
141
|
+
- 'lib/that_language/service/version.rb'
|
|
142
|
+
- 'spec/spec_helper.rb'
|
|
143
|
+
- 'spec/support/that_language_service_spec_helper.rb'
|
|
144
|
+
- 'spec/that_language/service/application_spec.rb'
|
|
145
|
+
- 'that_language-service.gemspec'
|
|
146
|
+
|
|
147
|
+
# Offense count: 1
|
|
148
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
149
|
+
# Configuration parameters: MinSize.
|
|
150
|
+
# SupportedStyles: percent, brackets
|
|
151
|
+
Style/SymbolArray:
|
|
152
|
+
EnforcedStyle: brackets
|
|
153
|
+
|
|
154
|
+
# Offense count: 1
|
|
155
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
156
|
+
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
157
|
+
# URISchemes: http, https
|
|
158
|
+
Layout/LineLength:
|
|
159
|
+
Max: 199
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4.0.6
|
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby 4.0.6
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
## 0.2.0 [☰](https://github.com/Deradon/that_language-service/compare/v0.1.3...v0.2.0) (2026-07-20)
|
|
2
|
+
|
|
3
|
+
Revival release, and the first one that is actually installable: `gem install
|
|
4
|
+
that_language-service` previously resolved a core gem that could not run on
|
|
5
|
+
Ruby 3+, so it failed at the first request rather than at install.
|
|
6
|
+
|
|
7
|
+
Note the jump from 0.1.3 to 0.2.0 — it skips 0.1.4 to keep the version aligned
|
|
8
|
+
with `that_language` and `that_language-client`, which mirror this gem's API and
|
|
9
|
+
move with it.
|
|
10
|
+
|
|
11
|
+
### Breaking changes
|
|
12
|
+
|
|
13
|
+
* `required_ruby_version` is now `>= 3.1`.
|
|
14
|
+
* The `that_language` dependency is `~> 0.2`, which requires the revived core
|
|
15
|
+
gem. `~> 0.1` was too loose: it resolves to the published 0.1.2, which
|
|
16
|
+
installs cleanly and then raises on the first wordlist load.
|
|
17
|
+
* `thin` is no longer a runtime dependency. This gem is a library and the
|
|
18
|
+
deployment picks its own web server; the old `thin ~> 1.6.4` pin is what made
|
|
19
|
+
the gem uninstallable in the first place.
|
|
20
|
+
|
|
21
|
+
### Enhancements
|
|
22
|
+
|
|
23
|
+
* Sinatra 1.4.8 → 4.2.1 and Rack 1.6.13 → 3.2.6, on `Sinatra::Base` rather than
|
|
24
|
+
the classic `Sinatra::Application`.
|
|
25
|
+
* Gemspec: dropped the `bundler ~> 1.10` development dependency that made
|
|
26
|
+
`bundle install` unsolvable, and modernised the remaining pins.
|
|
27
|
+
* CI moved from Travis to GitHub Actions, covering Ruby 3.1 through 4.0.
|
|
28
|
+
* The `/version` spec asserts against `ThatLanguage::VERSION` instead of a
|
|
29
|
+
hardcoded string, so it tracks the core gem instead of rotting against it.
|
|
30
|
+
|
|
31
|
+
All eight endpoints are verified over both GET and POST. The API surface is
|
|
32
|
+
unchanged.
|
|
33
|
+
|
|
1
34
|
## 0.1.3 [☰](https://github.com/Deradon/that_language-service/compare/v0.1.2...v0.1.3) (2016-05-23)
|
|
2
35
|
|
|
3
36
|
### Bug fixes
|
data/README.md
CHANGED
|
@@ -1,41 +1,113 @@
|
|
|
1
|
+
[](https://github.com/Deradon/that_language-service/actions/workflows/ci.yml)
|
|
2
|
+
|
|
1
3
|
# ThatLanguage::Service
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
A thin [Sinatra](https://sinatrarb.com) wrapper that exposes the
|
|
6
|
+
[ThatLanguage](https://github.com/Deradon/that_language) language-detection
|
|
7
|
+
library over HTTP as eight JSON endpoints.
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
This is a **library gem, not an application**: it ships a `config.ru` but
|
|
10
|
+
declares no web server, so the deployment picks its own.
|
|
6
11
|
|
|
7
12
|
## Installation
|
|
8
13
|
|
|
9
|
-
Add
|
|
14
|
+
Add it to your Gemfile:
|
|
10
15
|
|
|
11
16
|
```ruby
|
|
12
|
-
gem
|
|
17
|
+
gem "that_language-service"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
> **Note.** The published `that_language` 0.1.2 on rubygems.org predates the
|
|
21
|
+
> Ruby 3+ fixes and will not run on a modern Ruby. Until `that_language` 0.1.3
|
|
22
|
+
> is released, point at the source directly:
|
|
23
|
+
>
|
|
24
|
+
> ```ruby
|
|
25
|
+
> gem "that_language", git: "https://github.com/Deradon/that_language.git"
|
|
26
|
+
> ```
|
|
27
|
+
|
|
28
|
+
## Running it
|
|
29
|
+
|
|
30
|
+
```console
|
|
31
|
+
$ bundle install
|
|
32
|
+
$ bundle exec puma config.ru -p 9292
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Then:
|
|
36
|
+
|
|
37
|
+
```console
|
|
38
|
+
$ curl --get --data-urlencode 'text=Hallo Welt' http://localhost:9292/detect
|
|
39
|
+
{"language":"German","language_code":"de","confidence":0.5}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Endpoints
|
|
43
|
+
|
|
44
|
+
Every endpoint answers both `GET` and `POST`, takes the input in a `text`
|
|
45
|
+
parameter, and responds with `Content-Type: application/json`.
|
|
46
|
+
|
|
47
|
+
| Endpoint | Returns |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `/language` | `{"language": "German"}` |
|
|
50
|
+
| `/language_code` | `{"language_code": "de"}` |
|
|
51
|
+
| `/detect` | `{"language": …, "language_code": …, "confidence": …}` |
|
|
52
|
+
| `/details` | the full ranked result set, best match first |
|
|
53
|
+
| `/available` | `{"available": {"de": "German", …}}` |
|
|
54
|
+
| `/available_languages` | list of language names |
|
|
55
|
+
| `/available_language_codes` | list of language codes |
|
|
56
|
+
| `/version` | the **core library** version, not the service version |
|
|
57
|
+
|
|
58
|
+
`/details` returns every candidate language with its scoring breakdown:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{"results":[{"language":"German","language_code":"de","confidence":0.5,
|
|
62
|
+
"value":1.0,"hit_ratio":0.5,"hit_count":1,"words_count":2}]}
|
|
13
63
|
```
|
|
14
64
|
|
|
15
|
-
|
|
65
|
+
## Configuration
|
|
16
66
|
|
|
17
|
-
|
|
67
|
+
The wordlist tier is a property of the core library, not of this service.
|
|
68
|
+
Configure it before the application is mounted:
|
|
18
69
|
|
|
19
|
-
|
|
70
|
+
```ruby
|
|
71
|
+
ThatLanguage.configure do |config|
|
|
72
|
+
config.wordlist_path = File.join("wordlists", "100k")
|
|
73
|
+
end
|
|
74
|
+
```
|
|
20
75
|
|
|
21
|
-
|
|
76
|
+
**Warm the cache at boot.** The wordlists are loaded lazily on the first
|
|
77
|
+
request, which costs about a second and a few hundred megabytes. Without a
|
|
78
|
+
warm-up the first user pays for it:
|
|
22
79
|
|
|
23
|
-
|
|
80
|
+
```ruby
|
|
81
|
+
ThatLanguage.language_code("Hello world!") # in config.ru, before `run`
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Cross-origin requests
|
|
24
85
|
|
|
25
|
-
|
|
86
|
+
`Rack::Protection::JsonCsrf` is deliberately disabled — it answers `403` to any
|
|
87
|
+
request carrying a cross-origin `Referer`, which would block the intended
|
|
88
|
+
browser use case while guarding data that is already public. CORS headers are
|
|
89
|
+
not set here; the deployment adds them.
|
|
26
90
|
|
|
27
91
|
## Development
|
|
28
92
|
|
|
29
|
-
|
|
93
|
+
```console
|
|
94
|
+
$ bundle install
|
|
95
|
+
$ bundle exec rspec
|
|
96
|
+
$ bundle exec rubocop
|
|
97
|
+
```
|
|
30
98
|
|
|
31
|
-
|
|
99
|
+
Requires Ruby >= 3.1; developed and pinned against 4.0.6
|
|
100
|
+
(see `.tool-versions`).
|
|
32
101
|
|
|
33
102
|
## Contributing
|
|
34
103
|
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at
|
|
36
|
-
|
|
104
|
+
Bug reports and pull requests are welcome on GitHub at
|
|
105
|
+
<https://github.com/Deradon/that_language-service>. This project is intended to
|
|
106
|
+
be a safe, welcoming space for collaboration, and contributors are expected to
|
|
107
|
+
adhere to the [Contributor Covenant](https://contributor-covenant.org) code of
|
|
108
|
+
conduct.
|
|
37
109
|
|
|
38
110
|
## License
|
|
39
111
|
|
|
40
|
-
|
|
41
|
-
|
|
112
|
+
Available as open source under the terms of the
|
|
113
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "json"
|
|
2
|
+
require "sinatra/base"
|
|
2
3
|
require "sinatra/multi_route"
|
|
3
4
|
require "that_language"
|
|
4
5
|
|
|
5
6
|
module ThatLanguage
|
|
6
7
|
module Service
|
|
7
|
-
|
|
8
|
+
# Modular style: `require "sinatra"` would boot a classic top-level app with
|
|
9
|
+
# an at_exit server runner, which is wrong for a library gem. config.ru runs
|
|
10
|
+
# this class explicitly.
|
|
11
|
+
class Application < Sinatra::Base
|
|
12
|
+
register Sinatra::MultiRoute
|
|
13
|
+
|
|
14
|
+
# Rack::Protection::JsonCsrf answers 403 to any request carrying a
|
|
15
|
+
# cross-origin Referer. This API is public, unauthenticated and read-only,
|
|
16
|
+
# and is deployed with CORS enabled precisely so browsers on other origins
|
|
17
|
+
# can call it -- so the protection would block the intended use case while
|
|
18
|
+
# guarding data that is already public. There is also no session, cookie
|
|
19
|
+
# or state change anywhere in the service for a CSRF to abuse.
|
|
20
|
+
#
|
|
21
|
+
# Revisit this if the service ever gains authentication, sessions, or an
|
|
22
|
+
# endpoint that is not a pure function of its input -- the reasoning above
|
|
23
|
+
# collapses the moment a request carries ambient authority.
|
|
8
24
|
set :protection, except: [:json_csrf]
|
|
9
25
|
|
|
10
26
|
route :get, :post, '/language' do
|
|
@@ -10,32 +10,40 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.email = ["me@patrick-helm.de"]
|
|
11
11
|
|
|
12
12
|
spec.summary = %q{Simple Sinatra wrapper for ThatLanguage.}
|
|
13
|
-
|
|
13
|
+
spec.description = %q{Exposes the ThatLanguage language-detection library over HTTP as eight JSON endpoints. Packaged as a gem rather than an application; the deployment supplies the web server.}
|
|
14
14
|
spec.homepage = "https://github.com/Deradon/that_language-service"
|
|
15
15
|
spec.license = "MIT"
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
spec.required_ruby_version = ">= 3.1"
|
|
18
|
+
|
|
19
|
+
spec.metadata = {
|
|
20
|
+
"homepage_uri" => spec.homepage,
|
|
21
|
+
"source_code_uri" => spec.homepage,
|
|
22
|
+
"bug_tracker_uri" => "#{spec.homepage}/issues",
|
|
23
|
+
"rubygems_mfa_required" => "true"
|
|
24
|
+
}
|
|
24
25
|
|
|
25
26
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
27
|
spec.bindir = "exe"
|
|
27
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
29
|
spec.require_paths = ["lib"]
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
spec.add_dependency "
|
|
31
|
+
# Must not be loosened to "~> 0.1". The published 0.1.x predates the Ruby 3+
|
|
32
|
+
# fixes in the core gem, so a looser pin resolves to a version that installs
|
|
33
|
+
# cleanly and then raises on the first request.
|
|
34
|
+
spec.add_dependency "that_language", "~> 0.2"
|
|
35
|
+
spec.add_dependency "sinatra", "~> 4.2"
|
|
36
|
+
spec.add_dependency "sinatra-contrib", "~> 4.2"
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
# No web server is declared as a runtime dependency. This gem is a library;
|
|
39
|
+
# the deployment picks the server and supplies its own rackup. The old
|
|
40
|
+
# `thin ~> 1.6.4` runtime pin is exactly what made this gem uninstallable.
|
|
41
|
+
# `puma` is a development dependency so `config.ru` can be run locally.
|
|
36
42
|
spec.add_development_dependency "pry"
|
|
37
|
-
spec.add_development_dependency "
|
|
38
|
-
spec.add_development_dependency "
|
|
39
|
-
spec.add_development_dependency "
|
|
40
|
-
spec.add_development_dependency "rspec
|
|
43
|
+
spec.add_development_dependency "puma", "~> 8.0"
|
|
44
|
+
spec.add_development_dependency "rack-test", "~> 2.2"
|
|
45
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
46
|
+
spec.add_development_dependency "rspec", "~> 3.13"
|
|
47
|
+
spec.add_development_dependency "rspec-its", "~> 2.0"
|
|
48
|
+
spec.add_development_dependency "rubocop", "~> 1.88"
|
|
41
49
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: that_language-service
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Patrick Helm
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: that_language
|
|
@@ -16,150 +15,156 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
18
|
+
version: '0.2'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
25
|
+
version: '0.2'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: sinatra
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
30
|
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
32
|
+
version: '4.2'
|
|
34
33
|
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
39
|
+
version: '4.2'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
41
|
name: sinatra-contrib
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
|
-
- - "
|
|
44
|
+
- - "~>"
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
46
|
+
version: '4.2'
|
|
48
47
|
type: :runtime
|
|
49
48
|
prerelease: false
|
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
50
|
requirements:
|
|
52
|
-
- - "
|
|
51
|
+
- - "~>"
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
53
|
+
version: '4.2'
|
|
55
54
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
55
|
+
name: pry
|
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements:
|
|
59
|
-
- - "
|
|
58
|
+
- - ">="
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
62
|
-
type: :
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :development
|
|
63
62
|
prerelease: false
|
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
64
|
requirements:
|
|
66
|
-
- - "
|
|
65
|
+
- - ">="
|
|
67
66
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
67
|
+
version: '0'
|
|
69
68
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
69
|
+
name: puma
|
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
|
72
71
|
requirements:
|
|
73
72
|
- - "~>"
|
|
74
73
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
74
|
+
version: '8.0'
|
|
76
75
|
type: :development
|
|
77
76
|
prerelease: false
|
|
78
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
78
|
requirements:
|
|
80
79
|
- - "~>"
|
|
81
80
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
81
|
+
version: '8.0'
|
|
83
82
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
83
|
+
name: rack-test
|
|
85
84
|
requirement: !ruby/object:Gem::Requirement
|
|
86
85
|
requirements:
|
|
87
|
-
- - "
|
|
86
|
+
- - "~>"
|
|
88
87
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '
|
|
88
|
+
version: '2.2'
|
|
90
89
|
type: :development
|
|
91
90
|
prerelease: false
|
|
92
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
92
|
requirements:
|
|
94
|
-
- - "
|
|
93
|
+
- - "~>"
|
|
95
94
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '
|
|
95
|
+
version: '2.2'
|
|
97
96
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
97
|
+
name: rake
|
|
99
98
|
requirement: !ruby/object:Gem::Requirement
|
|
100
99
|
requirements:
|
|
101
|
-
- - "
|
|
100
|
+
- - "~>"
|
|
102
101
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '0'
|
|
102
|
+
version: '13.0'
|
|
104
103
|
type: :development
|
|
105
104
|
prerelease: false
|
|
106
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
106
|
requirements:
|
|
108
|
-
- - "
|
|
107
|
+
- - "~>"
|
|
109
108
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '0'
|
|
109
|
+
version: '13.0'
|
|
111
110
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name:
|
|
111
|
+
name: rspec
|
|
113
112
|
requirement: !ruby/object:Gem::Requirement
|
|
114
113
|
requirements:
|
|
115
114
|
- - "~>"
|
|
116
115
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: '
|
|
116
|
+
version: '3.13'
|
|
118
117
|
type: :development
|
|
119
118
|
prerelease: false
|
|
120
119
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
120
|
requirements:
|
|
122
121
|
- - "~>"
|
|
123
122
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: '
|
|
123
|
+
version: '3.13'
|
|
125
124
|
- !ruby/object:Gem::Dependency
|
|
126
|
-
name: rspec
|
|
125
|
+
name: rspec-its
|
|
127
126
|
requirement: !ruby/object:Gem::Requirement
|
|
128
127
|
requirements:
|
|
129
|
-
- - "
|
|
128
|
+
- - "~>"
|
|
130
129
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: '0'
|
|
130
|
+
version: '2.0'
|
|
132
131
|
type: :development
|
|
133
132
|
prerelease: false
|
|
134
133
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
134
|
requirements:
|
|
136
|
-
- - "
|
|
135
|
+
- - "~>"
|
|
137
136
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: '0'
|
|
137
|
+
version: '2.0'
|
|
139
138
|
- !ruby/object:Gem::Dependency
|
|
140
|
-
name:
|
|
139
|
+
name: rubocop
|
|
141
140
|
requirement: !ruby/object:Gem::Requirement
|
|
142
141
|
requirements:
|
|
143
|
-
- - "
|
|
142
|
+
- - "~>"
|
|
144
143
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: '
|
|
144
|
+
version: '1.88'
|
|
146
145
|
type: :development
|
|
147
146
|
prerelease: false
|
|
148
147
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
148
|
requirements:
|
|
150
|
-
- - "
|
|
149
|
+
- - "~>"
|
|
151
150
|
- !ruby/object:Gem::Version
|
|
152
|
-
version: '
|
|
153
|
-
description:
|
|
151
|
+
version: '1.88'
|
|
152
|
+
description: Exposes the ThatLanguage language-detection library over HTTP as eight
|
|
153
|
+
JSON endpoints. Packaged as a gem rather than an application; the deployment supplies
|
|
154
|
+
the web server.
|
|
154
155
|
email:
|
|
155
156
|
- me@patrick-helm.de
|
|
156
157
|
executables: []
|
|
157
158
|
extensions: []
|
|
158
159
|
extra_rdoc_files: []
|
|
159
160
|
files:
|
|
161
|
+
- ".github/workflows/ci.yml"
|
|
160
162
|
- ".gitignore"
|
|
161
163
|
- ".rspec"
|
|
162
|
-
- ".
|
|
164
|
+
- ".rubocop.yml"
|
|
165
|
+
- ".rubocop_todo.yml"
|
|
166
|
+
- ".ruby-version"
|
|
167
|
+
- ".tool-versions"
|
|
163
168
|
- CHANGELOG.md
|
|
164
169
|
- CODE_OF_CONDUCT.md
|
|
165
170
|
- Gemfile
|
|
@@ -176,8 +181,11 @@ files:
|
|
|
176
181
|
homepage: https://github.com/Deradon/that_language-service
|
|
177
182
|
licenses:
|
|
178
183
|
- MIT
|
|
179
|
-
metadata:
|
|
180
|
-
|
|
184
|
+
metadata:
|
|
185
|
+
homepage_uri: https://github.com/Deradon/that_language-service
|
|
186
|
+
source_code_uri: https://github.com/Deradon/that_language-service
|
|
187
|
+
bug_tracker_uri: https://github.com/Deradon/that_language-service/issues
|
|
188
|
+
rubygems_mfa_required: 'true'
|
|
181
189
|
rdoc_options: []
|
|
182
190
|
require_paths:
|
|
183
191
|
- lib
|
|
@@ -185,16 +193,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
185
193
|
requirements:
|
|
186
194
|
- - ">="
|
|
187
195
|
- !ruby/object:Gem::Version
|
|
188
|
-
version: '
|
|
196
|
+
version: '3.1'
|
|
189
197
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
198
|
requirements:
|
|
191
199
|
- - ">="
|
|
192
200
|
- !ruby/object:Gem::Version
|
|
193
201
|
version: '0'
|
|
194
202
|
requirements: []
|
|
195
|
-
|
|
196
|
-
rubygems_version: 2.4.8
|
|
197
|
-
signing_key:
|
|
203
|
+
rubygems_version: 4.0.16
|
|
198
204
|
specification_version: 4
|
|
199
205
|
summary: Simple Sinatra wrapper for ThatLanguage.
|
|
200
206
|
test_files: []
|
data/.travis.yml
DELETED