wrata_api 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 557d84f0f762d728293064900d541e64bbac2f72cee30cbbc7453255f7f1dcc3
4
- data.tar.gz: ab8a8885d4fe45746712d1614c9fc0b35676934eee88b9583fbe5550fbf48ddf
3
+ metadata.gz: 640eef20434b6c404876a8e1ba485f5a996b3e176a85f719cb62650e5e1fd2e9
4
+ data.tar.gz: 6cb44e65eb0a69f83129b1e631d3a9ddda161da0127ac65042854161c5e6a010
5
5
  SHA512:
6
- metadata.gz: 73a54b8332386382265bc660375cdeccb022a56d7cbc1b0898aa3447e11b792ad7e811ccb0b16cf4644a2eb690af56648b032e63b70d4e36a6c7b39b1f963dd0
7
- data.tar.gz: 254b4c171a0d637a1c1ffc1d5013d98127212f4c6ff6fe727afaf94fd79687d692928682338330c573516e5d264ee54c08ef376296e2f16cd48d505ceffbc33a
6
+ metadata.gz: 486b088799264af6295f5db2f5f1f1f66c98d8f35124d9cae14d85bff4611fc3b83bb21b53270e9f1399c044b5dabb21677de28cc255cf52db64f05ec8f1a31c
7
+ data.tar.gz: 8a759e7c6babe7fe68de87d0bce43d9aac921751ab00a894e1e0431f45c33d3ac3bef4addf1b20d8b5763ead69833b781b82997c5a9a7f125e88b44d02cb80ae
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Module to work with clients api
4
+ module ClientsMethods
5
+ # Get current user info
6
+ # @return [Array<Hash>] current user info
7
+ def profile
8
+ uri = URI.parse("#{@uri}/profile.json")
9
+ perform_get(uri)
10
+ end
11
+ end
@@ -3,6 +3,10 @@
3
3
  module WrataApi
4
4
  # Methods to work with file tree
5
5
  module FileListMethods
6
+ # Return list of files in specific project
7
+ # @param project [String] name of project
8
+ # @param ref [String] branch or hash of commit to get list of files
9
+ # @return [Array<String>] list of files
6
10
  def file_list(project, ref = 'master')
7
11
  uri = URI.parse("#{@uri}/runner/file_tree")
