Module: Tux::Commands

Defined in:
lib/tux/commands.rb

Constant Summary collapse

SETTINGS =
%w{methodoverride inline_templates}

Instance Method Summary collapse

Instance Method Details

#appObject



21
22
23
24
25
26
27
28
# File 'lib/tux/commands.rb', line 21

def app
  @app ||= begin
    obj = Tux.app_class.new!
    obj.request = Sinatra::Request.new({})
    obj.response = Sinatra::Response.new
    obj
  end
end

#routesObject



7
8
9
10
11
12
13
# File 'lib/tux/commands.rb', line 7

def routes
  Tux.app_class.routes.inject([]) {|arr, (k,v)|
    arr += v.map {|e|
      [k, (str = e[0].inspect[%r{/\^(.*)\$/}, 1]) ? str.tr('\\', '') : e[0]]
    }
  }
end

#settingsObject



15
16
17
18
19
# File 'lib/tux/commands.rb', line 15

def settings
  meths = (class << Tux.app_class; self; end).instance_methods(false).
    sort.map(&:to_s).select {|e| e[/=$/] }.map {|e| e[0..-2] } - SETTINGS
  meths.map {|meth| [meth, Tux.app_class.send(meth)] }
end