active_utils 2.2.3 → 3.3.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +5 -5
  2. data/.github/probots.yml +2 -0
  3. data/.travis.yml +39 -3
  4. data/CHANGELOG.md +92 -0
  5. data/CONTRIBUTING.md +32 -0
  6. data/Gemfile +1 -1
  7. data/README.md +30 -16
  8. data/active_utils.gemspec +4 -1
  9. data/gemfiles/Gemfile.activesupport-master +4 -0
  10. data/gemfiles/Gemfile.activesupport42 +4 -0
  11. data/gemfiles/Gemfile.activesupport50 +4 -0
  12. data/gemfiles/Gemfile.activesupport52 +4 -0
  13. data/lib/active_utils/{common/connection.rb → connection.rb} +9 -3
  14. data/lib/active_utils/{common/country.rb → country.rb} +18 -3
  15. data/lib/active_utils/currency_code.rb +56 -0
  16. data/lib/active_utils/{common/error.rb → error.rb} +8 -6
  17. data/lib/active_utils/{common/network_connection_retries.rb → network_connection_retries.rb} +27 -11
  18. data/lib/active_utils/{common/post_data.rb → post_data.rb} +1 -1
  19. data/lib/active_utils/{common/posts_data.rb → posts_data.rb} +19 -10
  20. data/lib/active_utils/{common/requires_parameters.rb → requires_parameters.rb} +1 -1
  21. data/lib/active_utils/{common/validateable.rb → validateable.rb} +1 -1
  22. data/lib/active_utils/version.rb +1 -1
  23. data/lib/active_utils.rb +17 -16
  24. data/lib/certs/cacert.pem +1701 -2393
  25. data/test/test_helper.rb +7 -4
  26. data/test/unit/connection_test.rb +43 -15
  27. data/test/unit/country_test.rb +19 -0
  28. data/test/unit/network_connection_retries_test.rb +88 -11
  29. data/test/unit/post_data_test.rb +6 -6
  30. data/test/unit/posts_data_test.rb +19 -4
  31. data/test/unit/validateable_test.rb +1 -1
  32. metadata +38 -41
  33. checksums.yaml.gz.sig +0 -0
  34. data/lib/active_utils/common/currency_code.rb +0 -50
  35. data/lib/active_utils/common/utils.rb +0 -20
  36. data/test/unit/utils_test.rb +0 -7
  37. data.tar.gz.sig +0 -1
  38. metadata.gz.sig +0 -1
data/test/test_helper.rb CHANGED
@@ -1,8 +1,11 @@
1
1
  require 'active_utils'
2
-
3
2
  require 'minitest/autorun'
3
+ require 'mocha/setup'
4
4
 
5
- require 'mocha'
6
- require 'mocha/mini_test'
5
+ include ActiveUtils
7
6
 
8
- include ActiveMerchant
7
+ # This makes sure that Minitest::Test exists when an older version of Minitest
8
+ # (i.e. 4.x) is required by ActiveSupport.
9
+ unless defined?(Minitest::Test)
10
+ Minitest::Test = MiniTest::Unit::TestCase
11
+ end
@@ -6,23 +6,27 @@ class ConnectionTest < Minitest::Test
6
6
  @ok = stub(:code => 200, :message => 'OK', :body => 'success')
7
7
 
8
8
  @endpoint = 'https://example.com/tx.php'
9
- @connection = ActiveMerchant::Connection.new(@endpoint)
9
+ @connection = ActiveUtils::Connection.new(@endpoint)
10
10
  @connection.logger = stub(:info => nil, :debug => nil, :error => nil)
11
11
  end
12
12
 
13
+ def test_path_to_cert_is_correct
14
+ assert File.exists?(ActiveUtils::Connection::CA_FILE)
15
+ end
16
+
13
17
  def test_connection_endpoint_parses_string_to_uri
14
18
  assert_equal URI.parse(@endpoint), @connection.endpoint
15
19
  end
16
20
 
17
21
  def test_connection_endpoint_accepts_uri
18
22
  endpoint = URI.parse(@endpoint)
19
- connection = ActiveMerchant::Connection.new(endpoint)
23
+ connection = ActiveUtils::Connection.new(endpoint)
20
24
  assert_equal endpoint, connection.endpoint
21
25
  end
22
26
 
