Sha256: beca7646e7aa8d4ae2ec3769904c65e1e4bfa6c061737fb1e4b5677d4c81cdc9

Contents?: true

Size: 1.27 KB

Versions: 18

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

require 'activerecord-postgres-json'
require 'active_model_serializers'
require 'flowcommerce'
require 'flowcommerce_spree/api'
require 'flowcommerce_spree/refresher'
require 'flowcommerce_spree/engine'
require 'flowcommerce_spree/logging_http_client'
require 'flowcommerce_spree/logging_http_handler'
require 'flowcommerce_spree/session'
require 'flow/simple_gateway'
require 'oj'

module FlowcommerceSpree
  API_KEY = ENV.fetch('FLOW_TOKEN', 'test_key')
  ENV['FLOW_TOKEN'] = API_KEY

  def self.client(logger: FlowcommerceSpree.logger, **opts)
    FlowCommerce.instance(http_handler: LoggingHttpHandler.new(logger: logger), **opts)
  end

  def self.configure
    yield self if block_given?
  end

  def self.logger
    logger = ActiveSupport::Logger.new(STDOUT)

    logger_formatter = proc do |severity, datetime, _progname, msg|
      "\n#{datetime}, #{severity}: #{msg}\n"
    end

    logger.formatter = logger_formatter

    # Broadcast the log into the file besides STDOUT, if `log` folder exists
    if Dir.exist?('log')
      file_logger = ActiveSupport::Logger.new('log/flowcommerce_spree.log', 3, 10_485_760)
      file_logger.formatter = logger_formatter

      logger.extend(ActiveSupport::Logger.broadcast(file_logger))
    end
    logger
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
flowcommerce_spree-0.0.22 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.21 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.20 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.19 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.18 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.17 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.16 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.15 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.14 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.13 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.12 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.11 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.10 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.9 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.8 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.7 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.6 lib/flowcommerce_spree.rb
flowcommerce_spree-0.0.5 lib/flowcommerce_spree.rb