Sha256: 6c2424e0fecb0839c1ec4cbc0dabf1ddac26ee0d4bf3b7279bdcae935856316e

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require 'rails'
module GhostInThePost
  ATTRIBUTE_NAMES = [
    :phantomjs_path,
    :includes,
    :remove_js_tags,
  ]
  private_constant :ATTRIBUTE_NAMES
  cattr_reader(*ATTRIBUTE_NAMES)

  @@phantomjs_path = nil #setting this to nil helps testing
  @@includes = []
  @@remove_js_tags = true

  def self.config=(new_config={})
    self.complain_about_unknown_keys(new_config.keys)
    @@phantomjs_path = new_config[:phantomjs_path]
    @@includes = Array(new_config[:includes])
    @@remove_js_tags = new_config[:remove_js_tags].nil? ? true : new_config[:remove_js_tags]
    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

  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/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.0.1 lib/ghost_in_the_post.rb