bing_translator 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bing_translator.rb +9 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53e0ddff3b2953227f6e61bbe570910d8ed13648
|
4
|
+
data.tar.gz: fb795bf1aa917a82d9e440e092cbff13b6c970aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca4aec07220956fcdc5245217b47800dbd6aedc65281f38a1aff64136573c3cc822fa6b60ed451e4b34ea84023cf18d8cabee7ffcfb05c869f3dc83cb47d216b
|
7
|
+
data.tar.gz: b4c4ce7fa7243ea69e1eda1e295c90a92f7394d627c1699be005794dcaf71ae12df627dd6a00a6fcb312fd04d1a9dc9eec01222cd9b97c17780e532dc37adaf4
|
data/lib/bing_translator.rb
CHANGED
@@ -10,6 +10,8 @@ require 'net/https'
|
|
10
10
|
require 'nokogiri'
|
11
11
|
require 'json'
|
12
12
|
|
13
|
+
class BingTranslatorException < Exception; end
|
14
|
+
|
13
15
|
class BingTranslator
|
14
16
|
TRANSLATE_URI = 'http://api.microsofttranslator.com/V2/Http.svc/Translate'
|
15
17
|
DETECT_URI = 'http://api.microsofttranslator.com/V2/Http.svc/Detect'
|
@@ -97,6 +99,13 @@ private
|
|
97
99
|
{
|
98
100
|
'Authorization' => "Bearer #{@access_token['access_token']}"
|
99
101
|
})
|
102
|
+
|
103
|
+
if results.response.code.to_i == 200
|
104
|
+
results
|
105
|
+
else
|
106
|
+
html = Nokogiri::HTML(results.body)
|
107
|
+
raise BingTranslatorException, html.xpath("//text()").remove.map(&:to_s).join(' ')
|
108
|
+
end
|
100
109
|
end
|
101
110
|
|
102
111
|
# Private: Get a new access token
|
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
|
+
version: 3.3.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-
|
11
|
+
date: 2013-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -70,3 +70,4 @@ signing_key:
|
|
70
70
|
specification_version: 4
|
71
71
|
summary: Translate using the Bing HTTP API
|
72
72
|
test_files: []
|
73
|
+
has_rdoc:
|