Class: BBCDataService::FixtureLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/bbc_data_service/fixture_loader.rb

Class Method Summary collapse

Class Method Details

.load_fixture(name) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/bbc_data_service/fixture_loader.rb', line 3

def self.load_fixture(name)
  require ServiceConfig[:fixture_config].to_s
  app_fixture = AppFixture.fixtures[name]
  app_fixture = self.merge_fixtures(app_fixture) if app_fixture[:parent]
  if app_fixture
    self.parse_data(app_fixture)
  end
end

.merge_fixtures(app_fixture) ⇒ Object



14
15
16
17
# File 'lib/bbc_data_service/fixture_loader.rb', line 14

def self.merge_fixtures(app_fixture)
  parent_fixture = AppFixture.fixtures[app_fixture[:parent]]
  parent_fixture.merge(app_fixture)
end

.parse_data(app_fixture) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bbc_data_service/fixture_loader.rb', line 19

def self.parse_data(app_fixture)
  case app_fixture[:type]
  when :rdf
    fixtures = BBCDataService::RDFParser.parse_feed(app_fixture)
    if fixtures.size == 1
      return fixtures.first
    else
      return fixtures
    end
  when :json
    return BBCDataService::JSONParser.parse_feed(app_fixture)
  end
end