sinatra_more 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -1,5 +1,4 @@
1
1
  RACK_ENV = ENV["RACK_ENV"] ||= "development" unless defined? RACK_ENV
2
- ENV['DATABASE_URL'] = 'your_database_here'
3
2
 
4
3
  require File.dirname(__FILE__) + '/app.rb'
5
4
 
@@ -7,13 +7,28 @@ module ActiveRecordInitializer
7
7
  app.configure do
8
8
  ActiveRecord::Base.establish_connection(
9
9
  :adapter => 'sqlite3',
10
- :dbfile => ENV['DATABASE_URL']
10
+ :database => 'your_db_here'
11
11
  )
12
12
  end
13
13
  end
14
14
  end
15
15
  AR
16
16
 
17
+ RAKE = <<-RAKE
18
+ require 'active_record'
19
+ require 'sinatra/base'
20
+
21
+ namespace :db do
22
+ desc "Migrate the database"
23
+ task(:migrate) do
24
+ load 'config/boot.rb'
25
+ ActiveRecord::Base.logger = Logger.new(STDOUT)
26
+ ActiveRecord::Migration.verbose = true
27
+ ActiveRecord::Migrator.migrate("db/migrate")
28
+ end
29
+ end
30
+ RAKE
31
+
17
32
 
18
33
  MIGRATION = <<-MIGRATION
19
34
  class CreateUsers < ActiveRecord::Migration
@@ -52,7 +67,8 @@ USER
52
67
 
53
68
  def setup_orm
54
69
  insert_require 'active_record', :path => "config/dependencies.rb", :indent => 2
55
- create_file("config/initializers/activerecord.rb", AR)
70
+ create_file("config/initializers/active_record.rb", AR)
71
+ create_file("Rakefile", RAKE)
56
72
  create_file("db/migrate/001_create_users.rb", MIGRATION)
57
73
  create_file("app/models/user.rb", USER)
58
74
  end
@@ -2,10 +2,10 @@ module SinatraMore
2
2
  module DatamapperOrmGen
3
3
 
4
4
  DM = <<-DM
5
- module DatamapperInitializer
5
+ module DataMapperInitializer
6
6
  def self.registered(app)
7
7
  app.configure do
8
- DataMapper.setup(:default, ENV['DATABASE_URL'])
8
+ DataMapper.setup(:default, 'your_db_here')
9
9
  end
10
10
  end
11
11
  end
@@ -15,6 +15,7 @@ DM
15
15
  class User
16
16
  include DataMapper::Resource
17
17
 
18
+ property :id, Serial
18
19
  property :name, String
19
20
  property :username, String
20
21
  property :email, String
@@ -33,11 +34,12 @@ class User
33
34
  BCrypt::Password.new(crypted_password) == password
34
35
  end
35
36
  end
36
- USER
37
+ User.auto_upgrade!
38
+ USER
37
39
 
38
40
  def setup_orm
39
41
  insert_require 'dm-core', :path => "config/dependencies.rb", :indent => 2
40
- create_file("config/initializers/datamapper.rb", DM)
42
+ create_file("config/initializers/data_mapper.rb", DM)
41
43
  create_file("app/models/user.rb", USER)
42
44
  end
43
45
  end
@@ -4,11 +4,10 @@ module SinatraMore
4
4
  MONGO = <<-MONGO
5
5
  class MongoDBConnectionFailure < RuntimeError; end
6
6
 
7
- module MongoDBInitializer
7
+ module MongoDbInitializer
8
8
  def self.registered(app)
9
9
  MongoMapper.connection = Mongo::Connection.new('localhost')
10
- MongoMapper.database = 'fyourparking'
11
- User.first
10
+ MongoMapper.database = 'your_db_here'
12
11
  rescue RuntimeError
13
12
  raise MongoDBConnectionFailure.new("mongodb cannot connect to db! Start the mongodb process and try again.")
14
13
  end
@@ -37,8 +36,6 @@ class User
37
36
  key :username, String, :required => true
38
37
  key :email, String, :required => true
39
38
  key :crypted_password, String, :required => true
40
-
41
- many :car_photos
42
39
  end
43
40
  USER
44
41
 
@@ -85,7 +82,7 @@ AUTH
85
82
 
