active_record_survey 0.1.41 → 0.1.42

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: bb7390dcd049f2c36e3191239ddbfeb9200e63ca
4
- data.tar.gz: 97813d862d55b74742856764b515b5ba2cd2c928
3
+ metadata.gz: dbe716976900fa899ddff1304f5f0af1add82160
4
+ data.tar.gz: 9784ddb5461e775944ab103605ff4bdf5b72acfa
5
5
  SHA512:
6
- metadata.gz: f6fb676410c50d5834894017e6084e23514f5ba6c23e8d16f8a1735880152f6c1e88af0fa3c08d3fa277b672d177758bf4bc6dfd0e4377af6f0c162f406f81a8
7
- data.tar.gz: ae865a6cf14b316809bffc10b5a47dd2259f862be3c7cf8ce7095acfb2385fabbc848bd2fcbdda5b4b900866790db3ff9bbc15d3319fc96389ae4963ee92ea5a
6
+ metadata.gz: cb1f07e7e049696ffbe105476b15ce24e22f3479ebc587c342e506fc7ee68ee01a99f14a99949911f33ed80f826d34428af27e2af2ca8af3a7cb405e19a716ff
7
+ data.tar.gz: 38ff22b1e31e62a23870e35db8be76a0ca2439ff4c183bdf82752f64b0cd65a647484e91d346e89d0b7249292c24469520bfc9267277b80778ba0e11368f4695
@@ -24,6 +24,18 @@ module ActiveRecordSurvey
24
24
  end
25
25
  end
26
26
 
27
+ # All the connective edges
28
+ def edges
29
+ self.node_maps.select { |i| !i.marked_for_destruction? }.select { |i|
30
+ i.node && i.parent
31
+ }.collect { |i|
32
+ {
33
+ :source => i.parent.node.id,
34
+ :target => i.node.id,
35
+ }
36
+ }.uniq
37
+ end
38
+
27
39
  def as_map(*args)
28
40
  options = args.extract_options!
29
41
  options[:node_maps] ||= self.node_maps
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordSurvey
2
- VERSION = "0.1.41"
2
+ VERSION = "0.1.42"
3
3
  end
@@ -47,6 +47,15 @@ describe ActiveRecordSurvey::Survey, :survey_spec => true do
47
47
  @survey.save
48
48
  end
49
49
 
50
+ describe '#edges', :focus => true do
51
+ it 'should return an array of all the connective edges' do
52
+ edges = @survey.edges
53
+
54
+ expect(edges.length).to eq(16)
55
+ expect(edges).to eq([{:source=>1, :target=>2}, {:source=>1, :target=>12}, {:source=>1, :target=>13}, {:source=>2, :target=>3}, {:source=>3, :target=>4}, {:source=>3, :target=>8}, {:source=>12, :target=>9}, {:source=>9, :target=>10}, {:source=>9, :target=>11}, {:source=>13, :target=>5}, {:source=>5, :target=>6}, {:source=>5, :target=>7}, {:source=>4, :target=>5}, {:source=>8, :target=>9}, {:source=>10, :target=>5}, {:source=>11, :target=>5}])
56
+ end
57
+ end
58
+
50
59
  describe '#questions' do
51
60
  it 'should return all the questions' do
52
61
  expect(@survey.questions.length).to be (4)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_survey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.41
4
+ version: 0.1.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - Butch Marshall