linguin 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c59595249f391eca362ace8550146028defcab40662a9d8d84c8d2ba064b739
4
- data.tar.gz: 0472447d4afb70e4b3f5be9834c6c8deb5270b175c4d36c45acd47fa4c980637
3
+ metadata.gz: 461d92619f5fd7fac0ad19de24ba4eea626bf451efb4b873d9bfb0cd6afab741
4
+ data.tar.gz: bb8a97a922a53411f020f81a8760baec5e19fcb35350636a78c6a290a874e949
5
5
  SHA512:
6
- metadata.gz: 41dcf5f9ed3c89e95955f81ee4e82cf171ac7704707e4cd3cb747e796b08ef69b9a5693b6e4949bd7639f6abe0234a904393a99c7ab480c008b1181a68e1cd85
7
- data.tar.gz: 0a2a092184db1c9f83afd9961c3f0f55166d5f8d1e6e3880e5d4b9439ebebea6fdcebc796bb3d4ebed0e5a85787a8789d4c47dd528a820b2d01b4a342ceab7bb
6
+ metadata.gz: f2c55feb0ddfdd683a3e57d135039f07e1873a8c81ebfe2dd248a74e62a0f180210449f3d99d9cc520232e8bb2fdc31aa4f92ea66d91ebfba765c03a2e4a3aa0
7
+ data.tar.gz: 1604d947cdb234df8004a23fbc8799a70e71cdbc8714c58ed1b1571d45a03d8ab48fbe83f45c80a36030c011221856f6d015c7b3d850e53f6f4e88797a7b259c
@@ -1,4 +1,4 @@
1
- name: Ruby
1
+ name: Tests
2
2
 
3
3
  on: [push,pull_request]
4
4
 
data/.gitignore CHANGED
@@ -9,6 +9,7 @@
9
9
  /test/tmp/
10
10
  /test/version_tmp/
11
11
  /tmp/
12
+ .gem_release.yml
12
13
 
13
14
  # Used by dotenv library to load environment variables.
14
15
  .env
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
- [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard) ![build](https://github.com/LinguinAI/linguin-ruby/actions/workflows/main.yml/badge.svg)
3
+ [![Gem Version](https://badge.fury.io/rb/linguin.svg)](https://badge.fury.io/rb/linguin) ![build](https://github.com/LinguinAI/linguin-ruby/actions/workflows/main.yml/badge.svg) [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Linguin
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
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.0.0
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-05-13 00:00:00.000000000 Z
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