flockdb 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/LICENSE +13 -0
- data/README.md +60 -0
- data/Rakefile +34 -0
- data/VERSION +1 -0
- data/flockdb.gemspec +82 -0
- data/lib/flock.rb +40 -0
- data/lib/flock/client.rb +124 -0
- data/lib/flock/mixins/sizeable.rb +17 -0
- data/lib/flock/mock_service.rb +178 -0
- data/lib/flock/operation.rb +116 -0
- data/lib/flock/operations/complex_operation.rb +15 -0
- data/lib/flock/operations/execute_operation.rb +14 -0
- data/lib/flock/operations/execute_operations.rb +35 -0
- data/lib/flock/operations/query_term.rb +25 -0
- data/lib/flock/operations/select_operation.rb +51 -0
- data/lib/flock/operations/simple_operation.rb +16 -0
- data/lib/flock/service.rb +16 -0
- data/lib/flock/thrift/edges.rb +1445 -0
- data/lib/flock/thrift/edges_types.rb +210 -0
- data/lib/flock/thrift/flock_constants.rb +12 -0
- data/lib/flock/thrift/flock_types.rb +168 -0
- data/lib/flock/thrift/shards.rb +1598 -0
- data/lib/flockdb.rb +1 -0
- data/spec/flock_spec.rb +102 -0
- data/spec/mock_service_spec.rb +27 -0
- data/spec/spec.opts +7 -0
- data/spec/spec_helper.rb +19 -0
- metadata +145 -0
data/lib/flockdb.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'flock'
|
data/spec/flock_spec.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Flock do
|
4
|
+
attr_accessor :flock
|
5
|
+
|
6
|
+
before do
|
7
|
+
@flock = new_flock_client
|
8
|
+
|
9
|
+
flock.add(1,1,1)
|
10
|
+
flock.add(1,1,2)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'add' do
|
14
|
+
it 'works' do
|
15
|
+
flock.contains(1,1,1).should == true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'remove' do
|
20
|
+
it 'works' do
|
21
|
+
flock.remove(1,1,1)
|
22
|
+
flock.contains(1,1,1).should == false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'count' do
|
27
|
+
it 'works' do
|
28
|
+
flock.count(1,1,nil).should == 2
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'select' do
|
33
|
+
attr_accessor :query
|
34
|
+
|
35
|
+
before do
|
36
|
+
@query = flock.select(1,1,nil)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "supports old style of select" do
|
40
|
+
flock.select([1,1,nil]).to_a.sort.should == [1,2]
|
41
|
+
end
|
42
|
+
|
43
|
+
it "supports selecting multiple nodes" do
|
44
|
+
flock.select(1,1,[1,2]).to_a.sort.should == [1,2]
|
45
|
+
end
|
46
|
+
|
47
|
+
it "turns nodes into ints if possible" do
|
48
|
+
user = mock!.to_i { 1 }.subject
|
49
|
+
flock.select(user, 1, nil).to_a.sort.should == [1,2]
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'to_a' do
|
53
|
+
it 'works' do
|
54
|
+
flock.select(1,1,nil).to_a.sort.should == [1,2]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'paginate' do
|
59
|
+
it 'works' do
|
60
|
+
page, next_cursor, prev_cursor = query.paginate(1).unapply
|
61
|
+
|
62
|
+
page.should == [1]
|
63
|
+
prev_cursor.should == Flock::CursorEnd
|
64
|
+
next_cursor.should_not == Flock::CursorEnd
|
65
|
+
|
66
|
+
page, next_cursor, prev_cursor = query.paginate(1, next_cursor).unapply
|
67
|
+
|
68
|
+
page.should == [2]
|
69
|
+
prev_cursor.should == Flock::CursorStart
|
70
|
+
next_cursor.should == Flock::CursorEnd
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'next_page' do
|
74
|
+
it 'works' do
|
75
|
+
results = query.paginate(1)
|
76
|
+
|
77
|
+
results.next_page?.should == true
|
78
|
+
results.next_page.should == [1]
|
79
|
+
|
80
|
+
results.next_page?.should == true
|
81
|
+
results.next_page.should == [2]
|
82
|
+
|
83
|
+
results.next_page?.should == false
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe 'next' do
|
88
|
+
it 'works' do
|
89
|
+
results = query.paginate(2)
|
90
|
+
|
91
|
+
results.next?.should == true
|
92
|
+
results.next.should == 1
|
93
|
+
|
94
|
+
results.next?.should == true
|
95
|
+
results.next.should == 2
|
96
|
+
|
97
|
+
results.next?.should == false
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Flock::MockService do
|
4
|
+
describe 'Class Methods' do
|
5
|
+
|
6
|
+
|
7
|
+
describe 'inspect'
|
8
|
+
describe 'execute'
|
9
|
+
describe 'select'
|
10
|
+
describe 'count'
|
11
|
+
describe 'counts_of_sources_for'
|
12
|
+
|
13
|
+
# private methods
|
14
|
+
describe 'select_query'
|
15
|
+
describe 'graphs'
|
16
|
+
describe 'iterate'
|
17
|
+
describe 'empty_result'
|
18
|
+
describe 'sources'
|
19
|
+
describe 'destinations'
|
20
|
+
describe 'archived_sources'
|
21
|
+
describe 'archived_destinations'
|
22
|
+
|
23
|
+
# deprecated public methods
|
24
|
+
describe 'offset_sources_for'
|
25
|
+
describe 'offset_destinations_for'
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
|
4
|
+
spec_dir = File.dirname(__FILE__)
|
5
|
+
$: << File.expand_path("#{spec_dir}/../lib")
|
6
|
+
|
7
|
+
require 'flock'
|
8
|
+
require 'flock/mock_service'
|
9
|
+
|
10
|
+
Spec::Runner.configure do |config|
|
11
|
+
config.mock_with :rr
|
12
|
+
config.before do
|
13
|
+
Flock::MockService.clear
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def new_flock_client
|
18
|
+
Flock.new(Flock::MockService)
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flockdb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Matt Freels
|
13
|
+
- Rael Dornfest
|
14
|
+
- Nick Kallen
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2010-04-19 00:00:00 -07:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: thrift
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 2
|
32
|
+
- 0
|
33
|
+
version: 0.2.0
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: thrift_client
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
- 4
|
46
|
+
- 1
|
47
|
+
version: 0.4.1
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rspec
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rr
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
72
|
+
type: :development
|
73
|
+
version_requirements: *id004
|
74
|
+
description: Get your flock on in Ruby.
|
75
|
+
email: freels@twitter.com
|
76
|
+
executables: []
|
77
|
+
|
78
|
+
extensions: []
|
79
|
+
|
80
|
+
extra_rdoc_files:
|
81
|
+
- LICENSE
|
82
|
+
- README.md
|
83
|
+
files:
|
84
|
+
- .gitignore
|
85
|
+
- LICENSE
|
86
|
+
- README.md
|
87
|
+
- Rakefile
|
88
|
+
- VERSION
|
89
|
+
- flockdb.gemspec
|
90
|
+
- lib/flock.rb
|
91
|
+
- lib/flock/client.rb
|
92
|
+
- lib/flock/mixins/sizeable.rb
|
93
|
+
- lib/flock/mock_service.rb
|
94
|
+
- lib/flock/operation.rb
|
95
|
+
- lib/flock/operations/complex_operation.rb
|
96
|
+
- lib/flock/operations/execute_operation.rb
|
97
|
+
- lib/flock/operations/execute_operations.rb
|
98
|
+
- lib/flock/operations/query_term.rb
|
99
|
+
- lib/flock/operations/select_operation.rb
|
100
|
+
- lib/flock/operations/simple_operation.rb
|
101
|
+
- lib/flock/service.rb
|
102
|
+
- lib/flock/thrift/edges.rb
|
103
|
+
- lib/flock/thrift/edges_types.rb
|
104
|
+
- lib/flock/thrift/flock_constants.rb
|
105
|
+
- lib/flock/thrift/flock_types.rb
|
106
|
+
- lib/flock/thrift/shards.rb
|
107
|
+
- lib/flockdb.rb
|
108
|
+
- spec/flock_spec.rb
|
109
|
+
- spec/mock_service_spec.rb
|
110
|
+
- spec/spec.opts
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
has_rdoc: true
|
113
|
+
homepage: http://twitter.com
|
114
|
+
licenses: []
|
115
|
+
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options:
|
118
|
+
- --charset=UTF-8
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
version: "0"
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
segments:
|
133
|
+
- 0
|
134
|
+
version: "0"
|
135
|
+
requirements: []
|
136
|
+
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 1.3.6
|
139
|
+
signing_key:
|
140
|
+
specification_version: 3
|
141
|
+
summary: Ruby Flock client
|
142
|
+
test_files:
|
143
|
+
- spec/flock_spec.rb
|
144
|
+
- spec/mock_service_spec.rb
|
145
|
+
- spec/spec_helper.rb
|