Module: UkParliament

Included in:
Commons, DocPipeline, HouseMembers, HouseMembersManager, Lords, Parliament, QueueManager
Defined in:
lib/uk_parliament.rb,
lib/uk_parliament/lords.rb,
lib/uk_parliament/commons.rb,
lib/uk_parliament/version.rb,
lib/uk_parliament/doc_pipeline.rb,
lib/uk_parliament/house_members.rb,
lib/uk_parliament/queue_manager.rb,
lib/uk_parliament/file_house_members.rb,
lib/uk_parliament/http_house_members.rb,
lib/uk_parliament/house_members_manager.rb,
lib/uk_parliament/member_list_doc_pipeline.rb,
lib/uk_parliament/member_summary_doc_pipeline.rb,
lib/uk_parliament/house_members_source_factory.rb

Overview

Module defining classes and methods enabling scraping of UK Parliament members contact data from parliament.uk web site, or loading of scraped data from file.

Defined Under Namespace

Classes: Commons, DocPipeline, FileHouseMembers, HouseMembers, HouseMembersManager, HouseMembersSourceFactory, HttpHouseMembers, Lords, MemberListDocPipeline, MemberSummaryDocPipeline, Parliament, QueueManager

Constant Summary collapse

DATA_SOURCE_FILE =

Constants representing where data can come from.

'file'
DATA_SOURCE_HTTP =
'http'
VERSION =
"0.1.0"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configurationObject

Define set of configuration values for the module.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/uk_parliament.rb', line 45

def self.configuration
  if @configuration.nil?
    base_dir = File.join(Dir.home, 'uk_parliament')
    FileUtils.mkdir_p(base_dir) unless Dir.exist?(base_dir)

    @configuration = {
      :log_file_path => base_dir,
      :data_file_path => base_dir,
      :queue_file_path => base_dir,
      :scrape_no_of_threads => 4,
      :scrape_request_delay => 2,
      :backup_before_write => true
    }
  end

  @configuration
end

.logObject

Setup a Logger instance, if one doesn’t already exist.



29
30
31
32
33
34
35
36
37
# File 'lib/uk_parliament.rb', line 29

def self.log
  if @log.nil?
    config = configuration
    @log = Logger.new(File.join(config[:log_file_path], 'uk_parliament.log'), 'daily')
    @log.level = Logger::INFO
  end

  @log
end

Instance Method Details

#configurationObject

Setup module-wide access to a set of configuration values.



40
41
42
# File 'lib/uk_parliament.rb', line 40

def configuration
  UkParliament.configuration
end

#logObject

Setup module-wide access to Log to file.



24
25
26
# File 'lib/uk_parliament.rb', line 24

def log
  UkParliament.log
end