v_trans 0.0.1 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0bb1777aaa577981d9b64c16c29e5f00aee5ac80
4
- data.tar.gz: 86d4ae6bffc4ee5d9e0d45153e68f61d03b2ef2c
3
+ metadata.gz: 28e973e7d090a683f2bd0bd49f652593ce100e37
4
+ data.tar.gz: e522d32d4ba3f13309979ac0c80f59f3334c8f94
5
5
  SHA512:
6
- metadata.gz: 6d717e9419e8ce828516606cb388dc6ad14797983cd34d50ad90dce4314dee6f47a92c2858ae5203d00c98bb4b67668c7e21d5bf649ac87f8454b9decf326853
7
- data.tar.gz: e2d67d28ccca21cf68266303277529521239253ad71ba589e895e34f7fa211961e9141399c16dbfd67c68b3a1686aa3b01893e02e4278b7e620399bd8b2c51f1
6
+ metadata.gz: bbd193db5be3207d9ff87ec3c493bdbaa0a71fdd9f32fad23e5eec1a801cf4683f65af321fe3ff1b7baa01844fb1ee67c123b296ed03e9bcc6b8b8f9e789f4b3
7
+ data.tar.gz: 77f57d7088c352a7009609eb35682f01c32fab467d15a873338711a5899f138043a0a6ff48d9a948e76ed4a529b96975049a6d0add8af0caab3e4ea579ba920f
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  /Gemfile.lock
4
4
  /_yardoc/
5
5
  /coverage/
6
- /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ cache: bundler
3
+
4
+ rvm:
5
+ - 2.0.0
6
+
7
+ script: 'bundle exec rake'
8
+
9
+ notifications:
10
+ email:
11
+ recipients:
12
+ - vinh.nguyenlexuan@asnet.com.vn
13
+ on_failure: always
14
+ on_success: change
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # VTrans
2
2
 
