Skip to content

Commit b4ceb2e

Browse files
author
Sunny Raj Rathod
authored
Merge pull request #156 from AuthorizeNet/future
Merge from future for 1.9.5 release
2 parents 330dadd + 4d4936c commit b4ceb2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3525
-3707
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
Gemfile.lock
2-
spec/credentials.yml
32
.ruby-*
43
.idea
54
gemfiles/*.lock

.rubocop.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
AllCops:
2+
TargetRubyVersion: 2.2
3+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
4+
# to ignore them, so only the ones explicitly set in this file are enabled.
5+
Exclude:
6+
- 'sample-code-ruby/**/*'
7+
8+
Style/FrozenStringLiteralComment:
9+
Enabled: false
10+
11+
# Check quotes usage according to lint rule below.
12+
Style/StringLiterals:
13+
Enabled: true
14+
EnforcedStyle: single_quotes
15+
AutoCorrect: false
16+
17+
Style/ConditionalAssignment:
18+
Enabled: true
19+
AutoCorrect: false

.scrutinizer.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ checks:
22
ruby:
33
code_rating: true
44
duplicate_code: true
5+
tools:
6+
external_code_coverage: true

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ gemfile:
1212
- gemfiles/rails_42.gemfile
1313
- gemfiles/rails_50.gemfile
1414
- gemfiles/rails_51.gemfile
15+
- gemfiles/rails_52.gemfile
1516

1617
before_script:
1718
- git submodule update --remote --recursive
1819

1920
script:
2021
- bundle exec rake spec:ci
22+
- bundle exec rake spec:aim
2123
- bundle exec rake spec:api
24+
- bundle exec rake spec:cim
25+
- bundle exec rake spec:reporting
2226
- bundle exec rake spec:testrunner

Appraisals

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ end
99
appraise "rails-51" do
1010
gem 'rails', '~> 5.1', '>= 5.1.1'
1111
end
12+
13+
appraise "rails-52" do
14+
gem 'rails', '~> 5.2.0.beta2'
15+
end

README.md

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Authorize.Net Ruby SDK
22

