tripod 0.10.8 → 0.10.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65ac9003b41041c38eca5b5a994c5a38fce051a9
4
- data.tar.gz: 308116012a566cc07df65597074fa67b8ce371fc
3
+ metadata.gz: 40ee076fa76f2dd85f1f03f328f38e4e2813612b
4
+ data.tar.gz: af419e68c83352681b72f40c7d009929f6878ddf
5
5
  SHA512:
6
- metadata.gz: 51eb6d4cae3e25e1d07585efd3478011f5f772d851c2398f0c06382121bee37074032055d7764248aa243f8a3436236003feec89f2dc5b9802da47482f4ad88f
7
- data.tar.gz: 928a70bedfa0b096f93e66cf42a0fd1f302ff1eb0e8b5100412fa132797a15c942392c0524bf2b029151e5f8870e16e6703747464667ffb986cf473638f4d9cb
6
+ metadata.gz: 7c99e9887bf0e13489e3bcc33aa4d29a83780d82a78b8c1767b308129dba8df70da0e5f3ff966492ac30d962e80fb91d91628481258ae2607814fc826ea6180b
7
+ data.tar.gz: 65136c91f3e23f23f7061c1b113620176e555eff080f12a104a531edfe24a30022ad6ea64d5c4e4cccda22a320dea8d98db027acc248a13269c9acae7f376d21
data/lib/tripod.rb CHANGED
@@ -93,9 +93,11 @@ require "tripod/predicates"
93
93
  require "tripod/attributes"
94
94
  require "tripod/callbacks"
95
95
  require "tripod/validations/is_url"
96
+ require "tripod/rdf_type"
96
97
  require "tripod/errors"
97
98
  require "tripod/repository"
98
99
  require "tripod/fields"
100
+ require "tripod/dirty"
99
101
  require "tripod/criteria"
100
102
  require "tripod/links"
101
103
  require "tripod/finders"
@@ -104,6 +106,9 @@ require "tripod/eager_loading"
104
106
  require "tripod/serialization"
105
107
  require "tripod/state"
106
108
  require "tripod/graphs"
109
+ require "tripod/embeds"
110
+ require "tripod/embeds/many"
111
+ require "tripod/embedded_resource"
107
112
  require "tripod/version"
108
113
 
109
114
  # these need to be at the end
@@ -23,18 +23,18 @@ module Tripod::Attributes
23
23
  field ||= self.class.get_field(name)
24
24
 
25
25
  attr_values = read_predicate(field.predicate)
26
-
26
+
27
27
  if field.multivalued
28
28
  # If the field is multivalued, return an array of the results
29
- # just return the uri or the value of the literal.
29
+ # just return the uri or the value of the literal.
30
30
  attr_values.map { |v| field.is_uri? ? v : v.object }
31
- else
31
+ else
32
32
  # If it's not multivalued, return the first (should be only) result.
33
- if field.is_uri?
33
+ if field.is_uri?
34
34
  attr_values.first
35
35
  else
36
36
  # try to get it in english if it's there. (TODO: make it configurable what the default is)
37
- val = attr_values.select{ |v| v.language == :en }.first || attr_values.first
37
+ val = attr_values.select{ |v| v.language == :en }.first || attr_values.first
38
38
  val.object if val
39
39
  end
40
40
  end
@@ -70,6 +70,7 @@ module Tripod::Attributes
70
70
  new_val = write_value_for_field(value, field)
71
71
  end
72
72
 
73
+ attribute_will_change!(name)
73
74
  write_predicate(field.predicate, new_val)
74
75
  end
75
76
  alias :[]= :write_attribute
@@ -17,9 +17,12 @@ module Tripod::Components
17
17
  include Tripod::Attributes
18
18
  include Tripod::Callbacks
19
19
  include Tripod::Validations
20
+ include Tripod::RdfType
20
21
  include Tripod::Persistence
21
22
  include Tripod::Fields
22
23
  include Tripod::Links
24
+ include Tripod::Embeds
25
+ include Tripod::Dirty
23
26
  include Tripod::Finders
