Class: Purdie::Bernard

Inherits:
Object
  • Object
show all
Defined in:
lib/purdie/bernard.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBernard

Returns a new instance of Bernard.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/purdie/bernard.rb', line 7

def initialize
  @config = Config.instance.config
  begin
    @sources = Dir.entries(@config['source_dir']).select { |e|
      e !~ /^\./
    }.map { |s|
      "#{@config['source_dir']}/#{s}"
    }
  rescue Errno::ENOENT
    @sources = nil
  end
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/purdie/bernard.rb', line 5

def config
  @config
end

Instance Method Details

#fetchObject

def source_file= path

  @sources = path
end


24
25
26
27
28
29
30
# File 'lib/purdie/bernard.rb', line 24

def fetch
  raise PurdieException.new 'No data sources specified' unless @sources

  @sources.map { |s| SourceList.from_file s }.each do |source|
    source.write
  end
end