8
12
  body = {
@@ -34,9 +34,10 @@ module WrataApi
34
34
  def powering_status(server_name)
35
35
  all_data = server_data(server_name)
36
36
  status = all_data['_status']
37
- if status == 'created'
37
+ case status
38
+ when 'created'
38
39
  :on
39
- elsif status == 'destroyed'
40
+ when 'destroyed'
40
41
  :off
41
42
  else
42
43
  :other
@@ -106,7 +107,7 @@ module WrataApi
106
107
  # @return [String] error for server timeout
107
108
  def server_status_timeout_error(server, status)
108
109
  "Couldn't wait until #{server} have status "\
109
- "#{status} in specified timeout"
110
+ "#{status} in specified timeout"
110
111
  end
111
112
  end
112
113
  end
@@ -4,6 +4,6 @@ module WrataApi
4
4
  # This module holds the WrataApi version information.
5
5
  module Version
6
6
  # @return [String] current gem version
7
- STRING = '0.1.0'
7
+ STRING = '1.0.0'
8
8
  end
9
9
  end
@@ -7,7 +7,7 @@ module WrataApi
7
7
  # @return [Hash] default header for requests
8
8
  def default_header
9
9
  { 'Cookie' => "remember_token=#{@cookie}; \
10
- _runner_session=#{@wrata_session}",
10
+ _runner_session=#{CGI.escape(@wrata_session)}",
11
11
  'X-CSRF-Token' => @csrf_token }
12
12
  end
13
13
 
@@ -16,10 +16,9 @@ module WrataApi
16
16
  # @param body [Hash] body of request
17
17
  # @return [JSON] result of request
18
18
  def perform_get(uri, body = {})
19
- http = Net::HTTP.new(uri.host, uri.port)
20
19
  request = Net::HTTP::Get.new(uri.request_uri, default_header)
21
20
  request.set_form_data(body)
22
- body = http.request(request).body
21
+ body = http_object(uri).request(request).body
23
22
  @logger.info("Get request: #{uri} answered: #{body}")
24
23
  return {} if body.empty?
25
24
 
@@ -31,7 +30,7 @@ module WrataApi
31
30
  # @param body [Hash] body of request
32
31
  # @return [JSON] result of request
33
32
  def perform_post(uri, body = {})
34
- http = Net::HTTP.new(uri.host, uri.port)
33
+ http = http_object(uri)
35
34
  request = Net::HTTP::Post.new(uri.request_uri, default_header)
36
35
  request.set_form_data(body)
37
36
  http.read_timeout = 500
@@ -41,5 +40,13 @@ module WrataApi
41
40
 
42
41
  JSON.parse(body)
43
42
  end
43
+
44
+ # @param uri [URI] url of server
45
+ # @return [Net:HTTP] http instance
46
+ def http_object(uri)
47
+ http = Net::HTTP.new(uri.host, uri.port)
48
+ http.use_ssl = true if uri.scheme == 'https'
49
+ http
50
+ end
44
51
  end
45
52
  end
data/lib/wrata_api.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'wrata_api/clients_methods'
3
4
  require_relative 'wrata_api/wrata_api_request'
4
5
  require_relative 'wrata_api/server_list'
5
6
  require_relative 'wrata_api/server_methods'
@@ -13,6 +14,7 @@ require 'yaml'
13
14
  module WrataApi
14
15
  # Class for working with wrata api
15
16
  class WrataApi
17
+ include ClientsMethods
16
18
  include WrataApiRequest
17
19
  include ServerMethods
18
20
  include FileListMethods
@@ -24,7 +26,7 @@ module WrataApi
24
26
  @cookie = config['cookie']
25
27
  @wrata_session = config['wrata_session']
26
28
  @csrf_token = config['csrf_token']
27
- @logger = Logger.new(STDOUT)
29
+ @logger = Logger.new($stdout)
28
30
  @waiting_timeout = 5 * 60
29
31
  @between_request_timeout = 10
30
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wrata_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ONLYOFFICE
@@ -9,22 +9,134 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-05-26 00:00:00.000000000 Z
12
+ date: 2022-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: codecov
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: overcommit
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
14
42
  - !ruby/object:Gem::Dependency
15
43
  name: rake
16
44
  requirement: !ruby/object:Gem::Requirement
17
45
  requirements:
18
46
  - - "~>"
19
47
  - !ruby/object:Gem::Version
20
- version: '13.0'
48
+ version: '13'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '13'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rubocop
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '1'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rubocop-performance
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '1'
21
91
  type: :development
22
92
  prerelease: false
23
93
  version_requirements: !ruby/object:Gem::Requirement
24
94
  requirements:
25
95
  - - "~>"
26
96
  - !ruby/object:Gem::Version
27
- version: '13.0'
97
+ version: '1'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rubocop-rake
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rubocop-rspec
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '2'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '2'
126
+ - !ruby/object:Gem::Dependency
127
+ name: yard
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 0.9.20
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: 0.9.20
28
140
  description: Wrapper around wrata API
29
141
  email:
30
142
  - shockwavenn@gmail.com
@@ -33,6 +145,7 @@ extensions: []
33
145
  extra_rdoc_files: []
34
146
  files:
35
147
  - lib/wrata_api.rb
148
+ - lib/wrata_api/clients_methods.rb
36
149
  - lib/wrata_api/file_tree.rb
37
150
  - lib/wrata_api/name.rb
38
151
  - lib/wrata_api/queue_methos.rb
@@ -50,6 +163,7 @@ metadata:
50
163
  documentation_uri: https://www.rubydoc.info/gems/wrata_api
51
164
  homepage_uri: https://github.com/ONLYOFFICE/wrata_api
52
165
  source_code_uri: https://github.com/ONLYOFFICE/wrata_api
166
+ rubygems_mfa_required: 'true'
53
167
  post_install_message:
54
168
  rdoc_options: []
55
169
  require_paths:
@@ -58,14 +172,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
172
  requirements:
59
173
  - - ">="
60
174
  - !ruby/object:Gem::Version
61
- version: '2.4'
175
+ version: '2.5'
62
176
  required_rubygems_version: !ruby/object:Gem::Requirement
63
177
  requirements:
64
178
  - - ">="
65
179
  - !ruby/object:Gem::Version
66
180
  version: '0'
67
181
  requirements: []
68
- rubygems_version: 3.1.2
182
+ rubygems_version: 3.3.4
69
183
  signing_key:
70
184
  specification_version: 4
71
185
  summary: Wrata API Gem