Class: Expirer::Config

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

Constant Summary collapse

DEFAULTS =
{
  private_only: true,
  expire_date: '1 year ago'
}.freeze
OPTIONS =
[:username, :password, :organization, :private_only, :expire_date]

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



15
16
17
# File 'lib/expirer/config.rb', line 15

def initialize
  reset!
end

Instance Method Details

#expire_dateObject



31
32
33
# File 'lib/expirer/config.rb', line 31

def expire_date
  @parsed_expire_date ||= Chronic.parse(@expire_date).to_datetime
end

#load_from_file!(file) ⇒ Object



19
20
21
# File 'lib/expirer/config.rb', line 19

def load_from_file!(file)
  set_options(config_from_file(file)) if file && File.exists?(file)
end

#load_from_options!(options) ⇒ Object



27
28
29
# File 'lib/expirer/config.rb', line 27

def load_from_options!(options)
  set_options(options.underscore_keys.symbolize_keys)
end

#private_only?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/expirer/config.rb', line 35

def private_only?
  private_only
end

#reset!Object



23
24
25
# File 'lib/expirer/config.rb', line 23

def reset!
  set_options(DEFAULTS)
end