tongues 0.0.12 → 0.0.13

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
  SHA1:
3
- metadata.gz: 1f4e3a0acae7988ff9f24b1b16b3c247e15a3064
4
- data.tar.gz: 032219a331050e0121a136755dff9b4dbe2df14c
3
+ metadata.gz: b0ebfb2f5ac9c3aa1e4ac263b2edcf13949222bc
4
+ data.tar.gz: 5c714c36b58d490cd3e07b6e7136f2bd905fc836
5
5
  SHA512:
6
- metadata.gz: 763f84c82935ee0092574b6b77130766751d758d53a20fc2d9c2dbc88e14adeda593256db613976f08d1d7cf23716465c91f881eae190a7bac2793b9db616840
7
- data.tar.gz: 70114e1b6191f022e55786fb79ccef2948b47c58067b8e8c470ecd8e9c3812554a1ffb0f9a520c360f61d7d959c6e9ab95f3a2a69e7bdd5f0333ae1f49f17a36
6
+ metadata.gz: e5f8849b5cdab263b2b91a145cf1f47dc1e81682e8c0b2ece34d95a9a472f63909fce9b3124577a3581d98c3690cf33a91bd67f6c91c505f6b35b8d7481516cc
7
+ data.tar.gz: 91e8e069f0461640ba4f0549a29d54f23543cb3bd96157927e689af728fc032fa0e8b78c2315d4fc0a92b4f1bd8ed353fb36f50ec58672004959efb4071ff551
@@ -1,4 +1,4 @@
1
1
  Tongues.configure do |config|
2
2
  require 'tongues'
3
- config.api_key = ''
3
+ config.api_key = '' ## Get you api key from detectlanguage.com
4
4
  end
@@ -10,6 +10,8 @@ module Tongues
10
10
 
11
11
  ## Detects the language for the text in params
12
12
  def detect(text)
13
+ raise NoApiKeyError, 'Invalid api key. Check config/initializers/tongues.rb' if Tongues::Configuration.api_key.blank?
14
+
13
15
  response = call_api(text)
14
16
 
15
17
  if detection = parse_response(response)
@@ -43,4 +45,7 @@ module Tongues
43
45
  JSON.parse(response)['data']['detections'].first
44
46
  end
45
47
  end
48
+
49
+ class NoApiKeyError < StandardError
50
+ end
46
51
  end
@@ -22,7 +22,7 @@ module Tongues
22
22
 
23
23
  ## Returns the api key
24
24
  def api_key
25
- @@api_key
25
+ @@api_key ||= ''
26
26
  end
27
27
 
28
28
  ## Modifies the api_key
@@ -32,7 +32,7 @@ module Tongues
32
32
 
33
33
  ## Returns the api key
34
34
  def self.api_key
35
- @@api_key
35
+ @@api_key ||= ''
36
36
  end
37
37
 
38
38
  ## Modifies the api_key
@@ -1,3 +1,3 @@
1
1
  module Tongues
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tongues
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Zicat