linguin 1.0.0 → 1.1.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 +4 -4
- data/.github/workflows/main.yml +1 -1
- data/.gitignore +1 -0
- data/.rubocop.yml +8 -0
- data/README.md +10 -1
- data/lib/linguin.rb +8 -0
- data/lib/linguin/client.rb +5 -0
- data/lib/linguin/languages.rb +22 -0
- data/lib/linguin/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 461d92619f5fd7fac0ad19de24ba4eea626bf451efb4b873d9bfb0cd6afab741
|
4
|
+
data.tar.gz: bb8a97a922a53411f020f81a8760baec5e19fcb35350636a78c6a290a874e949
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2c55feb0ddfdd683a3e57d135039f07e1873a8c81ebfe2dd248a74e62a0f180210449f3d99d9cc520232e8bb2fdc31aa4f92ea66d91ebfba765c03a2e4a3aa0
|
7
|
+
data.tar.gz: 1604d947cdb234df8004a23fbc8799a70e71cdbc8714c58ed1b1571d45a03d8ab48fbe83f45c80a36030c011221856f6d015c7b3d850e53f6f4e88797a7b259c
|
data/.github/workflows/main.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -72,3 +72,11 @@ Style/StringChars: # (new in 1.12)
|
|
72
72
|
Enabled: true
|
73
73
|
Style/SwapValues: # (new in 1.1)
|
74
74
|
Enabled: true
|
75
|
+
Lint/EmptyInPattern: # (new in 1.16)
|
76
|
+
Enabled: true
|
77
|
+
Style/InPatternThen: # (new in 1.16)
|
78
|
+
Enabled: true
|
79
|
+
Style/MultilineInPatternThen: # (new in 1.16)
|
80
|
+
Enabled: true
|
81
|
+
Style/QuotedSymbols: # (new in 1.16)
|
82
|
+
Enabled: true
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Linguin AI Ruby wrapper
|
2
2
|
|
3
|
-
[](https://badge.fury.io/rb/linguin)  [](https://github.com/testdouble/standard)
|
4
4
|
|
5
5
|
This is a Ruby wrapper for the [Linguin AI](https://linguin.ai) API (see [API docs](https://linguin.ai/api-docs/v1)) providing Language Detection as a Service.
|
6
6
|
|
@@ -81,6 +81,15 @@ status.daily_limit # => 50_000 or nil for no limit
|
|
81
81
|
status.remaining_today # => 45_500 or Float::INFINITY for unlimited
|
82
82
|
```
|
83
83
|
|
84
|
+
### Language list
|
85
|
+
|
86
|
+
You can fetch the list of supported languages:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
languages = Linguin.languages
|
90
|
+
# => { de: ["German", "Deutsch"], ... }
|
91
|
+
```
|
92
|
+
|
84
93
|
## Development
|
85
94
|
|
86
95
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/linguin.rb
CHANGED
@@ -7,6 +7,7 @@ require_relative "linguin/base_response"
|
|
7
7
|
require_relative "linguin/detection"
|
8
8
|
require_relative "linguin/bulk_detection"
|
9
9
|
require_relative "linguin/status"
|
10
|
+
require_relative "linguin/languages"
|
10
11
|
|
11
12
|
# == Linguin API wrapper module
|
12
13
|
# Can be used as a singleton to access all API methods.
|
@@ -26,6 +27,9 @@ require_relative "linguin/status"
|
|
26
27
|
# * number of requests today
|
27
28
|
# * daily detection limit of your account (false for unlimited)
|
28
29
|
# * remaining detections today (can be Infinity)
|
30
|
+
#
|
31
|
+
# = Linguin.languages
|
32
|
+
# Returns the list of supported languages.
|
29
33
|
module Linguin
|
30
34
|
class << self
|
31
35
|
def api_key=(api_key)
|
@@ -44,6 +48,10 @@ module Linguin
|
|
44
48
|
default_client.status
|
45
49
|
end
|
46
50
|
|
51
|
+
def languages
|
52
|
+
default_client.languages
|
53
|
+
end
|
54
|
+
|
47
55
|
private
|
48
56
|
|
49
57
|
def default_client
|
data/lib/linguin/client.rb
CHANGED
@@ -62,6 +62,11 @@ module Linguin
|
|
62
62
|
Status.from_httparty(response: httparty_response)
|
63
63
|
end
|
64
64
|
|
65
|
+
def languages
|
66
|
+
httparty_response = self.class.get("/languages")
|
67
|
+
Languages.from_httparty(response: httparty_response)
|
68
|
+
end
|
69
|
+
|
65
70
|
private
|
66
71
|
|
67
72
|
def configure_api_key(key)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Linguin
|
4
|
+
# == Linguin::Languages
|
5
|
+
# Returns a hash of supported languages.
|
6
|
+
class Languages < BaseResponse
|
7
|
+
class << self
|
8
|
+
def error(code, message)
|
9
|
+
new do |status|
|
10
|
+
status.error = {
|
11
|
+
code: code,
|
12
|
+
message: message
|
13
|
+
}
|
14
|
+
end.raise_on_error!
|
15
|
+
end
|
16
|
+
|
17
|
+
def success(response)
|
18
|
+
response
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/linguin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linguin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Schwenzien
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/linguin/client.rb
|
134
134
|
- lib/linguin/detection.rb
|
135
135
|
- lib/linguin/exceptions.rb
|
136
|
+
- lib/linguin/languages.rb
|
136
137
|
- lib/linguin/status.rb
|
137
138
|
- lib/linguin/version.rb
|
138
139
|
- linguin.gemspec
|