a_parser_client 0.1.1 → 0.1.6

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
  SHA256:
3
- metadata.gz: 487f5511052850dd7cd2d7b12a95651feaced8b69b252668d2c7abae5dc9ef50
4
- data.tar.gz: d8e84bd9df18a3d58c7760e6b6b31d5ce8b8d9f0e3e40040dcc8155cdde4a5f0
3
+ metadata.gz: 9ce1ab499b36e7ca18f90688137769f8a4dc153a1b7c6ffc683ec967fda1c6ff
4
+ data.tar.gz: 21f8cb0c7fab8275665471654c6fa9a1029412f37a236455fec9aa20951ef651
5
5
  SHA512:
6
- metadata.gz: 6be47c0a62d050e309e0c4f3321fddf26e90d3b11c146593ebc9053f80cf4f742bc553d2a30ebdebddb7c26a86a24246559c0db71d8eff20bcce46d66e95d8c9
7
- data.tar.gz: f82d899c71bd7222e5ea725f6aa842b931ba5584b6293fff0d83589a66f4762bcd5f088dcb2b5b9d93ad812d48202ff67c5fbd12466dc2352489289090e5ca3d
6
+ metadata.gz: 40deb64d676410e4c1bfc35c33078eb589855459378456806f3e7d3b07c1db47e53b4a9d6dd43a1be70512bc671b538ad25c4eb16a265f31d44d555b8a0181ed
7
+ data.tar.gz: 3280913d3d3afad37c3132074a015704de50e89bc9ed2f78e3905f86e073c9173f199fcdcfbdb7aeacbcb50784f69eebd03b793c08d1d37887b75ccf487d7574
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- a_parser_client (0.1.1)
4
+ a_parser_client (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # AParserClient
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/a_parser_client.svg)](https://badge.fury.io/rb/a_parser_client)
4
+
5
+ Ruby client for A-Parser user API.
6
+
7
+ This is a test release, more API coverage is upcoming.
8
+
9
+ Covered for now:
10
+
11
+ - ping
12
+ - info
13
+ - getTaskList
14
+ - getTaskState
15
+ - getTaskConf
16
+ - addTask
17
+ - changeTaskStatus
18
+ - getAccountsCount
19
+ - getProxies
20
+ - update
21
+ - getTaskResultsFile
22
+ - deleteTaskResultsFile
23
+ - moveTask
24
+ - getParserInfo
25
+ - getParserPreset
26
+
27
+ TODO:
28
+
29
+ - oneRequest
30
+ - bulkRequest
31
+
32
+
33
+
3
34
  ## Installation
4
35
 
5
36
  Add this line to your application's Gemfile:
@@ -18,7 +49,18 @@ Or install it yourself as:
18
49
 
19
50
  ## Usage
20
51
 
21
- TODO: Write usage instructions here
52
+ There will be a wiki page soon.
53
+
54
+ The code sample below is all for now...
55
+
56
+ ```ruby
57
+ require 'a_parser_client'
58
+
59
+ api = AParserClient::API.new 'http://<your_host_running_aparser>:9091/API, ''
60
+ api.ping
61
+
62
+ => {"success" : 1, "data" : "pong"}
63
+ ```
22
64
 
23
65
  ## Development
24
66
 
@@ -36,4 +78,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
36
78
 
37
79
  ## Code of Conduct
38
80
 
39
- Everyone interacting in the AParserClient project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/yvshevchenko /a_parser_client/blob/master/CODE_OF_CONDUCT.md).
81
+ Everyone interacting in the AParserClient project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/yvshevchenko/a_parser_client/blob/master/CODE_OF_CONDUCT.md).
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Yaroslav Shevchenko"]
9
9
  spec.email = ["yvshevchenko@gmail.com"]
10
10
 
11
- spec.summary = %q{A simple inerface to a-parser API.}
12
- spec.description = %q{Gem allowing to use a-parser API simple way.}
11
+ spec.summary = %q{A simple inerface to A-Parser API.}
12
+ spec.description = %q{Gem allowing to use A-Parser API simple way.}
13
13
  spec.homepage = "https://github.com/yvshevchenko/a_parser_client"
14
14
  spec.license = "MIT"
15
15
 
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = "https://github.com/yvshevchenko/a_parser_client"
20
- spec.metadata["changelog_uri"] = "https://github.com/yvshevchenko/a_parser_client"
20
+ spec.metadata["changelog_uri"] = "https://github.com/yvshevchenko/a_parser_client/wiki/Changes-Log"
21
21
 
22
22
  # Specify which files should be added to the gem when it is released.
23
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -20,7 +20,7 @@ module AParserClient
20
20
  end
21
21
  end
22
22
 
