Sha256: 9c0f84df8ca9bf91c2c7cfd4940981f2b6b2fe389151eac01bb397fa0317358f

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

require 'rails'
module GhostInThePost
  ATTRIBUTE_NAMES = [
    :phantomjs_path,
    :includes,
    :remove_js_tags,
    :timeout,
    :wait_event,
    :raise_js_errors,
    :raise_asset_errors,
    :debug,
  ]
  DEFAULT_TIMEOUT = 1000
  DEFAULT_WAIT_EVENT = "ghost_in_the_post:done"
  private_constant :ATTRIBUTE_NAMES
  cattr_accessor(*ATTRIBUTE_NAMES)

  #=======Defaults=========
  @@phantomjs_path = nil #setting this to nil helps testing
  @@timeout = DEFAULT_TIMEOUT
  @@wait_event = DEFAULT_WAIT_EVENT
  @@includes = []
  @@remove_js_tags = true
  @@raise_js_errors = true
  @@raise_asset_errors = true
  @@debug = false

  def self.config=(new_config={})
    self.complain_about_unknown_keys(new_config.keys)
    new_config.each do |key, value|
      self.send("#{key}=", value)
    end
    raise ArgumentError, "GhostInThePost.config.phantomjs_path is not set" if self.phantomjs_path.nil?
  end

  def self.phantomjs_path
    @@phantomjs_path or raise ArgumentError, "GhostInThePost.config.phantomjs_path is not set"
  end

  def self.includes= to_include
    @@includes = Array(to_include)
  end

  private
  
  def self.complain_about_unknown_keys(keys)
    invalid_keys = keys - ATTRIBUTE_NAMES
    if invalid_keys.size > 0
      raise ArgumentError, "Unknown configuration parameters: #{invalid_keys}", caller(1)
    end
  end

end
 
require "ghost_in_the_post/version"

require "ghost_in_the_post/js_inline"
require "ghost_in_the_post/phantom_transform"
require "ghost_in_the_post/mail_ghost"

require "ghost_in_the_post/ghost_on_command"
require "ghost_in_the_post/ghost_on_delivery"

require "ghost_in_the_post/mailer"
require "ghost_in_the_post/automatic"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ghost_in_the_post-0.1.0 lib/ghost_in_the_post.rb