3-
[![Travis CI Status](https://travis-ci.org/AuthorizeNet/sdk-ruby.svg?branch=master)](https://travis-ci.org/AuthorizeNet/sdk-ruby)
4-
[![Coverage Status](https://coveralls.io/repos/github/AuthorizeNet/sdk-ruby/badge.svg?branch=master)](https://coveralls.io/github/AuthorizeNet/sdk-ruby?branch=master)
5-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/AuthorizeNet/sdk-ruby/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/AuthorizeNet/sdk-ruby/?branch=master)
6-
[![Gem Version](https://badge.fury.io/rb/authorizenet.svg)](https://badge.fury.io/rb/authorizenet)
3+
[![Version ][rubygems_badge]][rubygems]
4+
[![Travis CI ][travis_badge]][travis]
5+
[![Coverage ][coverage_badge]][coverage]
6+
[![Scrutinizer ][scrutinizer_badge]][scrutinizer]
77

8+
Starting Release 1.8.6 November 2015 the Authorize.Net API has been [reorganized to be more merchant focused](https://developer.authorize.net/api/upgrade_guide/).
9+
AIM, ARB, CIM, Reporting and SIM have all been deprecated in favor of AuthorizeNet::API.
810

911
## Requirements
1012
* Ruby 2.2.2 or higher
@@ -108,4 +110,13 @@ For additional help in testing your own code, Authorize.Net maintains a [compreh
108110

109111

110112
## License
111-
This repository is distributed under a proprietary license. See the provided [`LICENSE.txt`](/LICENSE.txt) file.
113+
This repository is distributed under a proprietary license. See the provided [`LICENSE.txt`](/LICENSE.txt) file.
114+
115+
[rubygems_badge]: https://badge.fury.io/rb/authorizenet.svg
116+
[rubygems]: https://rubygems.org/gems/authorizenet
117+
[travis_badge]: https://travis-ci.org/AuthorizeNet/sdk-ruby.svg?branch=master
118+
[travis]: https://travis-ci.org/AuthorizeNet/sdk-ruby
119+
[coverage_badge]: https://scrutinizer-ci.com/g/AuthorizeNet/sdk-ruby/badges/coverage.png?b=master
120+
[coverage]: https://scrutinizer-ci.com/g/AuthorizeNet/sdk-ruby/?branch=master
121+
[scrutinizer_badge]: https://scrutinizer-ci.com/g/AuthorizeNet/sdk-ruby/badges/quality-score.png?b=master
122+
[scrutinizer]: https://scrutinizer-ci.com/g/AuthorizeNet/sdk-ruby/?branch=master

Rakefile

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require "rake"
22
require "rspec/core/rake_task"
33

4-
task :default => :spec
4+
task default: :spec
55
desc "Run all specs"
66
RSpec::Core::RakeTask.new(:spec) do |spec|
77
spec.pattern = FileList['spec/**/*_spec.rb']
@@ -11,46 +11,46 @@ end
1111
namespace "spec" do
1212
desc "Run the CIM spec"
1313
RSpec::Core::RakeTask.new('cim') do |spec|
14-
spec.pattern = FileList['spec/cim_spec.rb']
14+
spec.pattern = FileList['spec/cim_spec.rb']
1515
spec.rspec_opts = ['--options', 'spec/spec.opts']
1616
end
17-
17+
1818
desc "Run the ARB spec"
1919
RSpec::Core::RakeTask.new('arb') do |spec|
2020
spec.pattern = FileList['spec/arb_spec.rb']
2121
spec.rspec_opts = ['--options', 'spec/spec.opts']
2222
end
23-
23+
2424
desc "Run the AIM spec"
2525
RSpec::Core::RakeTask.new('aim') do |spec|
2626
spec.pattern = FileList['spec/aim_spec.rb']
2727
spec.rspec_opts = ['--options', 'spec/spec.opts']
2828
end
29-
29+
3030
desc "Run the API spec"
3131
RSpec::Core::RakeTask.new('api') do |spec|
3232
spec.pattern = FileList['spec/api_spec.rb']
3333
spec.rspec_opts = ['--options', 'spec/spec.opts']
3434
end
35-
35+
3636
desc "Run the CI Unit Test spec"
37-
RSpec::Core::RakeTask.new('ci') do |spec|
38-
spec.pattern = FileList['spec/authorize_net_spec.rb']
39-
spec.rspec_opts = ['--options', 'spec/spec.opts']
40-
end
41-
37+
RSpec::Core::RakeTask.new('ci') do |spec|
38+
spec.pattern = FileList['spec/authorize_net_spec.rb']
39+
spec.rspec_opts = ['--options', 'spec/spec.opts']
40+
end
41+
4242
desc "Run the SIM spec"
4343
RSpec::Core::RakeTask.new('sim') do |spec|
4444
spec.pattern = FileList['spec/sim_spec.rb']
4545
spec.rspec_opts = ['--options', 'spec/spec.opts']
4646
end
47-
47+
4848
desc "Run the Reporting spec"
4949
RSpec::Core::RakeTask.new('reporting') do |spec|
5050
spec.pattern = FileList['spec/reporting_spec.rb']
5151
spec.rspec_opts = ['--options', 'spec/spec.opts']
5252
end
53-
53+
5454
desc "Run the Sample code Test Runner"
5555
RSpec::Core::RakeTask.new('testrunner') do |spec|
5656
spec.pattern = FileList['sample-code-ruby/spec/sample_code_spec.rb']
@@ -60,18 +60,18 @@ end
6060

6161
desc "Builds the gem"
6262
task :gem do
63-
%x"gem build authorizenet.gemspec"
63+
`gem build authorizenet.gemspec`
6464
end
6565

6666
desc "Builds the documentation"
6767
task :doc do
68-
%x"rdoc -U -S --main=README.rdoc -A documented_accessor=RW README.rdoc lib/"
68+
`rdoc -U -S --main=README.rdoc -A documented_accessor=RW README.rdoc lib/`
6969
end
7070

7171
namespace "doc" do
7272
desc "Builds the documentation with graphical class hierarchy"
7373
task :graph do
74-
%x"rdoc -U -d -S --main=README.rdoc -A documented_accessor=RW README.rdoc lib/"
74+
`rdoc -U -d -S --main=README.rdoc -A documented_accessor=RW README.rdoc lib/`
7575
end
7676
end
7777

@@ -82,7 +82,7 @@ end
8282

8383
desc "Bundles the sample app."
8484
task :samples do
85-
%x". sample_app_version && zip -r anet_ruby_samples-$VERSION.zip sample_app -x '*/.*' -x '*/Icon' -x '*/__MACOSX'"
85+
`. sample_app_version && zip -r anet_ruby_samples-$VERSION.zip sample_app -x '*/.*' -x '*/Icon' -x '*/__MACOSX'`
8686
end
8787

8888
desc "Bundles the sample app and gem."

authorizenet.gemspec

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ Gem::Specification.new do |s|
1616

1717
s.add_runtime_dependency 'activesupport', '>= 4.2.6'
1818
s.add_runtime_dependency 'nokogiri', '~> 1.6', '>= 1.6.4'
19-
s.add_runtime_dependency "roxml", "= 3.3.1"
19+
s.add_runtime_dependency 'roxml', '>= 3.3.1'
2020

21+
s.add_development_dependency('appraisal')
2122
s.add_development_dependency 'rake', '~> 0.8', '>= 0.8.7'
2223
s.add_development_dependency 'rspec', '~> 2.1'
23-
s.add_development_dependency('appraisal')
24+
s.add_development_dependency 'simplecov'
25+
s.add_development_dependency 'scrutinizer-ocular'
2426
end

gemfiles/rails_52.gemfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "coveralls", require: false
6+
gem "rails", "~> 5.2.0.beta2"
7+
8+
gemspec path: "../"

lib/app/helpers/authorize_net_helper.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# The Authorize.Net Rails Helper module. Provides methods to assist with integrating the various APIs.
22

33
module AuthorizeNetHelper
4-
54
# Generates a collection of hidden form fields (as a raw HTML string) for a AuthorizeNet::SIM::Transaction
65
# (sim_transaction). You can specify any html_options that hidden_field_tag accepts, and the
76
# hidden fields will be built with those options.
87
def sim_fields(sim_transaction, html_options = {})
98
fields = sim_transaction.form_fields.collect do |k, v|
10-
if v.kind_of? Array
9+
if v.is_a? Array
1110
v.collect { |val| hidden_field_tag(k, val, html_options) }
1211
else
1312
hidden_field_tag(k, v, html_options)
@@ -21,4 +20,4 @@ def sim_fields(sim_transaction, html_options = {})
2120
return field_str
2221
end
2322
end
24-
end
23+
end

lib/authorize_net.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# the current runtime to see if Rails is present. If it is, we inject our helper into
33
# ActiveSupport.
44

5-
#coverall
5+
# coverall
66
# require 'coveralls'
77
# Coveralls.wear!
88

@@ -16,7 +16,7 @@
1616

1717
# TODO: Add local data validation where possible
1818

19-
$:.unshift File.dirname(__FILE__)
19+
$LOAD_PATH.unshift File.dirname(__FILE__)
2020

2121
require "authorize_net/authorize_net"
2222
require "authorize_net/payment_methods/credit_card"
@@ -86,8 +86,8 @@
8686
if defined?(Rails::Railtie)
8787
module AuthorizeNet
8888
class Railtie < Rails::Railtie
89-
initializer "authorize_net.load_path_initialize" do |app|
90-
%w{ models controllers helpers }.each do |dir|
89+
initializer "authorize_net.load_path_initialize" do |_app|
90+
%w[models controllers helpers].each do |dir|
9191
path = File.join(File.dirname(__FILE__), 'app', dir)
9292
$LOAD_PATH << path
9393
ActiveSupport::Dependencies.autoload_paths << path
@@ -97,7 +97,7 @@ class Railtie < Rails::Railtie
9797
end
9898
end
9999
else
100-
%w{ models controllers helpers }.each do |dir|
100+
%w[models controllers helpers].each do |dir|
101101
path = File.join(File.dirname(__FILE__), 'app', dir)
102102
$LOAD_PATH << path
103103
ActiveSupport::Dependencies.load_paths << path
+15-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
module AuthorizeNet
2-
32
# Models an address.
43
class Address
5-
64
include AuthorizeNet::Model
7-
5+
86
attr_accessor :first_name, :last_name, :company, :street_address, :city, :state, :zip, :country, :phone, :fax, :customer_address_id
9-
7+
108
def to_hash
119
hash = {
12-
:first_name => @first_name,
13-
:last_name => @last_name,
14-
:company => @company,
15-
:address => @street_address,
16-
:city => @city,
17-
:state => @state,
18-
:zip => @zip,
19-
:country => @country,
20-
:phone => @phone,
21-
:fax => @fax,
22-
:customer_address_id => @customer_address_id
10+
first_name: @first_name,
11+
last_name: @last_name,
12+
company: @company,
13+
address: @street_address,
14+
city: @city,
15+
state: @state,
16+
zip: @zip,
17+
country: @country,
18+
phone: @phone,
19+
fax: @fax,
20+
customer_address_id: @customer_address_id
2321
}
24-
hash.delete_if {|k, v| v.nil?}
22+
hash.delete_if { |_k, v| v.nil? }
2523
end
26-
2724
end
28-
29-
end
25+
end
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
module AuthorizeNet
2-
32
# Models a shipping address.
43
class ShippingAddress < Address
5-
64
include AuthorizeNet::Model
75

86
def to_hash
97
hash = {
10-
:ship_to_first_name => @first_name,
11-
:ship_to_last_name => @last_name,
12-
:ship_to_company => @company,
13-
:ship_to_address => @street_address,
14-
:ship_to_city => @city,
15-
:ship_to_state => @state,
16-
:ship_to_zip => @zip,
17-
:ship_to_country => @country,
18-
:ship_to_phone => @phone,
19-
:ship_to_fax => @fax
8+
ship_to_first_name: @first_name,
9+
ship_to_last_name: @last_name,
10+
ship_to_company: @company,
11+
ship_to_address: @street_address,
12+
ship_to_city: @city,
13+
ship_to_state: @state,
14+
ship_to_zip: @zip,
15+
ship_to_country: @country,
16+
ship_to_phone: @phone,
17+
ship_to_fax: @fax
2018
}
21-
hash.delete_if {|k, v| v.nil?}
19+
hash.delete_if { |_k, v| v.nil? }
2220
end
23-
2421
end
25-
26-
end
22+
end

0 commit comments

Comments
 (0)