bing_translator 3.3.0 → 3.4.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bing_translator.rb +4 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53e0ddff3b2953227f6e61bbe570910d8ed13648
4
- data.tar.gz: fb795bf1aa917a82d9e440e092cbff13b6c970aa
3
+ metadata.gz: 9cc06c8225da2733b070e4802c2a9a5008fb6877
4
+ data.tar.gz: fe975ae7a7f5721d8aeb3578fb62dd3079fbd470
5
5
  SHA512:
6
- metadata.gz: ca4aec07220956fcdc5245217b47800dbd6aedc65281f38a1aff64136573c3cc822fa6b60ed451e4b34ea84023cf18d8cabee7ffcfb05c869f3dc83cb47d216b
7
- data.tar.gz: b4c4ce7fa7243ea69e1eda1e295c90a92f7394d627c1699be005794dcaf71ae12df627dd6a00a6fcb312fd04d1a9dc9eec01222cd9b97c17780e532dc37adaf4
6
+ metadata.gz: 26b891fa711b5b55f7be124572f2d7f895a951c73665265a6586934d4e4755753a54afc017ead0531b9e6fb9a65778a1e25f0a9b52b661242df1105ee2cdaec4
7
+ data.tar.gz: 2abfc115215243aa5ada27835af92db327417a5d0c029bc4575bc16e9f336ab236dd9cda40700a72692acf764fac389deb7137a1caa396cdad05b3ab6f0e5d13
@@ -11,6 +11,7 @@ require 'nokogiri'
11
11
  require 'json'
12
12
 
13
13
  class BingTranslatorException < Exception; end
14
+ class BingTranslatorAuthenticationException < Exception; end
14
15
 
15
16
  class BingTranslator
16
17
  TRANSLATE_URI = 'http://api.microsofttranslator.com/V2/Http.svc/Translate'
@@ -44,7 +45,7 @@ class BingTranslator
44
45
  params[:from] = from unless from.empty?
45
46
  result = result @translate_uri, params
46
47
 
47
- Nokogiri.parse(result.body).xpath("//xmlns:string")[0].content
48
+ Nokogiri.parse(result.body).at_xpath("//xmlns:string").content
48
49
  end
49
50
 
50
51
  def detect(text)
@@ -55,7 +56,7 @@ class BingTranslator
55
56
  }
56
57
  result = result @detect_uri, params
57
58
 
58
- Nokogiri.parse(result.body).xpath("//xmlns:string")[0].content.to_sym
59
+ Nokogiri.parse(result.body).at_xpath("//xmlns:string").content.to_sym
59
60
  end
60
61
 
61
62
  # format: 'audio/wav' [default] or 'audio/mp3'
@@ -134,7 +135,7 @@ private
134
135
 
135
136
  response = http.post(@access_token_uri.path, prepare_param_string(params))
136
137
  @access_token = JSON.parse(response.body)
137
- raise "Authentication error: #{@access_token['error']}" if @access_token["error"]
138
+ raise BingTranslatorAuthenticationException, @access_token['error'] if @access_token["error"]
138
139
  @access_token['expires_at'] = Time.now + @access_token['expires_in'].to_i
139
140
  @access_token
140
141
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bing_translator
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricky Elrod