yandex-translator-api 0.9.2 → 1.0.0

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: c0f4b1bdcb3caa7e79e5debce7faf671cbe7f7db
4
- data.tar.gz: 05b5cfec72eaa8ccfcb2830bc43a5dee11eab241
3
+ metadata.gz: 46d9608bcfdc944f75b0b5f4df553b3db20cef4a
4
+ data.tar.gz: ead7ffaf10b823fa0fae61c843374c37fedcef42
5
5
  SHA512:
6
- metadata.gz: 3a2209a2e80482dffff70bb557d28a488320ac4cff0d05d207400317b39d80526eeafd1916bdafa33132b445ea09dcad75d595d7ed58c6163fc2399e129c0070
7
- data.tar.gz: 412c3a1c025e1ea7924bcb032e53f339a460724cb210aed7ea4c561362ccbef47cdcbe83c24dc5ec4344a069866322e31781a7dcf3587b35051e25045a2bf8e7
6
+ metadata.gz: 67c3ed3b8634f8f1108e6d0a495f97555fe6a16ee84c9308a2d23cb7778385e8ac6c9bc5cff63c8f2dba55a888320f0cb23f1240b807c229601008a30f3681a2
7
+ data.tar.gz: 43d444a507b52c87a0f588c7421be5835994360fb51b0a40f8f5cc325a1b7558d4e4b938a5ae3c0d4fddcc781a5ffe62b4182a63e5c87a2bf3a2f823f698e027
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Yandex Translator API
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/yandex`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Text translating by Yandex Translator API
4
4
 
5
5
  ## Installation
6
6
 
@@ -20,20 +20,51 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ Create Translator object.
24
24
 
25
- ## Development
25
+ ```ruby
26
+ translator = Yandex::Translator.new('api_key')
27
+ ```
28
+
29
+ ### Langs
30
+
31
+ Request for getting possible translation directions is #langs.
32
+
33
+ ```ruby
34
+ translator.langs
35
+ ```
36
+
37
+ It returns array of possible translations or error.
38
+
39
+ ### Detect
40
+
41
+ Request for detecting language of the text is #detect.
26
42
 
27
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
+ ```ruby
44
+ translator.detect text: 'Hello', hint: 'en,de'
45
+ ```
46
+
47
+ It returns locale of the text or error.
48
+ text - text for detecting, required param
49
+ hint - list of possible languages
50
+
51
+ ### Translate
52
+
53
+ Request for translating of the text is #translate.
28
54
 
29
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
55
+ ```ruby
56
+ translator.translate text: 'Hello', from: 'en', to: 'ru'
57
+ ```
58
+
59
+ It returns translated text or error.
60
+ text - text for detecting, required param
61
+ from - language of the text
62
+ to - translating direction, required param
30
63
 
31
64
  ## Contributing
32
65
 
33
66
  Bug reports and pull requests are welcome on GitHub at https://github.com/kortirso/yandex-translator-api.
34
67
 
35
-
36
68
  ## License
37
69
 
38
70
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
39
-
@@ -2,7 +2,7 @@ module Yandex
2
2
  class Translator
3
3
  module Detect
4
4
 
5
- def detect(args)
5
+ def detect(args = {})
6
6
  check_args(text: args[:text])
7
7
  response = call('/detect', { hint: args[:hint], text: args[:text] })
8
8
  JSON.parse(response.body)['lang']
@@ -2,7 +2,7 @@ module Yandex
2
2
  class Translator
3
3
  module Translate
4
4
 
5
- def translate(args)
5
+ def translate(args = {})
6
6
  check_args(text: args[:text], to: args[:to])
7
7
  translate_direction = args[:from].nil? ? args[:to] : "#{args[:from]}-#{args[:to]}"
8
8
  response = call('/translate', { lang: translate_direction, text: args[:text] })
@@ -1,3 +1,3 @@
1
1
  module Yandex
2
- VERSION = '0.9.2'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yandex-translator-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Bogdanov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2017-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler