resource_accessor 1.2.6 → 1.2.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
2
  SHA1:
3
- metadata.gz: ca3c89aaa549ea99eba018ece9947848c52f57eb
4
- data.tar.gz: 8cbc62dc0212cd28eb6adb06bb62be0360b57d42
3
+ metadata.gz: 31b1c91d25c84e2ce12e8f0526897c0a289502ea
4
+ data.tar.gz: 37e2aca6e83c4d706e96da56dfee51471986910b
5
5
  SHA512:
6
- metadata.gz: 54e5276a18b3690bd82987f2d3d70b425d2a25f76be31c695979056796572a5211ea1f0f23ffbaae416b361eda3b253972a9bd4a561f0bdc844c77a06c3ec253
7
- data.tar.gz: 20bb51c302b38a6817b4efa44ba53ccd5f46c8029ac19ba74bfe90431d8653b5aeded463f386362ff79ea721e84494c13db8dcaccec936b712fd421359b0afcd
6
+ metadata.gz: ebd4d64d7214aabcde7ca05e5dc633fe60a535af75d8fbcbbb8bab40e99f5e525288e33c3c63e9c6c53e4b6e709ebfbdc88c8f8ebf2b6f9c1015b1db01424af5
7
+ data.tar.gz: b64e6c64168725b6b51ae21e35b44e6804bf56bac08fbd5d2902ed2e0ce71140ce0cab6574d82c2b0bca09a4e580b7f1d80cecfc129a9ed99bee9c715970cfd3
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.4.1
data/CHANGES CHANGED
@@ -34,4 +34,9 @@
34
34
 
35
35
  == Version 1.2.4-1.2.6
36
36
 
37
- * Bug fix
37
+ * Bug fix
38
+
39
+ == Version 1.2.7
40
+
41
+ * Bug fix
42
+ * warnings fix
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- ruby "2.3.1"
3
+ ruby "2.4.1"
4
4
 
5
5
  group :default do
6
6
  end
@@ -1,25 +1,30 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- diff-lcs (1.2.4)
5
- file_utils (1.0.7)
4
+ diff-lcs (1.3)
5
+ file_utils (1.1.2)
6
6
  gemcutter (0.7.1)
7
7
  gemspec_deps_gen (1.1.2)
8
8
  bundler
9
9
  file_utils
10
10
  log4r (1.1.10)
11
- metaclass (0.0.1)
12
- mocha (0.14.0)
11
+ metaclass (0.0.4)
12
+ mocha (1.2.1)
13
13
  metaclass (~> 0.0.1)
14
- rspec (2.14.1)
15
- rspec-core (~> 2.14.0)
16
- rspec-expectations (~> 2.14.0)
17
- rspec-mocks (~> 2.14.0)
18
- rspec-core (2.14.5)
19
- rspec-expectations (2.14.2)
20
- diff-lcs (>= 1.1.3, < 2.0)
21
- rspec-mocks (2.14.3)
22
- thor (0.19.1)
14
+ rspec (3.6.0)
15
+ rspec-core (~> 3.6.0)
16
+ rspec-expectations (~> 3.6.0)
17
+ rspec-mocks (~> 3.6.0)
18
+ rspec-core (3.6.0)
19
+ rspec-support (~> 3.6.0)
20
+ rspec-expectations (3.6.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.6.0)
23
+ rspec-mocks (3.6.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.6.0)
26
+ rspec-support (3.6.0)
27
+ thor (0.19.4)
23
28
 
24
29
  PLATFORMS
25
30
  ruby
@@ -33,7 +38,7 @@ DEPENDENCIES
33
38
  thor (~> 0.19)
34
39
 
35
40
  RUBY VERSION
36
- ruby 2.3.1p112
41
+ ruby 2.4.1p111
37
42
 
38
43
  BUNDLED WITH
39
- 1.12.5
44
+ 1.15.3
@@ -1,43 +1,44 @@
1
1
  require 'net/https'
2
2
  require 'cgi'
3
+ require 'openssl/ssl'
3
4
 
4
5
  class ResourceAccessor
5
6
  attr_accessor :timeout, :ca_file, :validate_ssl_cert
6
7
 
7
8
  alias validate_ssl_cert? validate_ssl_cert
8
9
 
9
- def initialize timeout = 10000, ca_file = nil, validate_ssl_cert = false
10
+ def initialize(timeout = 10000, ca_file = nil, validate_ssl_cert = false)
10
11
  @timeout = timeout
11
12
  @ca_file = ca_file
12
13
  @validate_ssl_cert = validate_ssl_cert
13
14
  end
14
15
 
15
- def get_response params, headers = {}
16
+ def get_response(params, headers = {})
16
17
  locate_response(params[:url], params[:query], params[:method], headers, params[:body], params[:escape], params[:cookie])
17
18
  end
18
19
 
19
- def get_soap_response params, headers = {}
20
- headers["SOAPAction"] = params[:soap_action] if params[:soap_action]
21
- headers["SOAPAction"] = "" unless headers["SOAPAction"]
22
- headers["Content-Type"] = "text/xml;charset=UTF-8" unless headers["Content-Type"]
20
+ def get_soap_response(params, headers = {})
21
+ headers['SOAPAction'] = params[:soap_action] if params[:soap_action]
22
+ headers['SOAPAction'] = '' unless headers['SOAPAction']
23
+ headers['Content-Type'] = 'text/xml;charset=UTF-8' unless headers['Content-Type']
23
24
 
24
25
  locate_response(params[:url], params[:query], params[:method], headers, params[:body], params[:escape], params[:cookie])
25
26
  end
26
27
 
27
- def get_ajax_response params, headers = {}
28
+ def get_ajax_response(params, headers = {})
28
29
  headers['X-Requested-With'] = 'XMLHttpRequest'
29
30
 
30
31
  locate_response(params[:url], params[:query], params[:method], headers, params[:body], params[:escape], params[:cookie])
31
32
  end
32
33
 
33
- def get_json_response params, headers = {}
34
- headers["Content-Type"] = "application/json;charset=UTF-8"
34
+ def get_json_response(params, headers = {})
35
+ headers['Content-Type'] = 'application/json;charset=UTF-8'
35
36
 
36
37
  locate_response(params[:url], params[:query], params[:method], headers, params[:body], params[:escape], params[:cookie])
37
38
  end
38
39
 
39
- def get_cookie url, user_name, password
40
- headers = {"Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8"}
40
+ def get_cookie(url, user_name, password)
41
+ headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
41
42
 
42
43
  body = {:username => user_name, :password => password}
43
44
 
@@ -52,7 +53,7 @@ class ResourceAccessor
52
53
  encode params, escape
53
54
  end
54
55
 
55
- def locate_response url, query, method, headers, body, escape=true, cookie=nil
56
+ def locate_response(url, query, method, headers, body, escape=true, cookie=nil)
56
57
  response = execute_request url, query, method, headers, body, escape, cookie
57
58
 
58
59
  if response.class == Net::HTTPMovedPermanently
@@ -71,9 +72,9 @@ class ResourceAccessor
71
72
  response
72
73
  end
73
74
 
