google-translate 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/google_translate.gemspec +4 -4
- data/lib/google_translate.rb +10 -6
- data/spec/translate_spec.rb +1 -1
- metadata +21 -10
data/google_translate.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{google-translate}
|
5
|
-
s.version = "0.6.
|
5
|
+
s.version = "0.6.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
|
9
9
|
s.authors = ["Alexander Shvets"]
|
10
|
-
s.date = %q{
|
10
|
+
s.date = %q{2010-04-28}
|
11
11
|
s.description = %q{Simple client for Google Translate API.}
|
12
12
|
s.email = %q{alexander.shvets@gmail.com}
|
13
13
|
|
@@ -15,10 +15,10 @@ Gem::Specification.new do |s|
|
|
15
15
|
"bin/translate", "bin/translate.bat", "spec/spec_helper.rb" , "spec/translate_spec.rb"]
|
16
16
|
|
17
17
|
s.has_rdoc = true
|
18
|
-
s.homepage = %q{http://github.com/shvets/
|
18
|
+
s.homepage = %q{http://github.com/shvets/google-translate}
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
s.rubyforge_project = %q{google_translate}
|
21
|
-
s.rubygems_version = %q{1.3.
|
21
|
+
s.rubygems_version = %q{1.3.6}
|
22
22
|
s.summary = %q{Simple client for Google Translate API.}
|
23
23
|
|
24
24
|
if s.respond_to? :specification_version then
|
data/lib/google_translate.rb
CHANGED
@@ -98,8 +98,8 @@ module Google
|
|
98
98
|
open(URI.escape(request)) do |stream|
|
99
99
|
content = stream.read
|
100
100
|
|
101
|
-
from_languages = collect_languages content, 'sl', 'old_sl'
|
102
|
-
to_languages = collect_languages content, 'tl', 'old_tl'
|
101
|
+
from_languages = collect_languages content, 'sllangdropdown', 'sl', 'old_sl'
|
102
|
+
to_languages = collect_languages content, 'tllangdropdown', 'tl', 'old_tl'
|
103
103
|
|
104
104
|
response[:from_languages] = from_languages
|
105
105
|
response[:to_languages] = to_languages
|
@@ -108,15 +108,19 @@ module Google
|
|
108
108
|
response
|
109
109
|
end
|
110
110
|
|
111
|
-
def collect_languages buffer, tag_name, tag_id
|
111
|
+
def collect_languages buffer, class_name, tag_name, tag_id
|
112
112
|
languages = []
|
113
113
|
|
114
114
|
spaces = '\s?'
|
115
115
|
quote = '(\s|\'|")?'
|
116
|
-
text = '(.*)'
|
117
116
|
|
118
|
-
|
119
|
-
|
117
|
+
class_part = "class#{spaces}=#{spaces}#{quote}#{class_name}#{quote}"
|
118
|
+
name_part = "name#{spaces}=#{spaces}#{quote}#{tag_name}#{quote}"
|
119
|
+
id_part = "id#{spaces}=#{spaces}#{quote}old_sl#{quote}"
|
120
|
+
tabindex_part = "tabindex#{spaces}=#{spaces}#{quote}0#{quote}"
|
121
|
+
|
122
|
+
re1 = buffer.split(%r{<select#{spaces}#{class_part}#{spaces}#{name_part}#{spaces}#{id_part}#{spaces}#{tabindex_part}#{spaces}>(.*)?</select>}).select{|x| x =~ %r{<option} }
|
123
|
+
text = re1[0]
|
120
124
|
|
121
125
|
re2 = /<option(\s*)value="([a-z|A-Z]*)">([a-z|A-Z]*)<\/option>/
|
122
126
|
|
data/spec/translate_spec.rb
CHANGED
@@ -47,7 +47,7 @@ module Google
|
|
47
47
|
@translator.detect_language("azafretmkldt")['isReliable'].should be_false
|
48
48
|
end
|
49
49
|
|
50
|
-
it "should return list of
|
50
|
+
it "should return list of supported languages" do
|
51
51
|
languages = @translator.supported_languages
|
52
52
|
|
53
53
|
languages[:from_languages].size.should > 0
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-translate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 6
|
8
|
+
- 5
|
9
|
+
version: 0.6.5
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Alexander Shvets
|
@@ -9,19 +14,23 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-04-28 00:00:00 -04:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: json_pure
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 1
|
30
|
+
- 4
|
23
31
|
version: 1.1.4
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
description: Simple client for Google Translate API.
|
26
35
|
email: alexander.shvets@gmail.com
|
27
36
|
executables:
|
@@ -42,7 +51,7 @@ files:
|
|
42
51
|
- spec/spec_helper.rb
|
43
52
|
- spec/translate_spec.rb
|
44
53
|
has_rdoc: true
|
45
|
-
homepage: http://github.com/shvets/
|
54
|
+
homepage: http://github.com/shvets/google-translate
|
46
55
|
licenses: []
|
47
56
|
|
48
57
|
post_install_message:
|
@@ -54,18 +63,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
54
63
|
requirements:
|
55
64
|
- - ">="
|
56
65
|
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
57
68
|
version: "0"
|
58
|
-
version:
|
59
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
70
|
requirements:
|
61
71
|
- - ">="
|
62
72
|
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
63
75
|
version: "0"
|
64
|
-
version:
|
65
76
|
requirements:
|
66
77
|
- none
|
67
78
|
rubyforge_project: google_translate
|
68
|
-
rubygems_version: 1.3.
|
79
|
+
rubygems_version: 1.3.6
|
69
80
|
signing_key:
|
70
81
|
specification_version: 2
|
71
82
|
summary: Simple client for Google Translate API.
|