Sha256: 2f6c9dcd3c1bb6523fb45808c59fb220c501ee2363a002826d6431d995635eda

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

require 'yaml'

class MyApp < Sinatra::Application
  use Rack::Session::EncryptedCookie,
    secret: 'supersecretcookiefromgenerator'

  set :app_file, __FILE__
  set :server, :puma
  set :views, Proc.new { File.join(root, "app/views") }
  set :assets, Sprockets::Environment.new
  set :assets_manifest, %w(app.js app.css)
  use Rack::Csrf, raise: true

  configure do
    Sequel::Database.extension :pagination
    Sequel::Model.plugin :timestamps
    Sequel::Model.plugin :auto_validations,
      not_null: :presence, unique_opts: { only_if_modified: true }

    assets.append_path 'assets/stylesheets'
    assets.append_path 'assets/javascripts'
  end

  configure :development do
    require 'sinatra/reloader'
    require 'logger'

    register Sinatra::Reloader
    Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['development'],
      loggers: [Logger.new($stdout)]

    get '/assets/*' do
      env['PATH_INFO'].sub!('/assets', '')
      settings.assets.call(env)
    end
  end

  configure :test do
    Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['test']
  end

  configure :production do
    # Serve assets via Nginx or Apache
    disable :static

    assets.js_compressor  = :uglify
    assets.css_compressor = :sass
    Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['production']
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sinator-3.1.1 spec/fixtures/with_db/app.txt
sinator-3.1.0 spec/fixtures/with_db/app.txt
sinator-3.0.4 spec/fixtures/with_db/app.txt
sinator-3.0.3 spec/fixtures/with_db/app.txt
sinator-3.0.2 spec/fixtures/with_db/app.txt
sinator-3.0.1 spec/fixtures/with_db/app.txt
sinator-3.0.0 spec/fixtures/with_db/app.txt