active-triples 0.8.0 → 0.8.1

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: 134e560560581d9eb910f02fb4acfe1796a49e8c
4
- data.tar.gz: 06111e25af63727d289515c461f5d648bdfbf9ff
3
+ metadata.gz: 4928b254048d00cd2f52d050aea13407ba362425
4
+ data.tar.gz: 11c44cb9efe80bfc6dd09f6e33a6aee0d288666d
5
5
  SHA512:
6
- metadata.gz: 12bcd4d12842619f883cc042052f53e1a89bca2b6bf78f926318ebe7a6072ee3d9116ebfc56c52deceb7401694a2d3fdaaadbea7753f5348aa5e5c44e8e469c5
7
- data.tar.gz: 61a6ee297b43bd909bf89f5a91ea815fdcef3dced6a8863a4f2af7b7f989ad77bc187e5140a4ea6001876d943ea8a011a126febdfa1ae97fe499746ba94c2fc1
6
+ metadata.gz: 665fe27ad696dda89568310375194243760cfa22d8761bc10fc40eca9dcd39a81352c840e283e3501c4eb2504bdb1d663efa96138478660f5f9ab3454d3e874f
7
+ data.tar.gz: ec21704f5faf6aadf57ec45c95bfb64113ef772f3fd48c8e7e26f4ddfa9dd08dfe786cd2039743c7b742d9cf24b600141f5e7dcfd1e1579f2d57fc181e625d8b
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.8.1
2
+ -----
3
+
4
+ - Reverts changing `Relation`'s delete methods to remove all values until we
5
+ have a clear path forward for those depending on that functionality.
6
+
1
7
  0.8.0
2
8
  -----
3
9
  - Adds RDF.rb interfaces to `RDFSource`, improving interoperability
@@ -55,13 +55,11 @@ module ActiveTriples
55
55
  parent.persist! if parent.persistence_strategy.is_a? ParentStrategy
56
56
  end
57
57
 
58
- ##
59
- # Deletes the values for this relation. This removes all triples matching
60
- # the basic graph pattern [:rdf_subject :predicate ?object] from the parent
61
- # Enumerable.
62
58
  def empty_property
63
59
  parent.query([rdf_subject, predicate, nil]).each_statement do |statement|
64
- parent.delete(statement)
60
+ if !uri_class(statement.object) || uri_class(statement.object) == class_for_property
61
+ parent.delete(statement)
62
+ end
65
63
  end
66
64
  end
67
65
 
@@ -1,3 +1,3 @@
1
1
  module ActiveTriples
2
- VERSION = "0.8.0".freeze
2
+ VERSION = "0.8.1".freeze
3
3
  end
@@ -146,44 +146,6 @@ describe ActiveTriples::RDFSource do
146
146
  it 'sets a value'
147
147
  end
148
148
 
149
- describe "inheritance" do
150
- before do
151
- class PrincipalResource
152
- include ActiveTriples::RDFSource
153
-
154
- configure type: RDF::FOAF.Agent
155
- property :name, predicate: RDF::FOAF.name
156
- end
157
-
158
- class UserSource < PrincipalResource
159
- configure type: RDF::FOAF.Person
160
- end
161
-
162
- class DummySource
163
- include ActiveTriples::RDFSource
164
-
165
- property :creator, predicate: RDF::DC.creator
166
- end
167
- end
168
-
169
- after do
170
- Object.send(:remove_const, :PrincipalResource)
171
- Object.send(:remove_const, :UserSource)
172
- Object.send(:remove_const, :DummySource)
173
- end
174
-
175
- let(:dummy) { DummySource.new }
176
- let(:bob) { UserSource.new.tap {|u| u.name = "bob"} }
177
- let(:sally) { UserSource.new.tap {|u| u.name = "sally"} }
178
-
179
- it "should replace values" do
180
- dummy.creator = bob
181
- expect(dummy.creator).to eq [bob]
182
- dummy.creator = sally
183
- expect(dummy.creator).to eq [sally]
184
- end
185
- end
186
-
187
149
  describe 'validation' do
188
150
  it { is_expected.to be_valid }
189
151
 
@@ -3,10 +3,6 @@ require 'rdf/isomorphic'
3
3
 
4
4
  describe ActiveTriples::Relation do
5
5
 
6
- subject do
7
- described_class.new(double("parent", reflections: []), double("value args"))
8
- end
9
-
10
6
  describe "#rdf_subject" do
11
7
  let(:parent_resource) { double("parent resource", reflections: {}) }
12
8
 
@@ -45,51 +41,39 @@ describe ActiveTriples::Relation do
45
41
  end
46
42
 
47
43
  describe "#valid_datatype?" do
48
- before do
49
- allow(subject.parent).to receive(:rdf_subject) { "parent subject" }
50
- end
51
-
44
+ subject { described_class.new(double("parent", reflections: []), "value" ) }
45
+ before { allow(subject.parent).to receive(:rdf_subject) { "parent subject" } }
52
46
  context "the value is not a Resource" do
53
47
  it "should be true if value is a String" do
54
48
  expect(subject.send(:valid_datatype?, "foo")).to be true
55
49
  end
56
-
57
50
  it "should be true if value is a Symbol" do
58
51
  expect(subject.send(:valid_datatype?, :foo)).to be true
59
52
  end
60
-
61
53
  it "should be true if the value is a Numeric" do
62
54
  expect(subject.send(:valid_datatype?, 1)).to be true
63
55
  expect(subject.send(:valid_datatype?, 0.1)).to be true
64
56
  end
65
-
66
57
  it "should be true if the value is a Date" do
67
58
  expect(subject.send(:valid_datatype?, Date.today)).to be true
68
59
  end
69
-
70
60
  it "should be true if the value is a Time" do
71
61
  expect(subject.send(:valid_datatype?, Time.now)).to be true
72
62
  end
73
-
74
63
  it "should be true if the value is a boolean" do
75
64
  expect(subject.send(:valid_datatype?, false)).to be true
76
65
  expect(subject.send(:valid_datatype?, true)).to be true
77
66
  end
78
67
  end
79
-
80
68
  context "the value is a Resource" do
81
69
  after { Object.send(:remove_const, :DummyResource) }
82
-
83
70
  let(:resource) { DummyResource.new }
84
-
85
71
  context "and the resource class does not include RDF::Isomorphic" do
86
72
  before { class DummyResource; include ActiveTriples::RDFSource; end }
87
-
88
73
  it "should be false" do
89
74
  expect(subject.send(:valid_datatype?, resource)).to be false
90
75
  end
91
76
  end
92
-
93
77
  context "and the resource class includes RDF:Isomorphic" do
94
78
  before do
95
79
  class DummyResource
@@ -97,12 +81,10 @@ describe ActiveTriples::Relation do
97
81
  include RDF::Isomorphic
98
82
  end
99
83
  end
100
-
101
84
  it "should be false" do
102
85
  expect(subject.send(:valid_datatype?, resource)).to be false
103
86
  end
104
87
  end
105
-
106
88
  context "and the resource class includes RDF::Isomorphic and aliases :== to :isomorphic_with?" do
107
89
  before do
108
90
  class DummyResource
@@ -111,7 +93,6 @@ describe ActiveTriples::Relation do
111
93
  alias_method :==, :isomorphic_with?
112
94
  end
113
95
  end
114
-
115
96
  it "should be false" do
116
97
  expect(subject.send(:valid_datatype?, resource)).to be false
117
98
  end
@@ -119,32 +100,4 @@ describe ActiveTriples::Relation do
119
100
  end
120
101
  end
121
102
 
122
- describe '#empty_property' do
123
-
124
- before { resource << RDF::Statement(resource, property, 'value') }
125
-
126
- subject { described_class.new(resource, value_args) }
127
- let(:resource) { ActiveTriples::Resource.new }
128
- let(:property) { RDF::URI.new('http://example.com/moomin') }
129
-
130
- let(:value_args) do
131
- double('value args',
132
- length: 1,
133
- first: 'first',
134
- last: property)
135
- end
136
-
137
- it 'deletes values from property' do
138
- expect { subject.empty_property }.to change { subject.result }
139
- .from(['value']).to([])
140
- end
141
-
142
- it 'deletes multiple values from property' do
143
- values = [Date.today, 'value2', RDF::Node.new, true]
144
- resource.set_value(property, values)
145
-
146
- expect { subject.empty_property }.to change { subject.result }
147
- .from(values).to([])
148
- end
149
- end
150
103
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-triples
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Johnson
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
281
  version: '0'
282
282
  requirements: []
283
283
  rubyforge_project:
284
- rubygems_version: 2.2.1
284
+ rubygems_version: 2.4.5
285
285
  signing_key:
286
286
  specification_version: 4
287
287
  summary: RDF graphs in ActiveModel wrappers.