Module: Barton

Defined in:
lib/barton.rb,
lib/barton/app.rb,
lib/barton/core.rb,
lib/barton/version.rb

Defined Under Namespace

Modules: Data, Find, Setup Classes: App

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.api_urlObject



14
15
16
# File 'lib/barton.rb', line 14

def api_url
  @@api_url ||= 'http://localhost:4567'
end

.api_url=(env) ⇒ Object



18
19
20
# File 'lib/barton.rb', line 18

def api_url=(env)
  @@api_url = env
end

.configObject



35
36
37
# File 'lib/barton/core.rb', line 35

def self.config
  Data.config
end

.electorates(query = {}) ⇒ Object

Returns an array of electorates matching the search criteria

Accepts a hash of criteria
  :id
  :tags
  :geo
  :address
Returns an array of hashes


16
17
18
# File 'lib/barton/core.rb', line 16

def self.electorates( query = {} )
  Find.electorates( query )
end

.environmentObject



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

def environment
  @@environment = ENV['BARTON'] || 'development'
end

.environment=(env) ⇒ Object



9
10
11
12
# File 'lib/barton.rb', line 9

def environment=(env)
  ENV['BARTON'] = env
  @@environment = env
end

.members(query = {}) ⇒ Object

Returns an array of member matching the search criteria

Accepts a hash of criteria
Returns an array of hashes


23
24
25
# File 'lib/barton/core.rb', line 23

def self.members( query={} )
  Find.members( query )
end

.setupObject

Loads electoral data from the yaml files into elasticsearch



28
29
30
31
32
33
# File 'lib/barton/core.rb', line 28

def self.setup
  Data.purge_es
  Dir['data/*.yaml'].each do |f|
    Setup.load_file( f )
  end
end