tripod 0.3.6 → 0.4.0

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/README.md CHANGED
@@ -29,21 +29,21 @@ ActiveModel-style Ruby ORM for RDF Linked Data. Works with SPARQL 1.1 HTTP endpo
29
29
  include Tripod::Resource
30
30
 
31
31
  # these are the default rdf-type and graph for resources of this class
32
- rdf_type 'http://person'
33
- graph_uri 'http://people'
34
-
35
- field :name, 'http://name'
36
- field :knows, 'http://knows', :multivalued => true
37
- field :aliases, 'http://alias', :multivalued => true
38
- field :age, 'http://age', :datatype => RDF::XSD.integer
39
- field :important_dates, 'http://importantdates', :datatype => RDF::XSD.date, :multivalued => true
32
+ rdf_type 'http://example.com/person'
33
+ graph_uri 'http://example.com/people'
34
+
35
+ field :name, 'http://example.com/name'
36
+ field :knows, 'http://example.com/knows', :multivalued => true
37
+ field :aliases, 'http://example.com/alias', :multivalued => true
38
+ field :age, 'http://example.com/age', :datatype => RDF::XSD.integer
39
+ field :important_dates, 'http://example.com/importantdates', :datatype => RDF::XSD.date, :multivalued => true
40
40
  end
41
41
 
42
42
  # Note: Active Model validations are supported
43
43
 
44
44
  4. Use it
45
45
 
46
- uri = 'http://ric'
46
+ uri = 'http://example.com/ric'
47
47
  p = Person.new(uri)
48
48
  p.name = 'Ric'
49
49
  p.age = 31
@@ -53,7 +53,7 @@ ActiveModel-style Ruby ORM for RDF Linked Data. Works with SPARQL 1.1 HTTP endpo
53
53
 
54
54
  people = Person.all.resources #=> returns all people as an array
55
55
 
56
- ric = Person.find('http://ric') #=> returns a single Person object.
56
+ ric = Person.find('http://example.com/ric') #=> returns a single Person object.
57
57
 
58
58
  ## Note:
59
59
 
@@ -64,16 +64,16 @@ Tripod doesn't supply a database. You need to install one. I recommend [Fuseki](
64
64
 
65
65
  ## Eager Loading
66
66
 
67
- asa = Person.find('http://asa')
68
- ric = Person.find('http://ric')
67
+ asa = Person.find('http://example.com/asa')
68
+ ric = Person.find('http://example.com/ric')
69
69
  ric.knows = asa.uri
70
70
 
71
71
  ric.eager_load_predicate_triples! #does a big DESCRIBE statement behind the scenes
72
- knows = ric.get_related_resource('http://knows', Resource)
72
+ knows = ric.get_related_resource('http://example.com/knows', Resource)
73
73
  knows.label # this won't cause another database lookup
74
74
 
75
75
  ric.eager_load_object_triples! #does a big DESCRIBE statement behind the scenes
76
- asa = ric.get_related_resource('http://asa', Person) # returns a fully hydrated Person object for asa, without an extra lookup
76
+ asa = ric.get_related_resource('http://example.com/asa', Person) # returns a fully hydrated Person object for asa, without an extra lookup
77
77
 
78
78
  ## Defining a graph at instantiation-time
79
79
 
@@ -84,7 +84,7 @@ Tripod doesn't supply a database. You need to install one. I recommend [Fuseki](
84
84
  # notice also that you don't need to supply an rdf type or graph here!
85
85
  end
86
86
 
87
- r = Resource.new('http://foo', 'http://mygraph')
87
+ r = Resource.new('http://example.com/foo', 'http://example.com/mygraph')
88
88
  r.label = "example"
89
89
  r.save
90
90
 
@@ -94,8 +94,8 @@ Tripod doesn't supply a database. You need to install one. I recommend [Fuseki](
94
94
 
95
95
  ## Reading and writing arbitrary predicates
96
96
 
97
- r.write_predicate(RDF.type, 'http://myresource/type')
98
- r.read_predicate(RDF.type) #=> [RDF::URI.new("http://myresource/type")]
97
+ r.write_predicate(RDF.type, 'http://example.com/myresource/type')
98
+ r.read_predicate(RDF.type) #=> [RDF::URI.new("http://example.com/myresource/type")]
99
99
 
100
100
  ## Finders and criteria
101
101
 
@@ -103,7 +103,7 @@ Tripod doesn't supply a database. You need to install one. I recommend [Fuseki](
103
103
  # It doesn't actually do anything against the DB until you run resources, first, or count on it.
104
104
  # (from Tripod::CriteriaExecution)
105
105
 
106
- Person.all #=> returns a Tripod::Criteria object which selects all resources of rdf_type http://person, in the http://people graph
106
+ Person.all #=> returns a Tripod::Criteria object which selects all resources of rdf_type http://example.com/person, in the http://example.com/people graph
107
107
 
108
108
  Resource.all #=> returns a criteria object to return resources in the database (as no rdf_type or graph_uri specified at class level)
109
109
 
@@ -114,17 +114,17 @@ Tripod doesn't supply a database. You need to install one. I recommend [Fuseki](
114
114
  Person.count #=> returns the count of all people (by crafting a count query under the covers that only returns a count)
115
115
 
116
116
  # note that you need to use ?uri as the variable for the subject.
117
- Person.where("?uri <http://name> 'Joe'") #=> returns a Tripod::Criteria object
117
+ Person.where("?uri <http://example.com/name> 'Joe'") #=> returns a Tripod::Criteria object
118
118
 
119
- Resource.graph("http://mygraph") #=> Retruns a criteria object with a graph restriction (note: if graph_uri set on the class, it will default to using this)
119
+ Resource.graph("http://example.com/mygraph") #=> Retruns a criteria object with a graph restriction (note: if graph_uri set on the class, it will default to using this)
120
120
 
121
121
  Resource.find_by_sparql('SELECT ?uri ?graph WHERE { GRAPH ?graph { ?uri ?p ?o } }') #=> allows arbitrary sparql. Again, use ?uri for the variable of the subjects (and ?graph for the graph).
122
122
 
123
123
  ## Chainable criteria
124
124
 
