Module: MyRepresentatives

Defined in:
lib/my_representatives.rb,
lib/my_representatives/errors.rb,
lib/my_representatives/person.rb,
lib/my_representatives/static.rb,
lib/my_representatives/version.rb,
lib/my_representatives/fileable.rb,
lib/my_representatives/hashable.rb,
lib/my_representatives/guessable.rb,
lib/my_representatives/electorate.rb,
lib/my_representatives/nt/web_show.rb,
lib/my_representatives/sa/web_show.rb,
lib/my_representatives/wa/web_show.rb,
lib/my_representatives/act/web_show.rb,
lib/my_representatives/nsw/web_show.rb,
lib/my_representatives/nt/web_index.rb,
lib/my_representatives/nt/web_lower.rb,
lib/my_representatives/qld/web_show.rb,
lib/my_representatives/sa/csv_lower.rb,
lib/my_representatives/sa/csv_upper.rb,
lib/my_representatives/sa/web_lower.rb,
lib/my_representatives/sa/web_upper.rb,
lib/my_representatives/vic/web_show.rb,
lib/my_representatives/wa/csv_lower.rb,
lib/my_representatives/wa/csv_upper.rb,
lib/my_representatives/wa/web_index.rb,
lib/my_representatives/wa/web_lower.rb,
lib/my_representatives/wa/web_upper.rb,
lib/my_representatives/abbreviatable.rb,
lib/my_representatives/act/csv_lower.rb,
lib/my_representatives/act/web_index.rb,
lib/my_representatives/act/web_lower.rb,
lib/my_representatives/nsw/csv_lower.rb,
lib/my_representatives/nsw/csv_upper.rb,
lib/my_representatives/nsw/web_index.rb,
lib/my_representatives/nsw/web_lower.rb,
lib/my_representatives/nsw/web_upper.rb,
lib/my_representatives/qld/csv_lower.rb,
lib/my_representatives/qld/web_index.rb,
lib/my_representatives/qld/web_lower.rb,
lib/my_representatives/tas/csv_lower.rb,
lib/my_representatives/tas/csv_upper.rb,
lib/my_representatives/vic/csv_lower.rb,
lib/my_representatives/vic/csv_upper.rb,
lib/my_representatives/vic/web_index.rb,
lib/my_representatives/vic/web_lower.rb,
lib/my_representatives/vic/web_upper.rb,
lib/my_representatives/sa/merge_lower.rb,
lib/my_representatives/sa/merge_upper.rb,
lib/my_representatives/wa/merge_lower.rb,
lib/my_representatives/wa/merge_upper.rb,
lib/my_representatives/act/merge_lower.rb,
lib/my_representatives/nsw/merge_lower.rb,
lib/my_representatives/nsw/merge_upper.rb,
lib/my_representatives/qld/merge_lower.rb,
lib/my_representatives/vic/merge_lower.rb,
lib/my_representatives/vic/merge_upper.rb,
lib/my_representatives/act/web_index_row.rb,
lib/my_representatives/sa/web_index_lower.rb,
lib/my_representatives/sa/web_index_upper.rb,
lib/my_representatives/commonwealth/web_show.rb,
lib/my_representatives/commonwealth/csv_email.rb,
lib/my_representatives/commonwealth/csv_lower.rb,
lib/my_representatives/commonwealth/csv_upper.rb,
lib/my_representatives/commonwealth/web_index.rb,
lib/my_representatives/commonwealth/web_lower.rb,
lib/my_representatives/commonwealth/web_upper.rb,
lib/my_representatives/commonwealth/merge_lower.rb,
lib/my_representatives/commonwealth/merge_upper.rb,
lib/my_representatives/commonwealth/commonwealth.rb

Overview

Dir[‘my_representatives/*/.rb’].each{ |f| require f }

Defined Under Namespace

Modules: ACT, Abbreviatable, Commonwealth, Fileable, Guessable, Hashable, NSW, NT, QLD, SA, Static, TAS, VIC, WA Classes: Electorate, Error, GenericPhantomJSError, InvalidURLError, NokogiriDocumentExpectedError, NokogiriDocumentPropertiesError, Person

Constant Summary collapse

VERSION =
'0.0.6'

Class Method Summary collapse

Class Method Details

.create_csv(people) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
# File 'lib/my_representatives.rb', line 138

def self.create_csv(people)
  filename = "tmp/csv_all_representatives.csv"
  File.delete(filename) if File.exist?(filename)

  CSV.open(filename, "wb") do |csv|
    csv << ["title", "first_name", "last_name", "preferred_name", "honorifics", "salutation", "gender", "email", "phone", "physical_address", "postal_address", "party_name", "electorate_name", "electorate_house", "electorate_state", "lower_house", "state_government"]
    people.each do |p|
      csv << [p.title, p.first_name, p.last_name, p.preferred_name, p.honorifics, p.salutation, p.gender, p.email, "'#{p.phone}'", p.physical_address, p.postal_address, p.party_name, p.electorate.name, p.electorate.house, p.electorate.state, p.electorate.lower_house, p.electorate.state_government]
    end
  end
end

.newObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/my_representatives.rb', line 83

def self.new
  people = []

  ### Commonwealth
  puts "Fetching Commonwealth House of Representatives ..."
  Commonwealth::MergeLower.new.people.each { |p| people << p }
  puts "Fetching Commonwealth Senate ..."
  Commonwealth::MergeUpper.new.people.each { |p| people << p }

  ### Australian Capital Territory
  puts "Fetching ACT Lower House ..."
  ACT::MergeLower.new.people.each { |p| people << p }

  ### New South Wales
  puts "Fetching NSW Lower House ..."
  NSW::MergeLower.new.people.each { |p| people << p }
  puts "Fetching NSW Upper House ..."
  NSW::MergeUpper.new.people.each { |p| people << p }

  ### Northern Territory
  puts "Fetching NT Lower House ..."
  NT::WebLower.new.people.each { |p| people << p }

  ### Queensland
  puts "Fetching QLD Lower House ..."
  QLD::MergeLower.new.people.each { |p| people << p }

  ### South Australia
  puts "Fetching SA Lower House ..."
  SA::MergeLower.new.people.each { |p| people << p }
  puts "Fetching SA Upper House ..."
  SA::MergeUpper.new.people.each { |p| people << p }

  ### Tasmania
  puts "Fetching TAS Lower House ..."
  TAS::CSVLower.new.people.each { |p| people << p }
  puts "Fetching TAS Upper House ..."
  TAS::CSVUpper.new.people.each { |p| people << p }

  ### VICTORIA
  puts "Fetching VIC Lower House ..."
  VIC::MergeLower.new.people.each { |p| people << p }
  puts "Fetching VIC Upper House ..."
  VIC::MergeUpper.new.people.each { |p| people << p }

  ### Western Australia
  puts "Fetching WA Lower House ..."
  WA::MergeLower.new.people.each { |p| people << p }
  puts "Fetching WA Upper House ..."
  WA::MergeUpper.new.people.each { |p| people << p }

  create_csv(people)
  people
end