Class: RailsERD::Config
- Inherits:
-
Object
- Object
- RailsERD::Config
- Defined in:
- lib/rails_erd/config.rb
Constant Summary collapse
- USER_WIDE_CONFIG_FILE =
File.(".erdconfig", ENV["HOME"])
- CURRENT_CONFIG_FILE =
File.(".erdconfig", Dir.pwd)
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load(extra_config_file = nil) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
16 17 18 |
# File 'lib/rails_erd/config.rb', line 16 def initialize @options = {} end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/rails_erd/config.rb', line 10 def @options end |
Class Method Details
.font_names_based_on_os ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rails_erd/config.rb', line 31 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
12 13 14 |
# File 'lib/rails_erd/config.rb', line 12 def self.load(extra_config_file=nil) new.load extra_config_file end |
.use_os_x_fonts? ⇒ Boolean
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/rails_erd/config.rb', line 100 def self.use_os_x_fonts? host = RbConfig::CONFIG['host_os'] return true if host == "darwin" if host.include? "darwin" darwin_version_array = host.split("darwin").last.split(".").map(&:to_i) return true if darwin_version_array[0] >= 13 return true if darwin_version_array[0] == 12 && darwin_version_array[1] >= 5 end false end |
Instance Method Details
#load(extra_config_file = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rails_erd/config.rb', line 20 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.(extra_config_file, Dir.pwd) load_file(extra_config_path) if File.exist?(extra_config_path) end @options end |