laximo 0.6.5.1 → 0.7

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
- SHA1:
3
- metadata.gz: 03ede08d655e997ba3cd7984c915919a1fae0a73
4
- data.tar.gz: 8c264484cdedc5b7c33092c748d90de3c783abb5
2
+ SHA256:
3
+ metadata.gz: c5231fd40d0de250d120193a3b50f0c6686313e1bc2969024230fa45c550a1ef
4
+ data.tar.gz: ee05b5bce8fc90ff18d006bdd530cb364be4be261cfda8dbea51708f058e91db
5
5
  SHA512:
6
- metadata.gz: ee1b821651bd6683d2a739d74d412cd79a45433b3f91524aa39493a50f43f0f4eff67fdcbcfa8a2c41b3118daaf8af3f699aad8aee0c8ce0707065e8a54151bb
7
- data.tar.gz: 421d851481fbb3cc214be66526dd83cc4a8d69181d3bdf078308623365e93bfbb1b262a7246259c89de536db06624eadf37271ccd242a8c61fcc177f8d9a86f9
6
+ metadata.gz: 76b415fdf80d0bb1b921a5d304c0a9e53738acbc772a3426e3705dfc33e1ce3605b466a227f10f2fbe0347531e1cecec2c99082bbb30d1b838625d9832802635
7
+ data.tar.gz: 55b581b6aa6713f1ca86d639302453553b94629c8b3f994119b387af41e8a892e92a87fdf3cb4284c9d596370d9f656e69744997751681bcfa4883ab758e6d05
data/README.md CHANGED
@@ -12,21 +12,18 @@ Ruby 1.9.3+
12
12
  2. В консоли `bundle install`
13
13
  3. Задаем параметры конфигурации в файле `config/initializers/laximo.rb`:
14
14
  ```ruby
15
- Laximo.options.use_ssl true
16
- Laximo.options.ssl_key ::File.join(Rails.root, 'db', 'ssl', 'client.key')
17
- Laximo.options.ssl_cert ::File.join(Rails.root, 'db', 'ssl', 'client.pem')
18
- Laximo.options.ssl_verify false
15
+ Laximo.options.login 'mylogin' # имейте в виду, что такие параметры
16
+ Laximo.options.password 'mypassword' # должны быть вынесены в переменные окружения
19
17
 
20
18
  Laximo.options.timeout 10
21
19
  Laximo.options.debug false
22
20
  ```
23
- или для авторизации по подписке
21
+
22
+ Авторизация по ssl считается устаревшей и в ближайшее время будет удалена:
24
23
  ```ruby
25
24
  Laximo.options.use_ssl true
26
- Laximo.options.use_login true
27
- Laximo.options.login 'mylogin' # имейте в виду, что такие параметры
28
- Laximo.options.password 'mypassword' # должны быть вынесены в переменные окружения
29
- Laximo.options.ssl_verify false
25
+ Laximo.options.ssl_key ::File.join(Rails.root, 'db', 'ssl', 'client.key')
26
+ Laximo.options.ssl_cert ::File.join(Rails.root, 'db', 'ssl', 'client.pem')
30
27
 
31
28
  Laximo.options.timeout 10
32
29
  Laximo.options.debug false
@@ -128,4 +125,4 @@ res.result # []
128
125
  Автор: [Tyralion](mailto:piliaiev@gmail.com)
129
126
  [Список контрибьюторов](https://github.com/dancingbytes/laximo/graphs/contributors)
130
127
 
131
- Copyright (c) 2015-2016 DansingBytes.ru, под лицензией BSD
128
+ Copyright (c) 2015-2018 DansingBytes.ru, под лицензией BSD
@@ -4,6 +4,7 @@ require 'nokogiri'
4
4
  require 'cgi'
5
5
  require 'uri'
6
6
  require 'net/http'
7
+ require 'net/https'
7
8
 
8
9
  require 'laximo/version'
9
10
  require 'laximo/options'
@@ -7,8 +7,10 @@ module Laximo
7
7
 
8
8
  def use_login(str = nil)
9
9
 
10
- return @use_login if str.nil?
11
- @use_login = str === true
10
+ ::Laximo.deprecated!
11
+
12
+ return (@use_login === true) if str.nil?
13
+ @use_login = str
12
14
 
13
15
  end # use login
14
16
 
@@ -28,6 +30,8 @@ module Laximo
28
30
 
29
31
  def ssl_key(str = nil)
30
32
 
33
+ ::Laximo.deprecated!
34
+
31
35
  return @ssl_key if str.nil?
32
36
  raise ::LoadError.new("File #{str} is not found") unless File.exists?(str)
33
37
 
@@ -37,6 +41,8 @@ module Laximo
37
41
 
38
42
  def ssl_cert(str = nil)
39
43
 
44
+ ::Laximo.deprecated!
45
+
40
46
  return @ssl_cert if str.nil?
41
47
  raise ::LoadError.new("File #{str} is not found") unless File.exists?(str)
42
48
 
@@ -46,6 +52,8 @@ module Laximo
46
52
 
47
53
  def ssl_verify(str = nil)
48
54
 
55
+ ::Laximo.deprecated!
56
+
49
57
  return @ssl_verify if str.nil?
50
58
  @ssl_verify = (str === true ? ::OpenSSL::SSL::VERIFY_PEER : ::OpenSSL::SSL::VERIFY_NONE)
51
59
 
@@ -53,8 +61,8 @@ module Laximo
53
61
 
54
62
  def use_ssl(str = nil)
55
63
 
56
- return @use_ssl if str.nil?
57
- @use_ssl = str === true
64
+ return (@use_ssl === true) if str.nil?
65
+ @use_ssl = str
58
66
 
59
67
  end # use_ssl
60
68
 
@@ -32,9 +32,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://sch
32
32
  @soap_endpoint = soap_endpoint
33
33
  @soap_action = soap_action
34
34
 
35
- uri = URI(soap_endpoint)
36
- @http = ::Net::HTTP.new(uri.host, uri.port)
37
- @request = ::Net::HTTP::Post.new(uri.request_uri)
35
+ @uri = URI(soap_endpoint)
36
+ @http = ::Net::HTTP.new(@uri.host, @uri.port)
37
+ @request = ::Net::HTTP::Post.new(@uri.request_uri)
38
38
 
39
39
  set_request_params
40
40
  set_http_params
@@ -43,18 +43,18 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://sch
43
43
 
44
44
  def call(msg)
45
45
 
46
- if ::Laximo.options.use_login
46
+ if ::Laximo.options.use_ssl
47
+ @request.body = REQUEST_MSG % {
48
+ msg: msg,
49
+ act: @soap_action
50
+ }
51
+ else
47
52
  @request.body = REQUEST_LOGIN_MSG % {
48
53
  msg: msg,
49
54
  act: @soap_action,
50
55
  login: ::Laximo.options.login,
51
56
  hash: hash(msg, ::Laximo.options.password)
52
57
  }
53
- else
54
- @request.body = REQUEST_MSG % {
55
- msg: msg,
56
- act: @soap_action
57
- }
58
58
  end
59
59
 
60
60
  begin
@@ -71,12 +71,12 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://sch
71
71
 
72
72
  @http.set_debug_output($stdout) if ::Laximo.options.debug?
73
73
 
74
- @http.use_ssl = ::Laximo.options.use_ssl
75
- @http.verify_mode = ::Laximo.options.ssl_verify
74
+ @http.use_ssl = ssl?
75
+ @http.verify_mode = ::OpenSSL::SSL::VERIFY_NONE
76
76
 
77
- unless ::Laximo.options.use_login
78
- @http.key = ::Laximo.options.ssl_key
79
- @http.cert = ::Laximo.options.ssl_cert
77
+ if ::Laximo.options.use_ssl
78
+ @http.key = ::Laximo.options.ssl_key
79
+ @http.cert = ::Laximo.options.ssl_cert
80
80
  end
81
81
 
82
82
  @http.open_timeout = ::Laximo.options.timeout
@@ -99,11 +99,13 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://sch
99
99
  end # set_request_params
100
100
 
101
101
  def hash(command, password)
102
-
103
- Digest::MD5::hexdigest "#{command}#{password}"
104
-
102
+ ::Digest::MD5::hexdigest "#{command}#{password}"
105
103
  end # hash
106
104
 
105
+ def ssl?
106
+ @uri.scheme == 'https'.freeze
107
+ end
108
+
107
109
  end # Request
108
110
 
109
111
  end # Laximo
@@ -38,7 +38,7 @@ module Laximo
38
38
 
39
39
  def result!
40
40
 
41
- raise error if failure?
41
+ raise StandardError, error.inspect if failure?
42
42
  result
43
43
 
44
44
  end # result!
@@ -132,11 +132,8 @@ module Laximo
132
132
  doc = ::Nokogiri::XML(http.body)
133
133
  doc.remove_namespaces!
134
134
 
135
- if ::Laximo.options.use_login
136
- res = doc.xpath(RESPONSE_LOGIN_RESULT).children[0].to_s
137
- else
138
- res = doc.xpath(RESPONSE_RESULT).children[0].to_s
139
- end
135
+ res = doc.xpath(RESPONSE_LOGIN_RESULT).children[0].to_s
136
+ res = doc.xpath(RESPONSE_RESULT).children[0].to_s if res.blank?
140
137
 
141
138
  @error = nil
142
139
  @result = parsing_result(
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Laximo
3
3
 
4
- VERSION = '0.6.5.1'.freeze
4
+ VERSION = '0.7'.freeze
5
5
 
6
6
  end # Laximo
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: laximo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5.1
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Pilyaev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-26 00:00:00.000000000 Z
11
+ date: 2018-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.6.11
95
+ rubygems_version: 2.7.6
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: Api for Laximo services