23
27
  def test_connection_endpoint_raises_uri_error
24
28
  assert_raises URI::InvalidURIError do
25
- ActiveMerchant::Connection.new("not a URI")
29
+ ActiveUtils::Connection.new("not a URI")
26
30
  end
27
31
  end
28
32
 
@@ -34,7 +38,7 @@ class ConnectionTest < Minitest::Test
34
38
  end
35
39
 
36
40
  def test_successful_post_request
37
- Net::HTTP.any_instance.expects(:post).with('/tx.php', 'data', ActiveMerchant::Connection::RUBY_184_POST_HEADERS).returns(@ok)
41
+ Net::HTTP.any_instance.expects(:post).with('/tx.php', 'data', ActiveUtils::Connection::RUBY_184_POST_HEADERS).returns(@ok)
38
42
  response = @connection.request(:post, 'data', {})
39
43
  assert_equal 'success', response.body
40
44
  end
@@ -45,6 +49,12 @@ class ConnectionTest < Minitest::Test
45
49
  assert_equal 'success', response.body
46
50
  end
47
51
 
52
+ def test_successful_patch_request
53
+ Net::HTTP.any_instance.expects(:patch).with('/tx.php', 'data', {}).returns(@ok)
54
+ response = @connection.request(:patch, 'data', {})
55
+ assert_equal 'success', response.body
56
+ end
57
+
48
58
  def test_successful_delete_request
49
59
  Net::HTTP.any_instance.expects(:delete).with('/tx.php', {}).returns(@ok)
50
60
  response = @connection.request(:delete, nil, {})
@@ -76,7 +86,7 @@ class ConnectionTest < Minitest::Test
76
86
  end
77
87
 
78
88
  def test_default_read_timeout
79
- assert_equal ActiveMerchant::Connection::READ_TIMEOUT, @connection.read_timeout
89
+ assert_equal ActiveUtils::Connection::READ_TIMEOUT, @connection.read_timeout
80
90
  end
81
91
 
82
92
  def test_override_read_timeout
@@ -90,7 +100,7 @@ class ConnectionTest < Minitest::Test
90
100
  end
91
101
 
92
102
  def test_default_verify_peer
93
- assert_equal ActiveMerchant::Connection::VERIFY_PEER, @connection.verify_peer
103
+ assert_equal ActiveUtils::Connection::VERIFY_PEER, @connection.verify_peer
94
104
  end
95
105
 
96
106
  def test_override_verify_peer
@@ -99,8 +109,8 @@ class ConnectionTest < Minitest::Test
99
109
  end
100
110
 
101
111
  def test_default_ca_file
102
- assert_equal ActiveMerchant::Connection::CA_FILE, @connection.ca_file
103
- assert_equal ActiveMerchant::Connection::CA_FILE, @connection.send(:http).ca_file
112
+ assert_equal ActiveUtils::Connection::CA_FILE, @connection.ca_file
113
+ assert_equal ActiveUtils::Connection::CA_FILE, @connection.send(:http).ca_file
104
114
  end
105
115
 
106
116
  def test_override_ca_file
@@ -110,8 +120,8 @@ class ConnectionTest < Minitest::Test
110
120
  end
111
121
 
112
122
  def test_default_ca_path
113
- assert_equal ActiveMerchant::Connection::CA_PATH, @connection.ca_path
114
- assert_equal ActiveMerchant::Connection::CA_PATH, @connection.send(:http).ca_path
123
+ assert_equal ActiveUtils::Connection::CA_PATH, @connection.ca_path
124
+ assert_equal ActiveUtils::Connection::CA_PATH, @connection.send(:http).ca_path
115
125
  end
116
126
 
117
127
  def test_override_ca_path
@@ -120,11 +130,29 @@ class ConnectionTest < Minitest::Test
120
130
  assert_equal "/bogus", @connection.send(:http).ca_path
121
131
  end
122
132
 
133
+ def test_default_proxy_address_is_nil
134
+ assert_equal nil, @connection.proxy_address
135
+ end
136
+
137
+ def test_default_proxy_port_is_nil
138
+ assert_equal nil, @connection.proxy_port
139
+ end
140
+
141
+ def test_override_proxy_address
142
+ @connection.proxy_address = "http://proxy.example.com"
143
+ assert_equal "http://proxy.example.com", @connection.proxy_address
144
+ end
145
+
146
+ def test_override_proxy_port
147
+ @connection.proxy_port = "8888"
148
+ assert_equal "8888", @connection.proxy_port
149
+ end
150
+
123
151
  def test_unrecoverable_exception
124
152
  @connection.logger.expects(:info).once
125
153
  Net::HTTP.any_instance.expects(:post).raises(EOFError)
126
154
 
127
- assert_raises(ActiveMerchant::ConnectionError) do
155
+ assert_raises(ActiveUtils::ConnectionError) do
128
156
  @connection.request(:post, '')
129
157
  end
130
158
  end
@@ -138,9 +166,9 @@ class ConnectionTest < Minitest::Test
138
166
 
139
167
  def test_failure_limit_reached
140
168
  @connection.logger.expects(:info).once
141
- Net::HTTP.any_instance.expects(:post).times(ActiveMerchant::Connection::MAX_RETRIES).raises(Errno::ECONNREFUSED)
169
+ Net::HTTP.any_instance.expects(:post).times(ActiveUtils::Connection::MAX_RETRIES).raises(Errno::ECONNREFUSED)
142
170
 
143
- assert_raises(ActiveMerchant::ConnectionError) do
171
+ assert_raises(ActiveUtils::ConnectionError) do
144
172
  @connection.request(:post, '')
145
173
  end
146
174
  end
@@ -160,7 +188,7 @@ class ConnectionTest < Minitest::Test
160
188
 
161
189
  @connection.retry_safe = true
162
190
 
163
- assert_raises(ActiveMerchant::ConnectionError) do
191
+ assert_raises(ActiveUtils::ConnectionError) do
164
192
  @connection.request(:post, '')
165
193
  end
166
194
  end
@@ -169,7 +197,7 @@ class ConnectionTest < Minitest::Test
169
197
  @connection.logger.expects(:error).once
170
198
  Net::HTTP.any_instance.expects(:post).raises(OpenSSL::X509::CertificateError)
171
199
 
172
- assert_raises(ActiveMerchant::ClientCertificateError) do
200
+ assert_raises(ActiveUtils::ClientCertificateError) do
173
201
  @connection.request(:post, '')
174
202
  end
175
203
  end
@@ -65,4 +65,23 @@ class CountryTest < Minitest::Test
65
65
  assert_equal(country_names.sort, country_names)
66
66
  end
67
67
 
68
+ def test_countries_that_do_not_use_postalcodes_are_unique
69
+ country_codes = Country::COUNTRIES_THAT_DO_NOT_USE_POSTALCODES
70
+ assert_equal(country_codes.uniq.length, country_codes.length)
71
+ end
72
+
73
+ def test_change_to_countries_that_do_not_use_postalcodes_is_intentional
74
+ country_codes = Country::COUNTRIES_THAT_DO_NOT_USE_POSTALCODES
75
+ assert_equal(country_codes.length, 31)
76
+ end
77
+
78
+ def test_canada_uses_postal_codes
79
+ canada = Country.find('Canada')
80
+ assert canada.uses_postal_codes?
81
+ end
82
+
83
+ def test_qatar_does_not_use_postal_codes
84
+ qatar = Country.find('Qatar')
85
+ refute qatar.uses_postal_codes?
86
+ end
68
87
  end
@@ -15,15 +15,66 @@ class NetworkConnectionRetriesTest < Minitest::Test
15
15
  end
16
16
 
17
17
  def test_unrecoverable_exception
18
- assert_raises(ActiveMerchant::ConnectionError) do
18
+ raised = assert_raises(ActiveUtils::ConnectionError) do
19
19
  retry_exceptions do
20
20
  raise EOFError
21
21
  end
22
22
  end
23
+ assert_equal "The remote server dropped the connection", raised.message
24
+ end
25
+
26
+ def test_econnreset_raises_correctly
27
+ raised = assert_raises(ActiveUtils::ConnectionError) do
28
+ retry_exceptions do
29
+ raise Errno::ECONNRESET
30
+ end
31
+ end
32
+ assert_equal "The remote server reset the connection", raised.message
33
+ end
34
+
35
+ def test_timeout_errors_raise_correctly
36
+ exceptions = [Timeout::Error, Errno::ETIMEDOUT]
37
+ if RUBY_VERSION >= '2.0.0'
38
+ exceptions += [Net::ReadTimeout, Net::OpenTimeout]
39
+ end
40
+
41
+ exceptions.each do |exception|
42
+ raised = assert_raises(ActiveUtils::ConnectionError) do
43
+ retry_exceptions do
44
+ raise exception
45
+ end
46
+ end
47
+ assert_equal "The connection to the remote server timed out", raised.message
48
+ end
49
+ end
50
+
51
+ def test_socket_error_raises_correctly
52
+ raised = assert_raises(ActiveUtils::ConnectionError) do
53
+ retry_exceptions do
54
+ raise SocketError
55
+ end
56
+ end
57
+ assert_equal "The connection to the remote server could not be established", raised.message
58
+ end
59
+
60
+ def test_ssl_errors_raise_correctly
61
+ exceptions = [OpenSSL::SSL::SSLError]
62
+ if RUBY_VERSION >= '2.1.0'
63
+ exceptions += [OpenSSL::SSL::SSLErrorWaitWritable, OpenSSL::SSL::SSLErrorWaitReadable]
64
+ end
65
+
66
+ exceptions.each do |exception|
67
+ raised = assert_raises(ActiveUtils::ConnectionError) do
68
+ retry_exceptions do
69
+ raise exception
70
+ end
71
+ end
72
+ assert_equal "The SSL connection to the remote server could not be established", raised.message
73
+ end
23
74
  end
24
75
 
25
76
  def test_invalid_response_error
26
- assert_raises(ActiveMerchant::InvalidResponseError) do
77
+ assert_raises(ActiveUtils::InvalidResponseError) do
27
78
  retry_exceptions do
28
79
  raise Zlib::BufError
29
80
  end
@@ -32,7 +83,7 @@ class NetworkConnectionRetriesTest < Minitest::Test
32
83
 
33
84
  def test_unrecoverable_exception_logged_if_logger_provided
34
85
  @logger.expects(:info).once
35
- assert_raises(ActiveMerchant::ConnectionError) do
86
+ assert_raises(ActiveUtils::ConnectionError) do
36
87
  retry_exceptions :logger => @logger do
37
88
  raise EOFError
38
89
  end
@@ -48,9 +99,9 @@ class NetworkConnectionRetriesTest < Minitest::Test
48
99
  end
49
100
 
50
101
  def test_failure_limit_reached
51
- @requester.expects(:post).times(ActiveMerchant::NetworkConnectionRetries::DEFAULT_RETRIES).raises(Errno::ECONNREFUSED)
102
+ @requester.expects(:post).times(ActiveUtils::NetworkConnectionRetries::DEFAULT_RETRIES).raises(Errno::ECONNREFUSED)
52
103
 
53
- assert_raises(ActiveMerchant::ConnectionError) do
104
+ assert_raises(ActiveUtils::ConnectionError) do
54
105
  retry_exceptions do
55
106
  @requester.post
56
107
  end
@@ -59,9 +110,9 @@ class NetworkConnectionRetriesTest < Minitest::Test
59
110
 
60
111
  def test_failure_limit_reached_logs_final_error
61
112
  @logger.expects(:info).times(3)
62
- @requester.expects(:post).times(ActiveMerchant::NetworkConnectionRetries::DEFAULT_RETRIES).raises(Errno::ECONNREFUSED)
113
+ @requester.expects(:post).times(ActiveUtils::NetworkConnectionRetries::DEFAULT_RETRIES).raises(Errno::ECONNREFUSED)
63
114
 
64
- assert_raises(ActiveMerchant::ConnectionError) do
115
+ assert_raises(ActiveUtils::ConnectionError) do
65
116
  retry_exceptions(:logger => @logger) do
66
117
  @requester.post
67
118
  end
@@ -91,17 +142,35 @@ class NetworkConnectionRetriesTest < Minitest::Test
91
142
  raises(Errno::ECONNREFUSED).
92
143
  raises(EOFError)
93
144
 
94
- assert_raises(ActiveMerchant::ConnectionError) do
145
+ assert_raises(ActiveUtils::ConnectionError) do
95
146
  retry_exceptions :retry_safe => true do
96
147
  @requester.post
97
148
  end
98
149
  end
99
150
  end
100
151
 
152
+ def test_delay_between_retries
153
+ @requester.expects(:post).times(2).raises(EOFError).then.returns(@ok)
154
+ Kernel.expects(sleep: 0.5)
155
+
156
+ retry_exceptions retry_safe: true, delay: 0.5 do
157
+ @requester.post
158
+ end
159
+ end
160
+
161
+ def test_no_delay_without_specified_option
162
+ @requester.expects(:post).times(2).raises(EOFError).then.returns(@ok)
163
+ Kernel.expects(sleep: 0.5).never
164
+
165
+ retry_exceptions retry_safe: true do
166
+ @requester.post
167
+ end
168
+ end
169
+
101
170
  def test_failure_with_ssl_certificate
102
171
  @requester.expects(:post).raises(OpenSSL::X509::CertificateError)
103
172
 
104
- assert_raises(ActiveMerchant::ClientCertificateError) do
173
+ assert_raises(ActiveUtils::ClientCertificateError) do
105
174
  retry_exceptions do
106
175
  @requester.post
107
176
  end
@@ -112,7 +181,7 @@ class NetworkConnectionRetriesTest < Minitest::Test
112
181
  @logger.expects(:error).once
113
182
  @requester.expects(:post).raises(OpenSSL::X509::CertificateError)
114
183
 
115
- assert_raises(ActiveMerchant::ClientCertificateError) do
184
+ assert_raises(ActiveUtils::ClientCertificateError) do
116
185
  retry_exceptions :logger => @logger do
117
186
  @requester.post
118
187
  end
@@ -122,7 +191,7 @@ class NetworkConnectionRetriesTest < Minitest::Test
122
191
  def test_failure_with_additional_exceptions_specified
123
192
  @requester.expects(:post).raises(MyNewError)
124
193
 
125
- assert_raises(ActiveMerchant::ConnectionError) do
194
+ assert_raises(ActiveUtils::ConnectionError) do
126
195
  retry_exceptions :connection_exceptions => {MyNewError => "my message"} do
127
196
  @requester.post
128
197
  end
@@ -138,4 +207,12 @@ class NetworkConnectionRetriesTest < Minitest::Test
138
207
  end
139
208
  end
140
209
  end
210
+
211
+ def test_retries_with_custom_error_specified
212
+ @requester.expects(:post).times(2).raises(Errno::ETIMEDOUT).then.returns(@ok)
213
+
214
+ retry_exceptions retriable_exceptions: { Errno::ETIMEDOUT => "The connection to the remote server timed out"} do
215
+ @requester.post
216
+ end
217
+ end
141
218
  end
@@ -1,24 +1,24 @@
1
1
  require 'test_helper'
2
2
 
3
- class MyPost < ActiveMerchant::PostData
3
+ class MyPost < ActiveUtils::PostData
4
4
  self.required_fields = [ :ccnumber, :ccexp, :firstname, :lastname, :username, :password, :order_id, :key, :time ]
5
5
  end
6
6
 
7
7
  class PostDataTest < Minitest::Test
8
8
  def teardown
9
- ActiveMerchant::PostData.required_fields = []
9
+ ActiveUtils::PostData.required_fields = []
10
10
  end
11
11
 
12
12
  def test_element_assignment
13
13
  name = 'Cody Fauser'
14
- post = ActiveMerchant::PostData.new
14
+ post = ActiveUtils::PostData.new
15
15
 
16
16
  post[:name] = name
17
17
  assert_equal name, post[:name]
18
18
  end
19
19
 
20
20
  def test_ignore_blank_fields
21
- post = ActiveMerchant::PostData.new
21
+ post = ActiveUtils::PostData.new
22
22
  assert_equal 0, post.keys.size
23
23
 
24
24
  post[:name] = ''
@@ -29,8 +29,8 @@ class PostDataTest < Minitest::Test
29
29
  end
30
30
 
31
31
  def test_dont_ignore_required_blank_fields
32
- ActiveMerchant::PostData.required_fields = [ :name ]
33
- post = ActiveMerchant::PostData.new
32
+ ActiveUtils::PostData.required_fields = [ :name ]
33
+ post = ActiveUtils::PostData.new
34
34
 
35
35
  assert_equal 0, post.keys.size
36
36
 
@@ -18,7 +18,7 @@ class PostsDataTest < Minitest::Test
18
18
  requester.expects(:post).raises(Errno::ECONNREFUSED).times(3)
19
19
  Connection.any_instance.stubs(:http => requester)
20
20
 
21
- assert_raises ActiveMerchant::ConnectionError do
21
+ assert_raises ActiveUtils::ConnectionError do
22
22
  @poster.raw_ssl_request(:post, "https://shopify.com", "", {})
23
23
  end
24
24
  end
@@ -29,11 +29,11 @@ class PostsDataTest < Minitest::Test
29
29
  requester.expects(:post).raises(Errno::ECONNREFUSED).times(1)
30
30
  Connection.any_instance.stubs(:http => requester)
31
31
 
32
- assert_raises ActiveMerchant::ConnectionError do
32
+ assert_raises ActiveUtils::ConnectionError do
33
33
  @poster.raw_ssl_request(:post, "https://shopify.com", "", {})
34
34
  end
35
35
  ensure
36
- SSLPoster.max_retries = ActiveMerchant::Connection::MAX_RETRIES
36
+ SSLPoster.max_retries = ActiveUtils::Connection::MAX_RETRIES
37
37
  end
38
38
 
39
39
  def test_logger_warns_if_ssl_strict_disabled
@@ -54,5 +54,20 @@ class PostsDataTest < Minitest::Test
54
54
  SSLPoster.ssl_strict = true
55
55
  @poster.raw_ssl_request(:post, "https://shopify.com", "", {})
56
56
  end
57
-
57
+
58
+ def test_set_proxy_address_and_port
59
+ SSLPoster.proxy_address = 'http://proxy.example.com'
60
+ SSLPoster.proxy_port = '8888'
61
+ assert_equal @poster.proxy_address, 'http://proxy.example.com'
62
+ assert_equal @poster.proxy_port, '8888'
63
+ end
64
+
65
+ class HttpConnectionAbort < StandardError; end
66
+
67
+ def test_respecting_environment_proxy_settings
68
+ Net::HTTP.stubs(:new).with('example.com', 80, :ENV, nil).raises(PostsDataTest::HttpConnectionAbort)
69
+ assert_raises(PostsDataTest::HttpConnectionAbort) do
70
+ @poster.ssl_post('http://example.com', '')
71
+ end
72
+ end
58
73
  end
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class Dood
4
- include ActiveMerchant::Validateable
4
+ include ActiveUtils::Validateable
5
5
 
6
6
  attr_accessor :name, :email, :country
7
7
 
metadata CHANGED
@@ -1,36 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 3.3.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQ8wDQYDVQQDDAZhZG1p
14
- bnMxFzAVBgoJkiaJk/IsZAEZFgdzaG9waWZ5MRMwEQYKCZImiZPyLGQBGRYDY29t
15
- MB4XDTE0MDUxNTIwMzM0OFoXDTE1MDUxNTIwMzM0OFowPzEPMA0GA1UEAwwGYWRt
16
- aW5zMRcwFQYKCZImiZPyLGQBGRYHc2hvcGlmeTETMBEGCgmSJomT8ixkARkWA2Nv
17
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL0/81O3e1vh5smcwp2G
18
- MpLQ6q0kejQLa65bPYPxdzWA1SYOKyGfw+yR9LdFzsuKpwWzKq6zX35lj1IckWS4
19
- bNBEQzxmufUxU0XPM02haFB8fOfDJzdXsWte9Ge4IFwahwn68gpMqN+BvxL+KMYz
20
- Iut9YmN44d4LZdsENEIO5vmybuG2vYDz7R56qB0PA+Q2P2CdhymsBad2DQs69FBo
21
- uico9V6VMYYctL9lCYdzu9IXrOYNTt88suKIVzzAlHOKeN0Ng5qdztFoTR8sfxDr
22
- Ydg3KHl5n47wlpgd8R0f/4b5gGxW+v9pyJCgQnLlRu7DedVSvv7+GMtj3g9r3nhJ
23
- KqECAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFI/o
24
- maf34HXbUOQsdoLHacEKQgunMB0GA1UdEQQWMBSBEmFkbWluc0BzaG9waWZ5LmNv
25
- bTAdBgNVHRIEFjAUgRJhZG1pbnNAc2hvcGlmeS5jb20wDQYJKoZIhvcNAQEFBQAD
26
- ggEBADkK9aj5T0HPExsov4EoMWFnO+G7RQ28C30VAfKxnL2UxG6i4XMHVs6Xi94h
27
- qXFw1ec9Y2eDUqaolT3bviOk9BB197+A8Vz/k7MC6ci2NE+yDDB7HAC8zU6LAx8Y
28
- Iqvw7B/PSZ/pz4bUVFlTATif4mi1vO3lidRkdHRtM7UePSn2rUpOi0gtXBP3bLu5
29
- YjHJN7wx5cugMEyroKITG5gL0Nxtu21qtOlHX4Hc4KdE2JqzCPOsS4zsZGhgwhPs
30
- fl3hbtVFTqbOlwL9vy1fudXcolIE/ZTcxQ+er07ZFZdKCXayR9PPs64heamfn0fp
31
- TConQSX2BnZdhIEYW+cKzEC/bLc=
32
- -----END CERTIFICATE-----
33
- date: 2014-08-11 00:00:00.000000000 Z
10
+ cert_chain: []
11
+ date: 2021-11-08 00:00:00.000000000 Z
34
12
  dependencies:
35
13
  - !ruby/object:Gem::Dependency
36
14
  name: activesupport
@@ -38,14 +16,14 @@ dependencies:
38
16
  requirements:
39
17
  - - ">="
40
18
  - !ruby/object:Gem::Version
41
- version: 2.3.11
19
+ version: '4.2'
42
20
  type: :runtime
43
21
  prerelease: false
44
22
  version_requirements: !ruby/object:Gem::Requirement
45
23
  requirements:
46
24
  - - ">="
47
25
  - !ruby/object:Gem::Version
48
- version: 2.3.11
26
+ version: '4.2'
49
27
  - !ruby/object:Gem::Dependency
50
28
  name: i18n
51
29
  requirement: !ruby/object:Gem::Requirement
@@ -74,6 +52,20 @@ dependencies:
74
52
  - - ">="
75
53
  - !ruby/object:Gem::Version
76
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
77
69
  - !ruby/object:Gem::Dependency
78
70
  name: mocha
79
71
  requirement: !ruby/object:Gem::Requirement
@@ -95,24 +87,30 @@ executables: []
95
87
  extensions: []
96
88
  extra_rdoc_files: []
97
89
  files:
90
+ - ".github/probots.yml"
98
91
  - ".gitignore"
99
92
  - ".travis.yml"
93
+ - CHANGELOG.md
94
+ - CONTRIBUTING.md
100
95
  - Gemfile
101
96
  - MIT-LICENSE
102
97
  - README.md
103
98
  - Rakefile
104
99
  - active_utils.gemspec
100
+ - gemfiles/Gemfile.activesupport-master
101
+ - gemfiles/Gemfile.activesupport42
102
+ - gemfiles/Gemfile.activesupport50
103
+ - gemfiles/Gemfile.activesupport52
105
104
  - lib/active_utils.rb
106
- - lib/active_utils/common/connection.rb
107
- - lib/active_utils/common/country.rb
108
- - lib/active_utils/common/currency_code.rb
109
- - lib/active_utils/common/error.rb
110
- - lib/active_utils/common/network_connection_retries.rb
111
- - lib/active_utils/common/post_data.rb
112
- - lib/active_utils/common/posts_data.rb
113
- - lib/active_utils/common/requires_parameters.rb
114
- - lib/active_utils/common/utils.rb
115
- - lib/active_utils/common/validateable.rb
105
+ - lib/active_utils/connection.rb
106
+ - lib/active_utils/country.rb
107
+ - lib/active_utils/currency_code.rb
108
+ - lib/active_utils/error.rb
109
+ - lib/active_utils/network_connection_retries.rb
110
+ - lib/active_utils/post_data.rb
111
+ - lib/active_utils/posts_data.rb
112
+ - lib/active_utils/requires_parameters.rb
113
+ - lib/active_utils/validateable.rb
116
114
  - lib/active_utils/version.rb
117
115
  - lib/certs/cacert.pem
118
116
  - shipit.rubygems.yml
@@ -124,12 +122,12 @@ files:
124
122
  - test/unit/network_connection_retries_test.rb
125
123
  - test/unit/post_data_test.rb
126
124
  - test/unit/posts_data_test.rb
127
- - test/unit/utils_test.rb
128
125
  - test/unit/validateable_test.rb
129
126
  homepage: http://github.com/shopify/active_utils
130
127
  licenses:
131
128
  - MIT
132
- metadata: {}
129
+ metadata:
130
+ allowed_push_host: https://rubygems.org
133
131
  post_install_message:
134
132
  rdoc_options: []
135
133
  require_paths:
@@ -145,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
143
  - !ruby/object:Gem::Version
146
144
  version: '0'
147
145
  requirements: []
148
- rubyforge_project: active_utils
149
- rubygems_version: 2.2.2
146
+ rubygems_version: 3.2.20
150
147
  signing_key:
151
148
  specification_version: 4
152
149
  summary: Common utils used by active_merchant, active_fulfillment, and active_shipping
checksums.yaml.gz.sig DELETED
Binary file
@@ -1,50 +0,0 @@
1
- module ActiveMerchant
2
- class InvalidCurrencyCodeError < StandardError
3
- end
4
-
5
- class CurrencyCode
6
- ISO_CURRENCIES = [
7
- "AED", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD",
8
- "BND", "BOB", "BRL", "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CHF", "CLP", "CNY", "COP", "CRC",
9
- "CZK", "DKK", "DOP", "DZD", "EGP", "ETB", "EUR", "FJD", "GBP", "GEL", "GHS", "GMD", "GTQ", "GYD",
10
- "HKD", "HNL", "HRK", "HUF", "IDR", "ILS", "INR", "ISK", "JEP", "JMD", "JOD", "JPY", "KES", "KGS",
11
- "KHR", "KRW", "KWD", "KYD", "KZT", "LBP", "LKR", "LTL", "LVL", "MAD", "MDL", "MGA", "MKD", "MMK",
12
- "MNT", "MOP", "MUR", "MVR", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR",
13
- "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SCR", "SEK",
14
- "SGD", "STD", "SYP", "THB", "TND", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "VEF",
15
- "VND", "VUV", "WST", "XAF", "XCD", "XOF", "XPF", "ZAR", "ZMW"
16
- ]
17
-
18
- NON_ISO_TO_ISO = {
19
- "ARN" => "ARS",
20
- "AZM" => "AZN",
21
- "CHP" => "CLP",
22
- "DHS" => "AED",
23
- "ECD" => "XCD",
24
- "GHC" => "GHS",
25
- "JAD" => "JMD",
26
- "JYE" => "JPY",
27
- "KUD" => "KWD",
28
- "MZM" => "MZN",
29
- "NTD" => "TWD",
30
- "NMP" => "MXN",
31
- "RDD" => "DOP",
32
- "RMB" => "CNY",
33
- "SFR" => "CHF",
34
- "SID" => "SGD",
35
- "UKL" => "GBP",
36
- "WON" => "KRW"
37
- }
38
-
39
- def self.standardize(code)
40
- code = code.upcase unless code.nil?
41
-
42
- return code if is_iso?(code)
43
- NON_ISO_TO_ISO[code] || raise(InvalidCurrencyCodeError, "#{code} is not an ISO currency, nor can it be converted to one.")
44
- end
45
-
46
- def self.is_iso?(code)
47
- ISO_CURRENCIES.include? code
48
- end
49
- end
50
- end
@@ -1,20 +0,0 @@
1
- require 'securerandom'
2
-
3
- module ActiveMerchant #:nodoc:
4
- module Utils #:nodoc:
5
- def generate_unique_id
6
- SecureRandom.hex(16)
7
- end
8
-
9
- module_function :generate_unique_id
10
-
11
- def deprecated(message)
12
- warning = Kernel.caller[1] + message
13
- if respond_to?(:logger) && logger.present?
14
- logger.warn(warning)
15
- else
16
- warn(warning)
17
- end
18
- end
19
- end
20
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class UtilsTest < Minitest::Test
4
- def test_unique_id_should_be_32_chars_and_alphanumeric
5
- assert_match /^\w{32}$/, ActiveMerchant::Utils.generate_unique_id
6
- end
7
- end
data.tar.gz.sig DELETED
@@ -1 +0,0 @@
1
- �:2�Jߔ*o��ϰ��F>��c-�kw� ��Mz�=� �)y��l�e��8����z k.�Y���XGb^#�`�5��#z\� ������, ܤU����s