23
- def ping_a_parser
23
+ def ping
24
24
  request = {
25
25
  password: @api_pass,
26
26
  action: 'ping'
@@ -30,7 +30,7 @@ module AParserClient
30
30
 
31
31
  #updates alive status
32
32
  def alive?
33
- @alive = ping_a_parser ? true : false
33
+ @alive = ping ? true : false
34
34
  end
35
35
 
36
36
 
@@ -46,7 +46,7 @@ module AParserClient
46
46
  def get_task_state(task_id)
47
47
  request = {
48
48
  password: @api_password,
49
- action: 'getTasksState',
49
+ action: 'getTaskState',
50
50
  data: {taskUid: task_id}
51
51
  }
52
52
  do_it request
@@ -55,7 +55,7 @@ module AParserClient
55
55
  def get_task_conf(task_id)
56
56
  request = {
57
57
  password: @api_password,
58
- action: 'getTasksConf',
58
+ action: 'getTaskConf',
59
59
  data: {taskUid: task_id}
60
60
  }
61
61
  do_it request
@@ -98,6 +98,87 @@ module AParserClient
98
98
  do_it request
99
99
  end
100
100
 
101
+ def get_accounts_count
102
+ request = {
103
+ password: @api_password,
104
+ action: 'getAccountsCount',
105
+ data: {}
106
+ }
107
+ do_it request
108
+ end
109
+
110
+
111
+ def get_proxies
112
+ request = {
113
+ password: @api_password,
114
+ action: 'getProxies'
115
+ }
116
+ do_it request
117
+ end
118
+
119
+ def update!
120
+ request = {
121
+ password: @api_password,
122
+ action: 'update',
123
+ data: {}
124
+ }
125
+ do_it request
126
+ end
127
+
128
+ def get_task_results_file(task_id)
129
+ request = {
130
+ password: @api_password,
131
+ action: 'getTaskResultsFile',
132
+ data: {taskUid: task_id}
133
+ }
134
+ do_it request
135
+ end
136
+
137
+ def delete_task_results_file(task_id)
138
+ request = {
139
+ password: @api_password,
140
+ action: 'deleteTaskResultsFile',
141
+ data: {taskUid: task_id}
142
+ }
143
+ do_it request
144
+ end
145
+
146
+ def move_task(task_id, direction)
147
+ request = {
148
+ password: @api_password,
149
+ action: 'moveTask',
150
+ data: {
151
+ taskUid: task_id,
152
+ toStatus: direction
153
+ }
154
+ }
155
+ do_it request
156
+ end
157
+
158
+ def get_parser_info(parser_name)
159
+ request = {
160
+ password: @api_password,
161
+ action: 'getParserInfo',
162
+ data: {
163
+ parser: parser_name
164
+ }
165
+ }
166
+ do_it request
167
+ end
168
+
169
+
170
+ def get_parser_preset(parser_name, preset_name)
171
+ request = {
172
+ password: @api_password,
173
+ action: 'getParserInfo',
174
+ data: {
175
+ parser: parser_name,
176
+ reset: preset_name
177
+ }
178
+ }
179
+ do_it request
180
+ end
181
+
101
182
 
102
183
  private # internal use only
103
184
 
@@ -123,7 +204,11 @@ module AParserClient
123
204
  end
124
205
 
125
206
  if res
126
- response = JSON.parse res.body
207
+ begin
208
+ response = JSON.parse res.body
209
+ rescue JSON::ParserError => e
210
+ raise "Not a JSON type response from the server #{@api_url}. Probably not an API endpoint."
211
+ end
127
212
  else
128
213
  nil
129
214
  end
@@ -1,3 +1,3 @@
1
1
  module AParserClient
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: a_parser_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shevchenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-24 00:00:00.000000000 Z
11
+ date: 2020-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- description: Gem allowing to use a-parser API simple way.
55
+ description: Gem allowing to use A-Parser API simple way.
56
56
  email:
57
57
  - yvshevchenko@gmail.com
58
58
  executables: []
@@ -80,7 +80,7 @@ metadata:
80
80
  allowed_push_host: https://rubygems.org
81
81
  homepage_uri: https://github.com/yvshevchenko/a_parser_client
82
82
  source_code_uri: https://github.com/yvshevchenko/a_parser_client
83
- changelog_uri: https://github.com/yvshevchenko/a_parser_client
83
+ changelog_uri: https://github.com/yvshevchenko/a_parser_client/wiki/Changes-Log
84
84
  post_install_message:
85
85
  rdoc_options: []
86
86
  require_paths:
@@ -100,5 +100,5 @@ rubyforge_project:
100
100
  rubygems_version: 2.7.7
101
101
  signing_key:
102
102
  specification_version: 4
103
- summary: A simple inerface to a-parser API.
103
+ summary: A simple inerface to A-Parser API.
104
104
  test_files: []