bbc_data_service 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .DS_STORE
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bbc-data-service.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+ require 'sinatra/activerecord/rake'
4
+ require 'rspec/core/rake_task'
5
+
6
+ desc "Run specs"
7
+ RSpec::Core::RakeTask.new do |t|
8
+ t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
9
+ # Put spec opts in a file named .rspec in root
10
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "bbc_data_service/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "bbc_data_service"
7
+ s.version = BBCDataService::VERSION
8
+ s.authors = ["Matthew Crouch"]
9
+ s.email = ["matthew.crouch@bbc.co.uk"]
10
+ s.homepage = "https://github.com/mobzilla/bbc-data-service"
11
+ s.summary = %q{BBC Data Service}
12
+ s.description = %q{BBC Data Service for fixture management}
13
+
14
+ s.rubyforge_project = "bbc-data-service"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = ["bbc_data_service"]
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency("sinatra", "~>1.2.6")
22
+ s.add_dependency("activemodel", "~>3.1.0")
23
+ #s.add_dependency("rdf-rdfxml", "0.3.4")
24
+ s.add_dependency("rdf-json", "~>0.3.0")
25
+ # Development Dependencies
26
+ s.add_development_dependency("rspec", "~>2.6.0")
27
+ s.add_development_dependency("turn", "~>0.8.2")
28
+
29
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.push File.expand_path('../../lib', __FILE__)
4
+
5
+ require 'rubygems'
6
+ require 'optparse'
7
+ require 'bbc_data_service/service_config'
8
+
9
+ OptionParser.new do |opts|
10
+ opts.banner = "Usage: bbc_data_service [options]"
11
+
12
+ opts.on("-f", "--fixture-config FILE_PATH", "Path to your fixture configuration file") do |fixture_config_file_path|
13
+ ServiceConfig[:fixture_config] = fixture_config_file_path
14
+ end
15
+
16
+ opts.on_tail("-h", "--help", "Just shows this!") do
17
+ puts opts
18
+ exit
19
+ end
20
+ end.parse!
21
+
22
+ require 'bbc_data_service'
23
+ require ServiceConfig[:fixture_config].to_s
24
+
25
+ BBCDataService::Application.run!
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,26 @@
1
+ module BBCDataService
2
+ class AppFixture < Hash
3
+
4
+ def initalize
5
+ @app_fixtures = {}
6
+ end
7
+
8
+ def self.register_fixture(name, mapping)
9
+ @fixtures ||= AppFixture.new
10
+ @fixtures[name] = mapping
11
+ end
12
+
13
+ def self.find_by_endpoint(endpoint)
14
+ @fixtures.each do |f|
15
+ if f.last[:endpoint] == endpoint
16
+ return f.last
17
+ end
18
+ end
19
+ end
20
+
21
+ def self.fixtures
22
+ @fixtures
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,30 @@
1
+ module BBCDataService
2
+ class FeedFixture
3
+ include ActiveModel::Serialization
4
+ include ActiveModel::Conversion
5
+ extend ActiveModel::Naming
6
+
7
+ attr_accessor :attributes
8
+
9
+ def initialize(attributes = {})
10
+ @attributes = attributes
11
+ @attributes.each do |name, value|
12
+ FeedFixture.instance_eval <<-EOS
13
+ attr_accessor :#{name}
14
+ EOS
15
+ send("#{name}=", value.to_s)
16
+ end
17
+ end
18
+
19
+ def add_relationship(name, values)
20
+ FeedFixture.instance_eval <<-EOS
21
+ attr_accessor :#{name}
22
+ EOS
23
+ send("#{name}=", values)
24
+ end
25
+
26
+ def to_header
27
+ @attributes.map{|key, value| "#{key.upcase}: #{value}" }.join("\r\n")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,33 @@
1
+ module BBCDataService
2
+ class FixtureLoader
3
+ def self.load_fixture(name)
4
+ require ServiceConfig[:fixture_config].to_s
5
+ app_fixture = AppFixture.fixtures[name]
6
+ app_fixture = self.merge_fixtures(app_fixture) if app_fixture[:parent]
7
+ if app_fixture
8
+ self.parse_data(app_fixture)
9
+ end
10
+ end
11
+
12
+ protected
13
+
14
+ def self.merge_fixtures(app_fixture)
15
+ parent_fixture = AppFixture.fixtures[app_fixture[:parent]]
16
+ parent_fixture.merge(app_fixture)
17
+ end
18
+
19
+ def self.parse_data(app_fixture)
20
+ case app_fixture[:type]
21
+ when :rdf
22
+ fixtures = BBCDataService::RDFParser.parse_feed(app_fixture)
23
+ if fixtures.size == 1
24
+ return fixtures.first
25
+ else
26
+ return fixtures
27
+ end
28
+ when :json
29
+ return BBCDataService::JSONParser.parse_feed(app_fixture)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,8 @@
1
+ module BBCDataService
2
+ class JSONParser
3
+ def self.parse_feed(feed_file)
4
+ feed_file = File.open(feed_file[:feed_url], "r")
5
+ ActiveSupport::JSON.decode(feed_file)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,67 @@
1
+ require "bbc_data_service/vocabulary"
2
+ require "bbc_data_service/feed_fixture"
3
+ require "rdf/json"
4
+ module BBCDataService
5
+ class RDFParser
6
+
7
+ include BBCDataService::Vocabulary
8
+
9
+ def self.parse_feed(registered_fixture)
10
+ feed_url = registered_fixture[:feed_url]
11
+ mappings = registered_fixture[:mappings]
12
+ rdf_type = registered_fixture[:rdf_type]
13
+ graph = RDF::Graph.load(feed_url)
14
+ query = RDF::Query.new({
15
+ :fixture => self.generate_query(mappings, rdf_type)
16
+ })
17
+ results = []
18
+ query.execute(graph).each do |fixture|
19
+ current_fixture = BBCDataService::FeedFixture.new(self.instance_eval(self.execute_query(graph, query, mappings)))
20
+ self.process_relationships(graph, registered_fixture, current_fixture, fixture)
21
+ results << current_fixture
22
+ end
23
+ results
24
+ end
25
+
26
+ def self.process_relationships(graph, fixture_data, current_fixture, rdf_fixture)
27
+ relationships = fixture_data[:relationships]
28
+ if relationships
29
+ relationships.each do |relationship|
30
+ key = relationship.first
31
+ values = relationship.last
32
+ # Parse this set of RDF, then add to an array on the main object
33
+ query = RDF::Query.new({
34
+ :fixture => self.generate_query(values[:mappings], values[:rdf_type])
35
+ })
36
+ results = []
37
+ query.execute(graph).each do |fixture|
38
+ results << BBCDataService::FeedFixture.new(self.instance_eval(self.execute_query(graph, query, values[:mappings])))
39
+ end
40
+ current_fixture.add_relationship(key, results)
41
+ end
42
+ end
43
+ end
44
+
45
+ def self.generate_query(mappings, rdf_type)
46
+ query_hash = ""
47
+ rdf_vocabulary, rdf_value = rdf_type.split(":")
48
+ query_hash << "RDF.type => self.vocabularies[:#{rdf_vocabulary}].#{rdf_value},"
49
+ mappings.each do |vocabulary, values|
50
+ values.each do |key, value|
51
+ query_hash << "self.vocabularies[:#{vocabulary}].#{value} => :#{key},"
52
+ end
53
+ end
54
+ self.instance_eval("{#{query_hash}}")
55
+ end
56
+
57
+ def self.execute_query(graph, query, mappings)
58
+ query_values = ""
59
+ mappings.each do |vocabulary, values|
60
+ values.each do |key, value|
61
+ query_values << ":#{key} => fixture.#{key},"
62
+ end
63
+ end
64
+ "{#{query_values}}"
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,3 @@
1
+ ServiceConfig = {
2
+ :fixture_config => "fixture_config.rb"
3
+ }
@@ -0,0 +1,3 @@
1
+ module BBCDataService
2
+ VERSION = "0.1.10"
3
+ end
@@ -0,0 +1,90 @@
1
+ require "rdf/rdfxml"
2
+ module BBCDataService
3
+ module Vocabulary
4
+
5
+ def self.included(base)
6
+ base.send :extend, ClassMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ def vocabularies
11
+ {
12
+ :foaf => RDF::Vocabulary.new("http://xmlns.com/foaf/0.1/"),
13
+ :domain => RDF::Vocabulary.new("http://www.bbc.co.uk/ontologies/domain/"),
14
+ :owlim => RDF::Vocabulary.new("http://www.ontotext.com/"),
15
+ :tzont => RDF::Vocabulary.new("http://www.w3.org/2006/timezone#"),
16
+ :ns => RDF::Vocabulary.new("http://xmlns.com/foaf/0.1/"),
17
+ :bbcevent => RDF::Vocabulary.new("http://www.bbc.co.uk/ontologies/event/"),
18
+ :tl => RDF::Vocabulary.new("http://purl.org/NET/c4dm/timeline.owl#"),
19
+ :tag => RDF::Vocabulary.new("http://www.bbc.co.uk/ontologies/tag/"),
20
+ :dcam => RDF::Vocabulary.new("http://purl.org/dc/dcam/"),
21
+ :geo_pos => RDF::Vocabulary.new("http://www.w3.org/2003/01/geo/wgs84_pos#"),
22
+ :umbel_ac => RDF::Vocabulary.new("http://umbel.org/umbel/ac/"),
23
+ :time => RDF::Vocabulary.new("http://www.w3.org/2006/time#"),
24
+ :sw_vocab => RDF::Vocabulary.new("http://www.w3.org/2003/06/sw-vocab-status/ns#"),
25
+ :ff => RDF::Vocabulary.new("http://factforge.net/"),
26
+ :event => RDF::Vocabulary.new("http://purl.org/NET/c4dm/event.owl#"),
27
+ :participation => RDF::Vocabulary.new("http://purl.org/vocab/participation/schema#"),
28
+ :music_ont => RDF::Vocabulary.new("http://purl.org/ontology/mo/"),
29
+ :oly => RDF::Vocabulary.new("http://www.bbc.co.uk/ontologies/2012olympics/"),
30
+ :opencyc_en => RDF::Vocabulary.new("http://sw.opencyc.org/2008/06/10/concept/en/"),
31
+ :dc_term => RDF::Vocabulary.new("http://purl.org/dc/terms/"),
32
+ :om => RDF::Vocabulary.new("http://www.ontotext.com/owlim/"),
33
+ :factbook => RDF::Vocabulary.new("http://www.daml.org/2001/12/factbook/factbook-ont#"),
34
+ :rdf => RDF::Vocabulary.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#"),
35
+ :exif => RDF::Vocabulary.new("http://www.w3.org/2003/12/exif/ns#"),
36
+ :dc => RDF::Vocabulary.new("http://purl.org/dc/elements/1.1/"),
37
+ :protege => RDF::Vocabulary.new("http://protege.stanford.edu/plugins/owl/protege#"),
38
+ :asset => RDF::Vocabulary.new("http://www.bbc.co.uk/ontologies/asset/"),
39
+ :yago => RDF::Vocabulary.new("http://mpii.de/yago/resource/"),
40
+ :xml => RDF::Vocabulary.new("http://www.w3.org/XML/1998/namespace"),
41
+ :daml => RDF::Vocabulary.new("http://www.daml.org/2001/03/daml+oil#"),
42
+ :ontology => RDF::Vocabulary.new("http://www.bbc.co.uk/ontology/"),
43
+ :gn => RDF::Vocabulary.new("http://www.geonames.org/ontology#"),
44
+ :umbel => RDF::Vocabulary.new("http://umbel.org/umbel#"),
45
+ :wordnet16 => RDF::Vocabulary.new("http://xmlns.com/wordnet/1.6/"),
46
+ :swrlb => RDF::Vocabulary.new("http://www.w3.org/2003/11/swrlb#"),
47
+ :owl => RDF::Vocabulary.new("http://www.w3.org/2002/07/owl#"),
48
+ :po => RDF::Vocabulary.new("http://purl.org/ontology/po/"),
49
+ :wordnet => RDF::Vocabulary.new("http://www.w3.org/2006/03/wn/wn20/instances/"),
50
+ :gr => RDF::Vocabulary.new("http://purl.org/goodrelations/v1#"),
51
+ :cc => RDF::Vocabulary.new("http://creativecommons.org/ns#"),
52
+ :go => RDF::Vocabulary.new("http://aims.fao.org/aos/geopolitical.owl"),
53
+ :opencyc => RDF::Vocabulary.new("http://sw.opencyc.org/concept/"),
54
+ :wordn_sc => RDF::Vocabulary.new("http://www.w3.org/2006/03/wn/wn20/schema/"),
55
+ :nytimes => RDF::Vocabulary.new("http://data.nytimes.com/"),
56
+ :dbp_prop => RDF::Vocabulary.new("http://dbpedia.org/property/"),
57
+ :geonames => RDF::Vocabulary.new("http://sws.geonames.org/"),
58
+ :protons => RDF::Vocabulary.new("http://proton.semanticweb.org/2005/04/protons#"),
59
+ :protonu => RDF::Vocabulary.new("http://proton.semanticweb.org/2005/04/protonu#"),
60
+ :protont => RDF::Vocabulary.new("http://proton.semanticweb.org/2005/04/protont#"),
61
+ :wot => RDF::Vocabulary.new("http://xmlns.com/wot/0.1/"),
62
+ :rdfs => RDF::Vocabulary.new("http://www.w3.org/2000/01/rdf-schema#"),
63
+ :swrl => RDF::Vocabulary.new("http://www.w3.org/2003/11/swrl#"),
64
+ :domain => RDF::Vocabulary.new("http://www.bbc.co.uk/ontologies/domain/"),
65
+ :dbpedia => RDF::Vocabulary.new("http://dbpedia.org/resource/"),
66
+ :sesame => RDF::Vocabulary.new("http://www.openrdf.org/schema/sesame#"),
67
+ :oasis => RDF::Vocabulary.new("http://psi.oasis-open.org/iso/639/#"),
68
+ :ex => RDF::Vocabulary.new("http://example.org/"),
69
+ :umbel_en => RDF::Vocabulary.new("http://umbel.org/umbel/ne/wikipedia/"),
70
+ :xsp => RDF::Vocabulary.new("http://www.owl-ontologies.com/2005/08/07/xsp.owl#"),
71
+ :news => RDF::Vocabulary.new("http://www.bbc.co.uk/ontologies/news/"),
72
+ :lingvoj => RDF::Vocabulary.new("http://www.lingvoj.org/ontology#"),
73
+ :bbcsys => RDF::Vocabulary.new("http://www.bbc.co.uk/ontologies/system/"),
74
+ :sport => RDF::Vocabulary.new("http://www.bbc.co.uk/ontologies/sport/"),
75
+ :fb => RDF::Vocabulary.new("http://rdf.freebase.com/ns/"),
76
+ :dbtune => RDF::Vocabulary.new("http://dbtune.org/bbc/peel/work/"),
77
+ :umbel_sc => RDF::Vocabulary.new("http://umbel.org/umbel/sc/"),
78
+ :dbp_ont => RDF::Vocabulary.new("http://dbpedia.org/ontology/"),
79
+ :ub => RDF::Vocabulary.new("http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#"),
80
+ :xsd => RDF::Vocabulary.new("http://www.w3.org/2001/XMLSchema#"),
81
+ :damloil => RDF::Vocabulary.new("http://www.daml.org/2000/12/daml+oil#"),
82
+ :skos => RDF::Vocabulary.new("http://www.w3.org/2004/02/skos/core#"),
83
+ :protonkm => RDF::Vocabulary.new("http://proton.semanticweb.org/2005/04/protonkm#"),
84
+ :geo_pol => RDF::Vocabulary.new("http://www.bbc.co.uk/ontologies/geopolitical/"),
85
+ :par => RDF::Vocabulary.new("http://purl.org/vocab/participation/schema#")
86
+ }
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,39 @@
1
+ require "rubygems"
2
+ require "sinatra"
3
+ require "active_model"
4
+ require "bbc_data_service/service_config"
5
+ require "bbc_data_service/version"
6
+ require "bbc_data_service/rdf_parser"
7
+ require "bbc_data_service/json_parser"
8
+ require "bbc_data_service/app_fixture"
9
+ require "bbc_data_service/fixture_loader"
10
+
11
+ module BBCDataService
12
+ class Application < Sinatra::Base
13
+
14
+ %w{get post put delete}.each do |method|
15
+ send method, /.*/ do
16
+ app_fixture = AppFixture.find_by_endpoint(request.fullpath)
17
+ if app_fixture
18
+ puts "Serving Fixture: #{app_fixture[:feed_url]} for #{request.fullpath}"
19
+ open(app_fixture[:feed_url])
20
+ else
21
+ try_redirect(request, method) or status 404
22
+ end
23
+ end
24
+ end
25
+
26
+ protected
27
+
28
+ def try_redirect(request, method)
29
+ r = nil
30
+ [{ pattern: 'esp-service', to: 'http://open.int.bbc.co.uk' }, { pattern: '.*', to: 'https://api.test.bbc.co.uk' }].map do |p|
31
+ if request.fullpath =~ /#{p[:pattern]}/
32
+ r = p
33
+ end
34
+ end
35
+ r && redirect( "#{r[:to]}#{request.fullpath}" )
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,41 @@
1
+ require "spec_helper"
2
+
3
+ describe BBCDataService::FixtureLoader do
4
+
5
+ before(:each) do
6
+ ServiceConfig[:fixture_config] = File.expand_path("../fixtures/test_config.rb", __FILE__)
7
+ end
8
+
9
+ it "should return individual feed objects" do
10
+ object = BBCDataService::FixtureLoader.load_fixture(:single_instance)
11
+ object.class.should == BBCDataService::FeedFixture
12
+ end
13
+
14
+ it "should return an array of objects if there is more than one item in a feed" do
15
+ objects = BBCDataService::FixtureLoader.load_fixture(:multiple_items)
16
+ objects.class.should == Array
17
+ objects.size.should == 2
18
+ end
19
+
20
+ it "should set the key and values on the model" do
21
+ object = BBCDataService::FixtureLoader.load_fixture(:single_instance)
22
+ object.name.should == "Team GB"
23
+ object.short_name.should == "Great Britain & N. Ireland"
24
+ object.url.should == "great-britain"
25
+ object.long_name.should == "United Kingdom of Great Britain and Northern Ireland"
26
+ end
27
+
28
+ it "should parse json feeds" do
29
+ object = BBCDataService::FixtureLoader.load_fixture(:json_groups)
30
+ object.class.should == Hash
31
+ end
32
+
33
+ it "should allow to inherit from other fixtures" do
34
+ object = BBCDataService::FixtureLoader.load_fixture(:parent_instance)
35
+ object.name.should == "Team GB"
36
+ object.short_name.should == "Great Britain & N. Ireland"
37
+ object.url.should == "great-britain"
38
+ object.long_name.should == "United Kingdom of Great Britain and Northern Ireland"
39
+ end
40
+
41
+ end
@@ -0,0 +1 @@
1
+ {"http:\/\/www.bbc.co.uk\/things\/territories\/ag#id":{"http:\/\/www.bbc.co.uk\/ontologies\/geopolitical\/isInGroup":[{"value":"http:\/\/www.bbc.co.uk\/things\/e2ec6578-aa80-49a3-9561-5b22fe6955be#id","type":"uri"}],"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#type":[{"value":"http:\/\/www.bbc.co.uk\/ontologies\/geopolitical\/Territory","type":"uri"}]},"http:\/\/www.bbc.co.uk\/things\/53e9bcb8-3cad-4842-8cd3-8acd4485bd97#id":{"http:\/\/www.bbc.co.uk\/ontologies\/domain\/externalId":[{"value":"urn:ioc2012:tha","type":"uri"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/longName":[{"value":"Kingdom of Thailand","datatype":"xsd:string","type":"literal"}],"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#type":[{"value":"http:\/\/www.bbc.co.uk\/ontologies\/sport\/CompetitiveSportingOrganisation","type":"uri"}],"http:\/\/www.bbc.co.uk\/ontologies\/2012olympics\/urlName":[{"value":"thailand","datatype":"xsd:string","type":"literal"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/name":[{"value":"Thailand","datatype":"xsd:string","type":"literal"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/document":[{"value":"http:\/\/www.bbc.co.uk\/sport\/olympics\/2012\/countries\/thailand","type":"uri"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/canonicalName":[{"value":"OlympicTeam-Thailand","datatype":"xsd:string","type":"literal"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/shortName":[{"value":"Thailand","datatype":"xsd:string","type":"literal"}],"http:\/\/www.bbc.co.uk\/ontologies\/2012olympics\/territory":[{"value":"http:\/\/www.bbc.co.uk\/things\/territories\/th#id","type":"uri"}]},"http:\/\/www.bbc.co.uk\/things\/f81bc0a0-ae57-4084-a614-8791c17d7981#id":{"http:\/\/www.bbc.co.uk\/ontologies\/domain\/externalId":[{"value":"urn:ioc2012:usa","type":"uri"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/longName":[{"value":"United States of America","datatype":"xsd:string","type":"literal"}],"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#type":[{"value":"http:\/\/www.bbc.co.uk\/ontologies\/sport\/CompetitiveSportingOrganisation","type":"uri"}],"http:\/\/www.bbc.co.uk\/ontologies\/2012olympics\/urlName":[{"value":"united-states","datatype":"xsd:string","type":"literal"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/name":[{"value":"Team USA","datatype":"xsd:string","type":"literal"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/canonicalName":[{"value":"OlympicTeam-Team USA","datatype":"xsd:string","type":"literal"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/document":[{"value":"http:\/\/www.teamusa.org","type":"uri"},{"value":"http:\/\/www.bbc.co.uk\/sport\/olympics\/2012\/countries\/united-states","type":"uri"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/shortName":[{"value":"United States","datatype":"xsd:string","type":"literal"}]}}
@@ -0,0 +1 @@
1
+ {"http:\/\/www.bbc.co.uk\/things\/7ef7ffdf-f101-4470-adc0-38a5abac9122#id":{"http:\/\/www.bbc.co.uk\/ontologies\/domain\/longName":[{"value":"United Kingdom of Great Britain and Northern Ireland","datatype":"xsd:string","type":"literal"}],"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#type":[{"value":"http:\/\/www.bbc.co.uk\/ontologies\/sport\/CompetitiveSportingOrganisation","type":"uri"}],"http:\/\/www.bbc.co.uk\/ontologies\/2012olympics\/urlName":[{"value":"great-britain","datatype":"xsd:string","type":"literal"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/name":[{"value":"Team GB","datatype":"xsd:string","type":"literal"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/canonicalName":[{"value":"OlympicTeam-Team GB","datatype":"xsd:string","type":"literal"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/document":[{"value":"http:\/\/www.bbc.co.uk\/sport\/olympics\/2012\/countries\/great-britain","type":"uri"},{"value":"http:\/\/www.olympics.org.uk","type":"uri"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/shortName":[{"value":"Great Britain & N. Ireland","datatype":"xsd:string","type":"literal"}],"http:\/\/www.bbc.co.uk\/ontologies\/2012olympics\/territory":[{"value":"http:\/\/www.bbc.co.uk\/things\/territories\/gb#id","type":"uri"}]},"http:\/\/www.bbc.co.uk\/sport\/olympics\/2012\/countries\/great-britain":{"http:\/\/www.bbc.co.uk\/ontologies\/domain\/documentType":[{"value":"http:\/\/www.bbc.co.uk\/things\/document-types\/bbc-document","type":"uri"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/domain":[{"value":"http:\/\/www.bbc.co.uk\/things\/domains\/olympics2012","type":"uri"}],"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#type":[{"value":"http:\/\/www.bbc.co.uk\/ontologies\/domain\/Document","type":"uri"}]},"http:\/\/www.bbc.co.uk\/things\/81b14df8-f9d2-4dff-a676-43a1a9a5c0a5#id":{"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#type":[{"value":"http:\/\/www.bbc.co.uk\/ontologies\/geopolitical\/Group","type":"uri"},{"value":"http:\/\/www.w3.org\/2000\/01\/rdf-schema#Resource","type":"uri"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/name":[{"value":"Europe","datatype":"xsd:string","type":"literal"}]},"http:\/\/www.bbc.co.uk\/things\/territories\/gb#id":{"http:\/\/www.bbc.co.uk\/ontologies\/geopolitical\/isInGroup":[{"value":"http:\/\/www.bbc.co.uk\/things\/81b14df8-f9d2-4dff-a676-43a1a9a5c0a5#id","type":"uri"}],"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#type":[{"value":"http:\/\/www.bbc.co.uk\/ontologies\/geopolitical\/Territory","type":"uri"}]},"http:\/\/www.olympics.org.uk":{"http:\/\/www.bbc.co.uk\/ontologies\/domain\/documentType":[{"value":"http:\/\/www.bbc.co.uk\/things\/document-types\/external","type":"uri"}],"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#type":[{"value":"http:\/\/www.bbc.co.uk\/ontologies\/domain\/Document","type":"uri"},{"value":"http:\/\/www.w3.org\/2002\/07\/owl#Thing","type":"uri"},{"value":"http:\/\/www.w3.org\/2000\/01\/rdf-schema#Resource","type":"uri"}],"http:\/\/www.bbc.co.uk\/ontologies\/domain\/name":[{"value":"British Olympic Association","datatype":"xsd:string","type":"literal"}],"http:\/\/www.w3.org\/2000\/01\/rdf-schema#label":[{"value":"British Olympic Association","datatype":"xsd:string","type":"literal"}],"http:\/\/xmlns.com\/foaf\/0.1\/name":[{"value":"British Olympic Association","datatype":"xsd:string","type":"literal"}]}}
@@ -0,0 +1,165 @@
1
+ {
2
+ "groups": {
3
+ "competitionId": "118996114",
4
+ "structureId": "1",
5
+ "group": {
6
+ "competitions": {
7
+ "item": [
8
+ {
9
+ "isMultiTable": "false",
10
+ "hasTable": "true",
11
+ "competition": {
12
+ "bbcId": "118996114",
13
+ "url": "http://www.bbc.co.uk/sport/football/premier-league",
14
+ "matchType": "200",
15
+ "id": "100",
16
+ "name": {
17
+ "abbrTextLong": "Premier League",
18
+ "abbrTextShort": "Premier League",
19
+ "abbrTextCode": "PREM",
20
+ "abbrTextMedium": "Barclays Premier League"
21
+ }
22
+ }
23
+ },
24
+ {
25
+ "competition": {
26
+ "bbcId": "118998036",
27
+ "url": "http://www.bbc.co.uk/sport/football/fa-cup",
28
+ "matchType": "201",
29
+ "id": "300",
30
+ "name": {
31
+ "abbrTextLong": "FA Cup",
32
+ "abbrTextShort": "FA Cup",
33
+ "abbrTextCode": "FAC",
34
+ "abbrTextMedium": "The FA Cup"
35
+ }
36
+ }
37
+ },
38
+ {
39
+ "competition": {
40
+ "bbcId": "118998037",
41
+ "url": "http://www.bbc.co.uk/sport/football/league-cup",
42
+ "id": "301",
43
+ "name": {
44
+ "abbrTextLong": "Carling Cup",
45
+ "abbrTextShort": "League Cup",
46
+ "abbrTextCode": "CAC",
47
+ "abbrTextMedium": "Carling Cup"
48
+ }
49
+ }
50
+ },
51
+ {
52
+ "isMultiTable": "false",
53
+ "hasTable": "true",
54
+ "competition": {
55
+ "bbcId": "118996115",
56
+ "matchType": "200",
57
+ "id": "101",
58
+ "name": {
59
+ "abbrTextLong": "Npower Championship",
60
+ "abbrTextShort": "Championship",
61
+ "abbrTextCode": "Chsp",
62
+ "abbrTextMedium": "Npower Championship"
63
+ }
64
+ }
65
+ },
66
+ {
67
+ "isMultiTable": "false",
68
+ "hasTable": "true",
69
+ "competition": {
70
+ "bbcId": "118996116",
71
+ "url": "http://www.bbc.co.uk/sport/football/league-one",
72
+ "matchType": "200",
73
+ "id": "102",
74
+ "name": {
75
+ "abbrTextLong": "League One",
76
+ "abbrTextShort": "League One",
77
+ "abbrTextCode": "Lge1",
78
+ "abbrTextMedium": "Npower League One"
79
+ }
80
+ }
81
+ },
82
+ {
83
+ "isMultiTable": "false",
84
+ "hasTable": "true",
85
+ "competition": {
86
+ "bbcId": "118996117",
87
+ "url": "http://www.bbc.co.uk/sport/football/league-two",
88
+ "matchType": "200",
89
+ "id": "103",
90
+ "name": {
91
+ "abbrTextLong": "League Two",
92
+ "abbrTextShort": "League Two",
93
+ "abbrTextCode": "Lge2",
94
+ "abbrTextMedium": "Npower League Two"
95
+ }
96
+ }
97
+ },
98
+ {
99
+ "competition": {
100
+ "bbcId": "118998038",
101
+ "id": "302",
102
+ "name": {
103
+ "abbrTextLong": "Johnstone's Paint Trophy ",
104
+ "abbrTextShort": "JP Trophy",
105
+ "abbrTextCode": "JPT",
106
+ "abbrTextMedium": "JP Trophy"
107
+ }
108
+ }
109
+ },
110
+ {
111
+ "isMultiTable": "false",
112
+ "hasTable": "true",
113
+ "competition": {
114
+ "bbcId": "118996118",
115
+ "url": "http://www.bbc.co.uk/sport/football/conference",
116
+ "matchType": "200",
117
+ "id": "104",
118
+ "name": {
119
+ "abbrTextLong": "Blue Square Bet Premier",
120
+ "abbrTextShort": "Conference",
121
+ "abbrTextCode": "BSBP",
122
+ "abbrTextMedium": "Blue Square Bet Premier"
123
+ }
124
+ }
125
+ },
126
+ {
127
+ "isMultiTable": "false",
128
+ "hasTable": "true",
129
+ "competition": {
130
+ "bbcId": "118996307",
131
+ "id": "167",
132
+ "name": {
133
+ "abbrTextLong": "Blue Square Bet North",
134
+ "abbrTextShort": "Blue Square ",
135
+ "abbrTextCode": "BSBN",
136
+ "abbrTextMedium": "Blue Square Bet North"
137
+ }
138
+ }
139
+ },
140
+ {
141
+ "isMultiTable": "false",
142
+ "hasTable": "true",
143
+ "competition": {
144
+ "bbcId": "118996308",
145
+ "id": "168",
146
+ "name": {
147
+ "abbrTextLong": "Blue Square Bet South",
148
+ "abbrTextShort": "Blue Square ",
149
+ "abbrTextCode": "BSBS",
150
+ "abbrTextMedium": "Blue Square Bet South"
151
+ }
152
+ }
153
+ }
154
+ ]
155
+ },
156
+ "id": "1",
157
+ "name": {
158
+ "abbrTextLong": "English",
159
+ "abbrTextShort": "English",
160
+ "abbrTextCode": "en",
161
+ "abbrTextMedium": "English"
162
+ }
163
+ }
164
+ }
165
+ }
@@ -0,0 +1 @@
1
+ {"groups":{"structureId":"1","group":{"id":"1","competitions":{"item":[{"hasTable":"true","competition":{"id":"100","name":{"abbrTextLong":"Premier League","abbrTextMedium":"Barclays Premier League","abbrTextShort":"Premier League","abbrTextCode":"PREM"},"matchType":"200","bbcId":"118996114","url":"http://www.bbc.co.uk/sport/football/premier-league"},"isMultiTable":"false"},{"competition":{"id":"300","name":{"abbrTextLong":"FA Cup","abbrTextMedium":"The FA Cup","abbrTextShort":"FA Cup","abbrTextCode":"FAC"},"matchType":"201","bbcId":"118998036","url":"http://www.bbc.co.uk/sport/football/fa-cup"}},{"competition":{"id":"301","name":{"abbrTextLong":"Carling Cup","abbrTextMedium":"Carling Cup","abbrTextShort":"League Cup","abbrTextCode":"CAC"},"bbcId":"118998037","url":"http://www.bbc.co.uk/sport/football/league-cup"}},{"hasTable":"true","competition":{"id":"101","name":{"abbrTextLong":"Npower Championship","abbrTextMedium":"Npower Championship","abbrTextShort":"Championship","abbrTextCode":"Chsp"},"matchType":"200","bbcId":"118996115"},"isMultiTable":"false"},{"hasTable":"true","competition":{"id":"102","name":{"abbrTextLong":"League One","abbrTextMedium":"Npower League One","abbrTextShort":"League One","abbrTextCode":"Lge1"},"matchType":"200","bbcId":"118996116","url":"http://www.bbc.co.uk/sport/football/league-one"},"isMultiTable":"false"},{"hasTable":"true","competition":{"id":"103","name":{"abbrTextLong":"League Two","abbrTextMedium":"Npower League Two","abbrTextShort":"League Two","abbrTextCode":"Lge2"},"matchType":"200","bbcId":"118996117","url":"http://www.bbc.co.uk/sport/football/league-two"},"isMultiTable":"false"},{"competition":{"id":"302","name":{"abbrTextLong":"Johnstone's Paint Trophy ","abbrTextMedium":"JP Trophy","abbrTextShort":"JP Trophy","abbrTextCode":"JPT"},"bbcId":"118998038"}},{"hasTable":"true","competition":{"id":"104","name":{"abbrTextLong":"Blue Square Bet Premier","abbrTextMedium":"Blue Square Bet Premier","abbrTextShort":"Conference","abbrTextCode":"BSBP"},"matchType":"200","bbcId":"118996118","url":"http://www.bbc.co.uk/sport/football/conference"},"isMultiTable":"false"},{"hasTable":"true","competition":{"id":"167","name":{"abbrTextLong":"Blue Square Bet North","abbrTextMedium":"Blue Square Bet North","abbrTextShort":"Blue Square ","abbrTextCode":"BSBN"},"bbcId":"118996307"},"isMultiTable":"false"},{"hasTable":"true","competition":{"id":"168","name":{"abbrTextLong":"Blue Square Bet South","abbrTextMedium":"Blue Square Bet South","abbrTextShort":"Blue Square ","abbrTextCode":"BSBS"},"bbcId":"118996308"},"isMultiTable":"false"}]},"name":{"abbrTextLong":"English","abbrTextMedium":"English","abbrTextShort":"English","abbrTextCode":"en"}},"competitionId":"118996114"}}
@@ -0,0 +1,107 @@
1
+ BBCDataService::AppFixture.register_fixture :single_instance, {
2
+ :endpoint => "/dsp/sport/olympics/2012/countries",
3
+ :type => :rdf,
4
+ :feed_url => File.expand_path("../country.rdf.json", __FILE__),
5
+ :rdf_type => "sport:CompetitiveSportingOrganisation",
6
+ :mappings => {
7
+ :domain => {
8
+ :cononical_name => "canonicalName",
9
+ :name => "name",
10
+ :short_name => "shortName",
11
+ :long_name => "longName"
12
+ },
13
+ :oly => {
14
+ :url => "urlName"
15
+ }
16
+ }
17
+ }
18
+ BBCDataService::AppFixture.register_fixture :parent_instance, {
19
+ :parent => :single_instance
20
+ }
21
+ BBCDataService::AppFixture.register_fixture :multiple_items, {
22
+ :endpoint => "/dsp/sport/olympics/2012/countries",
23
+ :type => :rdf,
24
+ :feed_url => File.expand_path("../countries.rdf.json", __FILE__),
25
+ :rdf_type => "sport:CompetitiveSportingOrganisation",
26
+ :mappings => {
27
+ :domain => {
28
+ :name => "name",
29
+ :long_name => "longName",
30
+ :canonical_name => "canonicalName",
31
+ :short_name => "shortName"
32
+ }
33
+ }
34
+ }
35
+ BBCDataService::AppFixture.register_fixture :json_groups, {
36
+ :endpoint => "/dsp/sport/olympics/2012/countries",
37
+ :type => :json,
38
+ :feed_url => File.expand_path("../groups.json", __FILE__),
39
+ :mappings => {
40
+ :domain => {
41
+ :name => "name",
42
+ :long_name => "longName",
43
+ :canonical_name => "canonicalName",
44
+ :short_name => "shortName"
45
+ }
46
+ }
47
+ }
48
+ BBCDataService::AppFixture.register_fixture :json_groups_individual, {
49
+ :endpoint => "/dsp/sport/olympics/2012/countries",
50
+ :type => :json,
51
+ :feed_url => File.expand_path("../groups-individual.json", __FILE__),
52
+ :mappings => {
53
+ :groups => {
54
+ :name => "name",
55
+ :long_name => "longName",
56
+ :canonical_name => "canonicalName",
57
+ :short_name => "shortName"
58
+ }
59
+ }
60
+ }
61
+ BBCDataService::AppFixture.register_fixture :relationships, {
62
+ :endpoint => "/dsp/sport/olympics/2012/athletes/4e40ce40-b632-4a42-98d7-cf97067f7bf9",
63
+ :type => :rdf,
64
+ :feed_url => File.expand_path("../athlete.json", __FILE__),
65
+ :rdf_type => "sport:Person",
66
+ :mappings => {
67
+ :foaf => {
68
+ :family_name => "familyName",
69
+ :given_name => "givenName"
70
+ },
71
+ :domain => {
72
+ :name => "name",
73
+ :canonical_name => "canonicalName",
74
+ :url => "document"
75
+ },
76
+ :oly => {
77
+ :date_of_birth => "dateOfBirth",
78
+ :height => "height",
79
+ :weight => "weight",
80
+ :gender => "gender"
81
+ },
82
+ :par => {
83
+ :role_at => "role_at"
84
+ }
85
+ },
86
+ # :relationships => {
87
+ # :team => {
88
+ # #:foreign_key => :role_at,
89
+ # :rdf_type => "sport:CompetitiveSportingOrganisation",
90
+ # :mappings => {
91
+ # :domain => {
92
+ # :name => "name",
93
+ # :short_name => "shortName"
94
+ # }
95
+ # }
96
+ # },
97
+ # :competes_in => {
98
+ # :rdf_type => "sport:MedalCompetition",
99
+ # :mappings => {
100
+ # :domain => {
101
+ # :name => "name",
102
+ # :short_name => "shortName"
103
+ # }
104
+ # }
105
+ # }
106
+ # }
107
+ }
@@ -0,0 +1,6 @@
1
+ dir = File.dirname(__FILE__)
2
+ $LOAD_PATH.unshift "#{dir}/../lib"
3
+
4
+ require 'rubygems'
5
+ require 'rspec'
6
+ require 'bbc_data_service'
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bbc_data_service
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.10
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matthew Crouch
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-26 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sinatra
16
+ requirement: &2160759200 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.2.6
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2160759200
25
+ - !ruby/object:Gem::Dependency
26
+ name: activemodel
27
+ requirement: &2160757540 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 3.1.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2160757540
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdf-json
38
+ requirement: &2160754780 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.3.0
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2160754780
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &2160748860 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.6.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2160748860
58
+ - !ruby/object:Gem::Dependency
59
+ name: turn
60
+ requirement: &2160747720 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 0.8.2
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2160747720
69
+ description: BBC Data Service for fixture management
70
+ email:
71
+ - matthew.crouch@bbc.co.uk
72
+ executables:
73
+ - bbc_data_service
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - Rakefile
80
+ - bbc_data_service.gemspec
81
+ - bin/bbc_data_service
82
+ - lib/.DS_Store
83
+ - lib/bbc_data_service.rb
84
+ - lib/bbc_data_service/app_fixture.rb
85
+ - lib/bbc_data_service/feed_fixture.rb
86
+ - lib/bbc_data_service/fixture_loader.rb
87
+ - lib/bbc_data_service/json_parser.rb
88
+ - lib/bbc_data_service/rdf_parser.rb
89
+ - lib/bbc_data_service/service_config.rb
90
+ - lib/bbc_data_service/version.rb
91
+ - lib/bbc_data_service/vocabulary.rb
92
+ - spec/fixture_loader_spec.rb
93
+ - spec/fixtures/countries.rdf.json
94
+ - spec/fixtures/country.rdf.json
95
+ - spec/fixtures/groups-individual.json
96
+ - spec/fixtures/groups.json
97
+ - spec/fixtures/test_config.rb
98
+ - spec/spec_helper.rb
99
+ homepage: https://github.com/mobzilla/bbc-data-service
100
+ licenses: []
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ segments:
112
+ - 0
113
+ hash: 2641502053244583530
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ segments:
121
+ - 0
122
+ hash: 2641502053244583530
123
+ requirements: []
124
+ rubyforge_project: bbc-data-service
125
+ rubygems_version: 1.8.6
126
+ signing_key:
127
+ specification_version: 3
128
+ summary: BBC Data Service
129
+ test_files:
130
+ - spec/fixture_loader_spec.rb
131
+ - spec/fixtures/countries.rdf.json
132
+ - spec/fixtures/country.rdf.json
133
+ - spec/fixtures/groups-individual.json
134
+ - spec/fixtures/groups.json
135
+ - spec/fixtures/test_config.rb
136
+ - spec/spec_helper.rb