Class: Whisper::Config
- Inherits:
-
Object
- Object
- Whisper::Config
- Defined in:
- lib/whisper/config.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- REQUIRED =
[ :whisper_dir, :title, :tagline, :root, :public_url_root, :from_email_address, :comment_mbox ]
- OPTIONAL =
[ :post_dir, :comment_dir, :template_dir, :static_dir, :helper_dir, :draft_dir, :sendmail, :development_port, :port, :page_size, :rack_handler, :mbox_offset_filename, :author_dir, :x_accel_redirect, :formatter_dir]
- ALL =
REQUIRED + OPTIONAL
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
Instance Method Summary collapse
-
#initialize(fn, base_dir, mode = :development) ⇒ Config
constructor
A new instance of Config.
- #use_this_port ⇒ Object
Constructor Details
#initialize(fn, base_dir, mode = :development) ⇒ Config
Returns a new instance of Config.
16 17 18 19 20 21 22 23 |
# File 'lib/whisper/config.rb', line 16 def initialize fn, base_dir, mode=:development @mode = mode @hash = YAML.load_file fn @hash[:whisper_dir] = base_dir REQUIRED.each { |k| raise Error, "missing required configuration value '#{k}'" unless @hash[k] } @hash.keys.each { |k| raise Error, "unknown configuration value '#{k}'" unless ALL.member? k } fill_defaults! end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
25 26 27 |
# File 'lib/whisper/config.rb', line 25 def mode @mode end |
Instance Method Details
#use_this_port ⇒ Object
27 |
# File 'lib/whisper/config.rb', line 27 def use_this_port; @mode == :development ? @hash[:development_port] : @hash[:port] end |