Sha256: 0a49612b24e01ec0ebfc3ca23f1875b02ca95174cfb66aeaa84d8ba5af4b0a72

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

require 'net/http'
require 'net/https'
require 'digest'
require 'logger'

require 'json'
require 'base64'

require 'postageapp/utils'
require 'postageapp/version'
require 'postageapp/configuration'
require 'postageapp/logger'
require 'postageapp/request'
require 'postageapp/failed_request'
require 'postageapp/response'
require 'postageapp/mail'
require 'postageapp/mail/delivery_method'

require 'postageapp/rails/railtie' if (defined?(Rails::Railtie))

module PostageApp
  class Error < StandardError ; end
  
  # Call this method to modify your configuration
  # Example:
  #   PostageApp.configure do |config|
  #     config.api_key             = '1234567890abcdef'
  #     config.recipient_override  = 'test@test.test' if Rails.env.staging?
  #   end
  # 
  # If you do not want/need to initialize the gem in this way, you can use the environment
  # variable POSTAGEAPP_API_KEY to set up your key.
  
  def self.configure
    yield(configuration)
  end
  
  # Accessor for the PostageApp::Configuration object
  # Example use:
  #   PostageApp.configuration.api_key = '1234567890abcdef'
  def self.configuration
    @configuration ||= Configuration.new
  end

  class << self
    alias :config :configuration
  end
  
  # Logger for the plugin
  def self.logger
    @logger ||= begin
      configuration.logger || PostageApp::Logger.new(
        if (configuration.project_root)
          FileUtils.mkdir_p(File.join(File.expand_path(configuration.project_root), 'log'))
          File.join(configuration.project_root, "log/postageapp_#{configuration.environment}.log")
        else
          STDOUT
        end
      )
    end
  end
end

require 'postageapp/mail/extensions'

if (defined?(::Mail))
  PostageApp::Mail::Extensions.install!
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
postageapp-1.2.6 lib/postageapp.rb
postageapp-1.2.5 lib/postageapp.rb