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.



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

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

#verboseObject

Returns the value of attribute verbose.



3
4
5
# File 'lib/purdie/bernard.rb', line 3

def verbose
  @verbose
end

Instance Method Details

#fetchObject

def source_file= path

  @sources = path
end


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

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

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