Skip to content

Commit

Permalink
Fix rails engine (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshields authored Apr 26, 2023
1 parent 6cc274c commit 13ef7e4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

## Next

## 0.2.2 - 2023-04-26

- [PR#11](https://github.com/tablecheck/paygate-ruby/pull/12) Re-add Rails Engine (was dropped in version 0.2.0) ([johnnyshields](https://github.com/johnnyshields))
- [PR#12](https://github.com/tablecheck/paygate-ruby/pull/12) Rename Paygate::ActionView::FormHelper to Paygate::Rails::FormHelper. ([johnnyshields](https://github.com/johnnyshields))

## 0.2.1 - 2023-04-26

- [PR#11](https://github.com/tablecheck/paygate-ruby/pull/11) Deep freeze constants. ([johnnyshields](https://github.com/johnnyshields))

## 0.2.0 - 2023-04-26

- [PR#9](https://github.com/tablecheck/paygate-ruby/pull/9) Rename Paygate::FormHelper to Paygate::Rails::FormHelper. ([johnnyshields](https://github.com/johnnyshields))
- [PR#9](https://github.com/tablecheck/paygate-ruby/pull/9) Rename Paygate::FormHelper to Paygate::ActionView::FormHelper. ([johnnyshields](https://github.com/johnnyshields))
- [PR#9](https://github.com/tablecheck/paygate-ruby/pull/9) Do not include Paygate::FormHelper in ActionView::Base. ([johnnyshields](https://github.com/johnnyshields))
- [PR#9](https://github.com/tablecheck/paygate-ruby/pull/9) Update BIN list. Note BINs can now be a flexible number of digits. ([johnnyshields](https://github.com/johnnyshields))
- [PR#9](https://github.com/tablecheck/paygate-ruby/pull/9) Rename data config YAML keys. ([johnnyshields](https://github.com/johnnyshields))
Expand Down
15 changes: 8 additions & 7 deletions lib/paygate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
require 'paygate/response'
require 'paygate/transaction'
require 'paygate/profile'
require 'paygate/action_view/form_helper' if defined?(ActionView)

if defined?(Rails)
require 'paygate/rails/engine'
require 'paygate/rails/form_helper'
end

module Paygate
extend self

CONFIG = YAML.safe_load(File.read(File.expand_path('../data/config.yml', __dir__)),
permitted_classes: [Symbol]).freeze
LOCALES_MAP = CONFIG[:locales].freeze
LOCALES_MAP.each { |k, v| k.freeze; v.freeze } # rubocop:disable Style/Semicolon
INTL_BRANDS_MAP = CONFIG[:intl_brands].freeze
INTL_BRANDS_MAP.each_value(&:freeze)
KOREA_BIN_NUMBERS = CONFIG[:korea_bin_numbers].freeze
KOREA_BIN_NUMBERS.each(&:freeze)
(LOCALES_MAP = CONFIG[:locales].freeze).each { |k, v| k.freeze; v.freeze } # rubocop:disable Style/Semicolon
(INTL_BRANDS_MAP = CONFIG[:intl_brands].freeze).each_value(&:freeze)
(KOREA_BIN_NUMBERS = CONFIG[:korea_bin_numbers].freeze).each(&:freeze)
DEFAULT_CURRENCY = 'WON'
DEFAULT_LOCALE = 'US'

Expand Down
8 changes: 8 additions & 0 deletions lib/paygate/rails/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

module Paygate
module Rails
class Engine < ::Rails::Engine
end
end
end
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

module Paygate
module ActionView
module Rails
module FormHelper
PAYGATE_FORM_TEXT_FIELDS = {
(PAYGATE_FORM_TEXT_FIELDS = {
mid: {
placeholder: 'Member ID'
},
Expand Down Expand Up @@ -117,13 +117,13 @@ module FormHelper

profile_no: {
placeholder: 'Profile No'
},
}.freeze,

hash_result: {
name: 'hashresult',
placeholder: 'Hash Result'
}
}.freeze
}.freeze).each_value(&:freeze)

def paygate_open_pay_api_js_url
if Paygate.configuration.mode == :live
Expand Down
2 changes: 1 addition & 1 deletion lib/paygate/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Paygate
VERSION = '0.2.1'
VERSION = '0.2.2'
end

0 comments on commit 13ef7e4

Please sign in to comment.