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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjYyMDMxN2JlZDQ0MzJmNGU0OWJmY2YxMmY4YmUwYmM0ZGQxZWE0Mg==
4
+ MWM3NGVjMDAxN2VkNmNjNjM0NGJlZmQ5ODFhMTE0Y2UwMDE5NTAzNQ==
5
5
  data.tar.gz: !binary |-
6
- MTM3MGQ2ZTdhNDMyZmUzOGNmOWJhZTk4ZmRlZGVjMGYzZTczZWJhNA==
6
+ MTkwYzIzNmE1ZTJlZTQyOGJmZDNjMWY0MWEwOWE4YzVkMjI5YjQ5OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDY2MWMwOTc0NWVkYjBkMmUyMzFlNDYzNWM5YTY1YzgzYjVjZGMwYjAwNzU0
10
- ZjgxMzE2ZTc2OTI2NmU1NzY5YmIyMTI1ZTUzMjZkNTlhZmNhMWM3YWJlMjk3
11
- OTFhMzU5ZDQ1YTQ0ZDZhZjNlZWFhZWZlYWY2OTNlYmExODFmMTc=
9
+ YTZmNDE3MjFmODg1MWMxNzNjNzVkNDBiMTMwMGFlNWRiMzY0ZWY3MDY1ODEy
10
+ NjBmYzViZGU4ZTEyZjc1NGFiZDAyNTgyZjFkYzc3ODY4NGIwMzJjMjFkMjEz
11
+ MDc3YTNlMGI0ZDJhM2I0MTcyZTc5ZjM1YTE1NGMxZmRjZTliOTM=
12
12
  data.tar.gz: !binary |-
13
- MzAwYzBmMDhjZTNiNDkwOTQ1NDNmNjg0Yzg0NTk2OTFhNTJiOTdiM2EwODA0
14
- NDRhZTc5ZTZkZmZlZjJiZmJjZjE4ODdhOTNkZjU4Y2JiMzVhNzgxZmNjZjJm
15
- Y2FmZWJiNzA1MDNmMWU1NzMxYTI2MzA0OGEwNjUwMWJmNzhmMDM=
13
+ YWNkOGE3YmZiMmEwYmJmZjU2OGI3NGU2Y2E2MTk0ZGI3ZGM2ZmYyZmEyOGQ2
14
+ OTU5ZmYwNWVmN2ZjNWU0OGY5MmZmY2E0NjVjNzAwM2U5YWE4NWI2ZmNmNDI1
15
+ YWRhNDI4MWI1ZjdiNmU5ZDdhNmI1OTI1NDM3MGJiMTA2MGEyODk=
@@ -1,3 +1,7 @@
1
- class Article
2
- attr_accessor :text, :position, :transcription, :translation
1
+ module DictionaryAPI
2
+
3
+ class Article
4
+ attr_accessor :text, :position, :transcription, :translation
5
+ end
6
+
3
7
  end
@@ -1,4 +1,4 @@
1
- require 'httparty'
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 = HTTParty.post(self.build_url(path, options))
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
- class TranslationArticle
2
- attr_accessor :text, :position, :gender, :animated, :synonym, :meaning, :example, :aspect
1
+ module DictionaryAPI
2
+
3
+ class TranslationArticle
4
+ attr_accessor :text, :position, :gender, :animated, :synonym, :meaning, :example, :aspect
5
+ end
6
+
3
7
  end
@@ -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', {'lang'=>lang, 'text'=>text}).body
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(api_key)
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.11
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-10 00:00:00.000000000 Z
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: httparty
56
+ name: httpclient
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0.13'
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: '0.13'
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