Module: PostageApp

Defined in:
lib/postageapp.rb,
lib/postageapp/engine.rb

Defined Under Namespace

Modules: CLI, Env, FailedRequest, HTTP, Mail, Rails Classes: Configuration, Diagnostics, Engine, Error, Logger, Mailer, Railtie, Request, Response

Constant Summary collapse

VERSION =

Call this method to modify your configuration Example:

PostageApp.configure do |config|
  config.api_key = '1234567890abcdef'

  if Rails.env.staging?
    config.recipient_override = '[email protected]'
  end
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.

File.read(File.expand_path('../VERSION', __dir__)).gsub(/\s/, '')

Class Method Summary collapse

Class Method Details

.configObject Also known as: configuration

Accessor for the PostageApp::Configuration object Example use:

PostageApp.configuration.api_key = '1234567890abcdef'


43
44
45
# File 'lib/postageapp.rb', line 43

def self.config
  @config ||= Configuration.new
end

.config_reset!Object Also known as: configuration_reset!



47
48
49
# File 'lib/postageapp.rb', line 47

def self.config_reset!
  @config = nil
end

.configure(reset: false) {|self.config| ... } ⇒ Object

Yields:



32
33
34
35
36
37
38
# File 'lib/postageapp.rb', line 32

def self.configure(reset: false)
  if (reset)
    self.config_reset!
  end

  yield(self.config)
end

.loggerObject

Logger for the plugin



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/postageapp.rb', line 57

def self.logger
  @logger ||= begin
    config.logger || PostageApp::Logger.new(
      if (config.project_root)
        FileUtils.mkdir_p(File.join(File.expand_path(config.project_root), 'log'))
        File.join(config.project_root, "log/postageapp_#{config.environment}.log")
      else
        $stdout
      end
    )
  end
end

.versionObject



28
29
30
# File 'lib/postageapp.rb', line 28

def self.version
  VERSION
end