Class: M2Config::Config
- Inherits:
-
Object
- Object
- M2Config::Config
- Defined in:
- lib/m2config.rb
Constant Summary collapse
- DEFAULT_CONFIG =
"config.sqlite"
- SCHEMA =
File.read("#{File.dirname __FILE__}/m2config/schema.sql")
- @@foundTables =
[]
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
Class Method Summary collapse
Instance Method Summary collapse
- #[]=(k, v) ⇒ Object
- #add_server(settings = {}) ⇒ Object
-
#initialize(fileName = DEFAULT_CONFIG, options = {}) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(fileName = DEFAULT_CONFIG, options = {}) ⇒ Config
Returns a new instance of Config.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/m2config.rb', line 26 def initialize(fileName = DEFAULT_CONFIG, ={}) @fileName = fileName creating = ! (File.exists? @fileName) @db = Sequel.connect "sqlite://#{@fileName}" @db.run SCHEMA if creating Sequel::Model.db = @db require "m2config/server" require "m2config/host" require "m2config/dir" require "m2config/route" require "m2config/proxy" require "m2config/handler" require "m2config/setting" require "m2config/mimetype" M2Config::MimeType.populate_table(nil,[:ignoreDoubles]) if creating end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
11 12 13 |
# File 'lib/m2config.rb', line 11 def db @db end |
Class Method Details
.tables ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/m2config.rb', line 15 def self.tables return @@foundTables unless @@foundTables.empty? SCHEMA.split("\n").each do |l| if l =~ /CREATE TABLE (\w+)/ @@foundTables.push $1 end end @@foundTables end |