74
- def execute_request url, query, method, headers, body, escape, cookie=nil
75
- headers["User-Agent"] = "Ruby/#{RUBY_VERSION}" unless headers["User-Agent"]
76
- headers["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8" unless headers["Content-Type"]
75
+ def execute_request(url, query, method, headers, body, escape, cookie=nil)
76
+ headers['User-Agent'] = "Ruby/#{RUBY_VERSION}" unless headers['User-Agent']
77
+ headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8' unless headers['Content-Type']
77
78
 
78
79
  if cookie
79
80
  headers['Cookie'] = cookie
@@ -87,7 +88,7 @@ class ResourceAccessor
87
88
 
88
89
  connection = Net::HTTP.new(uri.host, uri.port)
89
90
 
90
- if uri.scheme == "https"
91
+ if uri.scheme == 'https'
91
92
  connection.use_ssl = true
92
93
 
93
94
  if validate_ssl_cert?
@@ -1,3 +1,3 @@
1
- module ResourceAccessor
2
- VERSION = "1.2.6"
1
+ class ResourceAccessor
2
+ VERSION = '1.2.7'
3
3
  end
@@ -49,7 +49,7 @@ describe Gateway do
49
49
  end.to raise_error(GatewayError)
50
50
  end
51
51
 
52
- it "should set content type to text/xml for soap post request" do
52
+ it "sets content type to text/xml for soap post request" do
53
53
  Net::HTTP.any_instance.expects(:request => simple_response)
54
54
 
55
55
  params = {:url => some_https_url}
@@ -57,10 +57,10 @@ describe Gateway do
57
57
 
58
58
  subject.soap_post(params, headers)
59
59
 
60
- headers["Content-Type"].should match "text/xml"
60
+ expect(headers["Content-Type"]).to match "text/xml"
61
61
  end
62
62
 
63
- it "should set content type to application/x-www-form-urlencoded for regular post request" do
63
+ it "sets content type to application/x-www-form-urlencoded for regular post request" do
64
64
  Net::HTTP.any_instance.expects(:request => simple_response)
65
65
 
66
66
  params = {:url => some_https_url}
@@ -68,7 +68,7 @@ describe Gateway do
68
68
 
69
69
  subject.post(params, headers)
70
70
 
71
- headers["Content-Type"].should match "application/x-www-form-urlencoded"
71
+ expect(headers["Content-Type"]).to match "application/x-www-form-urlencoded"
72
72
  end
73
73
 
74
74
  it "logs body of request" do
@@ -79,7 +79,7 @@ describe Gateway do
79
79
  subject.soap_post(:url => some_https_url, :body => 'some_request')
80
80
  end
81
81
 
82
- it "should log timeout errors and raise GatewayError" do
82
+ it "logs timeout errors and raise GatewayError" do
83
83
  subject.logger.expects(:error).with("#{subject.class.name} received error: Timeout::Error")
84
84
  Net::HTTP.any_instance.expects(:request).raises(Timeout::Error.new(nil))
85
85
 
@@ -4,13 +4,13 @@ require 'resource_accessor'
4
4
 
5
5
  describe ResourceAccessor do
6
6
  context "#get_response" do
7
- it "should use provided url" do
7
+ it "uses provided url" do
8
8
  Net::HTTP.expects(:new).with("someurl.com", 80).returns(stub_everything(:request => stub_everything))
9
9
 
10
10
  subject.get_response :url => "http://someurl.com"
11
11
  end
12
12
 
13
- it "should use provided query parameters" do
13
+ it "uses provided query parameters" do
14
14
  Net::HTTP.expects(:new).with("someurl.com", 80).returns(stub_everything(:request => stub_everything))
15
15
 
16
16
  Net::HTTP::Get.expects(:new).with("/?param1=p1&param2=p2", {'User-Agent' => 'user_agent', 'Content-Type' => 'content_type'})
@@ -22,15 +22,15 @@ describe ResourceAccessor do
22
22
 
23
23
  context "#query_from_hash" do
24
24
  it "escapes ampersands and spaces in values" do
25
- subject.class.query_from_hash({:name1 => "name 1", :name2 => "name 2"}).should eql "name1=name+1&name2=name+2"
25
+ expect(subject.class.query_from_hash({:name1 => "name 1", :name2 => "name 2"})).to eql "name1=name+1&name2=name+2"
26
26
  end
27
27
 
28
28
  it "maps properly nil values" do
29
- subject.class.query_from_hash({:param1 => nil, :param2 => "A&B", :param3 => "C & D"}).should eql "param1=&param2=A%26B&param3=C+%26+D"
29
+ expect(subject.class.query_from_hash({:param1 => nil, :param2 => "A&B", :param3 => "C & D"})).to eql "param1=&param2=A%26B&param3=C+%26+D"
30
30
  end
31
31
 
32
32
  it "does not escapes ampersands if escape is turned off" do
33
- subject.class.query_from_hash({:name1 => "name 1", :name2 => "name 2"}, false).should eql "name1=name 1&name2=name 2"
33
+ expect(subject.class.query_from_hash({:name1 => "name 1", :name2 => "name 2"}, false)).to eql "name1=name 1&name2=name 2"
34
34
  end
35
35
  end
36
36
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resource_accessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shvets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-07 00:00:00.000000000 Z
11
+ date: 2017-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gemspec_deps_gen
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.5.1
101
+ rubygems_version: 2.6.12
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: This library is used to simplify access to protected or unprotected http