flockdb 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{flockdb}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Freels", "Rael Dornfest", "Nick Kallen"]
12
- s.date = %q{2010-04-19}
12
+ s.date = %q{2010-04-29}
13
13
  s.description = %q{Get your flock on in Ruby.}
14
14
  s.email = %q{freels@twitter.com}
15
15
  s.extra_rdoc_files = [
@@ -49,8 +49,9 @@ class Flock::Client
49
49
  end
50
50
 
51
51
  def contains(*query)
52
+ query = _query_args(query)
52
53
  _cache :contains, query do
53
- select(*query).any?
54
+ service.contains(*query)
54
55
  end
55
56
  end
56
57
 
@@ -51,9 +51,15 @@ module Flock
51
51
  end
52
52
  end
53
53
  when Edges::ExecuteOperationType::Remove
54
- destination_ids.each do |destination_id|
55
- backward_data_source[[destination_id, graph_id]].delete(source_id)
56
- forward_data_source[[source_id, graph_id]].delete(destination_id)
54
+ if destination_ids.nil?
55
+ backward_data_source.delete([source_id, graph_id]).to_a.each do |n|
56
+ forward_data_source[[n, graph_id]].delete(source_id)
57
+ end
58
+ else
59
+ destination_ids.each do |destination_id|
60
+ backward_data_source[[destination_id, graph_id]].delete(source_id)
61
+ forward_data_source[[source_id, graph_id]].delete(destination_id)
62
+ end
57
63
  end
58
64
  when Edges::ExecuteOperationType::Archive
59
65
  if destination_ids.nil?
@@ -63,7 +69,14 @@ module Flock
63
69
  forward_data_source[[n, graph_id]].delete(source_id)
64
70
  end
65
71
  else
66
- raise "not yet implemented"
72
+ destination_ids.each do |destination_id|
73
+ if backward_data_source[[destination_id, graph_id]].delete(source_id)
74
+ backward_archived_data_source[[destination_id, graph_id]] << source_id
75
+ end
76
+ if forward_data_source[[source_id, graph_id]].delete(destination_id)
77
+ forward_archived_data_source[[source_id, graph_id]] << destination_id
78
+ end
79
+ end
67
80
  end
68
81
  end
69
82
  end
@@ -73,15 +86,12 @@ module Flock
73
86
  iterate(select_query(select_operations), page)
74
87
  end
75
88
 
76
- def count(select_operations)
77
- select_query(select_operations).size
89
+ def contains(source_id, graph_id, destination_id)
90
+ !!destinations[[source_id, graph_id]].detect {|i| i == destination_id}
78
91
  end
79
92
 
80
- # FIXME
81
- def counts_of_sources_for(destination_ids, graph_id)
82
- destination_ids.unpack("Q*").map do |destination_id|
83
- (sources[[destination_id, graph_id]] || []).size
84
- end.pack("I*")
93
+ def count(select_operations)
94
+ select_query(select_operations).size
85
95
  end
86
96
 
87
97
  private
@@ -164,15 +174,5 @@ module Flock
164
174
  h[k] = []
165
175
  end
166
176
  end
167
-
168
- # deprecated
169
- public
170
- def offset_sources_for(destination_id, graph_id, offset, count)
171
- (sources[[destination_id, graph_id]].slice(offset, count) || []).pack("Q*")
172
- end
173
-
174
- def offset_destinations_for(source_id, graph_id, offset, count)
175
- (destinations[[source_id, graph_id]].slice(offset, count) || []).pack("Q*")
176
- end
177
177
  end
178
178
  end
@@ -8,7 +8,6 @@ describe Flock::MockService do
8
8
  describe 'execute'
9
9
  describe 'select'
10
10
  describe 'count'
11
- describe 'counts_of_sources_for'
12
11
 
13
12
  # private methods
14
13
  describe 'select_query'
@@ -19,9 +18,5 @@ describe Flock::MockService do
19
18
  describe 'destinations'
20
19
  describe 'archived_sources'
21
20
  describe 'archived_destinations'
22
-
23
- # deprecated public methods
24
- describe 'offset_sources_for'
25
- describe 'offset_destinations_for'
26
21
  end
27
22
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matt Freels
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-04-19 00:00:00 -07:00
19
+ date: 2010-04-29 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency