<commit_before>module SpreeGateway
  class Engine < Rails::Engine
    engine_name 'solidus_gateway'

    config.autoload_paths += %W(#{config.root}/lib)

    initializer "spree.gateway.payment_methods", :after => "spree.register.payment_methods" do |app|
        app.config.spree.payment_methods << Spree::Gateway::AuthorizeNetCim
        app.config.spree.payment_methods << Spree::Gateway::AuthorizeNet
        app.config.spree.payment_methods << Spree::Gateway::CardSave
        app.config.spree.payment_methods << Spree::Gateway::Eway
        app.config.spree.payment_methods << Spree::Gateway::Linkpoint
        app.config.spree.payment_methods << Spree::Gateway::Moneris
        app.config.spree.payment_methods << Spree::Gateway::PayJunction
        app.config.spree.payment_methods << Spree::Gateway::PayPalGateway
        app.config.spree.payment_methods << Spree::Gateway::SagePay
        app.config.spree.payment_methods << Spree::Gateway::Beanstream
        app.config.spree.payment_methods << Spree::Gateway::BraintreeGateway
        app.config.spree.payment_methods << Spree::Gateway::StripeGateway
        app.config.spree.payment_methods << Spree::Gateway::Worldpay
        app.config.spree.payment_methods << Spree::Gateway::Banwire
        app.config.spree.payment_methods << Spree::Gateway::UsaEpay
        app.config.spree.payment_methods << Spree::BillingIntegration::Skrill::QuickCheckout
        app.config.spree.payment_methods << Spree::Gateway::BalancedGateway
        app.config.spree.payment_methods << Spree::Gateway::DataCash
        app.config.spree.payment_methods << Spree::Gateway::UsaEpay
        app.config.spree.payment_methods << Spree::Gateway::PinGateway
        app.config.spree.payment_methods << Spree::Gateway::Paymill
        app.config.spree.payment_methods << Spree::Gateway::PayflowPro
        app.config.spree.payment_methods << Spree::Gateway::SecurePayAU
        app.config.spree.payment_methods << Spree::Gateway::Maxipago
        app.config.spree.payment_methods << Spree::Gateway::Migs
        app.config.spree.payment_methods << Spree::Gateway::SpreedlyCoreGateway
    end

    def self.activate
      if SpreeGateway::Engine.frontend_available?
        Rails.application.config.assets.precompile += [
          'lib/assets/javascripts/spree/frontend/solidus_gateway.js',
          'lib/assets/javascripts/spree/frontend/solidus_gateway.css',
        ]
        Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/frontend/*/*_decorator*.rb")) do |c|
          Rails.configuration.cache_classes ? require(c) : load(c)
        end
      end
    end

    def self.backend_available?
      @@backend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Backend::Engine')
    end

    def self.frontend_available?
      @@frontend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Frontend::Engine')
    end

    if self.backend_available?
      paths["app/views"] << "lib/views/backend"
    end

    if self.frontend_available?
      paths["app/controllers"] << "lib/controllers/frontend"
      paths["app/views"] << "lib/views/frontend"
    end

    config.to_prepare &method(:activate).to_proc
  end
end
<commit_msg>Set application_id attribute to Solidus<commit_after>module SpreeGateway
  class Engine < Rails::Engine
    engine_name 'solidus_gateway'

    config.autoload_paths += %W(#{config.root}/lib)

    initializer "spree.gateway.payment_methods", :after => "spree.register.payment_methods" do |app|
        app.config.spree.payment_methods << Spree::Gateway::AuthorizeNetCim
        app.config.spree.payment_methods << Spree::Gateway::AuthorizeNet
        app.config.spree.payment_methods << Spree::Gateway::CardSave
        app.config.spree.payment_methods << Spree::Gateway::Eway
        app.config.spree.payment_methods << Spree::Gateway::Linkpoint
        app.config.spree.payment_methods << Spree::Gateway::Moneris
        app.config.spree.payment_methods << Spree::Gateway::PayJunction
        app.config.spree.payment_methods << Spree::Gateway::PayPalGateway
        app.config.spree.payment_methods << Spree::Gateway::SagePay
        app.config.spree.payment_methods << Spree::Gateway::Beanstream
        app.config.spree.payment_methods << Spree::Gateway::BraintreeGateway
        app.config.spree.payment_methods << Spree::Gateway::StripeGateway
        app.config.spree.payment_methods << Spree::Gateway::Worldpay
        app.config.spree.payment_methods << Spree::Gateway::Banwire
        app.config.spree.payment_methods << Spree::Gateway::UsaEpay
        app.config.spree.payment_methods << Spree::BillingIntegration::Skrill::QuickCheckout
        app.config.spree.payment_methods << Spree::Gateway::BalancedGateway
        app.config.spree.payment_methods << Spree::Gateway::DataCash
        app.config.spree.payment_methods << Spree::Gateway::UsaEpay
        app.config.spree.payment_methods << Spree::Gateway::PinGateway
        app.config.spree.payment_methods << Spree::Gateway::Paymill
        app.config.spree.payment_methods << Spree::Gateway::PayflowPro
        app.config.spree.payment_methods << Spree::Gateway::SecurePayAU
        app.config.spree.payment_methods << Spree::Gateway::Maxipago
        app.config.spree.payment_methods << Spree::Gateway::Migs
        app.config.spree.payment_methods << Spree::Gateway::SpreedlyCoreGateway
    end

    # The application_id is a class attribute on all gateways and is used to
    # identify the "source" of the transaction. Braintree has asked us to
    # provide this value to attribute transactions to Solidus; we do not set
    # it on all gateways or the base gateway as other gateways' behavior with
    # the value may differ.
    initializer "spree.gateway.braintree_gateway.application_id" do |app|
      ActiveMerchant::Billing::BraintreeBlueGateway.application_id = "Solidus"
    end

    def self.activate
      if SpreeGateway::Engine.frontend_available?
        Rails.application.config.assets.precompile += [
          'lib/assets/javascripts/spree/frontend/solidus_gateway.js',
          'lib/assets/javascripts/spree/frontend/solidus_gateway.css',
        ]
        Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/frontend/*/*_decorator*.rb")) do |c|
          Rails.configuration.cache_classes ? require(c) : load(c)
        end
      end
    end

    def self.backend_available?
      @@backend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Backend::Engine')
    end

    def self.frontend_available?
      @@frontend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Frontend::Engine')
    end

    if self.backend_available?
      paths["app/views"] << "lib/views/backend"
    end

    if self.frontend_available?
      paths["app/controllers"] << "lib/controllers/frontend"
      paths["app/views"] << "lib/views/frontend"
    end

    config.to_prepare &method(:activate).to_proc
  end
end

{'fraction_non_alphanumeric': 0.1299546998867497, 'fraction_numerical': 0.0, 'mean_word_length': 3.7672064777327936, 'pattern_counts': {'":': 0, '<': 121, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1433794', 'n_tokens_mistral': 2187, 'n_tokens_neox': 2224, 'n_words': 298}