google-translate 0.6.9 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -32,3 +32,8 @@
32
32
  == Version 0.6.7
33
33
 
34
34
  * Deploy on gemcutter
35
+
36
+ == Version 0.7.0
37
+
38
+ * Fix changes in detect languages service
39
+
data/README CHANGED
@@ -3,8 +3,7 @@
3
3
  = Installing Google-Translate
4
4
 
5
5
  == Installing the Gem
6
- $ sudo gem sources -a http://gemcutter.org
7
- $ sudo gem install google-translate
6
+ $ gem install google-translate
8
7
 
9
8
  == Usage
10
9
 
data/Rakefile CHANGED
@@ -7,14 +7,43 @@ require 'spec/rake/spectask'
7
7
  require 'rake/rdoctask'
8
8
  require 'rcov/rcovtask'
9
9
 
10
- # spec_name = 'google_translate.gemspec'
11
- #
12
- # SPEC = Gem::Specification.load(spec_name)
10
+ task :default => :package
13
11
 
14
- # Rake::GemPackageTask.new(SPEC) do |pkg|
15
- # #pkg.need_tar = true
16
- # #pkg.need_zip = true
17
- # end
12
+ begin
13
+ require 'bundler'
14
+
15
+ begin
16
+ require 'jeweler'
17
+
18
+ Jeweler::Tasks.new do |gemspec|
19
+ gemspec.name = "google-translate"
20
+ gemspec.summary = "Simple client for Google Translate API (Summary)."
21
+ gemspec.description = "Simple client for Google Translate API."
22
+ gemspec.email = "alexander.shvets@gmail.com"
23
+ gemspec.homepage = "http://github.com/shvets/google-translate"
24
+ gemspec.authors = ["Alexander Shvets"]
25
+ gemspec.files = FileList["CHANGES", "google-translate.gemspec", "Rakefile", "README", "VERSION",
26
+ "lib/**/*", "bin/**/*"]
27
+ gemspec.add_dependency "json_pure", ">= 1.1.4"
28
+
29
+ gemspec.executables = ['translate', 't']
30
+ gemspec.requirements = ["none"]
31
+ gemspec.bindir = "bin"
32
+
33
+ gemspec.add_bundler_dependencies
34
+ end
35
+ rescue LoadError
36
+ puts "Jeweler not available. Install it s with: [sudo] gem install jeweler"
37
+ end
38
+ rescue LoadError
39
+ puts "Bundler not available. Install it s with: [sudo] gem install bundler"
40
+ end
41
+
42
+ desc "Run gem code locally"
43
+ task :"run:gem" do
44
+ command = "bin/translate " + (ENV['params'].nil? ? '' : ENV['params'])
45
+ puts ruby("#{command}")
46
+ end
18
47
 
19
48
  Spec::Rake::SpecTask.new do |task|
20
49
  task.libs << 'lib'
@@ -36,110 +65,3 @@ Rcov::RcovTask.new do |task|
36
65
  task.verbose = true
37
66
  end
38
67
 
