module Gamifier
Constants
- VERSION
Attributes
logger[W]
Public Class Methods
config()
click to toggle source
Returns the configuration Hash.
# File lib/gamifier.rb, line 22 def config @config ||= {} end
dsl(&block)
click to toggle source
Creates and returns a new DSL::Network
object. The given block will be evaluated in the context of the network object.
Usage:
network = Gamifier.dsl do site 'my-site' do set :url, 'my-site.com' ... end end
# File lib/gamifier.rb, line 46 def dsl(&block) network = DSL::Network.new DSL.eval_with_context(network, &block) end
engine(&block)
click to toggle source
Returns the global Engine
. If you need multiple engine with different API keys and/or URIs, you should create a new engine directly with Gamifier::Engine.new
# File lib/gamifier.rb, line 29 def engine(&block) @engine ||= Engine.new block.call(@engine) if block @engine end
logger()
click to toggle source
# File lib/gamifier.rb, line 51 def logger @logger ||= begin l = Logger.new(STDERR) l.level = Logger::WARN l end end
reset!()
click to toggle source
# File lib/gamifier.rb, line 59 def reset! @engine = nil config.clear end
set(key, opts = nil)
click to toggle source
Sets a configuration option. The keys will be symbolized.
# File lib/gamifier.rb, line 11 def set(key, opts = nil) if opts.nil? key.each do |k,v| config[k.to_sym] = v end else config[key.to_sym] = opts end end
underscore(camel_cased_word)
click to toggle source
# File lib/gamifier.rb, line 64 def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/'). gsub("Gamifier/", ''). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end