detect_language 1.0.7 → 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
  SHA1:
3
- metadata.gz: ca98c08af8db2e27c420fe04ef2118fd9e2f1e18
4
- data.tar.gz: c8ef3ca5e8c3eb887739d8823898e3e8f2cf5920
3
+ metadata.gz: 3f04b5f6f7debbcbe9ceb5d8dc3d8692acb9be2b
4
+ data.tar.gz: bb46979925797dfe44372542f91e70b4ac7596c3
5
5
  SHA512:
6
- metadata.gz: 55ac2c4abaff15fcabf57ff1a370740c54ff19b294078be2f2638577c3a68bd4db0b60870e832856a1f30ae922f19f6425ea862661a34a641e7aca8afd1c83d7
7
- data.tar.gz: ecc5959ed23946cbb5cfa8ce98e1badfbeb69a89a366da060aeed0d679805701231787f01d8ba5cf6bfcfda340a359d66ee0dadac6d34bf2afbabe91c35ba8a4
6
+ metadata.gz: 58790a0cc8ee72df7445598cbcae78d36b798914c8d8b57308128eb3016d723d7861771d2311889455e9357263e331d9d95e84225bd4611a08ce63f461aa9b83
7
+ data.tar.gz: 9406d7aff6fdf95d93b61363ba3d6365f170b1e0ae6d3406e38ee6d5acb21f12b6d75fc25cae9e6ae62712c9e4cacbebe4b13d8a9556695bb4f1bd2866da33c7
data/.travis.yml CHANGED
@@ -1,9 +1,15 @@
1
1
  rvm:
