bbc_data_service 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,11 @@
|
|
1
1
|
module BBCDataService
|
2
2
|
class FixtureLoader
|
3
|
-
def self.load_fixture(name)
|
3
|
+
def self.load_fixture(name, options = {})
|
4
4
|
require ServiceConfig[:fixture_config].to_s
|
5
5
|
app_fixture = AppFixture.fixtures[name]
|
6
6
|
app_fixture = self.merge_fixtures(app_fixture) if app_fixture[:parent]
|
7
7
|
if app_fixture
|
8
|
-
self.parse_data(app_fixture)
|
8
|
+
self.parse_data(app_fixture, options)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -16,10 +16,10 @@ module BBCDataService
|
|
16
16
|
parent_fixture.merge(app_fixture)
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.parse_data(app_fixture)
|
19
|
+
def self.parse_data(app_fixture, options)
|
20
20
|
case app_fixture[:type]
|
21
21
|
when :rdf
|
22
|
-
fixtures = BBCDataService::RDFParser.parse_feed(app_fixture)
|
22
|
+
fixtures = BBCDataService::RDFParser.parse_feed(app_fixture, options)
|
23
23
|
if fixtures.size == 1
|
24
24
|
return fixtures.first
|
25
25
|
else
|
@@ -6,7 +6,7 @@ module BBCDataService
|
|
6
6
|
|
7
7
|
include BBCDataService::Vocabulary
|
8
8
|
|
9
|
-
def self.parse_feed(registered_fixture)
|
9
|
+
def self.parse_feed(registered_fixture, options)
|
10
10
|
feed_url = registered_fixture[:feed_url]
|
11
11
|
mappings = registered_fixture[:mappings]
|
12
12
|
rdf_type = registered_fixture[:rdf_type]
|
@@ -16,7 +16,10 @@ module BBCDataService
|
|
16
16
|
})
|
17
17
|
results = []
|
18
18
|
fixtures = []
|
19
|
-
if
|
19
|
+
if options[:filter]
|
20
|
+
solutions = query.execute(graph)
|
21
|
+
fixtures = self.filter_graph(solutions, options[:filter])
|
22
|
+
elsif registered_fixture[:filter]
|
20
23
|
solutions = query.execute(graph)
|
21
24
|
fixtures = self.filter_graph(solutions, registered_fixture[:filter])
|
22
25
|
else
|
data/spec/fixture_loader_spec.rb
CHANGED
@@ -61,4 +61,14 @@ describe BBCDataService::FixtureLoader do
|
|
61
61
|
country.name.should == "Germany"
|
62
62
|
end
|
63
63
|
|
64
|
+
it "should allow filtering of data on the fly" do
|
65
|
+
object = BBCDataService::FixtureLoader.load_fixture(:multiple_items,
|
66
|
+
:filter => {
|
67
|
+
:column => :name,
|
68
|
+
:value => "Germany",
|
69
|
+
:type => :string
|
70
|
+
})
|
71
|
+
object.name.should == "Germany"
|
72
|
+
end
|
73
|
+
|
64
74
|
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bbc_data_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: "1.
|
8
|
+
- 1
|
9
|
+
version: "1.1"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Matthew Crouch
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-10-
|
17
|
+
date: 2011-10-20 00:00:00 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: sinatra
|