Permalink
Browse files

Group intersection code completed.

  • Loading branch information...
mjones-rpx committed Apr 15, 2010
1 parent daaea6c commit d4224e5788c105b55beaa44ef31fd7029ea2d6df
Showing with 29 additions and 9 deletions.
  1. +1 −1 LICENSE
  2. +2 −2 README.rdoc
  3. +3 −3 Rakefile
  4. +19 −0 lib/redis_logger.rb
  5. +4 −3 redis_logger.gemspec
View
@@ -1,4 +1,4 @@
-Copyright (c) 2009 mason
+Copyright (c) 2010 Mason Jones
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
@@ -1,6 +1,6 @@
= redis_logger
-Description goes here.
+Application logging to redis.
== Note on Patches/Pull Requests
@@ -14,4 +14,4 @@ Description goes here.
== Copyright
-Copyright (c) 2010 mason. See LICENSE for details.
+Copyright (c) 2010 Mason Jones. See LICENSE for details.
View
@@ -5,9 +5,9 @@ begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "redis_logger"
- gem.summary = %Q{Enable logging to Redis database}
- gem.description = %Q{Provides support for logging to a Redis database, including grouping log entries and timestamping}
- gem.email = "mason@rpxcorp.com"
+ gem.summary = %Q{Application logging into Redis}
+ gem.description = %Q{Provides support for applicationlogging to Redis, including grouping log entries and timestamping}
+ gem.email = "masonoise@charnel.com"
gem.homepage = "http://github.com/masonoise/redis_logger"
gem.authors = ["masonoise"]
gem.add_dependency('redis', '>= 1.0.4')
View
@@ -1,5 +1,8 @@
require 'redis'
+#
+# redis_logger
+# http://github.com/masonoise/redis_logger
#
# Enable logging into redis database, with support for grouping log entries into one or more
# groups.
@@ -74,6 +77,22 @@ def self.size(group)
#
def self.entries(group, start=0, per_page=50)
entry_list = redis.sort("logger:set:#{group}", { :limit => [ start, per_page ], :order => "DESC" })
+ fetch_entries(entry_list)
+ end
+
+ #
+ # Get the entries for an intersection of groups. Takes an array of group names and
+ # returns the resulting entries.
+ #
+ def self.intersect(groups)
+ entry_list = redis.sinter(groups.collect {|g| "logger:set:#{g}"})
+ fetch_entries(entry_list)
+ end
+
+ #
+ # Utility method to fetch entries given an array returned from a group set.
+ #
+ def self.fetch_entries(entry_list)
entries = []
entry_list.each do |e|
entries << redis.hgetall("log:#{e}")
View
@@ -10,8 +10,8 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["masonoise"]
s.date = %q{2010-04-15}
- s.description = %q{Provides support for logging to a Redis database, including grouping log entries and timestamping}
- s.email = %q{mason@rpxcorp.com}
+ s.description = %q{Provides support for applicationlogging to Redis, including grouping log entries and timestamping}
+ s.email = %q{masonoise@charnel.com}
s.extra_rdoc_files = [
"LICENSE",
"README.rdoc"
@@ -24,14 +24,15 @@ Gem::Specification.new do |s|
"Rakefile",
"VERSION",
"lib/redis_logger.rb",
+ "redis_logger.gemspec",
"test/helper.rb",
"test/test_redis_logger.rb"
]
s.homepage = %q{http://github.com/masonoise/redis_logger}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.5}
- s.summary = %q{Enable logging to Redis database}
+ s.summary = %q{Application logging into Redis}
s.test_files = [
"test/helper.rb",
"test/test_redis_logger.rb"

0 comments on commit d4224e5

Please sign in to comment.