File tree 5 files changed +25
-44
lines changed
5 files changed +25
-44
lines changed Original file line number Diff line number Diff line change 1
- source 'https:// rubygems.org'
1
+ source : rubygems
2
2
3
- # PostgreSQL driver
4
- gem 'pg '
3
+ # SQLite3 driver
4
+ gem 'sqlite3 '
5
5
6
6
# Sinatra driver
7
7
gem 'sinatra'
8
+ gem 'sinatra-contrib'
8
9
9
10
# Use Thin for our web server
10
11
gem 'thin'
11
12
12
13
gem 'activesupport'
13
14
gem 'activerecord'
15
+ gem 'shotgun'
14
16
15
17
gem 'rake'
18
+ gem 'bcrypt-ruby' , '~> 3.0.0'
19
+ gem 'pry'
16
20
17
- gem 'shotgun'
18
21
19
- gem 'oauth'
20
- gem 'twitter'
22
+ group :test do
23
+ gem 'faker'
24
+ gem 'rspec'
25
+ gem 'shoulda-matchers'
26
+ end
Original file line number Diff line number Diff line change 1
1
require 'rake'
2
-
2
+ require 'rspec/core/rake_task'
3
3
4
4
5
5
require ::File . expand_path ( '../config/environment' , __FILE__ )
@@ -89,13 +89,13 @@ namespace :db do
89
89
desc "Create the database at #{ DB_NAME } "
90
90
task :create do
91
91
puts "Creating database #{ DB_NAME } if it doesn't exist..."
92
- exec ( "createdb #{ DB_NAME } " )
92
+ exec ( "touch #{ DB_NAME } " )
93
93
end
94
94
95
95
desc "Drop the database at #{ DB_NAME } "
96
96
task :drop do
97
97
puts "Dropping database #{ DB_NAME } ..."
98
- exec ( "dropdb #{ DB_NAME } " )
98
+ exec ( "rm #{ DB_NAME } " )
99
99
end
100
100
101
101
desc "Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)."
@@ -122,3 +122,8 @@ desc 'Start IRB with application environment loaded'
122
122
task "console" do
123
123
exec "irb -r./config/environment"
124
124
end
125
+
126
+ desc "Run the specs"
127
+ RSpec ::Core ::RakeTask . new ( :spec )
128
+
129
+ task :default => :spec
Original file line number Diff line number Diff line change 13
13
autoload ActiveSupport ::Inflector . camelize ( filename ) , model_file
14
14
end
15
15
16
- # We have to do this in case we have models that inherit from each other.
17
- # If model Student inherits from model Person and app/models/student.rb is
18
- # required first, it will throw an error saying "Person" is undefined.
19
- #
20
- # With this lazy-loading technique, Ruby will try to load app/models/person.rb
21
- # the first time it sees "Person" and will only throw an exception if
22
- # that file doesn't define the Person class.
23
-
24
- # Heroku controls what database we connect to by setting the DATABASE_URL environment variable
25
- # We need to respect that if we want our Sinatra apps to run on Heroku without modification
26
- db = URI . parse ( ENV [ 'DATABASE_URL' ] || "postgres://localhost/#{ APP_NAME } _#{ Sinatra ::Application . environment } " )
27
-
28
- DB_NAME = db . path [ 1 ..-1 ]
29
-
30
- # Note:
31
- # Sinatra::Application.environment is set to the value of ENV['RACK_ENV']
32
- # if ENV['RACK_ENV'] is set. If ENV['RACK_ENV'] is not set, it defaults
33
- # to :development
16
+ DB_NAME = APP_ROOT . join ( 'db' , 'events.sqlite3' ) . to_s
34
17
35
18
ActiveRecord ::Base . establish_connection (
36
- :adapter => db . scheme == 'postgres' ? 'postgresql' : db . scheme ,
37
- :host => db . host ,
38
- :port => db . port ,
39
- :username => db . user ,
40
- :password => db . password ,
19
+ :adapter => 'sqlite3' ,
41
20
:database => DB_NAME ,
42
- :encoding => 'utf8'
43
21
)
Original file line number Diff line number Diff line change 11
11
require 'uri'
12
12
require 'pathname'
13
13
14
- require 'pg '
14
+ require 'sqlite3 '
15
15
require 'active_record'
16
16
require 'logger'
17
17
18
18
require 'sinatra'
19
- require 'shotgun'
20
-
19
+ require "sinatra/reloader" if development?
20
+ require 'bcrypt'
21
21
require 'erb'
22
22
23
- require 'oauth'
24
- require 'twitter'
25
-
26
23
# Some helper constants for path-centric logic
27
24
APP_ROOT = Pathname . new ( File . expand_path ( '../../' , __FILE__ ) )
28
25
34
31
35
32
# Set up the database and models
36
33
require APP_ROOT . join ( 'config' , 'database' )
37
-
38
- $client = Twitter ::REST ::Client . new do |config |
39
- config . consumer_key = ENV [ 'TWITTER_KEY' ]
40
- config . consumer_secret = ENV [ 'TWITTER_SECRET' ]
41
- end
You can’t perform that action at this time.
0 commit comments