ashikawa-core 0.13.0 → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -7
- data/CHANGELOG.md +5 -0
- data/lib/ashikawa-core/collection.rb +4 -3
- data/lib/ashikawa-core/edge_collection.rb +3 -2
- data/lib/ashikawa-core/version.rb +1 -1
- data/lib/ashikawa-core/vertex_collection.rb +10 -0
- data/spec/unit/collection_spec.rb +13 -4
- data/spec/unit/edge_collection_spec.rb +17 -5
- data/spec/unit/vertex_collection_spec.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5174468b7c49a72458d5d91bf9939caf77023f2c
|
4
|
+
data.tar.gz: dc22ceaaacccfd9133638c4707eac3581b71e56d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 690e9a24ebd4757b14992231d2601b314a9c27c3e7dcb85ceee47b571252cfdb9dcdc30f3b001b17b8ec81a94c25f807bf0acafc86418072bf4644753ecab9bf
|
7
|
+
data.tar.gz: 458b6482db0c04a39b3616901765991f398801ea0db65978b921d439be91603c70f728b566ccaf81c5902394bbd2c75c7a6f8aee880f7b78a26b510209e4c61c
|
data/.travis.yml
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
language: ruby
|
2
2
|
before_script:
|
3
|
-
|
3
|
+
- "./spec/setup/arangodb.sh"
|
4
4
|
rvm:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
- 1.9.3
|
6
|
+
- 2.0.0
|
7
|
+
- 2.1.2
|
8
|
+
- jruby-1.7.12
|
9
9
|
env:
|
10
|
-
|
11
|
-
script:
|
10
|
+
- ARANGODB_DISABLE_AUTHENTIFICATION=false VERSION=2.2
|
11
|
+
script: bundle exec rake ci
|
12
12
|
addons:
|
13
13
|
code_climate:
|
14
14
|
repo_token: 4d49e70568a106875f85f2918698df75118b4a83af20ad57317b10f5fc40d5e0
|
15
|
+
notifications:
|
16
|
+
slack:
|
17
|
+
secure: qx+GdQL63v5xCKi9m+GcEoX8XER9xbRUw7lJVn1CI1tcKLeTerEYoPknUoroCj9IpR3ebXa666L51pMaU0ZCIazefr7YPDTm3gdAIDcPyEUWr2ym2AONzBDpNAQE8o9AF3FAiFI6oZ7VRTxd1KcmvZAwONepyQSZ7tsUC08JfPY=
|
data/CHANGELOG.md
CHANGED
@@ -392,7 +392,7 @@ module Ashikawa
|
|
392
392
|
def create_document(attributes)
|
393
393
|
raise "Can't create a document in an edge collection" if @content_type == :edge
|
394
394
|
response = send_request_for_content(post: attributes)
|
395
|
-
|
395
|
+
build_content_class(response, attributes)
|
396
396
|
end
|
397
397
|
|
398
398
|
# Create a new edge between two documents with certain attributes
|
@@ -492,10 +492,11 @@ module Ashikawa
|
|
492
492
|
# Builds an instance for the content class
|
493
493
|
#
|
494
494
|
# @param [Hash] data The raw data to be used to instatiate the class
|
495
|
+
# @param [Hash] additional_attributes Initial attributes to be passed to the underlying content class
|
495
496
|
# @return [Document] The instatiated document
|
496
497
|
# @api private
|
497
|
-
def build_content_class(data)
|
498
|
-
@content_class.new(@database, data)
|
498
|
+
def build_content_class(data, additional_attributes = {})
|
499
|
+
@content_class.new(@database, data, additional_attributes)
|
499
500
|
end
|
500
501
|
|
501
502
|
private
|
@@ -70,10 +70,11 @@ module Ashikawa
|
|
70
70
|
# Builds a new edge object and passes the current graph to it
|
71
71
|
#
|
72
72
|
# @param [Hash] data The raw data to be used to instatiate the class
|
73
|
+
# @param [Hash] additional_atttributes Initial attributes to be passed to the Edge
|
73
74
|
# @return [Edge] The instatiated edge
|
74
75
|
# @api private
|
75
|
-
def build_content_class(data)
|
76
|
-
Edge.new(@database, data, graph: graph)
|
76
|
+
def build_content_class(data, additional_atttributes = {})
|
77
|
+
Edge.new(@database, data, additional_atttributes.merge(graph: graph))
|
77
78
|
end
|
78
79
|
|
79
80
|
private
|
@@ -30,6 +30,16 @@ module Ashikawa
|
|
30
30
|
|
31
31
|
raise CollectionNotInGraphException unless @graph.has_vertex_collection?(name)
|
32
32
|
end
|
33
|
+
|
34
|
+
# Builds a new document object and passes the current graph to it
|
35
|
+
#
|
36
|
+
# @param [Hash] data The raw data to be used to instatiate the class
|
37
|
+
# @param [Hash] additional_atttributes Initial attributes to be passed to the document
|
38
|
+
# @return [Edge] The instatiated edge
|
39
|
+
# @api private
|
40
|
+
def build_content_class(data, additional_atttributes = {})
|
41
|
+
Document.new(@database, data, additional_atttributes.merge(graph: graph))
|
42
|
+
end
|
33
43
|
end
|
34
44
|
end
|
35
45
|
end
|
@@ -236,12 +236,21 @@ describe Ashikawa::Core::Collection do
|
|
236
236
|
its(:content_type) { should be(:document) }
|
237
237
|
|
238
238
|
context 'building the content classes' do
|
239
|
+
let(:additional_attributes) { double('Hash') }
|
240
|
+
|
239
241
|
it 'should build documents' do
|
240
242
|
expect(Ashikawa::Core::Document).to receive(:new)
|
241
|
-
.with(database, raw_document)
|
243
|
+
.with(database, raw_document, {})
|
242
244
|
|
243
245
|
subject.build_content_class(raw_document)
|
244
246
|
end
|
247
|
+
|
248
|
+
it 'should accept additional attributes to be passed to the content class' do
|
249
|
+
expect(Ashikawa::Core::Document).to receive(:new)
|
250
|
+
.with(database, raw_document, additional_attributes)
|
251
|
+
|
252
|
+
subject.build_content_class(raw_document, additional_attributes)
|
253
|
+
end
|
245
254
|
end
|
246
255
|
|
247
256
|
context 'when using the key' do
|
@@ -301,8 +310,8 @@ describe Ashikawa::Core::Collection do
|
|
301
310
|
allow(database).to receive(:send_request)
|
302
311
|
.with('document?collection=60768679', post: raw_document)
|
303
312
|
.and_return(response)
|
304
|
-
expect(
|
305
|
-
.with(
|
313
|
+
expect(subject).to receive(:build_content_class)
|
314
|
+
.with(response, raw_document)
|
306
315
|
.and_return(document)
|
307
316
|
|
308
317
|
subject.create_document(raw_document)
|
@@ -329,7 +338,7 @@ describe Ashikawa::Core::Collection do
|
|
329
338
|
context 'building the content classes' do
|
330
339
|
it 'should build documents' do
|
331
340
|
expect(Ashikawa::Core::Edge).to receive(:new)
|
332
|
-
.with(database, raw_document)
|
341
|
+
.with(database, raw_document, {})
|
333
342
|
|
334
343
|
subject.build_content_class(raw_document)
|
335
344
|
end
|
@@ -94,12 +94,24 @@ describe Ashikawa::Core::EdgeCollection do
|
|
94
94
|
subject.send(:send_request_for_this_collection, 'edge_key')
|
95
95
|
end
|
96
96
|
|
97
|
-
|
98
|
-
|
99
|
-
.with(database, raw_edge, graph: graph)
|
100
|
-
.and_return(new_edge)
|
97
|
+
context 'building edge documents' do
|
98
|
+
let(:additional_attributes) { { moar: 'data' } }
|
101
99
|
|
102
|
-
|
100
|
+
it 'should overwrite the #build_content_class to create edges with the graph attached' do
|
101
|
+
expect(Ashikawa::Core::Edge).to receive(:new)
|
102
|
+
.with(database, raw_edge, graph: graph)
|
103
|
+
.and_return(new_edge)
|
104
|
+
|
105
|
+
subject.build_content_class(raw_edge)
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should overwrite the #build_content_class to create edges with the graph attached' do
|
109
|
+
expect(Ashikawa::Core::Edge).to receive(:new)
|
110
|
+
.with(database, raw_edge, graph: graph, moar: 'data')
|
111
|
+
.and_return(new_edge)
|
112
|
+
|
113
|
+
subject.build_content_class(raw_edge, additional_attributes)
|
114
|
+
end
|
103
115
|
end
|
104
116
|
end
|
105
117
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'unit/spec_helper'
|
3
3
|
require 'ashikawa-core/vertex_collection'
|
4
4
|
require 'ashikawa-core/graph'
|
5
|
+
require 'ashikawa-core/document'
|
5
6
|
require 'ashikawa-core/database'
|
6
7
|
|
7
8
|
describe Ashikawa::Core::VertexCollection do
|
@@ -17,6 +18,8 @@ describe Ashikawa::Core::VertexCollection do
|
|
17
18
|
}
|
18
19
|
end
|
19
20
|
let(:graph) { instance_double('Ashikawa::Core::Graph') }
|
21
|
+
let(:new_document) { instance_double('Ashikawa::Core::Document') }
|
22
|
+
let(:raw_document) { double('RawDocument') }
|
20
23
|
|
21
24
|
context 'building a vertex collection' do
|
22
25
|
before do
|
@@ -44,5 +47,25 @@ describe Ashikawa::Core::VertexCollection do
|
|
44
47
|
it 'should have a reference to its graph' do
|
45
48
|
expect(subject.graph).to eq graph
|
46
49
|
end
|
50
|
+
|
51
|
+
context 'building documents' do
|
52
|
+
let(:additional_attributes) { { moar: 'data' } }
|
53
|
+
|
54
|
+
it 'should overwrite the #build_content_class to create documents with the graph attached' do
|
55
|
+
expect(Ashikawa::Core::Document).to receive(:new)
|
56
|
+
.with(database, raw_document, graph: graph)
|
57
|
+
.and_return(new_document)
|
58
|
+
|
59
|
+
subject.build_content_class(raw_document)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should overwrite the #build_content_class to create edges with the graph attached' do
|
63
|
+
expect(Ashikawa::Core::Document).to receive(:new)
|
64
|
+
.with(database, raw_document, graph: graph, moar: 'data')
|
65
|
+
.and_return(new_document)
|
66
|
+
|
67
|
+
subject.build_content_class(raw_document, additional_attributes)
|
68
|
+
end
|
69
|
+
end
|
47
70
|
end
|
48
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ashikawa-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- moonglum
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|