web_translate_it 1.7.0.6 → 1.7.0.7.pre
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.
- data/history.md +4 -0
- data/lib/web_translate_it/util.rb +18 -2
- data/version.yml +1 -1
- metadata +12 -9
data/history.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module WebTranslateIt
|
3
|
+
require 'net/http'
|
4
|
+
require 'net/https'
|
5
|
+
require 'uri'
|
6
|
+
|
3
7
|
# A few useful functions
|
4
8
|
class Util
|
5
9
|
|
@@ -19,14 +23,26 @@ module WebTranslateIt
|
|
19
23
|
# response = http.request(request)
|
20
24
|
# end
|
21
25
|
#
|
26
|
+
# This method will try to connect through a proxy if `http_proxy` is set.
|
27
|
+
#
|
22
28
|
def self.http_connection
|
23
|
-
|
29
|
+
proxy = Util.get_proxy
|
30
|
+
if proxy
|
31
|
+
http = Net::HTTP::Proxy(proxy.host, proxy.port).new('webtranslateit.com', 443)
|
32
|
+
else
|
33
|
+
http = Net::HTTP.new('webtranslateit.com', 443)
|
34
|
+
end
|
24
35
|
http.use_ssl = true
|
25
36
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
26
|
-
http.read_timeout = 20
|
37
|
+
http.open_timeout = http.read_timeout = 20
|
27
38
|
yield http
|
28
39
|
end
|
29
40
|
|
41
|
+
def self.get_proxy
|
42
|
+
http_proxy = ENV["http_proxy"]
|
43
|
+
URI.parse(http_proxy) rescue nil
|
44
|
+
end
|
45
|
+
|
30
46
|
def self.calculate_percentage(processed, total)
|
31
47
|
return 0 if total == 0
|
32
48
|
((processed*10)/total).to_f.ceil*10
|
data/version.yml
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web_translate_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 961916152
|
5
|
+
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 7
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
|
10
|
+
- 7
|
11
|
+
- pre
|
12
|
+
version: 1.7.0.7.pre
|
12
13
|
platform: ruby
|
13
14
|
authors:
|
14
15
|
- "\xC3\x89douard Bri\xC3\xA8re"
|
@@ -16,7 +17,7 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2010-
|
20
|
+
date: 2010-10-12 00:00:00 +02:00
|
20
21
|
default_executable: wti
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
@@ -145,12 +146,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
147
|
none: false
|
147
148
|
requirements:
|
148
|
-
- - "
|
149
|
+
- - ">"
|
149
150
|
- !ruby/object:Gem::Version
|
150
|
-
hash:
|
151
|
+
hash: 25
|
151
152
|
segments:
|
152
|
-
-
|
153
|
-
|
153
|
+
- 1
|
154
|
+
- 3
|
155
|
+
- 1
|
156
|
+
version: 1.3.1
|
154
157
|
requirements: []
|
155
158
|
|
156
159
|
rubyforge_project:
|