public
Fork of listrophy/suprails
Description: Substitute for the "rails" command that can pre-install any gems, init a git db, and/or freeze rails, etc on top of a rails application
Homepage: http://suprails.org
Clone URL: git://github.com/ffmike/suprails.git
suprails / lib / db.rb
100644 74 lines (70 sloc) 2.219 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#
# Suprails: The customizable wrapper to the rails command
#
# Copyright 2008 Bradley Grzesiak
# This file is part of Suprails.
#
# Suprails is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Suprails is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Suprails. If not, see <http://www.gnu.org/licenses/>.
#
 
class DB
  attr_reader :development, :test, :production
  class Environment
    def initialize db_type
      @db_type = db_type
    end
    def adapter adapter
      # puts "db.#{@db_type}.adapter #{adapter}"
      puts 'database.yml modification not yet implemented'
    end
    def db db
      # puts "db.#{@db_type}.db #{db}"
      puts 'database.yml modification not yet implemented'
    end
    def database datab
      db datab
    end
    def host h
      # puts "db.#{@db_type}.host #{h}"
      puts 'database.yml modification not yet implemented'
    end
    def username uname
      # puts "db.#{@db_type}.username #{uname}"
      puts 'database.yml modification not yet implemented'
    end
    def password passwd
      # puts "db.#{@db_type}.password #{passwd}"
      puts 'database.yml modification not yet implemented'
    end
    def socket s
      # puts "db.#{@db_type}.socket #{s}"
      puts 'database.yml modification not yet implemented'
    end
    def timeout to
      # puts "db.#{@db_type}.timeout #{to}"
      puts 'database.yml modification not yet implemented'
    end
  end
  def initialize app_name
    @development = Environment.new 'development'
    @test = Environment.new 'test'
    @production = Environment.new 'production'
    @app_name = app_name
  end
  
  def create
    `cd #{@app_name}; rake db:create`
  end
  def migrate
    `cd #{@app_name}; rake db:migrate`
  end
    
end