Permalink
Browse files

Added Bundler and Datamapper

  • Loading branch information...
Peter Garbers
Peter Garbers committed Apr 3, 2012
1 parent 0a19af9 commit 2a9cd32adbc4b8818660d08da41367645ae87753
Showing with 157 additions and 51 deletions.
  1. +10 −0 Gemfile
  2. +92 −0 Gemfile.lock
  3. +2 −0 Rakefile
  4. +53 −0 app.rb
  5. +0 −51 application.rb
View
10 Gemfile
@@ -0,0 +1,10 @@
+source "http://rubygems.org"
+
+gem 'sinatra'
+gem 'sinatra-reloader'
+#gem 'activerecord'
+#gem 'sinatra-activerecord'
+gem 'datamapper'
+gem 'dm-sqlite-adapter'
+gem 'sqlite3'
+gem 'json'
View
@@ -0,0 +1,92 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ addressable (2.2.7)
+ backports (2.5.1)
+ bcrypt-ruby (3.0.1)
+ data_objects (0.10.8)
+ 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)
+ 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-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_sqlite3 (0.10.8)
+ data_objects (= 0.10.8)
+ eventmachine (0.12.10)
+ fastercsv (1.5.4)
+ json (1.6.6)
+ json_pure (1.6.6)
+ multi_json (1.0.4)
+ rack (1.4.1)
+ rack-protection (1.2.0)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ sinatra (1.3.2)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ sinatra-contrib (1.3.1)
+ backports (>= 2.0)
+ eventmachine
+ rack-protection
+ rack-test
+ sinatra (~> 1.3.0)
+ tilt (~> 1.3)
+ sinatra-reloader (1.0)
+ sinatra-contrib
+ sqlite3 (1.3.5)
+ stringex (1.3.2)
+ tilt (1.3.3)
+ uuidtools (2.1.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ datamapper
+ dm-sqlite-adapter
+ json
+ sinatra
+ sinatra-reloader
+ sqlite3
View
@@ -0,0 +1,2 @@
+#require 'app'
+require 'sinatra/activerecord/rake'
View
53 app.rb
@@ -0,0 +1,53 @@
+require 'rubygems'
+require 'sinatra'
+require 'data_mapper'
+require 'json'
+
+DataMapper.setup(:default, "sqlite3::memory:")
+
+
+class Province
+ include DataMapper::Resource
+ property :id, Serial
+ property :name, String
+
+ attr_accessor :name
+
+ def initialize(name)
+ @name = name
+ end
+
+ def to_json(*)
+ {name: @name}.to_json
+ end
+end
+
+get '/provinces' do
+ provinces = Province.all
+ content_type :json
+ provinces.to_json
+end
+
+class IncidentType
+ include DataMapper::Resource
+ property :id, Serial
+ property :name, String
+
+ attr_accessor :name
+
+ def initialize(name)
+ @name = name
+ end
+
+ def to_json(*)
+ {name: @name}.to_json
+ end
+end
+
+get '/incident_types' do
+ incident_types = IncidentType.all
+ content_type :json
+ incident_types.to_json
+end
+
+DataMapper.auto_upgrade!
View
@@ -1,51 +0,0 @@
-require 'rubygems'
-require 'sinatra'
-require "sinatra/reloader" if development?
-require 'json'
-
-class Province
- attr_accessor :name
-
- def initialize(name)
- @name = name
- end
-
- def to_json(*)
- {name: @name}.to_json
- end
-end
-
-provinces = [ Province.new('Gauteng'),
- Province.new('Mpumalanga'),
- Province.new('Western Cape'),
- Province.new('Limpopo')
- ]
-
-get '/provinces' do
- content_type :json
- provinces.to_json
-end
-
-class IncidentType
- attr_accessor :name
-
- def initialize(name)
- @name = name
- end
-
- def to_json(*)
- {name: @name}.to_json
- end
-end
-
-incident_types = [ IncidentType.new('Fire'),
- IncidentType.new('Water outage'),
- IncidentType.new('Electricity outage'),
- IncidentType.new('Faulty traffic light'),
- IncidentType.new('Crime')
- ]
-
-get '/incident_types' do
- content_type :json
- incident_types.to_json
-end

0 comments on commit 2a9cd32

Please sign in to comment.