Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

Commit

Permalink
Database setup added
Browse files Browse the repository at this point in the history
  • Loading branch information
otobrglez committed Nov 19, 2011
1 parent 7e338f2 commit 27661fb
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
.sass-cache
*.db
7 changes: 7 additions & 0 deletions Gemfile
Expand Up @@ -4,9 +4,16 @@ gem 'sinatra'
gem 'haml'
gem 'thin'
gem 'sass'
gem 'datamapper'

group :production do
gem 'pg'
gem 'dm-postgres-adapter'
end

group :development do
gem 'shotgun'
gem 'dm-sqlite-adapter'
end

group :test do
Expand Down
66 changes: 66 additions & 0 deletions Gemfile.lock
@@ -1,10 +1,70 @@
GEM
remote: http://rubygems.org/
specs:
addressable (2.2.6)
bcrypt-ruby (3.0.1)
daemons (1.1.4)
data_objects (0.10.7)
addressable (~> 2.1)
datamapper (1.2.0)
dm-aggregates (~> 1.2.0)
dm-constraints (~> 1.2.0)
dm-core (~> 1.2.0)
dm-migrations (~> 1.2.0)
dm-serializer (~> 1.2.0)
dm-timestamps (~> 1.2.0)
dm-transactions (~> 1.2.0)
dm-types (~> 1.2.0)
dm-validations (~> 1.2.0)
diff-lcs (1.1.3)
dm-aggregates (1.2.0)
dm-core (~> 1.2.0)
dm-constraints (1.2.0)
dm-core (~> 1.2.0)
dm-core (1.2.0)
addressable (~> 2.2.6)
dm-do-adapter (1.2.0)
data_objects (~> 0.10.6)
dm-core (~> 1.2.0)
dm-migrations (1.2.0)
dm-core (~> 1.2.0)
dm-postgres-adapter (1.2.0)
dm-do-adapter (~> 1.2.0)
do_postgres (~> 0.10.6)
dm-serializer (1.2.1)
dm-core (~> 1.2.0)
fastercsv (~> 1.5.4)
json (~> 1.6.1)
json_pure (~> 1.6.1)
multi_json (~> 1.0.3)
dm-sqlite-adapter (1.2.0)
dm-do-adapter (~> 1.2.0)
do_sqlite3 (~> 0.10.6)
dm-timestamps (1.2.0)
dm-core (~> 1.2.0)
dm-transactions (1.2.0)
dm-core (~> 1.2.0)
dm-types (1.2.1)
bcrypt-ruby (~> 3.0.0)
dm-core (~> 1.2.0)
fastercsv (~> 1.5.4)
json (~> 1.6.1)
multi_json (~> 1.0.3)
stringex (~> 1.3.0)
uuidtools (~> 2.1.2)
dm-validations (1.2.0)
dm-core (~> 1.2.0)
do_postgres (0.10.7)
data_objects (= 0.10.7)
do_sqlite3 (0.10.7)
data_objects (= 0.10.7)
eventmachine (0.12.10)
fastercsv (1.5.4)
haml (3.1.3)
json (1.6.1)
json_pure (1.6.1)
multi_json (1.0.3)
pg (0.11.0)
rack (1.3.5)
rack-protection (1.1.4)
rack
Expand All @@ -23,17 +83,23 @@ GEM
rack (~> 1.3, >= 1.3.4)
rack-protection (~> 1.1, >= 1.1.2)
tilt (~> 1.3, >= 1.3.3)
stringex (1.3.0)
thin (1.3.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
tilt (1.3.3)
uuidtools (2.1.2)

PLATFORMS
ruby

DEPENDENCIES
datamapper
dm-postgres-adapter
dm-sqlite-adapter
haml
pg
rspec
sass
shotgun
Expand Down
20 changes: 19 additions & 1 deletion onr_app.rb
@@ -1,5 +1,22 @@

# By Oto Brglez - <oto.brglez@opalab.com>
require 'rubygems'
require 'sinatra/base'
require 'data_mapper'
require 'pathname'

DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, ENV['DATABASE_URL'] || 'sqlite://'+Pathname.pwd.join("database.db"))

class Track
include DataMapper::Resource
property :id, Serial
property :raw, Text
property :created_at, DateTime
end

# DataMapper.auto_migrate!
DataMapper.finalize
Track.auto_upgrade!

class OnrApp < Sinatra::Base

Expand All @@ -10,6 +27,7 @@ class OnrApp < Sinatra::Base
end

get '/' do
@tracks = Track.all
haml :index
end

Expand Down
10 changes: 8 additions & 2 deletions views/index.haml
@@ -1,2 +1,8 @@
%p
Test
- if @tracks.empty?
%p No tracks
- else
%ul
- @tracks.each do |track|
%li
=track.raw
=track.created_at
4 changes: 2 additions & 2 deletions views/main.scss
Expand Up @@ -27,8 +27,8 @@ body{
div.wrap{
text-align:left;
display:block;
margin:0px auto;
max-width:$width;
margin:0px auto;
}
}

Expand All @@ -48,7 +48,7 @@ div#logo{
.header, .footer, .main{
display:block;
padding:10px;
width:$width - 20px;
max-width:$width - 20px;
}

.footer{
Expand Down

0 comments on commit 27661fb

Please sign in to comment.