ms_translate 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/ms_translate/version.rb +1 -1
- data/lib/ms_translate.rb +23 -16
- data/ms_translate.gemspec +1 -0
- data/spec/lib/ms_translate/api_spec.rb +5 -8
- metadata +52 -23
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YjBlODYzNGU2M2U5Njc5MTQ0ZDVlNzM4ZjAxZGQyYTQ3MTBlMmQ0Nw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MWM0NWMxYWQ0MTI4ZjQ0Y2Q4NzRiOWFiNDk2NDhiMGVlMzU1NThhNg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZjFlMjg1ODgwODA4NWJmNDhkNzhjZjIxNmIwOTcxMjMzNjk3YmNjOWM0MDli
|
10
|
+
NzA3NjRiYWFiYmE3MTFhNzU2ZDU4NjJhODYzZmM0YmI5YzU4ODA1YWY0M2Iy
|
11
|
+
ZDZlZDU4YTg4MzgwMTlmNzA5ZjRkZWMxMDZkYzQ4M2E1YjJlNzI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OGI4YjNjMWUzZjVmY2NhOWU1OTk2MDNiZWQ1YjllZjVlNjdlOTJjNjBlMjVm
|
14
|
+
ZDIxZmJhNjEwNTM5MDkwNjg2YjNiY2NiMjIyZGNkYTkxNWRlMWEzOWZmMzVh
|
15
|
+
YTgyNDc1ZjkyM2MxMGZkODhiM2U0MDMwYTcwZjhmZjJlNjgyM2M=
|
data/lib/ms_translate/version.rb
CHANGED
data/lib/ms_translate.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'rubygems' unless defined?(Gem)
|
2
2
|
require 'httparty'
|
3
|
+
require 'active_support/inflector/methods'
|
4
|
+
require 'active_support/inflector/inflections'
|
3
5
|
require 'ms_translate/version'
|
4
6
|
|
5
7
|
##
|
@@ -7,24 +9,28 @@ require 'ms_translate/version'
|
|
7
9
|
#
|
8
10
|
# @author Carlo Bertini
|
9
11
|
#
|
10
|
-
|
12
|
+
class String
|
11
13
|
##
|
12
|
-
#
|
14
|
+
# By default, +camelize+ converts strings to UpperCamelCase. If the argument to camelize
|
15
|
+
# is set to <tt>:lower</tt> then camelize produces lowerCamelCase.
|
13
16
|
#
|
14
|
-
#
|
17
|
+
# +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces.
|
15
18
|
#
|
16
|
-
#
|
17
|
-
#
|
19
|
+
# "active_record".camelize # => "ActiveRecord"
|
20
|
+
# "active_record".camelize(:lower) # => "activeRecord"
|
21
|
+
# "active_record/errors".camelize # => "ActiveRecord::Errors"
|
22
|
+
# "active_record/errors".camelize(:lower) # => "activeRecord::Errors"
|
18
23
|
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def camelize()
|
24
|
-
self.dup.split(/_/).map{ |word| word.capitalize }.join('')
|
24
|
+
def camelize(first_letter = :upper)
|
25
|
+
case first_letter
|
26
|
+
when :upper then ActiveSupport::Inflector.camelize(self, true)
|
27
|
+
when :lower then ActiveSupport::Inflector.camelize(self, false)
|
25
28
|
end
|
26
29
|
end
|
30
|
+
alias_method :camelcase, :camelize
|
31
|
+
end
|
27
32
|
|
33
|
+
module MsTranslate
|
28
34
|
##
|
29
35
|
# Wrapper for Microsoft Translator V2
|
30
36
|
#
|
@@ -141,7 +147,7 @@ module MsTranslate
|
|
141
147
|
# two-character Language codes for each row of the input array
|
142
148
|
#
|
143
149
|
def self.detect_array(texts)
|
144
|
-
|
150
|
+
raise MsTranslate::Api::HTTPMethodNotAllowed
|
145
151
|
end
|
146
152
|
|
147
153
|
##
|
@@ -162,7 +168,8 @@ module MsTranslate
|
|
162
168
|
# into the requested language
|
163
169
|
#
|
164
170
|
def self.get_language_names(locale, v1 = false)
|
165
|
-
|
171
|
+
raise MsTranslate::Api::HTTPMethodNotAllowed
|
172
|
+
# wrapper( __method__.to_s.camelize, { :locale => locale.to_s, :v1 => v1 })
|
166
173
|
end
|
167
174
|
|
168
175
|
##
|
@@ -223,7 +230,7 @@ module MsTranslate
|
|
223
230
|
#
|
224
231
|
#
|
225
232
|
def self.get_translations(text, max_translations)
|
226
|
-
|
233
|
+
raise MsTranslate::Api::HTTPMethodNotAllowed
|
227
234
|
end
|
228
235
|
|
229
236
|
##
|
@@ -252,7 +259,7 @@ module MsTranslate
|
|
252
259
|
# Returns a GetTranslationsResponse array
|
253
260
|
#
|
254
261
|
def self.get_translations_array(texts, max_translations)
|
255
|
-
|
262
|
+
raise MsTranslate::Api::HTTPMethodNotAllowed
|
256
263
|
end
|
257
264
|
|
258
265
|
##
|
@@ -295,7 +302,7 @@ module MsTranslate
|
|
295
302
|
# @return [Array]
|
296
303
|
# Returns a TranslateArrayResponse array
|
297
304
|
def self.translate_array(texts)
|
298
|
-
|
305
|
+
raise MsTranslate::Api::HTTPMethodNotAllowed
|
299
306
|
end
|
300
307
|
|
301
308
|
##
|
data/ms_translate.gemspec
CHANGED
@@ -47,14 +47,12 @@ describe MsTranslate::Api do
|
|
47
47
|
|
48
48
|
it "load list language available with appId code" do
|
49
49
|
MsTranslate::Api.appId.must_equal @api_real
|
50
|
-
MsTranslate::Api.get('GetLanguagesForTranslate', :query => {
|
51
|
-
:appId => MsTranslate::Api.appId
|
52
|
-
})
|
50
|
+
MsTranslate::Api.get('GetLanguagesForTranslate', :query => {:appId => MsTranslate::Api.appId })
|
53
51
|
end
|
52
|
+
|
54
53
|
it 'translate Ciao Mondo! from en to it' do
|
55
54
|
translate = MsTranslate::Api.translate('Hello World!', {:from => :en, :to => :it })
|
56
55
|
translate.must_equal 'Salve, mondo!'
|
57
|
-
|
58
56
|
end
|
59
57
|
|
60
58
|
it 'translate Ciao Mondo! from it to fr' do
|
@@ -70,7 +68,7 @@ describe MsTranslate::Api do
|
|
70
68
|
it 'must have a list language available' do
|
71
69
|
MsTranslate::Api.get_languages_for_translate
|
72
70
|
MsTranslate::Api.get_languages_for_translate.must_be_instance_of Array
|
73
|
-
MsTranslate::Api.get_languages_for_translate.must_equal
|
71
|
+
MsTranslate::Api.get_languages_for_translate.must_equal ["ar", "bg", "ca", "zh-CHS", "zh-CHT", "cs", "da", "nl", "en", "et", "fi", "fr", "de", "el", "ht", "he", "hi", "mww", "hu", "id", "it", "ja", "ko", "lv", "lt", "ms", "no", "fa", "pl", "pt", "ro", "ru", "sk", "sl", "es", "sv", "th", "tr", "uk", "ur", "vi"]
|
74
72
|
end
|
75
73
|
|
76
74
|
it 'translate Hello World! with invalid language' do
|
@@ -100,8 +98,7 @@ describe MsTranslate::Api do
|
|
100
98
|
end
|
101
99
|
|
102
100
|
it 'Get a list of the languages supported by the Translator Service *' do
|
103
|
-
lambda { MsTranslate::Api.get_language_names(:it
|
104
|
-
MsTranslate::Api.get_language_names(:it, true).must_include 'Italiano'
|
101
|
+
lambda { MsTranslate::Api.get_language_names(:it) }.must_raise MsTranslate::Api::HTTPMethodNotAllowed
|
105
102
|
end
|
106
103
|
|
107
104
|
it 'Get a list of the language codes supported by the Translator Service for speech synthesis.' do
|
@@ -134,7 +131,7 @@ describe MsTranslate::Api do
|
|
134
131
|
it 'Get an array of sentence lengths for each sentence of the given text' do
|
135
132
|
MsTranslate::Api.break_sentences('Hello World!', 'en').must_equal '12'
|
136
133
|
MsTranslate::Api.break_sentences('Ciao Mondo! Visto che bella giornata?', 'it').must_equal ['12', '25']
|
137
|
-
|
138
134
|
end
|
135
|
+
|
139
136
|
end
|
140
137
|
end
|
metadata
CHANGED
@@ -1,71 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ms_translate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Carlo Bertini
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-03-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: httparty
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.1.0
|
25
41
|
- !ruby/object:Gem::Dependency
|
26
42
|
name: webmock
|
27
|
-
requirement:
|
28
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
29
44
|
requirements:
|
30
45
|
- - ! '>='
|
31
46
|
- !ruby/object:Gem::Version
|
32
47
|
version: '0'
|
33
48
|
type: :development
|
34
49
|
prerelease: false
|
35
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
36
55
|
- !ruby/object:Gem::Dependency
|
37
56
|
name: vcr
|
38
|
-
requirement:
|
39
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
40
58
|
requirements:
|
41
59
|
- - ! '>='
|
42
60
|
- !ruby/object:Gem::Version
|
43
61
|
version: '0'
|
44
62
|
type: :development
|
45
63
|
prerelease: false
|
46
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
47
69
|
- !ruby/object:Gem::Dependency
|
48
70
|
name: turn
|
49
|
-
requirement:
|
50
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
51
72
|
requirements:
|
52
73
|
- - ! '>='
|
53
74
|
- !ruby/object:Gem::Version
|
54
75
|
version: '0'
|
55
76
|
type: :development
|
56
77
|
prerelease: false
|
57
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
58
83
|
- !ruby/object:Gem::Dependency
|
59
84
|
name: rake
|
60
|
-
requirement:
|
61
|
-
none: false
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
62
86
|
requirements:
|
63
87
|
- - ! '>='
|
64
88
|
- !ruby/object:Gem::Version
|
65
89
|
version: '0'
|
66
90
|
type: :development
|
67
91
|
prerelease: false
|
68
|
-
version_requirements:
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
description: MsTranslate is a wrapper for the Microsoft Translator API
|
70
98
|
email:
|
71
99
|
- waydotnet@gmail.com
|
@@ -84,27 +112,28 @@ files:
|
|
84
112
|
- spec/spec_helper.rb
|
85
113
|
homepage: http://www.waydotnet.com
|
86
114
|
licenses: []
|
115
|
+
metadata: {}
|
87
116
|
post_install_message:
|
88
117
|
rdoc_options: []
|
89
118
|
require_paths:
|
90
119
|
- lib
|
91
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
121
|
requirements:
|
94
122
|
- - ! '>='
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: '0'
|
97
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
126
|
requirements:
|
100
127
|
- - ! '>='
|
101
128
|
- !ruby/object:Gem::Version
|
102
129
|
version: '0'
|
103
130
|
requirements: []
|
104
131
|
rubyforge_project:
|
105
|
-
rubygems_version:
|
132
|
+
rubygems_version: 2.0.3
|
106
133
|
signing_key:
|
107
|
-
specification_version:
|
134
|
+
specification_version: 4
|
108
135
|
summary: Microsoft Translator API Wrapper for Ruby
|
109
|
-
test_files:
|
136
|
+
test_files:
|
137
|
+
- spec/lib/ms_translate/api_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
110
139
|
has_rdoc:
|