Class: RailsERD::Config

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

Constant Summary collapse

USER_WIDE_CONFIG_FILE =
File.expand_path(".erdconfig", ENV["HOME"])
CURRENT_CONFIG_FILE =
File.expand_path(".erdconfig", Dir.pwd)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.


14
15
16
# File 'lib/rails_erd/config.rb', line 14

def initialize
  @options = {}
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.


8
9
10
# File 'lib/rails_erd/config.rb', line 8

def options
  @options
end

Class Method Details

.font_names_based_on_osObject


29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rails_erd/config.rb', line 29

def self.font_names_based_on_os
  if use_os_x_fonts?
    { normal: "ArialMT",
      bold:   "Arial BoldMT",
      italic: "Arial ItalicMT" }
  else
    { normal: "Arial",
      bold:   "Arial Bold",
      italic: "Arial Italic" }
  end
end

.load(extra_config_file = nil) ⇒ Object


10
11
12
# File 'lib/rails_erd/config.rb', line 10

def self.load(extra_config_file=nil)
  new.load extra_config_file
end

Instance Method Details

#load(extra_config_file = nil) ⇒ Object


18
19
20
21
22
23
24
25
26
27
# File 'lib/rails_erd/config.rb', line 18

def load(extra_config_file=nil)
  load_file(USER_WIDE_CONFIG_FILE)
  load_file(CURRENT_CONFIG_FILE)
  if extra_config_file
    extra_config_path = File.expand_path(extra_config_file, Dir.pwd)
    load_file(extra_config_path) if File.exist?(extra_config_path)
  end

  @options
end