Sha256: c04c8a6dfcd36e8df9ca1e4077e8a7f8e3d0bab8c3eb484d1c682bd6360640e7

Contents?: true

Size: 880 Bytes

Versions: 7

Compression:

Stored size: 880 Bytes

Contents

require 'sinatra/base'
require 'tilt/erubis'
require 'json'
require 'yaml'

require_relative '<%= @gen.wormname %>/helpers'
require_relative '<%= @gen.wormname %>/racks'

module <%= @gen.camelname %>
  class App < Sinatra::Base
    helpers do
      include <%= @gen.camelname %>::Helpers
    end

    get '/' do
      headers 'Vary' => 'Accept'

      respond_to do |wants|
        wants.html do
          @content = '<h1>Hello from <%= @gen.camelname %></h1>'
          @title = '<%= @gen.camelname %>'
          @github_url = CONFIG['github_url']
          erb :index
        end

        wants.json do
          {
            app: '<%= @gen.camelname %>'
          }.to_json
        end
      end
    end

    # start the server if ruby file executed directly
    run! if app_file == $0

    not_found do
      status 404
      @title = '404'
      erb :oops
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
skellington-0.9.0.pre.rc1 lib/templates/sinatra/lib/app.rb
skellington-0.8.9 lib/templates/sinatra/lib/app.rb
skellington-0.8.8 lib/templates/sinatra/lib/app.rb
skellington-0.8.7 lib/sinatra/templates/lib/app.rb
skellington-0.8.6 lib/sinatra/templates/lib/app.rb
skellington-0.8.5 lib/sinatra/templates/lib/app.rb
skellington-0.8.4 lib/sinatra/templates/lib/app.rb