Initial Sinatra project strucutre
This commit is contained in:
20
lib/config.rb
Normal file
20
lib/config.rb
Normal file
@ -0,0 +1,20 @@
|
||||
require 'yaml'
|
||||
|
||||
class Config
|
||||
|
||||
def initialize(config_path)
|
||||
@data = YAML::load_file(config_path)
|
||||
end
|
||||
|
||||
def get(key, depth = 0)
|
||||
bits = key.split('.')
|
||||
value = @data
|
||||
|
||||
bits.each do |bit|
|
||||
value = value[bit]
|
||||
end
|
||||
|
||||
return value
|
||||
end
|
||||
|
||||
end
|
5
lib/models/item.rb
Normal file
5
lib/models/item.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class Item < Sequel::Model
|
||||
|
||||
|
||||
|
||||
end
|
7
lib/routes.rb
Normal file
7
lib/routes.rb
Normal file
@ -0,0 +1,7 @@
|
||||
get '/' do
|
||||
items = Item.all
|
||||
erb :index, :locals => {
|
||||
:title => 'Dashboard',
|
||||
:items => items
|
||||
}
|
||||
end
|
Reference in New Issue
Block a user