Class: Pith::ConfigProvider

Inherits:
Object
  • Object
show all
Includes:
Observable
Defined in:
lib/pith/config_provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Observable

#add_observer, #notify_observers, #remove_observer

Constructor Details

#initialize(project) ⇒ ConfigProvider

Returns a new instance of ConfigProvider.



10
11
12
13
14
# File 'lib/pith/config_provider.rb', line 10

def initialize(project)
  @project = project
  @last_load_mtime = :never
  sync
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



16
17
18
# File 'lib/pith/config_provider.rb', line 16

def config
  @config
end

Instance Method Details

#syncObject



18
19
20
21
22
23
24
25
26
# File 'lib/pith/config_provider.rb', line 18

def sync
  config_mtime = config_file.mtime rescue nil
  unless config_mtime == @last_load_mtime
    @last_load_mtime = config_mtime
    @project.logger.debug "loading config"
    @config = Pith::Config.load(config_file)
    notify_observers
  end
end