bing_translator 3.4.0 → 4.0.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 +5 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9cc06c8225da2733b070e4802c2a9a5008fb6877
4
- data.tar.gz: fe975ae7a7f5721d8aeb3578fb62dd3079fbd470
3
+ metadata.gz: 215d7a5fcf887591e5b6d7e8133cc995ae0e656c
4
+ data.tar.gz: 1f02356a8a7c04cba1ec36184c2481b8d3199904
5
5
  SHA512:
6
- metadata.gz: 26b891fa711b5b55f7be124572f2d7f895a951c73665265a6586934d4e4755753a54afc017ead0531b9e6fb9a65778a1e25f0a9b52b661242df1105ee2cdaec4
7
- data.tar.gz: 2abfc115215243aa5ada27835af92db327417a5d0c029bc4575bc16e9f336ab236dd9cda40700a72692acf764fac389deb7137a1caa396cdad05b3ab6f0e5d13
6
+ metadata.gz: c31d2e26d1c7a606c37f9cda72ddd220ae25598311b6d28fc3d87b3fd0fab81c35480c2427ef3101215beebc33ed335482f6102b26a129fea4f109fb16cc678d
7
+ data.tar.gz: ae3854820d91eee8a22ba7bf3ef9cbf5d571f3d7602e9d9839b869a4d5836dd280e1bd6d0dd57b814c5649b9f82c0048ce294284679dbefc53ba5e1a22e56a81
@@ -10,9 +10,6 @@ require 'net/https'
10
10
  require 'nokogiri'
11
11
  require 'json'
12
12
 
13
- class BingTranslatorException < Exception; end
14
- class BingTranslatorAuthenticationException < Exception; end
15
-
16
13
  class BingTranslator
17
14
  TRANSLATE_URI = 'http://api.microsofttranslator.com/V2/Http.svc/Translate'
18
15
  DETECT_URI = 'http://api.microsofttranslator.com/V2/Http.svc/Detect'
@@ -20,6 +17,9 @@ class BingTranslator
20
17
  ACCESS_TOKEN_URI = 'https://datamarket.accesscontrol.windows.net/v2/OAuth2-13'
21
18
  SPEAK_URI = 'http://api.microsofttranslator.com/v2/Http.svc/Speak'
22
19
 
20
+ class Exception < StandardError; end
21
+ class AuthenticationException < StandardError; end
22
+
23
23
  def initialize(client_id, client_secret, skip_ssl_verify = false)
24
24
  @client_id = client_id
25
25
  @client_secret = client_secret
@@ -105,7 +105,7 @@ private
105
105
  results
106
106
  else
107
107
  html = Nokogiri::HTML(results.body)
108
- raise BingTranslatorException, html.xpath("//text()").remove.map(&:to_s).join(' ')
108
+ raise Exception, html.xpath("//text()").remove.map(&:to_s).join(' ')
109
109
  end
110
110
  end
111
111
 
@@ -135,7 +135,7 @@ private
135
135
 
136
136
  response = http.post(@access_token_uri.path, prepare_param_string(params))
137
137
  @access_token = JSON.parse(response.body)
138
- raise BingTranslatorAuthenticationException, @access_token['error'] if @access_token["error"]
138
+ raise AuthenticationException, @access_token['error'] if @access_token["error"]
139
139
  @access_token['expires_at'] = Time.now + @access_token['expires_in'].to_i
140
140
  @access_token
141
141
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bing_translator
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricky Elrod
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-10 00:00:00.000000000 Z
11
+ date: 2013-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri