Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup standardrb #57

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
name: CI
on: [ push, pull_request ]
jobs:
standard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6 # keep it on the lowest supported Ruby version
bundler-cache: true

- name: Run Standard
run: bundle exec standardrb

tests:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -39,6 +53,10 @@ jobs:
steps:
- uses: actions/checkout@v4

# we otherwise run into issues with different versions of actionpack / activesupport with Appraisal
- name: Remove Gemfile.lock
run: rm Gemfile.lock

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*.gem
.bundle
pkg/*
*.lock
gemfiles/*.lock
coverage
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.8
2.6.10
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ source "http://rubygems.org"
# Specify your gem's dependencies in datatrans.gemspec
gemspec
gem "simplecov", group: :test, require: nil
gem "standard", group: :development, require: false
153 changes: 153 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
PATH
remote: .
specs:
datatrans (5.1.0)
activesupport (>= 5.2)
builder
httparty
i18n
multi_xml (>= 0.5.1)

GEM
remote: http://rubygems.org/
specs:
actionpack (6.1.5)
actionview (= 6.1.5)
activesupport (= 6.1.5)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (6.1.5)
activesupport (= 6.1.5)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activesupport (6.1.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
appraisal (2.4.1)
bundler
rake
thor (>= 0.14.0)
ast (2.4.2)
builder (3.2.4)
concurrent-ruby (1.1.10)
crass (1.0.6)
diff-lcs (1.5.0)
docile (1.4.0)
erubi (1.10.0)
httparty (0.20.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
json (2.7.1)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
loofah (2.16.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2022.0105)
mini_portile2 (2.8.5)
minitest (5.15.0)
multi_xml (0.6.0)
nokogiri (1.13.4)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nokogiri (1.13.4-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.4-x86_64-linux)
racc (~> 1.4)
parallel (1.24.0)
parser (3.3.0.3)
ast (~> 2.4.1)
racc
racc (1.6.0)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.9.0)
rexml (3.2.6)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rubocop (1.50.2)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-performance (1.16.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.13.0)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
standard (1.28.5)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50.2)
standard-custom (~> 1.0.0)
standard-performance (~> 1.0.1)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.0.1)
lint_roller (~> 1.0)
rubocop-performance (~> 1.16.0)
thor (1.2.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
zeitwerk (2.5.4)

PLATFORMS
ruby
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
actionpack (>= 5.2)
appraisal
datatrans!
rake
rspec
simplecov
standard

BUNDLED WITH
2.3.3
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'bundler/gem_tasks'
require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new("spec")
task :default => :spec
task default: :spec
42 changes: 20 additions & 22 deletions datatrans.gemspec
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "datatrans/version"

Gem::Specification.new do |s|
s.name = "datatrans"
s.version = Datatrans::VERSION
s.authors = ["Tobias Miesel", "Thomas Maurer", "Corin Langosch", "Pascal Betz"]
s.email = ["[email protected]"]
s.homepage = ""
s.summary = %q{Datatrans Integration for Ruby on Rails}
s.description = %q{Datatrans Integration for Ruby on Rails}
s.name = "datatrans"
s.version = Datatrans::VERSION
s.authors = ["Tobias Miesel", "Thomas Maurer", "Corin Langosch", "Pascal Betz"]
s.email = ["[email protected]"]
s.homepage = ""
s.summary = "Datatrans Integration for Ruby on Rails"
s.description = "Datatrans Integration for Ruby on Rails"

s.rubyforge_project = "datatrans"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.files = `git ls-files`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
s.require_paths = ["lib"]

s.required_ruby_version = '>= 2.6'
s.required_ruby_version = ">= 2.6"

s.add_dependency 'httparty'
s.add_dependency 'activesupport', '>= 5.2'
s.add_dependency 'i18n'
s.add_dependency 'builder'
s.add_dependency 'multi_xml', '>= 0.5.1'
s.add_dependency "httparty"
s.add_dependency "activesupport", ">= 5.2"
s.add_dependency "i18n"
s.add_dependency "builder"
s.add_dependency "multi_xml", ">= 0.5.1"

s.add_development_dependency 'actionpack', '>= 5.2'
s.add_development_dependency 'appraisal'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
s.license = 'MIT'
s.add_development_dependency "actionpack", ">= 5.2"
s.add_development_dependency "appraisal"
s.add_development_dependency "rake"
s.add_development_dependency "rspec"
s.license = "MIT"
end
18 changes: 9 additions & 9 deletions lib/datatrans.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
require 'active_support/core_ext/module'
require "active_support/core_ext/module"

module Datatrans
InvalidSignatureError = Class.new(StandardError)
end

require 'datatrans/version'
require 'datatrans/common'
require 'datatrans/config'
require 'datatrans/xml/transaction'
require 'datatrans/web/transaction'
require 'datatrans/json/transaction'
require "datatrans/version"
require "datatrans/common"
require "datatrans/config"
require "datatrans/xml/transaction"
require "datatrans/web/transaction"
require "datatrans/json/transaction"

begin
require 'action_view'
require 'datatrans/web/view_helper'
require "action_view"
require "datatrans/web/view_helper"
ActionView::Base.send(:include, Datatrans::Web::ViewHelper)
rescue LoadError
end
10 changes: 5 additions & 5 deletions lib/datatrans/common.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'openssl'
require "openssl"

module Datatrans::Common
def sign(*fields)
return nil unless self.datatrans.sign_key
key = self.datatrans.sign_key.split(/([a-f0-9][a-f0-9])/).reject(&:empty?)
return nil unless datatrans.sign_key
key = datatrans.sign_key.split(/([a-f0-9][a-f0-9])/).reject(&:empty?)
key = key.pack("H*" * key.size)
OpenSSL::HMAC.hexdigest(OpenSSL::Digest::MD5.new, key, fields.join)
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("MD5"), key, fields.join)
end
end
end
22 changes: 11 additions & 11 deletions lib/datatrans/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class Config
DEFAULT_SIGN_KEY = false

SUBDOMAINS = {
payment_page: 'pay',
server_to_server_api: 'api'
payment_page: "pay",
server_to_server_api: "api"
}
DOMAIN = 'datatrans.com'
DOMAIN = "datatrans.com"

attr_reader :environment, :merchant_id, :sign_key, :password, :proxy

Expand All @@ -21,10 +21,10 @@ class Config
# * :proxy (a hash containing :http_proxyaddr, :http_proxyport, :http_proxyuser, :http_proxypass)
def initialize(options = {})
@merchant_id = options[:merchant_id]
raise ArgumentError.new(":merchant_id is required") unless self.merchant_id
raise ArgumentError.new(":merchant_id is required") unless merchant_id
self.environment = options[:environment] || DEFAULT_ENVIRONMENT
@password = options[:password]
raise ArgumentError.new(":password is required") unless self.password
raise ArgumentError.new(":password is required") unless password
@sign_key = options[:sign_key] || DEFAULT_SIGN_KEY
@proxy = options[:proxy] || {}
end
Expand All @@ -34,7 +34,7 @@ def environment=(environment)
if ENVIRONMENTS.include?(environment)
@environment = environment
else
raise "Unknown environment '#{environment}'. Available: #{ENVIRONMENTS.join(', ')}"
raise "Unknown environment '#{environment}'. Available: #{ENVIRONMENTS.join(", ")}"
end
end

Expand All @@ -43,16 +43,16 @@ def url(what, options = {})
case what
when :web_authorize_url
subdomain = SUBDOMAINS[:payment_page]
path = '/upp/jsp/upStart.jsp'
path = "/upp/jsp/upStart.jsp"
when :xml_authorize_url
subdomain = SUBDOMAINS[:server_to_server_api]
path = '/upp/jsp/XML_authorize.jsp'
path = "/upp/jsp/XML_authorize.jsp"
when :xml_settlement_url
subdomain = SUBDOMAINS[:server_to_server_api]
path = '/upp/jsp/XML_processor.jsp'
path = "/upp/jsp/XML_processor.jsp"
when :xml_status_url
subdomain = SUBDOMAINS[:server_to_server_api]
path = '/upp/jsp/XML_status.jsp'
path = "/upp/jsp/XML_status.jsp"
when :init_transaction
subdomain = SUBDOMAINS[:server_to_server_api]
path = "/v1/transactions"
Expand All @@ -73,7 +73,7 @@ def url(what, options = {})
else
raise "Unknown wanted action '#{what}'."
end
subdomain += '.sandbox' unless self.environment == :production
subdomain += ".sandbox" unless environment == :production
"https://#{subdomain}.#{DOMAIN}#{path}"
end

Expand Down
Loading
Loading