-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
41 lines (35 loc) · 982 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env ruby
require 'sinatra'
require 'mongoid'
require_relative "config/config"
$: << File.join(File.dirname(File.realpath(__FILE__)), 'lib')
$ROOT = File.dirname(File.realpath(__FILE__))
require 'models'
require 'services'
require 'libs'
require 'helpers'
#load mongoid
Mongoid.load!("config/mongoid.yml")
#change the stringMax constant on open-uri to get always Tempfiles
#more info: http://adayinthepit.com/2011/06/03/ruby-openuri-open-returns-stringio-fileio/
OpenURI::Buffer.send :remove_const, 'StringMax' if OpenURI::Buffer.const_defined?('StringMax')
OpenURI::Buffer.const_set 'StringMax', 0
helpers Utils
not_found do
haml :not_found
end
get '/packages' do
@packages = Package.all
haml :index
end
get '/packages/:id' do
@package = Package.where(id: params[:id]).first
if @package
@package_vs = @package.package_versions if @package
haml :show
else
@message = "Invalid package id"
@packages = Package.all
haml :index
end
end