2
- - 1.9.2
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.1
6
- - jruby-19mode # JRuby in 1.9 mode
7
- - rbx-2
8
- script: "bundle exec rake spec"
9
-
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.1
5
+ - 2.3.4
6
+ - 2.4.1
7
+ - 2.5.0
8
+ - ruby-head
9
+ - ruby-head-clang
10
+ - jruby-1.7.26
11
+ - jruby-9.1.9.0
12
+ script: bundle exec rake spec
13
+ env:
14
+ global:
15
+ secure: Xt9aOp3jO9r7e+ljIRJSIZwifiYXzirp0wZ3GbsQ8zOd5vmIjIehReu+7e4fRm1/Wfp8q85Yl5otYPxa2HOeDl67aA9WIiCvSH8cSb4QrM6jahAc9T2td5io9GSiWPWaQiA3Th8dOOuPmBaiLWgBZ9k9MzMMJ5lj1F1whW6gTEE=
data/README.md CHANGED
@@ -4,7 +4,7 @@ Detect Language API Client [![Build Status](https://secure.travis-ci.org/detectl
4
4
  Detects language of given text. Returns detected language codes and scores.
5
5
 
6
6
  Before using Detect Language API client you have to setup your personal API key.
7
- You can get it by signing up at http://detectlanguage.com
7
+ You can get it by signing up at https://detectlanguage.com
8
8
 
9
9
  ## Installation
10
10
 
@@ -23,6 +23,9 @@ Otherwise just integrate following code into your apps configuration.
23
23
 
24
24
  DetectLanguage.configure do |config|
25
25
  config.api_key = "YOUR API KEY"
26
+
27
+ # enable secure mode (SSL) if you are passing sensitive data
28
+ # config.secure = true
26
29
  end
27
30
 
28
31
  ## Usage
@@ -50,7 +53,7 @@ If you need just a language code you can use `simple_detect`. It returns just th
50
53
  ### Batch detection
51
54
 
52
55
  It is possible to detect language of several texts with one request.
53
- This method is faster than doing one request per text.
56
+ This method is significantly faster than doing one request per text.
54
57
  To use batch detection just pass array of texts to `detect` method.
55
58
 
56
59
  DetectLanguage.detect(["Buenos dias señor", "Labas rytas"])
@@ -81,14 +84,6 @@ Result is array of detections in the same order as the texts were passed.
81
84
 
82
85
  Array of language codes and names.
83
86
 
84
- ### Secure Mode
85
-
86
- If you are passing sensitive information to the Detect Language API you can enable SSL.
87
-
88
- SSL usage adds data and processing overhead. Please use only if encryption is really necessary.
89
-
90
- DetectLanguage.configuration.secure = true
91
-
92
87
  ## License
93
88
 
94
89
  Detect Language API Client is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
@@ -38,7 +38,7 @@ module DetectLanguage
38
38
  end
39
39
 
40
40
  def user_status
41
- client.post('user/status')
41
+ client.get('user/status')
42
42
  end
43
43
 
44
44
  def languages
@@ -24,15 +24,15 @@ module DetectLanguage
24
24
  def execute(method, params, options)
25
25
  http = setup_http_connection
26
26
  http_method = options[:http_method]
27
- request_params = params.merge(:key => configuration.api_key)
28
27
  request = http_method.new(request_uri(method))
29
28
 
30
29
  if RUBY_VERSION == '1.8.7'
31
- set_form_data_18(request, request_params)
30
+ set_form_data_18(request, params)
32
31
  else
33
- request.set_form_data(request_params)
32
+ request.set_form_data(params)
34
33
  end
35
34
 
35
+ request.add_field('Authorization', 'Bearer ' + configuration.api_key)
36
36
  request.add_field('User-Agent', configuration.user_agent)
37
37
 
38
38
  response = http.request(request)
@@ -1,3 +1,3 @@
1
1
  module DetectLanguage
2
- VERSION = "1.0.7"
2
+ VERSION = '1.1.0'
3
3
  end
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe DetectLanguage do
6
6
 
7
- let(:api_key) { '93dfb956a294140a4370a09584af2ef6' }
7
+ let(:api_key) { ENV['DETECTLANGUAGE_API_KEY'] }
8
8
 
9
9
  before do
10
10
  DetectLanguage.configuration.api_key = api_key
@@ -12,9 +12,9 @@ describe DetectLanguage do
12
12
 
13
13
  context "configuration" do
14
14
  it "should have default configuration values" do
15
- subject.configuration.api_version.should == '0.2'
16
- subject.configuration.host.should == 'ws.detectlanguage.com'
17
- subject.configuration.user_agent.should == 'Detect Language API ruby gem'
15
+ subject.configuration.api_version.should == '0.2'
16
+ subject.configuration.host.should == 'ws.detectlanguage.com'
17
+ subject.configuration.user_agent.should == 'Detect Language API ruby gem'
18
18
  end
19
19
 
20
20
  it "should allow configuring" do
@@ -27,7 +27,7 @@ describe DetectLanguage do
27
27
  end
28
28
 
29
29
  context 'invalid api key' do
30
- let(:api_key) { 'invalid' }
30
+ let(:api_key) {'invalid'}
31
31
 
32
32
  it "should raise exception for invalid key" do
33
33
  lambda {
@@ -56,6 +56,13 @@ describe DetectLanguage do
56
56
  result[1][0]['language'].should == "lt"
57
57
  end
58
58
 
59
+ it "with empty text in the batch it detects correctly" do
60
+ result = subject.detect(["", "Hello", "Jau saulelė vėl atkopdama budino svietą"])
61
+
62
+ result[0].should be_empty
63
+ result[1][0]['language'].should == "en"
64
+ result[2][0]['language'].should == "lt"
65
+ end
59
66
 
60
67
  context 'secure mode' do
61
68
  before { DetectLanguage.configuration.secure = true }
@@ -69,7 +76,7 @@ describe DetectLanguage do
69
76
  end
70
77
 
71
78
  describe '.user_status' do
72
- subject(:user_status) { DetectLanguage.user_status }
79
+ subject(:user_status) {DetectLanguage.user_status}
73
80
 
74
81
  it 'fetches user status' do
75
82
  expect(user_status['date']).to be_kind_of(String)
@@ -82,10 +89,10 @@ describe DetectLanguage do
82
89
  end
83
90
 
84
91
  describe '.languages' do
85
- subject(:languages) { DetectLanguage.languages }
92
+ subject(:languages) {DetectLanguage.languages}
86
93
 
87
94
  it 'fetches list of detectable languages' do
88
- expect(languages).to include({'code' => 'en', 'name' => 'ENGLISH'})
95
+ expect(languages).to include({ 'code' => 'en', 'name' => 'ENGLISH' })
89
96
  end
90
97
  end
91
98
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: detect_language
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurynas Butkus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-02 00:00:00.000000000 Z
11
+ date: 2018-03-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Language Detection API Client
14
14
  email:
@@ -17,9 +17,9 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - .gitignore
21
- - .rspec
22
- - .travis.yml
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".travis.yml"
23
23
  - Gemfile
24
24
  - LICENSE
25
25
  - README.md
@@ -42,17 +42,17 @@ require_paths:
42
42
  - lib
43
43
  required_ruby_version: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - '>='
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  requirements: []
54
54
  rubyforge_project:
55
- rubygems_version: 2.0.14
55
+ rubygems_version: 2.6.11
56
56
  signing_key:
57
57
  specification_version: 4
58
58
  summary: Detects language of given text. Returns detected language codes and scores.