Sha256: df86e8be3dbb7cd0279f9ccf57d6ea3c7c33c7045c7404b660bd685bcef5561c

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

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

require 'json'

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

module PostageApp
  
  class Error < StandardError ; end
  
  class << self
    
    # 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
    def configure
      yield configuration
    end
    
    # Accessor for the PostageApp::Configuration object
    # Example use:
    #   PostageApp.configuration.api_key = '1234567890abcdef'
    def configuration
      @configuration ||= Configuration.new
    end
    alias :config :configuration
    
    # Logger for the plugin
    def 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
end

# Loading Rails hook
require 'postageapp/rails' if defined?(Rails)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
postageapp-1.0.3 lib/postageapp.rb
postageapp-1.0.2 lib/postageapp.rb
postageapp-1.0.1 lib/postageapp.rb