3
+ [![Build Status](https://travis-ci.org/vinhnguyenleasnet/v_trans.svg?branch=master)](https://travis-ci.org/vinhnguyenleasnet/v_trans)
4
+
3
5
  Translate the text from one language to another language.
4
6
 
5
7
  ## Installation
@@ -26,13 +28,13 @@ Please read the links:
26
28
 
27
29
  ```ruby
28
30
  $ require 'v_trans'
29
- $ VTrans("Hello everyone!", "en", "es", "AIzaSyCmt2Xnjn5In0RLu1MzF_KSOHlhlHUG9Vo")
31
+ $ VTrans.translate("Hello everyone!", "en", "es", "AIzaSyCmt2Xnjn5In0RLu1MzF_KSOHlhlHUG9Vo")
30
32
  # "hola a todos!"
31
33
  ```
32
34
 
33
35
  ## Contributing
34
36
 
35
- 1. Fork it ( https://github.com/[vinhnguyenleasnet/v_trans/fork )
37
+ 1. Fork it ( https://github.com/vinhnguyenleasnet/v_trans/fork )
36
38
  2. Create your feature branch (`git checkout -b my-new-feature`)
37
39
  3. Commit your changes (`git commit -am 'Add some feature'`)
38
40
  4. Push to the branch (`git push origin my-new-feature`)
@@ -0,0 +1,198 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: VTrans
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!VTrans.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index (V)</a> &raquo;
35
+
36
+
37
+ <span class="title">VTrans</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: VTrans
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dt class="r1 last">Defined in:</dt>
82
+ <dd class="r1 last">lib/v_trans.rb<span class="defines">,<br />
83
+ lib/v_trans/version.rb,<br /> lib/v_trans/v_trans_api.rb</span>
84
+ </dd>
85
+
86
+ </dl>
87
+ <div class="clear"></div>
88
+
89
+ <h2>Defined Under Namespace</h2>
90
+ <p class="children">
91
+
92
+
93
+
94
+
95
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="VTrans/TranslateApi.html" title="VTrans::TranslateApi (class)">TranslateApi</a></span>
96
+
97
+
98
+ </p>
99
+
100
+ <h2>Constant Summary</h2>
101
+
102
+ <dl class="constants">
103
+
104
+ <dt id="VERSION-constant" class="">VERSION =
105
+
106
+ </dt>
107
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.0.2</span><span class='tstring_end'>&quot;</span></span></pre></dd>
108
+
109
+ </dl>
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+ <h2>
120
+ Class Method Summary
121
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
122
+ </h2>
123
+
124
+ <ul class="summary">
125
+
126
+ <li class="public ">
127
+ <span class="summary_signature">
128
+
129
+ <a href="#translate-class_method" title="translate (class method)">+ (Object) <strong>translate</strong>(text, from_lang, to_lang, api_key) </a>
130
+
131
+
132
+
133
+ </span>
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+ <span class="summary_desc"><div class='inline'></div></span>
144
+
145
+ </li>
146
+
147
+
148
+ </ul>
149
+
150
+
151
+
152
+
153
+ <div id="class_method_details" class="method_details_list">
154
+ <h2>Class Method Details</h2>
155
+
156
+
157
+ <div class="method_details first">
158
+ <h3 class="signature first" id="translate-class_method">
159
+
160
+ + (<tt>Object</tt>) <strong>translate</strong>(text, from_lang, to_lang, api_key)
161
+
162
+
163
+
164
+
165
+
166
+ </h3><table class="source_code">
167
+ <tr>
168
+ <td>
169
+ <pre class="lines">
170
+
171
+
172
+ 5
173
+ 6
174
+ 7</pre>
175
+ </td>
176
+ <td>
177
+ <pre class="code"><span class="info file"># File 'lib/v_trans.rb', line 5</span>
178
+
179
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_translate'>translate</span> <span class='id identifier rubyid_text'>text</span><span class='comma'>,</span> <span class='id identifier rubyid_from_lang'>from_lang</span><span class='comma'>,</span> <span class='id identifier rubyid_to_lang'>to_lang</span><span class='comma'>,</span> <span class='id identifier rubyid_api_key'>api_key</span>
180
+ <span class='const'>TranslateApi</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_text'>text</span><span class='comma'>,</span> <span class='id identifier rubyid_from_lang'>from_lang</span><span class='comma'>,</span> <span class='id identifier rubyid_to_lang'>to_lang</span><span class='comma'>,</span> <span class='id identifier rubyid_api_key'>api_key</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_translate'>translate</span>
181
+ <span class='kw'>end</span></pre>
182
+ </td>
183
+ </tr>
184
+ </table>
185
+ </div>
186
+
187
+ </div>
188
+
189
+ </div>
190
+
191
+ <div id="footer">
192
+ Generated on Wed Feb 25 15:28:25 2015 by
193
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
194
+ 0.8.7.6 (ruby-2.0.0).
195
+ </div>
196
+
197
+ </body>
198
+ </html>
@@ -0,0 +1,310 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: VTrans::TranslateApi
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../';
20
+ framesUrl = "../frames.html#!VTrans/TranslateApi.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../_index.html">Index (T)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../VTrans.html" title="VTrans (module)">VTrans</a></span></span>
36
+ &raquo;
37
+ <span class="title">TranslateApi</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: VTrans::TranslateApi
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName">Object</span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next">VTrans::TranslateApi</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ <dt class="r2 last">Defined in:</dt>
97
+ <dd class="r2 last">lib/v_trans/v_trans_api.rb</dd>
98
+
99
+ </dl>
100
+ <div class="clear"></div>
101
+
102
+
103
+ <h2>Constant Summary</h2>
104
+
105
+ <dl class="constants">
106
+
107
+ <dt id="GOOGLE_TRANSLATE_SERVICE_URL-constant" class="">GOOGLE_TRANSLATE_SERVICE_URL =
108
+
109
+ </dt>
110
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://www.googleapis.com/language/translate/v2</span><span class='tstring_end'>&quot;</span></span></pre></dd>
111
+
112
+ </dl>
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+ <h2>
123
+ Instance Method Summary
124
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
125
+ </h2>
126
+
127
+ <ul class="summary">
128
+
129
+ <li class="public ">
130
+ <span class="summary_signature">
131
+
132
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (TranslateApi) <strong>initialize</strong>(text, from_lang, to_lang, api_key) </a>
133
+
134
+
135
+
136
+ </span>
137
+
138
+
139
+ <span class="note title constructor">constructor</span>
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+ <span class="summary_desc"><div class='inline'>
149
+ <p>A new instance of TranslateApi.</p>
150
+ </div></span>
151
+
152
+ </li>
153
+
154
+
155
+ <li class="public ">
156
+ <span class="summary_signature">
157
+
158
+ <a href="#translate-instance_method" title="#translate (instance method)">- (Object) <strong>translate</strong> </a>
159
+
160
+
161
+
162
+ </span>
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+ <span class="summary_desc"><div class='inline'></div></span>
173
+
174
+ </li>
175
+
176
+
177
+ </ul>
178
+
179
+
180
+ <div id="constructor_details" class="method_details_list">
181
+ <h2>Constructor Details</h2>
182
+
183
+ <div class="method_details first">
184
+ <h3 class="signature first" id="initialize-instance_method">
185
+
186
+ - (<tt><span class='object_link'><a href="" title="VTrans::TranslateApi (class)">TranslateApi</a></span></tt>) <strong>initialize</strong>(text, from_lang, to_lang, api_key)
187
+
188
+
189
+
190
+
191
+
192
+ </h3><div class="docstring">
193
+ <div class="discussion">
194
+
195
+ <p>Returns a new instance of TranslateApi</p>
196
+
197
+
198
+ </div>
199
+ </div>
200
+ <div class="tags">
201
+
202
+
203
+ </div><table class="source_code">
204
+ <tr>
205
+ <td>
206
+ <pre class="lines">
207
+
208
+
209
+ 8
210
+ 9
211
+ 10
212
+ 11
213
+ 12
214
+ 13</pre>
215
+ </td>
216
+ <td>
217
+ <pre class="code"><span class="info file"># File 'lib/v_trans/v_trans_api.rb', line 8</span>
218
+
219
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span> <span class='id identifier rubyid_text'>text</span><span class='comma'>,</span> <span class='id identifier rubyid_from_lang'>from_lang</span><span class='comma'>,</span> <span class='id identifier rubyid_to_lang'>to_lang</span><span class='comma'>,</span> <span class='id identifier rubyid_api_key'>api_key</span>
220
+ <span class='ivar'>@from_lang</span> <span class='op'>=</span> <span class='id identifier rubyid_from_lang'>from_lang</span>
221
+ <span class='ivar'>@to_lang</span> <span class='op'>=</span> <span class='id identifier rubyid_to_lang'>to_lang</span>
222
+ <span class='ivar'>@text</span> <span class='op'>=</span> <span class='id identifier rubyid_text'>text</span>
223
+ <span class='ivar'>@api_key</span> <span class='op'>=</span> <span class='id identifier rubyid_api_key'>api_key</span>
224
+ <span class='kw'>end</span></pre>
225
+ </td>
226
+ </tr>
227
+ </table>
228
+ </div>
229
+
230
+ </div>
231
+
232
+
233
+ <div id="instance_method_details" class="method_details_list">
234
+ <h2>Instance Method Details</h2>
235
+
236
+
237
+ <div class="method_details first">
238
+ <h3 class="signature first" id="translate-instance_method">
239
+
240
+ - (<tt>Object</tt>) <strong>translate</strong>
241
+
242
+
243
+
244
+
245
+
246
+ </h3><table class="source_code">
247
+ <tr>
248
+ <td>
249
+ <pre class="lines">
250
+
251
+
252
+ 15
253
+ 16
254
+ 17
255
+ 18
256
+ 19
257
+ 20
258
+ 21
259
+ 22
260
+ 23
261
+ 24
262
+ 25
263
+ 26
264
+ 27
265
+ 28
266
+ 29
267
+ 30
268
+ 31
269
+ 32
270
+ 33</pre>
271
+ </td>
272
+ <td>
273
+ <pre class="code"><span class="info file"># File 'lib/v_trans/v_trans_api.rb', line 15</span>
274
+
275
+ <span class='kw'>def</span> <span class='id identifier rubyid_translate'>translate</span>
276
+ <span class='kw'>if</span> <span class='ivar'>@text</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@from_lang</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@to_lang</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@api_key</span>
277
+ <span class='id identifier rubyid_translated'>translated</span> <span class='op'>=</span> <span class='id identifier rubyid_trans_service'>trans_service</span> <span class='ivar'>@text</span><span class='comma'>,</span> <span class='ivar'>@from_lang</span><span class='comma'>,</span> <span class='ivar'>@to_lang</span><span class='comma'>,</span> <span class='ivar'>@api_key</span>
278
+
279
+ <span class='kw'>if</span> <span class='id identifier rubyid_translated'>translated</span>
280
+ <span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_translated'>translated</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>data</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>translations</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span>
281
+ <span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_body'>body</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>translatedText</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span>
282
+ <span class='kw'>else</span>
283
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Please check paramaters. Maybe you&#39;re wrong languages code or api key. Thanks</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
284
+ <span class='kw'>end</span>
285
+
286
+ <span class='kw'>return</span> <span class='id identifier rubyid_result'>result</span>
287
+ <span class='kw'>else</span>
288
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Missing &#39;from&#39; language</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='ivar'>@from_lang</span>
289
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Missing &#39;to&#39; language</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='ivar'>@to_lang</span>
290
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Missing &#39;text&#39; for translation</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='ivar'>@text</span>
291
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Missing &#39;api key&#39; for the service</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='ivar'>@api_key</span>
292
+ <span class='kw'>end</span>
293
+ <span class='kw'>end</span></pre>
294
+ </td>
295
+ </tr>
296
+ </table>
297
+ </div>
298
+
299
+ </div>
300
+
301
+ </div>
302
+
303
+ <div id="footer">
304
+ Generated on Wed Feb 25 15:28:25 2015 by
305
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
306
+ 0.8.7.6 (ruby-2.0.0).
307
+ </div>
308
+
309
+ </body>
310
+ </html>