bing_translator 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/bing_translator.rb +15 -4
  3. metadata +19 -15
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 42f1060b0f46d9c132238b653e2e4ea336d8e822
4
+ data.tar.gz: e5c7a204ba5be51be2d008b83be4cf2d9d979882
5
+ SHA512:
6
+ metadata.gz: 22f5d063b4d9721cc7862f5f3715949313510ad768ab216c3d1f579d3aac270c4731a2e0ea1eee45caba171f8f73b13f63a5e78e36f6db68a94d8104cef5b734
7
+ data.tar.gz: 23555b3c99b95f6032ee4a078c0d6adab68d5ed8fc5bf5c9ee3428812475d64f13364f415248083c94213ab5ff20ef80ef3314dc3989c63e2db2cabb12414895
@@ -17,9 +17,11 @@ class BingTranslator
17
17
  ACCESS_TOKEN_URI = 'https://datamarket.accesscontrol.windows.net/v2/OAuth2-13'
18
18
  SPEAK_URI = 'http://api.microsofttranslator.com/v2/Http.svc/Speak'
19
19
 
20
- def initialize(client_id, client_secret)
20
+ def initialize(client_id, client_secret, skip_ssl_verify = false)
21
21
  @client_id = client_id
22
22
  @client_secret = client_secret
23
+ @skip_ssl_verify = skip_ssl_verify
24
+
23
25
  @translate_uri = URI.parse TRANSLATE_URI
24
26
  @detect_uri = URI.parse DETECT_URI
25
27
  @list_codes_uri = URI.parse LANG_CODE_LIST_URI
@@ -84,10 +86,17 @@ private
84
86
 
85
87
  def result(uri, params={}, headers={})
86
88
  get_access_token
87
- headers['Authorization'] = "Bearer #{@access_token['access_token']}"
88
- result = Net::HTTP.new(uri.host, uri.port).get(
89
+ http = Net::HTTP.new(uri.host, uri.port)
90
+ if uri.scheme == "https"
91
+ http.use_ssl = true
92
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @skip_ssl_verify
93
+ end
94
+
95
+ results = http.get(
89
96
  "#{uri.path}?#{prepare_param_string(params)}",
90
- headers)
97
+ {
98
+ 'Authorization' => "Bearer #{@access_token['access_token']}"
99
+ })
91
100
  end
92
101
 
93
102
  # Private: Get a new access token
@@ -112,6 +121,8 @@ private
112
121
 
113
122
  http = Net::HTTP.new(@access_token_uri.host, @access_token_uri.port)
114
123
  http.use_ssl = true
124
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @skip_ssl_verify
125
+
115
126
  response = http.post(@access_token_uri.path, prepare_param_string(params))
116
127
  @access_token = JSON.parse(response.body)
117
128
  raise "Authentication error: #{@access_token['error']}" if @access_token["error"]
metadata CHANGED
@@ -1,38 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bing_translator
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
5
- prerelease:
4
+ version: 3.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ricky Elrod
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-12 00:00:00.000000000 Z
11
+ date: 2013-04-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: nokogiri
16
- requirement: &10390120 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.5.9
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *10390120
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.5.9
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: json
27
- requirement: &6950060 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ~>
31
32
  - !ruby/object:Gem::Version
32
33
  version: 1.7.7
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *6950060
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.7.7
36
41
  description: Translate strings using the Bing HTTP API. Requires that you have a Client
37
42
  ID and Secret. See README.md for information.
38
43
  email: ricky@elrod.me
@@ -43,26 +48,25 @@ files:
43
48
  - lib/bing_translator.rb
44
49
  homepage: https://www.github.com/CodeBlock/bing_translator-gem
45
50
  licenses: []
51
+ metadata: {}
46
52
  post_install_message:
47
53
  rdoc_options: []
48
54
  require_paths:
49
55
  - lib
50
56
  required_ruby_version: !ruby/object:Gem::Requirement
51
- none: false
52
57
  requirements:
53
- - - ! '>='
58
+ - - '>='
54
59
  - !ruby/object:Gem::Version
55
60
  version: '0'
56
61
  required_rubygems_version: !ruby/object:Gem::Requirement
57
- none: false
58
62
  requirements:
59
- - - ! '>='
63
+ - - '>='
60
64
  - !ruby/object:Gem::Version
61
65
  version: '0'
62
66
  requirements: []
63
67
  rubyforge_project:
64
- rubygems_version: 1.8.17
68
+ rubygems_version: 2.0.3
65
69
  signing_key:
66
- specification_version: 3
70
+ specification_version: 4
67
71
  summary: Translate using the Bing HTTP API
68
72
  test_files: []