Module: Facade

Included in:
GSA
Defined in:
lib/facade.rb

Instance Method Summary collapse

Instance Method Details

#beautify_search_results(search_results) ⇒ Object



34
35
36
# File 'lib/facade.rb', line 34

def beautify_search_results(search_results)
  GSA::SearchConverter.convert(search_results)
end

#check_base_uriObject



30
31
32
# File 'lib/facade.rb', line 30

def check_base_uri
  raise GSA::URINotSetError, GSA::NO_URI_TEXT unless GSA.base_uri
end

#feed(args) ⇒ Object



2
3
4
5
# File 'lib/facade.rb', line 2

def feed(args)
  xml = records_to_xml(args)
  feed_to_gsa(xml, args[:datasource_name])
end

#feed_to_gsa(xml_file, datasource_name) ⇒ Object



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

def feed_to_gsa(xml_file, datasource_name)
  if GSA.base_uri
    GSA::Feeder.feed(xml_file, datasource_name)
  else
    raise GSA::URINotSetError, GSA::NO_URI_TEXT
  end
end

#records_to_xml(args) ⇒ Object



38
39
40
# File 'lib/facade.rb', line 38

def records_to_xml(args)
  GSA::RecordsConverter.convert(args)
end

#search(query, filters = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/facade.rb', line 7

def search(query, filters={})
  check_base_uri
  raw_results = GSA::Searcher.search(query, filters)
  return raw_results if raw_results == GSA::NO_RESULTS
  if filters[:embedded]
    raw_results
  else
    beautify_search_results(raw_results)
  end
end

#uids(pretty_search_results, uid) ⇒ Object



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

def uids(pretty_search_results, uid)
  GSA::UIDExtractor.extract(pretty_search_results, uid)
end