Module: Honeycomb::Model

Defined in:
lib/honeycomb/model.rb

Defined Under Namespace

Modules: FixtureTable

Class Method Summary collapse

Class Method Details

.all_databases(dir = Pathname.new(__FILE__).dirname.dirname.dirname.expand_path.join('data').join('logsql/').to_s) ⇒ Object

TODO: Comment



57
58
59
60
61
# File 'lib/honeycomb/model.rb', line 57

def self.all_databases(dir = Pathname.new(__FILE__).dirname.dirname.dirname.expand_path.join('data').join('logsql/').to_s)
  ret = Dir.entries(dir)
  ret.delete_if {|x| x =~ /^\./}
  ret
end

.setup!(dir = Pathname.new(__FILE__).dirname.dirname.dirname.expand_path.join('data').join('logsql/').to_s) ⇒ Object

Sets up the model using with the currently configured db_conn configuration.



65
66
67
68
69
70
71
72
73
74
# File 'lib/honeycomb/model.rb', line 65

def self.setup!(dir = Pathname.new(__FILE__).dirname.dirname.dirname.expand_path.join('data').join('logsql/').to_s)
  num = 1
  DataMapper.setup(:default, "sqlite:///#{dir}honeypot.sqlite")
  self.all_databases.each do |database|
    DataMapper.setup(num.to_s.to_sym, "sqlite:///#{dir}#{database}") 
    num = num + 1
  end  
  DataMapper.finalize
  @setup = true
end