module Tr8n

Decoration Token Forms:

link: click here

or

link

click here [/link]

Decoration Tokens Allow Nesting:

link: {count} {_messages}
link: {count||message}
link: {count||person, people}
link: {user.name}

Decoration Token Forms:

link: click here

or

link

click here [/link]

Decoration Tokens Allow Nesting:

link: {count} {_messages}
link: {count||message}
link: {count||person, people}
link: {user.name}

Constants

CACHE_VERSION_KEY

Attributes

config[RW]

Public Class Methods

cache() click to toggle source
# File lib/tr8n/cache.rb, line 41
def self.cache
  @cache ||= begin
    if Tr8n.config.cache_enabled?
      klass = Tr8n::CacheAdapters.const_get(Tr8n.config.cache[:adapter].camelcase)
      klass.new
    else
      # blank implementation
      Tr8n::Cache.new
    end
  end
end
configure() { |config| ... } click to toggle source

Allows you to configure Tr8n

Tr8n.configure do |config|

config.application = {:key => "", :secret => ""}

end

# File lib/tr8n/config.rb, line 53
def self.configure
  yield(self.config)
end
logger() click to toggle source
# File lib/tr8n/logger.rb, line 37
def self.logger
  @logger ||= begin
    logfile_path = File.expand_path(Tr8n.config.logger[:path])
    logfile_dir = logfile_path.split("/")[0..-2].join("/")
    FileUtils.mkdir_p(logfile_dir) unless File.exist?(logfile_dir)
    logfile = File.open(logfile_path, 'a')
    logfile.sync = true
    Tr8n::Logger.new(logfile)
  end
end
memory() click to toggle source
# File lib/tr8n/cache.rb, line 37
def self.memory
  @memory ||= Tr8n::CacheAdapters::Memory.new
end
session() click to toggle source
# File lib/tr8n/session.rb, line 35
def self.session
  Thread.current[:session] ||= Tr8n::Session.new
end
with_config_settings() { |config| ... } click to toggle source

Allows you to create a block to perform something on adjusted config settings Once the block exists, the config will be reset back to what it was before:

Tr8n.with_config_settings do |config|
   config.format = :text

   Do something....

end
# File lib/tr8n/config.rb, line 68
def self.with_config_settings
  old_config = @config.dup
  yield(@config)
  @config = old_config
end