24
27
  include Tripod::Repository
25
28
  include Tripod::EagerLoading
@@ -0,0 +1,68 @@
1
+ module Tripod::Dirty
2
+ extend ActiveSupport::Concern
3
+
4
+ def changed_attributes
5
+ @changed_attributes ||= {}
6
+ end
7
+
8
+ def changed
9
+ changed_attributes.keys
10
+ end
11
+
12
+ def changes
13
+ changed.reduce({}) do |memo, attr|
14
+ change = attribute_change(attr)
15
+ memo[attr] = change if change
16
+ memo
17
+ end
18
+ end
19
+
20
+ def attribute_will_change!(attr)
21
+ changed_attributes[attr] = read_attribute(attr) unless changed_attributes.has_key?(attr)
22
+ end
23
+
24
+ def attribute_change(attr)
25
+ [ changed_attributes[attr], read_attribute(attr) ] if attribute_changed?(attr)
26
+ end
27
+
28
+ def attribute_changed?(attr)
29
+ return false unless changed_attributes.has_key?(attr)
30
+ (changed_attributes[attr] != read_attribute(attr))
31
+ end
32
+
33
+ def post_persist
34
+ changed_attributes.clear
35
+ end
36
+
37
+ module ClassMethods
38
+ def create_dirty_methods(name, meth)
39
+ create_dirty_change_check(name, meth)
40
+ create_dirty_change_accessor(name, meth)
41
+ create_dirty_was_accessor(name, meth)
42
+ end
43
+
44
+ def create_dirty_change_accessor(name, meth)
45
+ generated_methods.module_eval do
46
+ re_define_method("#{meth}_change") do
47
+ attribute_change(name)
48
+ end
49
+ end
50
+ end
51
+
52
+ def create_dirty_change_check(name, meth)
53
+ generated_methods.module_eval do
54
+ re_define_method("#{meth}_changed?") do
55
+ attribute_changed?(name)
56
+ end
57
+ end
58
+ end
59
+
60
+ def create_dirty_was_accessor(name, meth)
61
+ generated_methods.module_eval do
62
+ re_define_method("#{meth}_was") do
63
+ changed_attributes[name]
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -7,6 +7,7 @@ module Tripod::EmbeddedResource
7
7
  include Tripod::Attributes
8
8
  include Tripod::Validations
9
9
  include Tripod::Fields
10
+ include Tripod::Dirty
10
11
  include Tripod::RdfType
11
12
 
12
13
  attr_reader :uri
data/lib/tripod/embeds.rb CHANGED
@@ -26,6 +26,10 @@ module Tripod::Embeds
26
26
  # use this as a way to get to all the embedded properties for validation
27
27
  @_EMBEDDED ||= []
28
28
  @_EMBEDDED << name
29
+
30
+ # add statements to our hydrate query so the repository is populated appropriately
31
+ append_to_hydrate_construct ->(u) { "#{ u } <#{ predicate.to_s }> ?es . ?es ?ep ?eo ." }
32
+ append_to_hydrate_where ->(u) { "OPTIONAL { #{ u } <#{ predicate.to_s }> ?es . ?es ?ep ?eo . }" }
29
33
  end
30
34
 
31
35
  def get_embedded
data/lib/tripod/fields.rb CHANGED
@@ -58,7 +58,7 @@ module Tripod::Fields
58
58
  # Define a field attribute for the +Resource+.
59
59
  #
60
60
  # @example Set the field.
61
- # Person.add_field(:name, :predicate => 'http://myfield')
61
+ # Person.add_field(:name, 'http://myfield')
62
62
  #
63
63
  # @param [ Symbol ] name The name of the field.
64
64
  # @param [ String, RDF::URI ] predicate The predicate for the field.
@@ -95,6 +95,9 @@ module Tripod::Fields
95
95
  create_field_getter(name, meth, field)
96
96
  create_field_setter(name, meth, field)
97
97
  create_field_check(name, meth, field)
98
+
99
+ # from dirty.rb
100
+ create_dirty_methods(name, meth)
98
101
  end
99
102
 
100
103
  # Create the getter method for the provided field.
@@ -172,15 +172,16 @@ module Tripod::Finders
172
172
  def _describe_query_for_select(select_sparql, opts={})
173
173
  uri_variable = opts[:uri_variable] || "uri"
174
174
  "
175
- CONSTRUCT { ?tripod_construct_s ?tripod_construct_p ?tripod_construct_o }
176
- WHERE {
177
- {
178
- SELECT (?#{uri_variable} as ?tripod_construct_s)
179
- {
180
- #{select_sparql}
181
- }
182
- }
183
- ?tripod_construct_s ?tripod_construct_p ?tripod_construct_o .
175
+ CONSTRUCT {
176
+ ?tripod_construct_s ?tripod_construct_p ?tripod_construct_o .
177
+ #{ all_triples_construct('?tripod_construct_s') }
178
+ }
179
+ WHERE {
180
+ { SELECT (?#{uri_variable} as ?tripod_construct_s) {
181
+ #{select_sparql}
182
+ } }
183
+ ?tripod_construct_s ?tripod_construct_p ?tripod_construct_o .
184
+ #{ all_triples_where('?tripod_construct_s') }
184
185
  }
185
186
  "
186
187
  end
@@ -216,6 +217,10 @@ module Tripod::Finders
216
217
  data_graph = RDF::Graph.new
217
218
  repo.query( [RDF::URI.new(u), :predicate, :object] ) do |statement|
218
219
  data_graph << statement
220
+
221
+ if statement.object.is_a? RDF::Node
222
+ repo.query( [statement.object, :predicate, :object] ) {|s| data_graph << s}
223
+ end
219
224
  end
220
225
 
221
226
  # use it to hydrate this resource
data/lib/tripod/links.rb CHANGED
@@ -124,13 +124,16 @@ module Tripod::Links
124
124
 
125
125
  uris = read_attribute(link.field_name)
126
126
 
127
- filter_str = "FILTER("
127
+ filter_str = ""
128
+
128
129
  if uris.any?
129
- filter_str += uris.map {|u| "?uri = <#{u.to_s}>" }.join(" || ")
130
+ filter_str += " VALUES ?uri { <"
131
+ filter_str += uris.join("> <")
132
+ filter_str += "> } "
130
133
  else
131
- filter_str += "1 = 0"
134
+ filter_str += "FILTER (1 = 0)"
132
135
  end
133
- filter_str += ")"
136
+
134
137
 
135
138
  criteria.where(filter_str).resources
136
139
  else
@@ -91,6 +91,7 @@ module Tripod::Persistence
91
91
  end
92
92
 
93
93
  @new_record = false # if running in a trans, just assume it worked. If the query is dodgy, it will throw an exception later.
94
+ post_persist
94
95
  true
95
96
  else
96
97
  false
@@ -56,11 +56,7 @@ module Tripod::Repository
56
56
  end
57
57
 
58
58
  def retrieve_triples_from_database(accept_header="application/n-triples")
59
- graph_selector = self.graph_uri.present? ? "<#{graph_uri.to_s}>" : "?g"
60
- Tripod::SparqlClient::Query.query(
61
- "CONSTRUCT {<#{uri}> ?p ?o} WHERE { GRAPH #{graph_selector} { <#{uri}> ?p ?o } }",
62
- accept_header
63
- )
59
+ Tripod::SparqlClient::Query.query(self.class.all_triples_query(uri, graph_uri: self.graph_uri), accept_header)
64
60
  end
65
61
 
66
62
  # returns a graph of triples from the underlying repository where this resource's uri is the subject.
@@ -87,6 +83,33 @@ module Tripod::Repository
87
83
  repo
88
84
  end
89
85
 
86
+ def append_to_hydrate_construct(statement)
87
+ @construct_statements ||= []
88
+ @construct_statements << statement
89
+ end
90
+
91
+ def append_to_hydrate_where(statement)
92
+ @where_statements ||= []
93
+ @where_statements << statement
94
+ end
95
+
96
+ def all_triples_query(uri, opts={})
97
+ graph_uri = opts.fetch(:graph_uri, nil)
98
+ graph_selector = graph_uri.present? ? "<#{graph_uri.to_s}>" : "?g"
99
+ uri_selector = "<#{uri}>"
100
+ "CONSTRUCT { #{uri_selector} ?p ?o . #{ all_triples_construct(uri_selector) } } WHERE { GRAPH #{graph_selector} { #{uri_selector} ?p ?o . #{ all_triples_where(uri_selector) } } }"
101
+ end
102
+
103
+ def all_triples_construct(uri)
104
+ extra_construct = @construct_statements.map{|s| s.call(uri) }.join if @construct_statements.present?
105
+ extra_construct || ''
106
+ end
107
+
108
+ def all_triples_where(uri)
109
+ extra_where = @where_statements.map{|s| s.call(uri) }.join if @where_statements.present?
110
+ extra_where || ''
111
+ end
112
+
90
113
  end
91
114
 
92
- end
115
+ end
@@ -13,8 +13,6 @@ module Tripod::Resource
13
13
  validates_presence_of :graph_uri
14
14
  # uri is a valid linked data url
15
15
  validates :uri, is_url: true
16
- # every instance of a resource has an rdf type field, which is set at the class level
17
- class_attribute :_RDF_TYPE
18
16
  # the Graph URI is set at the class level by default also, although this can be overridden in the constructor
19
17
  class_attribute :_GRAPH_URI
20
18
  end
@@ -52,7 +50,7 @@ module Tripod::Resource
52
50
  run_callbacks :initialize do
53
51
  graph_uri ||= self.class.get_graph_uri unless ignore_graph
54
52
  @graph_uri = RDF::URI(graph_uri) if graph_uri
55
- self.rdf_type = self.class.get_rdf_type if respond_to?(:rdf_type=) && self.class.get_rdf_type
53
+ set_rdf_type
56
54
  end
57
55
  end
58
56
 
@@ -107,17 +105,6 @@ module Tripod::Resource
107
105
  other.class == Class ? self <= other : other.is_a?(self)
108
106
  end
109
107
 
110
- # makes a "field" on this model called rdf_type
111
- # and sets a class level _RDF_TYPE variable with the rdf_type passed in.
112
- def rdf_type(new_rdf_type)
113
- self._RDF_TYPE = RDF::URI.new(new_rdf_type.to_s)
114
- field :rdf_type, RDF.type, :multivalued => true, :is_uri => true # things can have more than 1 type and often do
115
- end
116
-
117
- def get_rdf_type
118
- self._RDF_TYPE
119
- end
120
-
121
108
  def graph_uri(new_graph_uri)
122
109
  self._GRAPH_URI = new_graph_uri
123
110
  end
@@ -130,4 +117,4 @@ module Tripod::Resource
130
117
  end
131
118
 
132
119
  # causes any hooks to be fired, if they've been setup on_load of :tripod.
133
- ActiveSupport.run_load_hooks(:triploid, Tripod::Resource)
120
+ ActiveSupport.run_load_hooks(:triploid, Tripod::Resource)
@@ -1,3 +1,3 @@
1
1
  module Tripod
2
- VERSION = "0.10.8"
2
+ VERSION = "0.10.9"
3
3
  end
@@ -14,4 +14,6 @@ class Dog
14
14
 
15
15
  linked_to :arch_enemy, 'http://example.com/archenemy', class_name: 'Dog'
16
16
  linked_to :enemies, 'http://example.com/enemy', class_name: 'Dog'
17
- end
17
+
18
+ embeds :fleas, 'http://example.com/fleas'
19
+ end
data/spec/spec_helper.rb CHANGED
@@ -31,7 +31,7 @@ Tripod.configure do |config|
31
31
  # config.update_endpoint = 'http://127.0.0.1:3030/tripod-test/update'
32
32
  # config.query_endpoint = 'http://127.0.0.1:3030/tripod-test/sparql'
33
33
  # config.data_endpoint = 'http://127.0.0.1:3030/tripod-test/data'
34
-
34
+
35
35
  config.update_endpoint = 'http://127.0.0.1:3002/sparql/raw/update'
36
36
  config.query_endpoint = 'http://127.0.0.1:3002/sparql/raw'
37
37
  #config.data_endpoint = 'http://127.0.0.1:3030/tripod-test/data'
@@ -41,4 +41,4 @@ end
41
41
  Dir[ File.join(MODELS, "*.rb") ].sort.each do |file|
42
42
  name = File.basename(file, ".rb")
43
43
  autoload name.camelize.to_sym, name
44
- end
44
+ end
@@ -112,7 +112,7 @@ describe Tripod::Attributes do
112
112
  end
113
113
 
114
114
  context "where field is given" do
115
- let(:field) { Person.send(:field_for, :hat_type, 'http://example.com/hat', {}) }
115
+ let(:field) { Person.send(:add_field, :hat_type, 'http://example.com/hat') }
116
116
 
117
117
  it "should derive the predicate name from the given field" do
118
118
  person.write_attribute(:hat_type, 'http://example.com/bowlerhat', field)
@@ -121,7 +121,7 @@ describe Tripod::Attributes do
121
121
  end
122
122
 
123
123
  context "where a field of a particular datatype is given" do
124
- let(:field) { Person.send(:field_for, :hat_size, 'http://example.com/hatsize', {datatype: RDF::XSD.integer}) }
124
+ let(:field) { Person.send(:add_field, :hat_size, 'http://example.com/hatsize', {datatype: RDF::XSD.integer}) }
125
125
 
126
126
  it "should derive the datatype from the given field" do
127
127
  person.write_attribute(:hat_size, 10, field)
@@ -130,7 +130,7 @@ describe Tripod::Attributes do
130
130
  end
131
131
 
132
132
  context "where a multi-valued field of a given datatype is given" do
133
- let(:field) { Person.send(:field_for, :hat_heights, 'http://example.com/hatheight', {datatype: RDF::XSD.integer, multivalued: true}) }
133
+ let(:field) { Person.send(:add_field, :hat_heights, 'http://example.com/hatheight', {datatype: RDF::XSD.integer, multivalued: true}) }
134
134
 
135
135
  it "should co-erce the values passed" do
136
136
  person.write_attribute(:hat_heights, [5, 10, 15], field)
@@ -144,4 +144,4 @@ describe Tripod::Attributes do
144
144
  end
145
145
  end
146
146
  end
147
- end
147
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe Tripod::Dirty do
4
+ let(:dog) { Dog.new('http://example.com/dog/spot') }
5
+
6
+ describe '#changes' do
7
+ before do
8
+ dog.name = 'Spot'
9
+ end
10
+
11
+ it 'should report the original and current values for a changed field' do
12
+ expect(dog.changes[:name]).to eq([nil, 'Spot'])
13
+ end
14
+
15
+ context 'when the field is set more than once' do
16
+ before do
17
+ dog.name = 'Zit'
18
+ end
19
+
20
+ it 'should still report the original value correctly' do
21
+ expect(dog.changes[:name]).to eq([nil, 'Zit'])
22
+ end
23
+ end
24
+
25
+ context 'when the field is set back to its original value' do
26
+ before do
27
+ dog.name = nil
28
+ end
29
+
30
+ it 'should no longer report a change to the field' do
31
+ expect(dog.changes.keys).to_not include(:name)
32
+ end
33
+ end
34
+
35
+ context 'on save' do
36
+ before { dog.save }
37
+
38
+ it 'should reset changes' do
39
+ expect(dog.changes).to be_empty
40
+ end
41
+ end
42
+ end
43
+
44
+ context 'field methods' do
45
+ before { dog.name = 'Wrex' }
46
+
47
+ it 'should create a <field>_change method' do
48
+ expect(dog.name_change).to eq([nil, 'Wrex'])
49
+ end
50
+
51
+ it 'should create a <field>_changed? method' do
52
+ expect(dog.name_changed?).to eq(true)
53
+ end
54
+
55
+ it 'should create a <field>_was method' do
56
+ expect(dog.name_was).to eq(nil)
57
+ end
58
+ end
59
+ end
@@ -1,14 +1,14 @@
1
- # require 'spec_helper'
2
- #
3
- # module Tripod
4
- # describe EmbeddedResource do
5
- # describe 'an instance' do
6
- # let(:flea) { Flea.new }
7
- #
8
- # it 'should have getters & setters on fields' do
9
- # flea.name = 'Bob'
10
- # expect(flea.name).to eq('Bob')
11
- # end
12
- # end
13
- # end
14
- # end
1
+ require 'spec_helper'
2
+
3
+ module Tripod
4
+ describe EmbeddedResource do
5
+ describe 'an instance' do
6
+ let(:flea) { Flea.new }
7
+
8
+ it 'should have getters & setters on fields' do
9
+ flea.name = 'Bob'
10
+ expect(flea.name).to eq('Bob')
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,63 +1,62 @@
1
- # require 'spec_helper'
2
- #
3
- # describe Tripod::Embeds do
4
- # let(:uri) { 'http://example.com/id/spot' }
5
- # let(:dog) {
6
- # d = Dog.new(uri)
7
- # d.name = "Spot"
8
- # d
9
- # }
10
- # let(:flea) {
11
- # f = Flea.new
12
- # f.name = 'Starsky'
13
- # f
14
- # }
15
- #
16
- # it 'should set and get embedded resources through the proxy' do
17
- # dog.fleas << flea
18
- # expect(dog.fleas.include?(flea)).to eq(true)
19
- # end
20
- #
21
- # it 'should validate embedded resources' do
22
- # dog.fleas << Flea.new
23
- # expect(dog.valid?).to eq(false)
24
- # end
25
- #
26
- # context 'given a saved instance' do
27
- # before do
28
- # dog.fleas << flea
29
- # dog.save
30
- # end
31
- #
32
- # context 'retrieved by uri' do
33
- # let(:dogg) { Dog.find(uri) }
34
- #
35
- # it 'should hydrate embedded resources from the triple store' do
36
- # f = dogg.fleas.first
37
- # expect(f.name).to eq(flea.name)
38
- # end
39
- # end
40
- #
41
- # context 'retrieved as part of a resource collection' do
42
- # let(:dogg) { Dog.all.resources.first }
43
- #
44
- # # RR: this is commented out as I backed out the (slow) update to the hydration CONSTRUCT
45
- # it 'should hydrate embedded resources from the triple store' do
46
- # f = dogg.fleas.first
47
- # expect(f.name).to eq(flea.name)
48
- # end
49
- # end
50
- # end
51
- #
52
- #
53
- # describe 'delete' do
54
- # before do
55
- # dog.fleas << flea
56
- # end
57
- #
58
- # it 'should remove all trace of the resource' do
59
- # dog.fleas.delete(flea)
60
- # expect(dog.fleas.include?(flea)).to eq(false)
61
- # end
62
- # end
63
- # end
1
+ require 'spec_helper'
2
+
3
+ describe Tripod::Embeds do
4
+ let(:uri) { 'http://example.com/id/spot' }
5
+ let(:dog) {
6
+ d = Dog.new(uri)
7
+ d.name = "Spot"
8
+ d
9
+ }
10
+ let(:flea) {
11
+ f = Flea.new
12
+ f.name = 'Starsky'
13
+ f
14
+ }
15
+
16
+ it 'should set and get embedded resources through the proxy' do
17
+ dog.fleas << flea
18
+ expect(dog.fleas.include?(flea)).to eq(true)
19
+ end
20
+
21
+ it 'should validate embedded resources' do
22
+ dog.fleas << Flea.new
23
+ expect(dog.valid?).to eq(false)
24
+ end
25
+
26
+ context 'given a saved instance' do
27
+ before do
28
+ dog.fleas << flea
29
+ dog.save
30
+ end
31
+
32
+ context 'retrieved by uri' do
33
+ let(:dogg) { Dog.find(uri) }
34
+
35
+ it 'should hydrate embedded resources from the triple store' do
36
+ f = dogg.fleas.first
37
+ expect(f.name).to eq(flea.name)
38
+ end
39
+ end
40
+
41
+ context 'retrieved as part of a resource collection' do
42
+ let(:dogg) { Dog.all.resources.first }
43
+
44
+ it 'should hydrate embedded resources from the triple store' do
45
+ f = dogg.fleas.first
46
+ expect(f.name).to eq(flea.name)
47
+ end
48
+ end
49
+ end
50
+
51
+
52
+ describe 'delete' do
53
+ before do
54
+ dog.fleas << flea
55
+ end
56
+
57
+ it 'should remove all trace of the resource' do
58
+ dog.fleas.delete(flea)
59
+ expect(dog.fleas.include?(flea)).to eq(false)
60
+ end
61
+ end
62
+ end
@@ -30,9 +30,7 @@ describe Tripod::Repository do
30
30
 
31
31
  context 'graph_uri set on object' do
32
32
  it 'populates the object with triples, restricted to the graph_uri' do
33
- Tripod::SparqlClient::Query.should_receive(:query).with(
34
- "CONSTRUCT {<#{person.uri}> ?p ?o} WHERE { GRAPH <#{person.graph_uri}> { <#{person.uri}> ?p ?o } }",
35
- "application/n-triples").and_call_original
33
+ Tripod::SparqlClient::Query.should_receive(:query).with(Person.all_triples_query(person.uri, graph_uri: person.graph_uri), 'application/n-triples').and_call_original
36
34
  person.hydrate!
37
35
  person.repository.should_not be_empty
38
36
  end
@@ -40,9 +38,7 @@ describe Tripod::Repository do
40
38
 
41
39
  context 'graph_uri not set on object' do
42
40
  it 'populates the object with triples, not to a graph' do
43
- Tripod::SparqlClient::Query.should_receive(:query).with(
44
- "CONSTRUCT {<#{graphless_resource.uri}> ?p ?o} WHERE { GRAPH ?g { <#{graphless_resource.uri}> ?p ?o } }",
45
- "application/n-triples").and_call_original
41
+ Tripod::SparqlClient::Query.should_receive(:query).with(Person.all_triples_query(person.uri), 'application/n-triples').and_call_original
46
42
  graphless_resource.hydrate!
47
43
  graphless_resource.repository.should_not be_empty
48
44
  end
@@ -73,4 +69,4 @@ describe Tripod::Repository do
73
69
  end
74
70
 
75
71
 
76
- end
72
+ end
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.10.8
4
+ version: 0.10.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Roberts
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-01-26 00:00:00.000000000 Z
13
+ date: 2015-01-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -213,6 +213,7 @@ files:
213
213
  - lib/tripod/components.rb
214
214
  - lib/tripod/criteria.rb
215
215
  - lib/tripod/criteria/execution.rb
216
+ - lib/tripod/dirty.rb
216
217
  - lib/tripod/eager_loading.rb
217
218
  - lib/tripod/embedded_resource.rb
218
219
  - lib/tripod/embeds.rb
@@ -261,6 +262,7 @@ files:
261
262
  - spec/tripod/attributes_spec.rb
262
263
  - spec/tripod/criteria_execution_spec.rb
263
264
  - spec/tripod/criteria_spec.rb
265
+ - spec/tripod/dirty_spec.rb
264
266
  - spec/tripod/eager_loading_spec.rb
265
267
  - spec/tripod/embedded_resource_spec.rb
266
268
  - spec/tripod/embeds_spec.rb
@@ -311,6 +313,7 @@ test_files:
311
313
  - spec/tripod/attributes_spec.rb
312
314
  - spec/tripod/criteria_execution_spec.rb
313
315
  - spec/tripod/criteria_spec.rb
316
+ - spec/tripod/dirty_spec.rb
314
317
  - spec/tripod/eager_loading_spec.rb
315
318
  - spec/tripod/embedded_resource_spec.rb
316
319
  - spec/tripod/embeds_spec.rb