Module: Waxx

Extended by:
Waxx
Included in:
Waxx
Defined in:
waxx/x.rb,
waxx/req.rb,
waxx/res.rb,
waxx/waxx.rb,
waxx/version.rb

Overview

Waxx is a high-performance Ruby web application development framework. See www.waxx.io/ for more information.

Defined Under Namespace

Modules: App, Conf, Console, Csrf, Database, Encrypt, Error, Html, Http, Init, Json, Mongodb, Mysql2, Object, Pdf, Pg, Process, Server, Sqlite3, Supervisor, Test, Util, View Classes: Req, Res, X

Constant Summary collapse

Root =

TODO: Figure this out based on the waxx command opts

Dir.pwd
Version =
'0.1.3'

Instance Method Summary collapse

Instance Method Details

#/(str) ⇒ Object

Shortcut to Waxx::Waxx variables



33
34
35
# File 'waxx/waxx.rb', line 33

def /(str)
  Waxx::Conf/str
end

#[](str) ⇒ Object

Shortcut to Waxx::Waxx variables



27
28
29
# File 'waxx/waxx.rb', line 27

def [](str)
  Waxx::Conf[str]
end

#debug(str, level = 3) ⇒ Object

Output to the log

Waxx.debug(
  str,          # The text to output
  level         # The number 0 (most important) - 9 (least important)
)
# Set the level in config.yaml (debug.level) of what level or lower to ouutput


44
45
46
# File 'waxx/waxx.rb', line 44

def debug(str, level=3)
  puts "#{Time.new} #{Thread.current[:name]} #{str}" if level <= Waxx['debug']['level'].to_i
end

#random_string(size = 32, type = :an, chars = nil) ⇒ Object

Get a pseudo-random (non-cryptographically secure) string to use as a temporary password. If you need real random use SecureRandom.random_bytes(size) or SecureRandom.base64(size).

1. size: Length of string
2. type: [
     any: US keyboard characters
     an:  Alphanumeric (0-9a-zA-Z)
     anl: Alphanumeric lower: (0-9a-z)
     chars: Your own character list
   ]
3. chars: A string of your own characters


59
60
61
62
63
64
65
66
67
68
69
70
# File 'waxx/waxx.rb', line 59

def random_string(size=32, type=:an, chars=nil)
  if not type.to_sym == :chars
    types = {
      any: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@#$%^&*()_-+={[}]|:;<,>.?/',
      an: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
      anl: '0123456789abcdefghijklmnopqrstuvwxyz'
    }
    chars = types[type.to_sym].split("")
  end
  opts = chars.size
  1.upto(size).map{chars[rand(opts)]}.join
end