Sha256: 53b1ade0771fd732f698d2b15bd84dab33a0fe4e7a8f4f68228319e1b63f6f03

Contents?: true

Size: 561 Bytes

Versions: 2

Compression:

Stored size: 561 Bytes

Contents

require 'hashie'
require 'json'

class AppConfig

  def initialize(config)
    set_defaults config
    @config = Hashie::Mash.new config
  end

  def [](key)
    @config[key]
  end

  def users_with_password
    @config[:users].select { |u| u[:password] }
  end

  def self.from_file(path)
    json = File.read path
    config = JSON.parse json
    AppConfig.new config
  end

  private

  def set_defaults(config)
    config[:title] ||= 'Help Desk Dashboard'
    config[:output_dir] ||= 'output'
    config[:threads] = (config[:threads] || '1').to_i
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
help_desk_dashboard-0.0.5 lib/help_desk_dashboard/lib/app_config.rb
help_desk_dashboard-0.0.3 lib/help-desk-dashboard/app_config.rb