125
- Person.all.where("?uri <http://name> 'Ric'").where("?uri <http://knows> <http://asa>).first
125
+ Person.all.where("?uri <http://example.com/name> 'Ric'").where("?uri <http://example.com/knows> <http://example.com/asa>).first
126
126
 
127
- Person.where("?uri <http://name> ?name").limit(1).offset(0).order("DESC(?name)")
127
+ Person.where("?uri <http://example.com/name> ?name").limit(1).offset(0).order("DESC(?name)")
128
128
 
129
129
 
130
130
  [Full Documentation](http://rubydoc.info/gems/tripod/frames)
@@ -95,7 +95,7 @@ module Tripod::Finders
95
95
  uris_sparql_str = uris.map{ |u| "<#{u.to_s}>" }.join(" ")
96
96
 
97
97
  # Do a big describe statement, and read the results into an in-memory repo
98
- triples_string = Tripod::SparqlClient::Query.describe("DESCRIBE #{uris_sparql_str}")
98
+ triples_string = Tripod::SparqlClient::Query.query("DESCRIBE #{uris_sparql_str}", "application/n-triples")
99
99
 
100
100
  RDF::Reader.for(:ntriples).new(triples_string) do |reader|
101
101
  reader.each_statement do |statement|
@@ -14,7 +14,7 @@ module Tripod::Persistence
14
14
  attr_accessor :query
15
15
 
16
16
  def commit
17
- Tripod::SparqlClient::Update::update(self.query)
17
+ Tripod::SparqlClient::Update.update(self.query)
18
18
  clear_transaction
19
19
  end
20
20
 
@@ -34,8 +34,7 @@ module Tripod::Repository
34
34
  end
35
35
  end
36
36
  else
37
-
38
- triples = Tripod::SparqlClient::Query::describe("DESCRIBE <#{uri}>")
37
+ triples = Tripod::SparqlClient::Query.query("DESCRIBE <#{uri}>", "application/n-triples")
39
38
  @repository = RDF::Repository.new
40
39
  RDF::Reader.for(:ntriples).new(triples) do |reader|
41
40
  reader.each_statement do |statement|
@@ -10,20 +10,25 @@ module Tripod::SparqlClient
10
10
  # @example Run a query
11
11
  # Tripod::SparqlClient::Query.query('SELECT * WHERE {?s ?p ?o}')
12
12
  #
13
+ # @param [ String ] sparql The sparql query.
14
+ # @param [ String ] accept_header The accept header to send with the request
15
+ # @param [ Hash ] any extra params to send with the request
13
16
  # @return [ RestClient::Response ]
14
- def self.query(sparql, format='json', headers = {})
17
+ def self.query(sparql, accept_header, extra_params={})
15
18
 
16
19
  begin
17
- params = { :params => {:query => sparql, :output => format } }
18
- hdrs = headers.merge(params)
20
+ params = {:query => sparql}.merge(extra_params)
21
+ hdrs = {:accept => accept_header, :params => params}
19
22
 
20
- make_the_call =
21
- -> { RestClient::Request.execute(
23
+ make_the_call = -> {
24
+ response = RestClient::Request.execute(
22
25
  :method => :get,
23
26
  :url => Tripod.query_endpoint,
24
27
  :headers => hdrs,
25
28
  :timeout => Tripod.timeout_seconds
26
- ) }
29
+ )
30
+ response.body
31
+ }
27
32
 
28
33
  if Tripod.cache_store # if a cache store is configured
29
34
  # SHA-2 the key to keep the it within the small limit for many cache stores (e.g. Memcached is 250bytes)
@@ -40,69 +45,19 @@ module Tripod::SparqlClient
40
45
  end
41
46
  end
42
47
 
43
- # Runs a SELECT +query+ against the endpoint. Returns a hash of the results.
44
- # Specify +raw_format+ if you want the results raw, as returned from the SPARQL endpoint.
48
+ # Runs a SELECT +query+ against the endpoint. Returns a Hash of the results.
45
49
  #
46
50
  # @param [ String ] query The query to run
47
- # @param [ String ] raw_format valid formats are: 'json', 'text', 'csv', 'xml'
48
51
  #
49
52
  # @example Run a SELECT query
50
53
  #  Tripod::SparqlClient::Query.select('SELECT * WHERE {?s ?p ?o}')
51
54
  #
52
55
  # @return [ Hash, String ]
53
- def self.select(query, raw_format=nil)
54
- query_response = self.query(query, (raw_format || 'json'))
55
- if raw_format
56
- query_response.body
57
- else
58
- JSON.parse(query_response.body)["results"]["bindings"]
59
- end
60
- end
61
-
62
- # Executes a DESCRIBE +query+ against the SPARQL endpoint.
63
- # Executes the +query+ and returns ntriples by default
64
- #
65
- # @example Run a DESCRIBE query
66
- # Tripod::SparqlClient::Query.select('DESCRIBE <http://foo>')
67
- #
68
- # @param [ String ] query The query to run
69
- # @param [ String ] accept_header The header to pass to the database.
70
-
71
- # @return [ String ] the raw response from the endpoint
72
- def self.describe(query, accept_header='application/n-triples')
73
- response = self.query(query, nil, {:accept=>accept_header})
74
- return response.body
75
- end
76
-
77
- # Executes an ASK +query+ against the SPARQL endpoint.
78
- # Executes the +query+ and returns text by default
79
- #
80
- # @example Run a ASK query
81
- # Tripod::SparqlClient::Query.select('ASK <http://foo>')
82
- #
83
- # @param [ String ] query The query to run
84
- # @param [ String ] accept_header The format parameter to send to the database. Valud valid formats are text, xml, json
85
-
86
- # @return [ String ] the raw response from the endpoint
87
- def self.ask(query, format='text')
88
- response = self.query(query, format)
89
- return response.body
56
+ def self.select(query)
57
+ query_response = self.query(query, "application/sparql-results+json")
58
+ JSON.parse(query_response)["results"]["bindings"]
90
59
  end
91
60
 
92
- # Executes a CONSTRUCT +query+ against the SPARQL endpoint.
93
- # Executes the +query+ and returns ntriples by default
94
- #
95
- # @example Run a CONSTRUCT query
96
- # Tripod::SparqlClient::Query.select('CONSTRUCT <http://foo>')
97
- #
98
- # @param [ String ] query The query to run
99
- # @param [ String ] accept_header The header to pass to the database.
100
-
101
- # @return [ String ] the raw response from the endpoint
102
- def self.construct(query, accept_header='application/n-triples')
103
- response = self.query(query, nil, {:accept=>accept_header})
104
- return response.body
105
- end
106
61
  end
107
62
 
108
63
  module Update
@@ -1,3 +1,3 @@
1
1
  module Tripod
2
- VERSION = "0.3.6"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -2,14 +2,14 @@ class Person
2
2
 
3
3
  include Tripod::Resource
4
4
 
5
- rdf_type 'http://person'
6
- graph_uri 'http://graph'
7
-
8
- field :name, 'http://name'
9
- field :father, 'http://father'
10
- field :knows, 'http://knows', :multivalued => true
11
- field :aliases, 'http://alias', :multivalued => true
12
- field :age, 'http://age', :datatype => RDF::XSD.integer
13
- field :important_dates, 'http://importantdates', :datatype => RDF::XSD.date, :multivalued => true
5
+ rdf_type 'http://example.com/person'
6
+ graph_uri 'http://example.com/graph'
7
+
8
+ field :name, 'http://example.com/name'
9
+ field :father, 'http://example.com/father'
10
+ field :knows, 'http://example.com/knows', :multivalued => true
11
+ field :aliases, 'http://exmample.com/alias', :multivalued => true
12
+ field :age, 'http://example.com/age', :datatype => RDF::XSD.integer
13
+ field :important_dates, 'http://example.com/importantdates', :datatype => RDF::XSD.date, :multivalued => true
14
14
 
15
15
  end
@@ -4,13 +4,13 @@ describe Tripod::Attributes do
4
4
  describe ".read_attribute" do
5
5
 
6
6
  let!(:other_person) do
7
- p = Person.new('http://garry')
7
+ p = Person.new('http://example.com/id/garry')
8
8
  p.save!
9
9
  p
10
10
  end
11
11
 
12
12
  let(:person) do
13
- p = Person.new('http://barry')
13
+ p = Person.new('http://example.com/id/barry')
14
14
  p.name = 'Barry'
15
15
  p.father = other_person.uri
16
16
  p
@@ -49,13 +49,13 @@ describe Tripod::Attributes do
49
49
  end
50
50
 
51
51
  context "where field is given and single-valued" do
52
- let(:field) { Person.send(:field_for, :hat_type, 'http://hat', {}) }
52
+ let(:field) { Person.send(:field_for, :hat_type, 'http://example.com/hat', {}) }
53
53
  before do
54
- person.stub(:read_predicate).with('http://hat').and_return(['fez'])
54
+ person.stub(:read_predicate).with('http://example.com/hat').and_return(['fez'])
55
55
  end
56
56
 
57
57
  it "should use the predicate name from the given field" do
58
- person.should_receive(:read_predicate).with('http://hat').and_return(['fez'])
58
+ person.should_receive(:read_predicate).with('http://example.com/hat').and_return(['fez'])
59
59
  person.read_attribute(:hat_type, field)
60
60
  end
61
61
 
@@ -65,9 +65,9 @@ describe Tripod::Attributes do
65
65
  end
66
66
 
67
67
  context "where field is given and is multi-valued" do
68
- let(:field) { Person.send(:field_for, :hat_types, 'http://hat', {multivalued: true}) }
68
+ let(:field) { Person.send(:field_for, :hat_types, 'http://example.com/hat', {multivalued: true}) }
69
69
  before do
70
- person.stub(:read_predicate).with('http://hat').and_return(['fez', 'bowler'])
70
+ person.stub(:read_predicate).with('http://example.com/hat').and_return(['fez', 'bowler'])
71
71
  end
72
72
 
73
73
  it "should return an array of values" do
@@ -83,7 +83,7 @@ describe Tripod::Attributes do
83
83
  end
84
84
 
85
85
  describe ".write_attribute" do
86
- let(:person) { Person.new('http://barry') }
86
+ let(:person) { Person.new('http://example.com/id/barry') }
87
87
 
88
88
  it "should write the given attribute" do
89
89
  person[:name] = 'Barry'
@@ -92,40 +92,40 @@ describe Tripod::Attributes do
92
92
 
93
93
  it "should co-erce the value given to the correct datatype" do
94
94
  person[:age] = 34
95
- person.read_predicate('http://age').first.datatype.should == RDF::XSD.integer
95
+ person.read_predicate('http://example.com/age').first.datatype.should == RDF::XSD.integer
96
96
  end
97
97
 
98
98
  context "where the attribute is multi-valued" do
99
99
  it "should co-erce all the values to the correct datatype" do
100
100
  person[:important_dates] = [Date.today]
101
- person.read_predicate('http://importantdates').first.datatype.should == RDF::XSD.date
101
+ person.read_predicate('http://example.com/importantdates').first.datatype.should == RDF::XSD.date
102
102
  end
103
103
  end
104
104
 
105
105
  context "where field is given" do
106
- let(:field) { Person.send(:field_for, :hat_type, 'http://hat', {}) }
106
+ let(:field) { Person.send(:field_for, :hat_type, 'http://example.com/hat', {}) }
107
107
 
108
108
  it "should derive the predicate name from the given field" do
109
- person.write_attribute(:hat_type, 'http://bowlerhat', field)
110
- person.read_predicate('http://hat').first.to_s.should == 'http://bowlerhat'
109
+ person.write_attribute(:hat_type, 'http://example.com/bowlerhat', field)
110
+ person.read_predicate('http://example.com/hat').first.to_s.should == 'http://example.com/bowlerhat'
111
111
  end
112
112
  end
113
113
 
114
114
  context "where a field of a particular datatype is given" do
115
- let(:field) { Person.send(:field_for, :hat_size, 'http://hatsize', {datatype: RDF::XSD.integer}) }
115
+ let(:field) { Person.send(:field_for, :hat_size, 'http://example.com/hatsize', {datatype: RDF::XSD.integer}) }
116
116
 
117
117
  it "should derive the datatype from the given field" do
118
118
  person.write_attribute(:hat_size, 10, field)
119
- person.read_predicate('http://hatsize').first.datatype.should == RDF::XSD.integer
119
+ person.read_predicate('http://example.com/hatsize').first.datatype.should == RDF::XSD.integer
120
120
  end
121
121
  end
122
122
 
123
123
  context "where a multi-valued field of a given datatype is given" do
124
- let(:field) { Person.send(:field_for, :hat_heights, 'http://hatheight', {datatype: RDF::XSD.integer, multivalued: true}) }
124
+ let(:field) { Person.send(:field_for, :hat_heights, 'http://example.com/hatheight', {datatype: RDF::XSD.integer, multivalued: true}) }
125
125
 
126
126
  it "should co-erce the values passed" do
127
127
  person.write_attribute(:hat_heights, [5, 10, 15], field)
128
- person.read_predicate('http://hatheight').first.datatype.should == RDF::XSD.integer
128
+ person.read_predicate('http://example.com/hatheight').first.datatype.should == RDF::XSD.integer
129
129
  end
130
130
  end
131
131
 
@@ -11,14 +11,14 @@ describe Tripod::Criteria do
11
11
  end
12
12
 
13
13
  let!(:john) do
14
- p = Person.new('http://john')
14
+ p = Person.new('http://example.com/id/john')
15
15
  p.name = "John"
16
16
  p.save!
17
17
  p
18
18
  end
19
19
 
20
20
  let!(:barry) do
21
- p = Person.new('http://barry')
21
+ p = Person.new('http://example.com/id/barry')
22
22
  p.name = "Barry"
23
23
  p.save!
24
24
  p
@@ -28,22 +28,22 @@ describe Tripod::Criteria do
28
28
 
29
29
  context "for a class with an rdf_type and graph" do
30
30
  it "should return a SELECT query based with an rdf type restriction" do
31
- person_criteria.send(:build_select_query).should == "SELECT DISTINCT ?uri (<http://graph> as ?graph) WHERE { GRAPH <http://graph> { ?uri a <http://person> . ?uri ?p ?o } }"
31
+ person_criteria.send(:build_select_query).should == "SELECT DISTINCT ?uri (<http://example.com/graph> as ?graph) WHERE { GRAPH <http://example.com/graph> { ?uri a <http://example.com/person> . ?uri ?p ?o } }"
32
32
  end
33
33
 
34
34
  context "and extra restrictions" do
35
35
  before { person_criteria.where("[pattern]") }
36
36
 
37
37
  it "should return a SELECT query with the extra restriction" do
38
- person_criteria.send(:build_select_query).should == "SELECT DISTINCT ?uri (<http://graph> as ?graph) WHERE { GRAPH <http://graph> { ?uri a <http://person> . ?uri ?p ?o . [pattern] } }"
38
+ person_criteria.send(:build_select_query).should == "SELECT DISTINCT ?uri (<http://example.com/graph> as ?graph) WHERE { GRAPH <http://example.com/graph> { ?uri a <http://example.com/person> . ?uri ?p ?o . [pattern] } }"
39
39
  end
40
40
  end
41
41
 
42
42
  context "with an overriden graph" do
43
- before { person_criteria.graph("http://anothergraph") }
43
+ before { person_criteria.graph("http://example.com/anothergraph") }
44
44
 
45
45
  it "should override the graph in the query" do
46
- person_criteria.send(:build_select_query).should == "SELECT DISTINCT ?uri (<http://anothergraph> as ?graph) WHERE { GRAPH <http://anothergraph> { ?uri a <http://person> . ?uri ?p ?o } }"
46
+ person_criteria.send(:build_select_query).should == "SELECT DISTINCT ?uri (<http://example.com/anothergraph> as ?graph) WHERE { GRAPH <http://example.com/anothergraph> { ?uri a <http://example.com/person> . ?uri ?p ?o } }"
47
47
  end
48
48
  end
49
49
  end
@@ -62,10 +62,10 @@ describe Tripod::Criteria do
62
62
  end
63
63
 
64
64
  context "with a graph set" do
65
- before { resource_criteria.graph("http://graphy") }
65
+ before { resource_criteria.graph("http://example.com/graphy") }
66
66
 
67
67
  it "should override the graph in the query" do
68
- resource_criteria.send(:build_select_query).should == "SELECT DISTINCT ?uri (<http://graphy> as ?graph) WHERE { GRAPH <http://graphy> { ?uri ?p ?o } }"
68
+ resource_criteria.send(:build_select_query).should == "SELECT DISTINCT ?uri (<http://example.com/graphy> as ?graph) WHERE { GRAPH <http://example.com/graphy> { ?uri ?p ?o } }"
69
69
  end
70
70
  end
71
71
  end
@@ -92,7 +92,7 @@ describe Tripod::Criteria do
92
92
 
93
93
  context "with extra restrictions" do
94
94
 
95
- before { person_criteria.where("?uri <http://name> 'John'") }
95
+ before { person_criteria.where("?uri <http://example.com/name> 'John'") }
96
96
 
97
97
  it "should return a set of hydrated objects for the type and restrictions" do
98
98
  person_criteria.resources.to_a.should == [john]
@@ -118,7 +118,7 @@ describe Tripod::Criteria do
118
118
 
119
119
  it "should return a set of hydrated objects for the criteria" do
120
120
  person_criteria.count.should == 2
121
- person_criteria.where("?uri <http://name> 'John'").count.should ==1
121
+ person_criteria.where("?uri <http://example.com/name> 'John'").count.should ==1
122
122
  end
123
123
 
124
124
  it "should call Query.select with the 'count sparql'" do
@@ -128,7 +128,7 @@ describe Tripod::Criteria do
128
128
  end
129
129
 
130
130
  it "should execute the right Sparql" do
131
- sparql = "SELECT COUNT(*) { SELECT DISTINCT ?uri (<http://graph> as ?graph) WHERE { GRAPH <http://graph> { ?uri a <http://person> . ?uri ?p ?o } } LIMIT 10 OFFSET 20 }"
131
+ sparql = "SELECT COUNT(*) { SELECT DISTINCT ?uri (<http://example.com/graph> as ?graph) WHERE { GRAPH <http://example.com/graph> { ?uri a <http://example.com/person> . ?uri ?p ?o } } LIMIT 10 OFFSET 20 }"
132
132
  Tripod::SparqlClient::Query.should_receive(:select).with(sparql).and_call_original
133
133
  Person.all.limit(10).offset(20).count
134
134
  end
@@ -137,10 +137,10 @@ describe Tripod::Criteria do
137
137
 
138
138
  describe "exeuting a chained criteria" do
139
139
 
140
- let(:chained_criteria) { Person.where("?uri <http://name> ?name").limit(1).offset(0).order("DESC(?name)") }
140
+ let(:chained_criteria) { Person.where("?uri <http://example.com/name> ?name").limit(1).offset(0).order("DESC(?name)") }
141
141
 
142
142
  it "should run the right Sparql" do
143
- sparql = "SELECT DISTINCT ?uri (<http://graph> as ?graph) WHERE { GRAPH <http://graph> { ?uri a <http://person> . ?uri <http://name> ?name } } ORDER BY DESC(?name) LIMIT 1 OFFSET 0"
143
+ sparql = "SELECT DISTINCT ?uri (<http://example.com/graph> as ?graph) WHERE { GRAPH <http://example.com/graph> { ?uri a <http://example.com/person> . ?uri <http://example.com/name> ?name } } ORDER BY DESC(?name) LIMIT 1 OFFSET 0"
144
144
  Tripod::SparqlClient::Query.should_receive(:select).with(sparql).and_call_original
145
145
  chained_criteria.resources
146
146
  end
@@ -18,7 +18,7 @@ describe Tripod::Criteria do
18
18
 
19
19
  context "with rdf_type set on the class" do
20
20
  it "should initialize the where clauses to include a type restriction" do
21
- person_criteria.where_clauses.should == ["?uri a <http://person>", "?uri ?p ?o"]
21
+ person_criteria.where_clauses.should == ["?uri a <http://example.com/person>", "?uri ?p ?o"]
22
22
  end
23
23
  end
24
24
 
@@ -109,8 +109,8 @@ describe Tripod::Criteria do
109
109
 
110
110
  describe "#graph" do
111
111
  it "sets the graph_uri for this criteria, as a string" do
112
- resource_criteria.graph(RDF::URI("http://foobar"))
113
- resource_criteria.graph_uri.should == "http://foobar"
112
+ resource_criteria.graph(RDF::URI("http://example.com/foobar"))
113
+ resource_criteria.graph_uri.should == "http://example.com/foobar"
114
114
  end
115
115
  end
116
116
 
@@ -4,15 +4,15 @@ describe Tripod::EagerLoading do
4
4
 
5
5
  before do
6
6
 
7
- @name = Resource.new('http://name', 'http://names')
7
+ @name = Resource.new('http://example.com/name', 'http://example.com/names')
8
8
  @name.label = "Name"
9
9
  @name.save!
10
10
 
11
- @peter = Person.new('http://peter')
11
+ @peter = Person.new('http://example.com/peter')
12
12
  @peter.name = "Peter"
13
13
  @peter.save!
14
14
 
15
- @john = Person.new('http://john')
15
+ @john = Person.new('http://example.com/john')
16
16
  @john.name = "john"
17
17
  @john.knows = @peter.uri
18
18
  @john.save!
@@ -25,7 +25,7 @@ describe Tripod::EagerLoading do
25
25
  end
26
26
 
27
27
  it "should add triples to the repository for the predicates" do
28
- triples = @peter.repository.query([ RDF::URI.new('http://name'), :predicate, :object] )
28
+ triples = @peter.repository.query([ RDF::URI.new('http://example.com/name'), :predicate, :object] )
29
29
  triples.to_a.length.should_not == 0
30
30
  triples.first.predicate.should == RDF::RDFS.label
31
31
  triples.first.object.to_s.should == "Name"
@@ -43,11 +43,11 @@ describe Tripod::EagerLoading do
43
43
  triples = @john.repository.query([ @peter.uri, :predicate, :object] )
44
44
  triples.to_a.length.should_not == 0
45
45
 
46
- triples.first.predicate.should == RDF.type
47
- triples.first.object.to_s.should == RDF::URI('http://person')
46
+ triples.to_a[1].predicate.should == RDF.type
47
+ triples.to_a[1].object.to_s.should == RDF::URI('http://example.com/person')
48
48
 
49
- triples.to_a[1].predicate.should == RDF::URI('http://name')
50
- triples.to_a[1].object.to_s.should == "Peter"
49
+ triples.to_a[0].predicate.should == RDF::URI('http://example.com/name')
50
+ triples.to_a[0].object.to_s.should == "Peter"
51
51
  end
52
52
 
53
53
  end
@@ -66,7 +66,7 @@ describe Tripod::EagerLoading do
66
66
  context "and related resource doesn't exist" do
67
67
 
68
68
  it "should return nil" do
69
- res = @john.get_related_resource(RDF::URI.new('http://nonexistent/person'), Person)
69
+ res = @john.get_related_resource(RDF::URI.new('http://example.com/nonexistent/person'), Person)
70
70
  res.should be_nil
71
71
  end
72
72
  end
@@ -95,16 +95,16 @@ describe Tripod::EagerLoading do
95
95
 
96
96
  it "should not call find" do
97
97
  Person.should_not_receive(:find)
98
- @john.get_related_resource(RDF::URI.new('http://name'), Resource)
98
+ @john.get_related_resource(RDF::URI.new('http://example.com/name'), Resource)
99
99
  end
100
100
 
101
101
  it "should get the right instance of the resource class passed in" do
102
- res = @john.get_related_resource(RDF::URI.new('http://name'), Resource)
102
+ res = @john.get_related_resource(RDF::URI.new('http://example.com/name'), Resource)
103
103
  res.should == @name
104
104
  end
105
105
 
106
106
  it "should be possible to call methods on the returned object" do
107
- @john.get_related_resource(RDF::URI.new('http://name'), Resource).label.should == @name.label
107
+ @john.get_related_resource(RDF::URI.new('http://example.com/name'), Resource).label.should == @name.label
108
108
  end
109
109
  end
110
110
 
@@ -5,7 +5,7 @@ describe Tripod::Fields do
5
5
  describe ".field" do
6
6
 
7
7
  let(:barry) do
8
- b = Person.new('http://barry')
8
+ b = Person.new('http://example.com/id/barry')
9
9
  b.name = 'Barry'
10
10
  b
11
11
  b
@@ -3,14 +3,14 @@ require "spec_helper"
3
3
  describe Tripod::Finders do
4
4
 
5
5
  let(:ric) do
6
- r = Person.new('http://example.com/people/id/ric')
6
+ r = Person.new('http://example.com/id/ric')
7
7
  r.name = "ric"
8
- r.knows = RDF::URI.new("http://bill")
8
+ r.knows = RDF::URI.new("http://example.com/id/bill")
9
9
  r
10
10
  end
11
11
 
12
12
  let(:bill) do
13
- b = Person.new('http://example.com/people/id/bill')
13
+ b = Person.new('http://example.com/id/bill')
14
14
  b.name = "bill"
15
15
  b
16
16
  end
@@ -27,12 +27,12 @@ describe Tripod::Finders do
27
27
 
28
28
  it 'hydrates and return an object' do
29
29
  person.name.should == "ric"
30
- person.knows.should == [RDF::URI('http://bill')]
30
+ person.knows.should == [RDF::URI('http://example.com/id/bill')]
31
31
  end
32
32
 
33
33
  it 'sets the graph on the instantiated object' do
34
34
  person.graph_uri.should_not be_nil
35
- person.graph_uri.should == RDF::URI("http://graph")
35
+ person.graph_uri.should == RDF::URI("http://example.com/graph")
36
36
  end
37
37
 
38
38
  it "returns a non-new record" do
@@ -43,15 +43,15 @@ describe Tripod::Finders do
43
43
 
44
44
  context 'when record does not exist' do
45
45
  it 'raises not found' do
46
- lambda { Person.find('http://nonexistent') }.should raise_error(Tripod::Errors::ResourceNotFound)
46
+ lambda { Person.find('http://example.com/nonexistent') }.should raise_error(Tripod::Errors::ResourceNotFound)
47
47
  end
48
48
  end
49
49
 
50
50
  context 'with graph_uri supplied' do
51
51
  it 'should use that graph to call new' do
52
52
  ric # trigger the lazy load
53
- Person.should_receive(:new).with(ric.uri, 'http://graphx').and_call_original
54
- Person.find(ric.uri, "http://graphx")
53
+ Person.should_receive(:new).with(ric.uri, 'http://example.com/graphx').and_call_original
54
+ Person.find(ric.uri, "http://example.com/graphx")
55
55
  end
56
56
  end
57
57
 
@@ -135,7 +135,7 @@ describe Tripod::Finders do
135
135
  res.last.should == bill
136
136
 
137
137
  res.first.name.should == "ric"
138
- res.first.knows.should == [RDF::URI.new("http://bill")]
138
+ res.first.knows.should == [RDF::URI.new("http://example.com/id/bill")]
139
139
  end
140
140
 
141
141
  it 'uses the uri and graph variables if supplied' do
@@ -3,28 +3,28 @@ require "spec_helper"
3
3
  describe Tripod::Persistence do
4
4
 
5
5
  let(:unsaved_person) do
6
- @unsaved_uri = @uri = 'http://uri'
7
- @graph_uri = 'http://graph'
6
+ @unsaved_uri = @uri = 'http://example.com/uri'
7
+ @graph_uri = 'http://example.com/graph'
8
8
  @graph1 = RDF::Graph.new(@graph_uri)
9
9
  stmt = RDF::Statement.new
10
10
  stmt.subject = RDF::URI.new(@uri)
11
- stmt.predicate = RDF::URI.new('http://pred')
12
- stmt.object = RDF::URI.new('http://obj')
11
+ stmt.predicate = RDF::URI.new('http://example.com/pred')
12
+ stmt.object = RDF::URI.new('http://example.com/obj')
13
13
  @graph1 << stmt
14
- p = Person.new(@uri, 'http://graph')
14
+ p = Person.new(@uri, 'http://example.com/graph')
15
15
  p.hydrate!(:graph => @graph1)
16
16
  p
17
17
  end
18
18
 
19
19
  let(:saved_person) do
20
- @saved_uri = @uri2 = 'http://uri2'
20
+ @saved_uri = @uri2 = 'http://example.com/uri2'
21
21
  @graph2 = RDF::Graph.new
22
22
  stmt = RDF::Statement.new
23
23
  stmt.subject = RDF::URI.new(@uri2)
24
- stmt.predicate = RDF::URI.new('http://pred2')
25
- stmt.object = RDF::URI.new('http://obj2')
24
+ stmt.predicate = RDF::URI.new('http://example.com/pred2')
25
+ stmt.object = RDF::URI.new('http://example.com/obj2')
26
26
  @graph2 << stmt
27
- p = Person.new(@uri2, 'http://graph')
27
+ p = Person.new(@uri2, 'http://example.com/graph')
28
28
  p.hydrate!(:graph => @graph2)
29
29
  p.save
30
30
  p
@@ -35,7 +35,7 @@ describe Tripod::Persistence do
35
35
 
36
36
  context "with no graph_uri set" do
37
37
  it 'should raise a GraphUriNotSet error' do
38
- p = Resource.new('http://arbitrary/resource')
38
+ p = Resource.new('http://example.com/arbitrary/resource')
39
39
  lambda { p.save }.should raise_error(Tripod::Errors::GraphUriNotSet)
40
40
  end
41
41
  end
@@ -49,8 +49,8 @@ describe Tripod::Persistence do
49
49
  repo_statements = p2.repository.statements
50
50
  repo_statements.count.should == 1
51
51
  repo_statements.first.subject.should == RDF::URI.new(@uri)
52
- repo_statements.first.predicate.should == RDF::URI.new('http://pred')
53
- repo_statements.first.object.should == RDF::URI.new('http://obj')
52
+ repo_statements.first.predicate.should == RDF::URI.new('http://example.com/pred')
53
+ repo_statements.first.object.should == RDF::URI.new('http://example.com/obj')
54
54
  end
55
55
 
56
56
 
@@ -86,7 +86,7 @@ describe Tripod::Persistence do
86
86
  end
87
87
 
88
88
  describe '.update_attribute' do
89
- let (:person) { Person.new('http://newperson') }
89
+ let (:person) { Person.new('http://example.com/newperson') }
90
90
  before { person.stub(:save) }
91
91
 
92
92
  it 'should write the attribute' do
@@ -101,7 +101,7 @@ describe Tripod::Persistence do
101
101
  end
102
102
 
103
103
  describe '.update_attributes' do
104
- let (:person) { Person.new('http://newperson') }
104
+ let (:person) { Person.new('http://example.com/newperson') }
105
105
  before { person.stub(:save) }
106
106
 
107
107
  it 'should assign the attributes' do
@@ -122,18 +122,18 @@ describe Tripod::Persistence do
122
122
  transaction = Tripod::Persistence::Transaction.new
123
123
 
124
124
  unsaved_person.save(transaction: transaction)
125
- saved_person.write_predicate('http://pred2', 'blah')
125
+ saved_person.write_predicate('http://example.com/pred2', 'blah')
126
126
  saved_person.save(transaction: transaction)
127
127
 
128
128
  # nothing should have changed yet.
129
129
  lambda {Person.find(unsaved_person.uri)}.should raise_error(Tripod::Errors::ResourceNotFound)
130
- Person.find(saved_person.uri).read_predicate('http://pred2').first.to_s.should == RDF::URI.new('http://obj2').to_s
130
+ Person.find(saved_person.uri).read_predicate('http://example.com/pred2').first.to_s.should == RDF::URI.new('http://example.com/obj2').to_s
131
131
 
132
132
  transaction.commit
133
133
 
134
134
  # things should have changed now.
135
135
  lambda {Person.find(unsaved_person.uri)}.should_not raise_error()
136
- Person.find(saved_person.uri).read_predicate('http://pred2').first.should == 'blah'
136
+ Person.find(saved_person.uri).read_predicate('http://example.com/pred2').first.should == 'blah'
137
137
 
138
138
  end
139
139
 
@@ -143,7 +143,7 @@ describe Tripod::Persistence do
143
143
  unsaved_person.stub(:graph_uri).and_return(nil) # force a failure
144
144
  unsaved_person.save(transaction: transaction).should be_false
145
145
 
146
- saved_person.write_predicate('http://pred2', 'blah')
146
+ saved_person.write_predicate('http://example.com/pred2', 'blah')
147
147
  saved_person.save(transaction: transaction).should be_true
148
148
 
149
149
  transaction.commit
@@ -155,7 +155,7 @@ describe Tripod::Persistence do
155
155
  lambda {Person.find(unsaved_person.uri)}.should raise_error(Tripod::Errors::ResourceNotFound)
156
156
 
157
157
  # saved person SHOULD be updated
158
- Person.find(saved_person.uri).read_predicate('http://pred2').first.should == 'blah'
158
+ Person.find(saved_person.uri).read_predicate('http://example.com/pred2').first.should == 'blah'
159
159
  end
160
160
 
161
161
  it "can be aborted" do
@@ -3,30 +3,30 @@ require "spec_helper"
3
3
  describe Tripod::Predicates do
4
4
 
5
5
  before do
6
- @uri = 'http://ric'
7
- @graph = RDF::Graph.new('http://graph')
6
+ @uri = 'http://example.com/ric'
7
+ @graph = RDF::Graph.new('http://example.com/graph')
8
8
 
9
9
  stmt = RDF::Statement.new
10
10
  stmt.subject = RDF::URI.new(@uri)
11
- stmt.predicate = RDF::URI.new('http://blog')
12
- stmt.object = RDF::URI.new('http://blog1')
11
+ stmt.predicate = RDF::URI.new('http://example.com/blog')
12
+ stmt.object = RDF::URI.new('http://example.com/blog1')
13
13
  @graph << stmt
14
14
 
15
15
  stmt2 = RDF::Statement.new
16
16
  stmt2.subject = RDF::URI.new(@uri)
17
- stmt2.predicate = RDF::URI.new('http://blog')
18
- stmt2.object = RDF::URI.new('http://blog2')
17
+ stmt2.predicate = RDF::URI.new('http://example.com/blog')
18
+ stmt2.object = RDF::URI.new('http://example.com/blog2')
19
19
  @graph << stmt2
20
20
 
21
21
  stmt3 = RDF::Statement.new
22
22
  stmt3.subject = RDF::URI.new(@uri)
23
- stmt3.predicate = RDF::URI.new('http://name')
23
+ stmt3.predicate = RDF::URI.new('http://example.com/name')
24
24
  stmt3.object = "ric"
25
25
  @graph << stmt3
26
26
 
27
27
  # throw a random other statement (about name) in the mix!
28
28
  stmt4 = RDF::Statement.new
29
- stmt4.subject = RDF::URI.new('http://name')
29
+ stmt4.subject = RDF::URI.new('http://example.com/name')
30
30
  stmt4.predicate = RDF::RDFS.label
31
31
  stmt4.object = "name"
32
32
  @graph << stmt4
@@ -40,10 +40,10 @@ describe Tripod::Predicates do
40
40
 
41
41
  describe "#read_predicate" do
42
42
  it 'returns the values where the predicate matches' do
43
- values = person.read_predicate('http://blog')
43
+ values = person.read_predicate('http://example.com/blog')
44
44
  values.length.should == 2
45
- values.first.should == RDF::URI('http://blog1')
46
- values[1].should == RDF::URI('http://blog2')
45
+ values.first.should == RDF::URI('http://example.com/blog1')
46
+ values[1].should == RDF::URI('http://example.com/blog2')
47
47
  end
48
48
  end
49
49
 
@@ -51,15 +51,15 @@ describe Tripod::Predicates do
51
51
 
52
52
  context 'single term passed' do
53
53
  it 'replaces the values where the predicate matches' do
54
- person.write_predicate('http://name', 'richard')
55
- person.read_predicate('http://name').should == [RDF::Literal.new('richard')]
54
+ person.write_predicate('http://example.com/name', 'richard')
55
+ person.read_predicate('http://example.com/name').should == [RDF::Literal.new('richard')]
56
56
  end
57
57
  end
58
58
 
59
59
  context 'multiple terms passed' do
60
60
  it 'replaces the values where the predicate matches' do
61
- person.write_predicate('http://name', ['richard', 'ric', 'ricardo'])
62
- person.read_predicate('http://name').should == [RDF::Literal.new('richard'), RDF::Literal.new('ric'), RDF::Literal.new('ricardo')]
61
+ person.write_predicate('http://example.com/name', ['richard', 'ric', 'ricardo'])
62
+ person.read_predicate('http://example.com/name').should == [RDF::Literal.new('richard'), RDF::Literal.new('ric'), RDF::Literal.new('ricardo')]
63
63
  end
64
64
  end
65
65
 
@@ -67,22 +67,22 @@ describe Tripod::Predicates do
67
67
 
68
68
  describe '#remove_predicate' do
69
69
  it 'remnoves the values where the predicate matches' do
70
- person.remove_predicate('http://blog')
71
- person.read_predicate('http://blog').should be_empty
70
+ person.remove_predicate('http://example.com/blog')
71
+ person.read_predicate('http://example.com/blog').should be_empty
72
72
  end
73
73
  end
74
74
 
75
75
  describe "#append_to_predicate" do
76
76
  it 'appends values to the existing values for the predicate' do
77
- person.append_to_predicate('http://name', 'rico')
78
- person.read_predicate('http://name').should == [RDF::Literal.new('ric'), RDF::Literal.new('rico')]
77
+ person.append_to_predicate('http://example.com/name', 'rico')
78
+ person.read_predicate('http://example.com/name').should == [RDF::Literal.new('ric'), RDF::Literal.new('rico')]
79
79
  end
80
80
  end
81
81
 
82
82
  describe "#predicates" do
83
83
  it "returns a list of unique RDF::URIs for the predicates set on this resource" do
84
84
  person.predicates.length.should == 2
85
- person.predicates.should == [RDF::URI('http://blog'), RDF::URI('http://name')]
85
+ person.predicates.should == [RDF::URI('http://example.com/blog'), RDF::URI('http://example.com/name')]
86
86
  end
87
87
 
88
88
 
@@ -7,14 +7,14 @@ describe Tripod::Repository do
7
7
  context 'uri set' do
8
8
 
9
9
  before do
10
- @uri = 'http://foobar'
11
- @uri2 = 'http://bazbar'
12
- @graph_uri = 'http://graph'
10
+ @uri = 'http://example.com/foobar'
11
+ @uri2 = 'http://example.com/bazbar'
12
+ @graph_uri = 'http://example.com/graph'
13
13
 
14
14
  p1 = Person.new(@uri, @graph_uri)
15
- p1.write_predicate('http://pred', RDF::URI.new('http://obj'))
16
- p1.write_predicate('http://pred2', RDF::URI.new('http://obj2'))
17
- p1.write_predicate('http://pred3', 'literal')
15
+ p1.write_predicate('http://example.com/pred', RDF::URI.new('http://example.com/obj'))
16
+ p1.write_predicate('http://example.com/pred2', RDF::URI.new('http://example.com/obj2'))
17
+ p1.write_predicate('http://example.com/pred3', 'literal')
18
18
  p1.save!
19
19
  end
20
20
 
@@ -27,7 +27,7 @@ describe Tripod::Repository do
27
27
  context 'no predicate restrictions passed' do
28
28
 
29
29
  it 'populates the repository with a graph of triples from the db' do
30
- Tripod::SparqlClient::Query.should_receive(:describe).with("DESCRIBE <#{@uri}>").and_call_original
30
+ Tripod::SparqlClient::Query.should_receive(:query).with("DESCRIBE <#{@uri}>", "application/n-triples").and_call_original
31
31
  person.hydrate!
32
32
  person.repository.should_not be_empty
33
33
  end
@@ -43,7 +43,7 @@ describe Tripod::Repository do
43
43
  @graph << s
44
44
  end
45
45
 
46
- @graph << RDF::Statement.new( 'http://anotherresource', 'http://pred', 'http://obj')
46
+ @graph << RDF::Statement.new( 'http://example.com/anotherresource', 'http://example.com/pred', 'http://example.com/obj')
47
47
  @graph.statements.count.should ==2 # there'll already be a statement about type in the person.
48
48
 
49
49
  person.hydrate!(:graph => @graph)
@@ -10,20 +10,20 @@ describe Tripod::Resource do
10
10
 
11
11
  context 'with a URI' do
12
12
  let(:person) do
13
- Person.new('http://foobar')
13
+ Person.new('http://example.com/foobar')
14
14
  end
15
15
 
16
16
  it 'sets the uri instance variable' do
17
- person.uri.should == RDF::URI.new('http://foobar')
17
+ person.uri.should == RDF::URI.new('http://example.com/foobar')
18
18
  end
19
19
 
20
20
  it 'sets the graph_uri instance variable from the class by default' do
21
- person.graph_uri.should == RDF::URI.new('http://graph')
21
+ person.graph_uri.should == RDF::URI.new('http://example.com/graph')
22
22
  end
23
23
 
24
24
  context "with rdf_type specified at class level" do
25
25
  it "sets the rdf type from the class" do
26
- person.rdf_type.should == ['http://person']
26
+ person.rdf_type.should == ['http://example.com/person']
27
27
  end
28
28
  end
29
29
 
@@ -34,11 +34,11 @@ describe Tripod::Resource do
34
34
 
35
35
  context 'with a URI and a graph URI' do
36
36
  let(:person) do
37
- Person.new('http://foobar', 'http://foobar/graph')
37
+ Person.new('http://example.com/foobar', 'http://example.com/foobar/graph')
38
38
  end
39
39
 
40
40
  it "overrides the default graph URI with what's given" do
41
- person.graph_uri.should == RDF::URI.new('http://foobar/graph')
41
+ person.graph_uri.should == RDF::URI.new('http://example.com/foobar/graph')
42
42
  end
43
43
  end
44
44
  end
@@ -4,11 +4,11 @@ describe Tripod::Serialization do
4
4
 
5
5
  let(:person) do
6
6
 
7
- p2 = Person.new('http://fred')
7
+ p2 = Person.new('http://example.com/fred')
8
8
  p2.name = "fred"
9
9
  p2.save!
10
10
 
11
- p = Person.new('http://garry')
11
+ p = Person.new('http://example.com/garry')
12
12
  p.name = 'Garry'
13
13
  p.age = 30
14
14
  p.knows = p2.uri
@@ -6,28 +6,28 @@ describe Tripod::SparqlClient do
6
6
 
7
7
  describe "Data#append" do
8
8
  it "should add the graph uri to the configured data endpoint" do
9
- RestClient::Request.should_receive(:execute).with(hash_including(url: 'http://127.0.0.1:3030/tripod-test/data?graph=http://foo'))
10
- Tripod::SparqlClient::Data.append('http://foo', data)
9
+ RestClient::Request.should_receive(:execute).with(hash_including(url: 'http://127.0.0.1:3030/tripod-test/data?graph=http://example.com/foo'))
10
+ Tripod::SparqlClient::Data.append('http://example.com/foo', data)
11
11
  end
12
12
 
13
13
  it "should send the data as the payload" do
14
14
  RestClient::Request.should_receive(:execute).with(hash_including(payload: data))
15
- Tripod::SparqlClient::Data.append('http://foo', data)
15
+ Tripod::SparqlClient::Data.append('http://example.com/foo', data)
16
16
  end
17
17
 
18
18
  it "should HTTP POST the data" do
19
19
  RestClient::Request.should_receive(:execute).with(hash_including(method: :post))
20
- Tripod::SparqlClient::Data.append('http://foo', data)
20
+ Tripod::SparqlClient::Data.append('http://example.com/foo', data)
21
21
  end
22
22
 
23
23
  context "which fails with a 400 error" do
24
24
  before do
25
25
  WebMock.enable!
26
- stub_http_request(:post, 'http://127.0.0.1:3030/tripod-test/data?graph=http://foo').to_return(body: 'Error 400: Trousers missing', status: 400)
26
+ stub_http_request(:post, 'http://127.0.0.1:3030/tripod-test/data?graph=http://example.com/foo').to_return(body: 'Error 400: Trousers missing', status: 400)
27
27
  end
28
28
 
29
29
  it "should raise a 'parse failed' exception" do
30
- lambda { Tripod::SparqlClient::Data.append('http://foo', data) }.should raise_error(Tripod::Errors::BadDataRequest)
30
+ lambda { Tripod::SparqlClient::Data.append('http://example.com/foo', data) }.should raise_error(Tripod::Errors::BadDataRequest)
31
31
  end
32
32
 
33
33
  after do
@@ -39,7 +39,7 @@ describe Tripod::SparqlClient do
39
39
  describe "Data#replace" do
40
40
  it "should HTTP PUT the data" do
41
41
  RestClient::Request.should_receive(:execute).with(hash_including(method: :put))
42
- Tripod::SparqlClient::Data.replace('http://foo', data)
42
+ Tripod::SparqlClient::Data.replace('http://example.com/foo', data)
43
43
  end
44
44
  end
45
45
  end
@@ -7,7 +7,7 @@ describe Tripod::State do
7
7
  context "when calling new on the resource" do
8
8
 
9
9
  let(:person) do
10
- Person.new('http://uri', 'http://graph')
10
+ Person.new('http://example.com/uri', 'http://example.com/graph')
11
11
  end
12
12
 
13
13
  it "returns true" do
@@ -18,7 +18,7 @@ describe Tripod::State do
18
18
  context "when the object has been saved" do
19
19
 
20
20
  let(:person) do
21
- p = Person.new('http://uri', 'http://graph')
21
+ p = Person.new('http://example.com/uri', 'http://example.com/graph')
22
22
  p.save
23
23
  p
24
24
  end
@@ -32,7 +32,7 @@ describe Tripod::State do
32
32
  describe "#persisted?" do
33
33
 
34
34
  let(:person) do
35
- Person.new('http://uri', 'http://graph')
35
+ Person.new('http://example.com/uri', 'http://example.com/graph')
36
36
  end
37
37
 
38
38
  it "delegates to new_record?" do
@@ -54,7 +54,7 @@ describe Tripod::State do
54
54
  describe "destroyed?" do
55
55
 
56
56
  let(:person) do
57
- Person.new('http://uri', 'http://graph')
57
+ Person.new('http://example.com/uri', 'http://example.com/graph')
58
58
  end
59
59
 
60
60
  context "when destroyed is true" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tripod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2013-03-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rest-client
18
- requirement: &70167526722900 !ruby/object:Gem::Requirement
18
+ requirement: &70364886263520 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70167526722900
26
+ version_requirements: *70364886263520
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
- requirement: &70167526720820 !ruby/object:Gem::Requirement
29
+ requirement: &70364886262400 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ~>
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '3.1'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70167526720820
37
+ version_requirements: *70364886262400
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: equivalent-xml
40
- requirement: &70167518449700 !ruby/object:Gem::Requirement
40
+ requirement: &70364886261680 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *70167518449700
48
+ version_requirements: *70364886261680
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: rdf
51
- requirement: &70167518447940 !ruby/object:Gem::Requirement
51
+ requirement: &70364886260440 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '1.0'
57
57
  type: :runtime
58
58
  prerelease: false
59
- version_requirements: *70167518447940
59
+ version_requirements: *70364886260440
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rdf-rdfxml
62
- requirement: &70167518446320 !ruby/object:Gem::Requirement
62
+ requirement: &70364886259940 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0'
68
68
  type: :runtime
69
69
  prerelease: false
70
- version_requirements: *70167518446320
70
+ version_requirements: *70364886259940
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rdf-n3
73
- requirement: &70167518445720 !ruby/object:Gem::Requirement
73
+ requirement: &70364886258140 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ! '>='
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: '0'
79
79
  type: :runtime
80
80
  prerelease: false
81
- version_requirements: *70167518445720
81
+ version_requirements: *70364886258140
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: rdf-json
84
- requirement: &70167518444840 !ruby/object:Gem::Requirement
84
+ requirement: &70364886255600 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
- version_requirements: *70167518444840
92
+ version_requirements: *70364886255600
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: json-ld
95
- requirement: &70167518444020 !ruby/object:Gem::Requirement
95
+ requirement: &70364886254440 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,10 +100,10 @@ dependencies:
100
100
  version: '0'
101
101
  type: :runtime
102
102
  prerelease: false
103
- version_requirements: *70167518444020
103
+ version_requirements: *70364886254440
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: guid
106
- requirement: &70167518443180 !ruby/object:Gem::Requirement
106
+ requirement: &70364886240960 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
109
  - - ! '>='
@@ -111,10 +111,10 @@ dependencies:
111
111
  version: '0'
112
112
  type: :runtime
113
113
  prerelease: false
114
- version_requirements: *70167518443180
114
+ version_requirements: *70364886240960
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: dalli
117
- requirement: &70167518442440 !ruby/object:Gem::Requirement
117
+ requirement: &70364886240040 !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
120
120
  - - ~>
@@ -122,7 +122,7 @@ dependencies:
122
122
  version: '2.6'
123
123
  type: :runtime
124
124
  prerelease: false
125
- version_requirements: *70167518442440
125
+ version_requirements: *70364886240040
126
126
  description: RDF ruby ORM
127
127
  email:
128
128
  - ric@swirrl.com