86
83
  def setup_orm
87
84
  insert_require 'mongo_mapper', :path => "config/dependencies.rb", :indent => 2
88
- create_file("config/initializers/mongodb.rb", MONGO)
85
+ create_file("config/initializers/mongo_db.rb", MONGO)
89
86
  create_file("lib/ext/mongo_mapper.rb", CONCERNED)
90
87
  create_file("app/models/user.rb", USER)
91
88
  create_file("app/models/user/authentications.rb", AUTH)
@@ -5,7 +5,7 @@ module SinatraMore
5
5
  module SequelInitializer
6
6
  def self.registered(app)
7
7
  app.configure do
8
- Sequel.connect(ENV['DATABASE_URL'])
8
+ Sequel.connect('your_db_here')
9
9
  end
10
10
  end
11
11
  end
data/sinatra_more.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra_more}
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nathan Esquenazi"]
12
- s.date = %q{2009-11-08}
12
+ s.date = %q{2009-11-09}
13
13
  s.default_executable = %q{sinatra_gen}
14
14
  s.description = %q{Expands sinatra with standard helpers and tools to allow for complex applications}
15
15
  s.email = %q{nesquena@gmail.com}
@@ -75,7 +75,8 @@ class TestSkeletonGenerator < Test::Unit::TestCase
75
75
  buffer = silence_logger { SinatraMore::SkeletonGenerator.start(['sample_app', '/tmp', '--orm=activerecord', '--script=none']) }
76
76
  assert_match /Applying.*?activerecord.*?orm/, buffer
77
77
  assert_match_in_file(/require 'active_record'/, '/tmp/sample_app/config/dependencies.rb')
78
- assert_match_in_file(/ActiveRecordInitializer/, '/tmp/sample_app/config/initializers/activerecord.rb')
78
+ assert_match_in_file(/ActiveRecordInitializer/, '/tmp/sample_app/config/initializers/active_record.rb')
79
+ assert_match_in_file(/Migrate the database/, '/tmp/sample_app/Rakefile')
79
80
  assert_match_in_file(/CreateUsers < ActiveRecord::Migration/, '/tmp/sample_app/db/migrate/001_create_users.rb')
80
81
  assert_match_in_file(/class User < ActiveRecord::Base/, '/tmp/sample_app/app/models/user.rb')
81
82
  end
@@ -84,7 +85,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
84
85
  buffer = silence_logger { SinatraMore::SkeletonGenerator.start(['sample_app', '/tmp', '--orm=datamapper', '--script=none']) }
85
86
  assert_match /Applying.*?datamapper.*?orm/, buffer
86
87
  assert_match_in_file(/require 'dm-core'/, '/tmp/sample_app/config/dependencies.rb')
87
- assert_match_in_file(/DatamapperInitializer/, '/tmp/sample_app/config/initializers/datamapper.rb')
88
+ assert_match_in_file(/DataMapperInitializer/, '/tmp/sample_app/config/initializers/data_mapper.rb')
88
89
  assert_match_in_file(/class User.*?include DataMapper::Resource/m, '/tmp/sample_app/app/models/user.rb')
89
90
  end
90
91
 
@@ -92,7 +93,7 @@ class TestSkeletonGenerator < Test::Unit::TestCase
92
93
  buffer = silence_logger { SinatraMore::SkeletonGenerator.start(['sample_app', '/tmp', '--orm=mongomapper', '--script=none']) }
93
94
  assert_match /Applying.*?mongomapper.*?orm/, buffer
94
95
  assert_match_in_file(/require 'mongo_mapper'/, '/tmp/sample_app/config/dependencies.rb')
95
- assert_match_in_file(/MongoDBInitializer/, '/tmp/sample_app/config/initializers/mongodb.rb')
96
+ assert_match_in_file(/MongoDbInitializer/, '/tmp/sample_app/config/initializers/mongo_db.rb')
96
97
  assert_match_in_file(/class User.*?include MongoMapper::Document/m, '/tmp/sample_app/app/models/user.rb')
97
98
  end
98
99
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra_more
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Esquenazi
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-08 00:00:00 -08:00
12
+ date: 2009-11-09 00:00:00 -08:00
13
13
  default_executable: sinatra_gen
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency