Commit 573f0fc8 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

simple sinatra app

parent fe262214
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+1 −0
Original line number Diff line number Diff line
data
+4 −0
Original line number Diff line number Diff line
@@ -3,6 +3,10 @@ module FnordQuery; end
require "eventmachine"
require "json"
require "haml"
require "sinatra"

require "fnordquery/web/web"
require "fnordquery/web/app"

require "fnordquery/backends/redis_backend"
require "fnordquery/acceptor"
+12 −0
Original line number Diff line number Diff line
class FnordQuery::ReportManager

  def initialize(opts)
    @opts = opts
    reload!
  end

  def reload!
  	puts "RELOAD called!"
  end

end
 No newline at end of file
+16 −0
Original line number Diff line number Diff line
@@ -12,29 +12,37 @@ class FnordQuery::Runner
    shorts      = { redis: :r, fyrehose: :x, query: :q }

    OptionParser.new do |opts|

      opts.on("-h", "--help") do
        print_usage
        exit!
      end

      opts.on("-v", "--version") do
        print_version
        exit!
      end

      opts.on("--force") do
        @task_opts.merge!(:force => true) 
      end

      opts.on("-p [PATH]", "--path [PATH]") do |path|
        @task_opts.merge!(:path => path) 
      end

      %w(since until).each do |key|
        opts.on("--#{key} [ARG]") do |arg|
          @task_opts.merge!(key.to_sym => arg)
        end
      end

      { :task => tasks, :backend => backends }.each do |lkey, list|
        list.each do |key|

          okeys = ["--#{key} [ARG]"]
          okeys << "-#{shorts[key.to_sym]} [ARG]" if shorts[key.to_sym]

          opts.on(*(okeys << String)) do |arg|
            unless arg
              puts "error: missing argument: --#{key}"
@@ -51,8 +59,10 @@ class FnordQuery::Runner
            end
            @opts[lkey] = [key, arg]
          end
          
        end
      end

    end.parse!

    if [@opts[:task], @opts[:backend]].compact.size == 0
@@ -84,6 +94,12 @@ class FnordQuery::Runner
      )
    end

    if @opts[:task].first == "web"
      @task = FnordQuery::Web.new(
        :listen   => @opts[:task].last.split(":")
      )
    end

    if @opts[:task].first == "exec"
      execcfg = JSON.parse(File.open(@opts[:task].last).read)
      if !execcfg["klass"] || !executables.include?(execcfg["klass"])
+33 −0
Original line number Diff line number Diff line
# encoding: utf-8

class FnordQuery::Web::App < Sinatra::Base

  if RUBY_VERSION =~ /1.9.\d/
    Encoding.default_external = Encoding::UTF_8
  end

  enable :session

  #set :haml, :format => :html5
  #set :views, ::File.expand_path('../../../../haml', __FILE__)

  def initialize(opts)
    @opts = opts
    super(nil)
  end

  helpers do
    include Rack::Utils
    alias_method :h, :escape_html
  end

  if ENV['RACK_ENV'] == "test"
    set :raise_errors, true
  end

  get '/' do
  	'hello'
  end

end
Loading