Class: Root

Inherits:
Object
  • Object
show all
Defined in:
lib/root.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(single, force) ⇒ Root



5
6
7
# File 'lib/root.rb', line 5

def initialize(single, force)
  find_rails_root(single, force)
end

Instance Attribute Details

#dbObject

Returns the value of attribute db.



3
4
5
# File 'lib/root.rb', line 3

def db
  @db
end

#rails_rootObject

Returns the value of attribute rails_root.



3
4
5
# File 'lib/root.rb', line 3

def rails_root
  @rails_root
end

Instance Method Details

#databaseObject



19
20
21
# File 'lib/root.rb', line 19

def database
  @db.load
end

#find_rails_root(single, force) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/root.rb', line 9

def find_rails_root(single, force)
  @rails_root = `pwd`.sub(/\n/, '')
  if File.directory? "#{@rails_root}/config" and File.directory? "#{@rails_root}/app"
    @db = Database.new(@rails_root, single, force)
    database
  else
    p 'Either this is not a rails app or you are not in the root of your rails app'
  end
end