39
- begin
40
- require 'jeweler'
41
- Jeweler::Tasks.new do |gemspec|
42
- gemspec.name = "google-translate"
43
- gemspec.summary = "Simple client for Google Translate API (Summary)."
44
- gemspec.description = "Simple client for Google Translate API."
45
- gemspec.email = "alexander.shvets@gmail.com"
46
- gemspec.homepage = "http://github.com/shvets/google-translate"
47
- gemspec.authors = ["Alexander Shvets"]
48
- gemspec.files = FileList["CHANGES", "google-translate.gemspec", "Rakefile", "README", "VERSION",
49
- "lib/**/*", "bin/**/*"]
50
- gemspec.add_dependency "json_pure", ">= 1.1.4"
51
-
52
- gemspec.executables = ['translate', 't']
53
- gemspec.requirements = ["none"]
54
- gemspec.bindir = "bin"
55
- end
56
- Jeweler::GemcutterTasks.new
57
- rescue LoadError
58
- puts "Jeweler not available. Install it with: sudo gem install technicalsteaks-jeweler -s http://gems.github.com"
59
- end
60
-
61
- desc "Run gem code locally"
62
- task :"run:gem" do
63
- command = "bin/translate " + (ENV['params'].nil? ? '' : ENV['params'])
64
- puts ruby("#{command}")
65
- end
66
-
67
- # desc "test gem compatibility with github"
68
- # task :"github:validate" do
69
- # require 'yaml'
70
- #
71
- # require 'rubygems/specification'
72
- # data = File.read(spec_name)
73
- # spec = nil
74
- #
75
- # if data !~ %r{!ruby/object:Gem::Specification}
76
- # Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
77
- # else
78
- # spec = YAML.load(data)
79
- # end
80
- #
81
- # spec.validate
82
- #
83
- # puts spec
84
- # puts "OK"
85
- # end
86
-
87
- task :default => :package
88
-
89
-
90
- require 'yaml'
91
-
92
- # See: http://underpantsgnome.com/2007/1/16/managing-gems-with-rake
93
-
94
- class Util
95
- def self.load_gems
96
- config = YAML.load_file(
97
- File.join(RAILS_ROOT, 'config', 'gems.yml'))
98
- gems = config[:gems].reject {|gem| ! gem[:load] }
99
- gems.each do |gem|
100
- require_gem gem[:name], gem[:version]
101
- require gem[:name]
102
- end
103
- end
104
- end
105
-
106
- namespace :gems do
107
- require 'rubygems' if RUBY_VERSION.to_f < 1.9
108
-
109
- desc "Download and install all gems required by development"
110
- task :install do
111
- # defaults to --no-rdoc, set DOCS=(anything) to build docs
112
- docs = (ENV['DOCS'].nil? ? '--no-rdoc' : '')
113
- #grab the list of gems/version to check
114
- config = YAML.load_file(File.join('config', 'gems.yml'))
115
- gems = config[:gems]
116
-
117
- gems.each do |gem|
118
- # load the gem spec
119
- gem_spec = YAML.load(`gem spec #{gem[:name]} 2> /dev/null`)
120
- gem_loaded = false
121
- begin
122
- gem_loaded = require_gem gem[:name], gem[:version]
123
- rescue Exception
124
- end
125
-
126
- # if forced
127
- # or there is no gem_spec
128
- # or the spec version doesn't match the required version
129
- # or require_gem returns false
130
- # (return false also happens if the gem has already been loaded)
131
- if !ENV['FORCE'].nil? ||!gem_spec ||
132
- (gem_spec.version.version != gem[:version] && !gem_loaded)
133
- gem_config = gem[:config] ? " -- #{gem[:config]}" : ''
134
- source = gem[:source] || config[:source] || nil
135
- source = "--source #{source}" if source
136
- ret = system "gem install #{gem[:name]} -v #{gem[:version]} #{source} #{docs} #{gem_config}"
137
- # something bad happened, pass on the message
138
- p $? unless ret
139
- else
140
- puts "#{gem[:name]} #{gem[:version]} already installed"
141
- end
142
- end
143
- end
144
- end
145
-
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.9
1
+ 0.7.0
data/bin/translate CHANGED
@@ -42,6 +42,8 @@ class Translate
42
42
 
43
43
  case ARGV.shift
44
44
 
45
+ when /(-v)|(--version)/ then
46
+ p "Version: #{File.open(File::dirname(__FILE__) + "/../VERSION").readlines()}"
45
47
  when 'list' then
46
48
  hash = @translator.supported_languages
47
49
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{google-translate}
8
- s.version = "0.6.9"
8
+ s.version = "0.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alexander Shvets"]
12
- s.date = %q{2010-08-26}
12
+ s.date = %q{2010-09-14}
13
13
  s.description = %q{Simple client for Google Translate API.}
14
14
  s.email = %q{alexander.shvets@gmail.com}
15
15
  s.executables = ["translate", "t"]
@@ -45,11 +45,20 @@ Gem::Specification.new do |s|
45
45
 
46
46
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
47
  s.add_runtime_dependency(%q<json_pure>, [">= 1.1.4"])
48
+ s.add_runtime_dependency(%q<json_pure>, [">= 0"])
49
+ s.add_runtime_dependency(%q<jeweler>, [">= 0"])
50
+ s.add_runtime_dependency(%q<gemcutter>, [">= 0"])
48
51
  else
49
52
  s.add_dependency(%q<json_pure>, [">= 1.1.4"])
53
+ s.add_dependency(%q<json_pure>, [">= 0"])
54
+ s.add_dependency(%q<jeweler>, [">= 0"])
55
+ s.add_dependency(%q<gemcutter>, [">= 0"])
50
56
  end
51
57
  else
52
58
  s.add_dependency(%q<json_pure>, [">= 1.1.4"])
59
+ s.add_dependency(%q<json_pure>, [">= 0"])
60
+ s.add_dependency(%q<jeweler>, [">= 0"])
61
+ s.add_dependency(%q<gemcutter>, [">= 0"])
53
62
  end
54
63
  end
55
64
 
@@ -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, 0, 'sllangdropdown', 'sl', 'old_sl'
102
- to_languages = collect_languages content, 1, 'tllangdropdown', 'tl', 'old_tl'
101
+ from_languages = collect_languages content, 0, 'sl', 'gt-sl'
102
+ to_languages = collect_languages content, 1, 'tl', 'gt-tl'
103
103
 
104
104
  response[:from_languages] = from_languages
105
105
  response[:to_languages] = to_languages
@@ -108,22 +108,26 @@ module Google
108
108
  response
109
109
  end
110
110
 
111
- def collect_languages buffer, index, class_name, tag_name, tag_id
111
+ def collect_languages buffer, index, tag_name, tag_id
112
112
  languages = []
113
113
 
114
114
  spaces = '\s?'
115
115
  quote = '(\s|\'|")?'
116
116
 
117
- class_part = "class#{spaces}=#{spaces}#{quote}#{class_name}#{quote}"
118
- name_part = "name#{spaces}=#{spaces}#{quote}#{tag_name}#{quote}"
117
+
119
118
  id_part = "id#{spaces}=#{spaces}#{quote}#{tag_id}#{quote}"
119
+ name_part = "name#{spaces}=#{spaces}#{quote}#{tag_name}#{quote}"
120
120
  tabindex_part = "tabindex#{spaces}=#{spaces}#{quote}0#{quote}"
121
- re1 = buffer.split(%r{<select#{spaces}#{class_part}#{spaces}#{name_part}#{spaces}#{id_part}#{spaces}#{tabindex_part}#{spaces}>(.*)?</select>}).select{|x| x =~ %r{<option} }
121
+ phrase = "#{spaces}#{id_part}#{spaces}#{name_part}#{spaces}#{tabindex_part}#{spaces}"
122
+
123
+ re1 = buffer.split(%r{<select#{phrase}>(.*)?</select>}).select{|x| x =~ %r{<option} }
124
+
125
+ stopper = "</select></div>"
122
126
 
123
127
  text = re1[index]
124
128
 
125
129
  if index == 0
126
- pos = text.index('</select><span class=langselect')
130
+ pos = text.index(stopper)
127
131
  text = text[0..pos]
128
132
  end
129
133
 
@@ -132,7 +136,7 @@ module Google
132
136
  matches = text.gsub(/selected/i, '').squeeze.scan(re2)
133
137
 
134
138
  matches.each do |m|
135
- languages << Language.new(m[2], m[1])
139
+ languages << Language.new(m[2], m[1])
136
140
  end
137
141
 
138
142
  languages
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-translate
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 6
9
- - 9
10
- version: 0.6.9
8
+ - 7
9
+ - 0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alexander Shvets
@@ -15,13 +15,14 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-26 00:00:00 -04:00
18
+ date: 2010-09-14 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: json_pure
22
+ type: :runtime
23
23
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ name: json_pure
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
27
28
  - - ">="
@@ -32,8 +33,49 @@ dependencies:
32
33
  - 1
33
34
  - 4
34
35
  version: 1.1.4
36
+ requirement: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ type: :runtime
39
+ prerelease: false
40
+ name: json_pure
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 0
49
+ version: "0"
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
35
52
  type: :runtime
36
- version_requirements: *id001
53
+ prerelease: false
54
+ name: jeweler
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirement: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ type: :runtime
67
+ prerelease: false
68
+ name: gemcutter
69
+ version_requirements: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirement: *id004
37
79
  description: Simple client for Google Translate API.
38
80
  email: alexander.shvets@gmail.com
39
81
  executables: