redisk 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +23 -0
- data/LICENSE +20 -0
- data/README.rdoc +56 -0
- data/Rakefile +49 -0
- data/lib/redisk/helper.rb +13 -0
- data/lib/redisk/io.rb +867 -0
- data/lib/redisk/logger.rb +36 -0
- data/lib/redisk/stat.rb +382 -0
- data/lib/redisk.rb +37 -0
- data/redisk.gemspec +70 -0
- data/spec/fixtures/rails.log +100 -0
- data/spec/redis-test.conf +132 -0
- data/spec/redisk_io_spec.rb +348 -0
- data/spec/redisk_logger_spec.rb +53 -0
- data/spec/redisk_stat_spec.rb +87 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +47 -0
- metadata +105 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Aaron Quint
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
= redisk
|
2
|
+
|
3
|
+
An interface to Redis that mimic's Ruby's IO classes
|
4
|
+
|
5
|
+
== WHAT
|
6
|
+
|
7
|
+
Redis (http://code.google.com/p/redis/) is a super awesome persisted key-value store.
|
8
|
+
|
9
|
+
Why are we still logging to files then?
|
10
|
+
|
11
|
+
Redisk is a set of Ruby classes that mimic's Ruby's built in IO classes to allow
|
12
|
+
drop in replacement for logging and other fun things.
|
13
|
+
|
14
|
+
== USAGE
|
15
|
+
|
16
|
+
Currently, Redisk provides two main classes Redisk::IO and Redisk::Logger.
|
17
|
+
|
18
|
+
Redisk::IO implements _most_ of the methods of Ruby's IO class (http://ruby-doc.org/core/classes/IO.html)
|
19
|
+
|
20
|
+
require 'redisk'
|
21
|
+
|
22
|
+
io = Redisk::IO.new('mylog.log') # not a file, a Redis List
|
23
|
+
io.puts "Log this!"
|
24
|
+
io.gets #=> "Log this!"
|
25
|
+
io.gets #=> nil
|
26
|
+
io.lineno = 2
|
27
|
+
|
28
|
+
Its much more interesting to use it with logger.
|
29
|
+
|
30
|
+
logger = Logger.new(Redisk::IO.new('test.log))
|
31
|
+
logger.info("Hahah, I'm logging to redis")
|
32
|
+
logger.warn("whu?")
|
33
|
+
logger.error("zuh")
|
34
|
+
|
35
|
+
Theres also a nifty wrapper for that behavior:
|
36
|
+
|
37
|
+
logger = Redisk::Logger.new('test.log')
|
38
|
+
logger.info "10 less characters!"
|
39
|
+
|
40
|
+
By default, Redisk uses the Redis on localhost:6379, but you can change that by setting
|
41
|
+
|
42
|
+
Redisk.redis = 'myhost:myport'
|
43
|
+
|
44
|
+
== Note on Patches/Pull Requests
|
45
|
+
|
46
|
+
* Fork the project.
|
47
|
+
* Make your feature addition or bug fix.
|
48
|
+
* Add tests for it. This is important so I don't break it in a
|
49
|
+
future version unintentionally.
|
50
|
+
* Commit, do not mess with rakefile, version, or history.
|
51
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
52
|
+
* Send me a pull request. Bonus points for topic branches.
|
53
|
+
|
54
|
+
== Copyright
|
55
|
+
|
56
|
+
Copyright (c) 2009 Aaron Quint. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(File.expand_path(__FILE__)), 'lib'))
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'redisk'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = "redisk"
|
10
|
+
gem.version = Redisk::VERSION
|
11
|
+
gem.summary = %Q{An interface to Redis that mimic's Ruby's IO classes}
|
12
|
+
gem.description = %Q{Redisk includes Redisk::IO which is ~ Ruby's stdlib IO. It can be used with stdlib's Logger to log directly to redis}
|
13
|
+
gem.email = "aaron@quirkey.com"
|
14
|
+
gem.homepage = "http://github.com/quirkey/redis_log"
|
15
|
+
gem.authors = ["Aaron Quint"]
|
16
|
+
gem.add_dependency "redis", ">=0.1.1"
|
17
|
+
gem.add_dependency "redis-namespace", ">=0.1.0"
|
18
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
19
|
+
end
|
20
|
+
Jeweler::GemcutterTasks.new
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'spec/rake/spectask'
|
26
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
29
|
+
end
|
30
|
+
|
31
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
32
|
+
spec.libs << 'lib' << 'spec'
|
33
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
34
|
+
spec.rcov = true
|
35
|
+
end
|
36
|
+
|
37
|
+
task :spec => :check_dependencies
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "redis-log #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|