Skip to content

Commit 0ba31a4

Browse files
committed
Those damn CR+LF line endings...
1 parent 5f04750 commit 0ba31a4

13 files changed

+1425
-1425
lines changed

README.md

+61-61
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
1-
# redis-rdb #
2-
3-
This library provides a set of modules and classes that make it easy to handle binary
4-
database dumps generated by [Redis](http://redis.io) (.rdb files) in Ruby.
5-
6-
Currently redis-rdb allows developers to read .rdb files in a streamable flashion
7-
with `RDB::Reader` by providing a set of callbacks. Database objects can optionally
8-
be filtered by database / key / type using custom filters.
9-
10-
```ruby
11-
require 'rdb'
12-
13-
class MyCallbacks
14-
include RDB::ReaderCallbacks
15-
16-
KEY_SELECTOR = Regexp.compile(/user:\d+/)
17-
18-
def accept_object?(state)
19-
state.database == 15 && KEY_SELECTOR.match(state.key)
20-
end
21-
22-
def set(key, value, state)
23-
puts "SET \"#{key}\" \"#{value}\""
24-
end
25-
end
26-
27-
RDB::Reader.read_file('dump.rdb', callbacks: MyCallbacks.new)
28-
```
29-
30-
For more details about the supported callbacks you can take a look at the source code in
31-
[lib/rdb/callbacks.rb](https://github.com/nrk/redis-rdb/blob/master/lib/rdb/callbacks.rb).
32-
33-
## Additional notes and credits ##
34-
35-
Right now there is still no documentation about the binary format of .rdb files so we used
36-
the code in [rdb.c](https://github.com/antirez/redis/blob/unstable/src/rdb.c) as the reference
37-
implementation. Credit goes also to [sripathikrishnan](https://github.com/sripathikrishnan),
38-
his work on the [redis-rdb-tools](https://github.com/sripathikrishnan/redis-rdb-tools) Python
39-
library was quite an inspiration for the final design of `RDB::Reader` and we also reused the
40-
.rdb files shipped with his project for testing.
41-
42-
## Dependencies ##
43-
- Ruby >= 1.9.0
44-
45-
## Links ##
46-
47-
### Project ###
48-
- [Source code](https://github.com/nrk/redis-rdb/)
49-
- [Issue tracker](https://github.com/nrk/redis-rdb/issues)
50-
51-
### Related ###
52-
- [Redis](http://redis.io/)
53-
- [redis-rdb-tools](https://github.com/sripathikrishnan/redis-rdb-tools) (Python)
54-
55-
## Author ##
56-
57-
- [Daniele Alessandri](mailto:[email protected]) ([twitter](http://twitter.com/JoL1hAHN))
58-
59-
## License ##
60-
61-
The code for redis-rdb is distributed under the terms of the MIT license (see LICENSE).
1+
# redis-rdb #
2+
3+
This library provides a set of modules and classes that make it easy to handle binary
4+
database dumps generated by [Redis](http://redis.io) (.rdb files) in Ruby.
5+
6+
Currently redis-rdb allows developers to read .rdb files in a streamable flashion
7+
with `RDB::Reader` by providing a set of callbacks. Database objects can optionally
8+
be filtered by database / key / type using custom filters.
9+
10+
```ruby
11+
require 'rdb'
12+
13+
class MyCallbacks
14+
include RDB::ReaderCallbacks
15+
16+
KEY_SELECTOR = Regexp.compile(/user:\d+/)
17+
18+
def accept_object?(state)
19+
state.database == 15 && KEY_SELECTOR.match(state.key)
20+
end
21+
22+
def set(key, value, state)
23+
puts "SET \"#{key}\" \"#{value}\""
24+
end
25+
end
26+
27+
RDB::Reader.read_file('dump.rdb', callbacks: MyCallbacks.new)
28+
```
29+
30+
For more details about the supported callbacks you can take a look at the source code in
31+
[lib/rdb/callbacks.rb](https://github.com/nrk/redis-rdb/blob/master/lib/rdb/callbacks.rb).
32+
33+
## Additional notes and credits ##
34+
35+
Right now there is still no documentation about the binary format of .rdb files so we used
36+
the code in [rdb.c](https://github.com/antirez/redis/blob/unstable/src/rdb.c) as the reference
37+
implementation. Credit goes also to [sripathikrishnan](https://github.com/sripathikrishnan),
38+
his work on the [redis-rdb-tools](https://github.com/sripathikrishnan/redis-rdb-tools) Python
39+
library was quite an inspiration for the final design of `RDB::Reader` and we also reused the
40+
.rdb files shipped with his project for testing.
41+
42+
## Dependencies ##
43+
- Ruby >= 1.9.0
44+
45+
## Links ##
46+
47+
### Project ###
48+
- [Source code](https://github.com/nrk/redis-rdb/)
49+
- [Issue tracker](https://github.com/nrk/redis-rdb/issues)
50+
51+
### Related ###
52+
- [Redis](http://redis.io/)
53+
- [redis-rdb-tools](https://github.com/sripathikrishnan/redis-rdb-tools) (Python)
54+
55+
## Author ##
56+
57+
- [Daniele Alessandri](mailto:[email protected]) ([twitter](http://twitter.com/JoL1hAHN))
58+
59+
## License ##
60+
61+
The code for redis-rdb is distributed under the terms of the MIT license (see LICENSE).

Rakefile

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
require 'cutest'
2-
3-
task :test do
4-
Cutest.run(Dir['test/test_*.rb'])
5-
end
6-
7-
task :default => :test
1+
require 'cutest'
2+
3+
task :test do
4+
Cutest.run(Dir['test/test_*.rb'])
5+
end
6+
7+
task :default => :test

examples/read_rdb.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
$:.unshift File.expand_path('../lib', File.dirname(__FILE__))
2-
3-
require 'rdb'
4-
5-
RDB::Reader.read_file('test/rdb/multiple_databases.rdb', callbacks: RDB::DebugCallbacks.new)
1+
$:.unshift File.expand_path('../lib', File.dirname(__FILE__))
2+
3+
require 'rdb'
4+
5+
RDB::Reader.read_file('test/rdb/multiple_databases.rdb', callbacks: RDB::DebugCallbacks.new)

lib/rdb.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
require 'stringio'
2-
require 'rdb/version'
3-
require 'rdb/constants'
4-
require 'rdb/errors'
5-
require 'rdb/lzf'
6-
require 'rdb/callbacks'
7-
require 'rdb/reader-state'
8-
require 'rdb/reader'
1+
require 'stringio'
2+
require 'rdb/version'
3+
require 'rdb/constants'
4+
require 'rdb/errors'
5+
require 'rdb/lzf'
6+
require 'rdb/callbacks'
7+
require 'rdb/reader-state'
8+
require 'rdb/reader'

0 commit comments

Comments
 (0)