dictionary_api 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/dictionary_api/article.rb +6 -2
- data/lib/dictionary_api/client.rb +3 -12
- data/lib/dictionary_api/translation_article.rb +6 -2
- data/lib/dictionary_api.rb +6 -3
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWM3NGVjMDAxN2VkNmNjNjM0NGJlZmQ5ODFhMTE0Y2UwMDE5NTAzNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTkwYzIzNmE1ZTJlZTQyOGJmZDNjMWY0MWEwOWE4YzVkMjI5YjQ5OQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTZmNDE3MjFmODg1MWMxNzNjNzVkNDBiMTMwMGFlNWRiMzY0ZWY3MDY1ODEy
|
10
|
+
NjBmYzViZGU4ZTEyZjc1NGFiZDAyNTgyZjFkYzc3ODY4NGIwMzJjMjFkMjEz
|
11
|
+
MDc3YTNlMGI0ZDJhM2I0MTcyZTc5ZjM1YTE1NGMxZmRjZTliOTM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWNkOGE3YmZiMmEwYmJmZjU2OGI3NGU2Y2E2MTk0ZGI3ZGM2ZmYyZmEyOGQ2
|
14
|
+
OTU5ZmYwNWVmN2ZjNWU0OGY5MmZmY2E0NjVjNzAwM2U5YWE4NWI2ZmNmNDI1
|
15
|
+
YWRhNDI4MWI1ZjdiNmU5ZDdhNmI1OTI1NDM3MGJiMTA2MGEyODk=
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'httpclient'
|
2
2
|
|
3
3
|
module DictionaryAPI
|
4
4
|
|
@@ -8,12 +8,8 @@ module DictionaryAPI
|
|
8
8
|
|
9
9
|
BASE_URL = "https://dictionary.yandex.net/api/v1/dicservice.json/"
|
10
10
|
|
11
|
-
def initialize(key)
|
12
|
-
@api_key = key
|
13
|
-
end
|
14
|
-
|
15
11
|
def execute(path, options = {})
|
16
|
-
response =
|
12
|
+
response = HTTPClient.post(BASE_URL + path, options)
|
17
13
|
self.check_errors(response)
|
18
14
|
end
|
19
15
|
|
@@ -29,11 +25,6 @@ module DictionaryAPI
|
|
29
25
|
when 501 then raise 'Translate direction is not supported'
|
30
26
|
end
|
31
27
|
end
|
32
|
-
|
33
|
-
def build_url(path, options = {})
|
34
|
-
request = BASE_URL + path + "?key=#{@api_key}"
|
35
|
-
options.each_pair { |key, value| request += '&' + key + '=' + value }
|
36
|
-
request
|
37
|
-
end
|
38
28
|
end
|
29
|
+
|
39
30
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module DictionaryAPI
|
2
|
+
|
3
|
+
class TranslationArticle
|
4
|
+
attr_accessor :text, :position, :gender, :animated, :synonym, :meaning, :example, :aspect
|
5
|
+
end
|
6
|
+
|
3
7
|
end
|
data/lib/dictionary_api.rb
CHANGED
@@ -18,15 +18,18 @@ module DictionaryAPI
|
|
18
18
|
|
19
19
|
def lookup(lang, text)
|
20
20
|
text.gsub!(' ', '%20')
|
21
|
-
response= JSON.parse client.execute('lookup', {
|
22
|
-
parser = Parser.new
|
21
|
+
response= JSON.parse client.execute('lookup', {key: @api_key, lang: lang, text: text}).body
|
23
22
|
parser.parse(response)
|
24
23
|
end
|
25
24
|
|
26
25
|
protected
|
27
26
|
|
28
27
|
def client
|
29
|
-
@client ||= Client.new
|
28
|
+
@client ||= Client.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def parser
|
32
|
+
@parser ||= Parser.new
|
30
33
|
end
|
31
34
|
end
|
32
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dictionary_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- spitsman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,19 +53,25 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: httpclient
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '2.6'
|
62
|
+
- - ~>
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '2.4'
|
62
65
|
type: :runtime
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
66
69
|
- - ~>
|
67
70
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
71
|
+
version: '2.6'
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '2.4'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: json
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|