Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updates

  • Loading branch information...
commit f2337315f7f2a62c8d219cac213cbadfe7689c18 1 parent 284682b
@felixclack authored
View
25 Gemfile.lock
@@ -1,32 +1,45 @@
PATH
remote: .
specs:
- timeline (0.1.4)
+ redis_timeline (0.1.6)
activemodel (~> 3.2)
activesupport (~> 3.2)
hashie
multi_json
redis
+ redis-namespace
GEM
remote: http://rubygems.org/
specs:
- activemodel (3.2.1)
- activesupport (= 3.2.1)
+ activemodel (3.2.3)
+ activesupport (= 3.2.3)
builder (~> 3.0.0)
- activesupport (3.2.1)
+ activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
builder (3.0.0)
+ diff-lcs (1.1.3)
hashie (1.2.0)
i18n (0.6.0)
- multi_json (1.1.0)
+ multi_json (1.2.0)
redis (2.2.2)
+ redis-namespace (1.0.3)
+ redis (< 3.0.0)
+ rspec (2.10.0)
+ rspec-core (~> 2.10.0)
+ rspec-expectations (~> 2.10.0)
+ rspec-mocks (~> 2.10.0)
+ rspec-core (2.10.1)
+ rspec-expectations (2.10.0)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.10.1)
sqlite3 (1.3.5)
PLATFORMS
ruby
DEPENDENCIES
+ redis_timeline!
+ rspec
sqlite3
- timeline!
View
2  lib/redis-timeline.rb → lib/redis_timeline.rb
@@ -1,4 +1,4 @@
-require 'active_support'
+require 'active_support/concern'
require 'multi_json'
require 'hashie'
require 'timeline/config'
View
50 lib/timeline/actor.rb
@@ -1,32 +1,34 @@
-module Timeline::Actor
- extend ActiveSupport::Concern
+module Timeline
+ module Actor
+ extend ActiveSupport::Concern
- included do
- def timeline(options={})
- Timeline.get_list(timeline_options(options)).map do |item|
- Timeline::Activity.new Timeline.decode(item)
+ included do
+ def timeline(options={})
+ ::Timeline.get_list(timeline_options(options)).map do |item|
+ ::Timeline::Activity.new ::Timeline.decode(item)
+ end
end
- end
- def followers
- []
- end
+ def followers
+ []
+ end
- private
- def timeline_options(options)
- defaults = { list_name: "user:id:#{self.id}:activity", start: 0, end: 19 }
- if options.is_a? Hash
- defaults.merge!(options)
- elsif options.is_a? Symbol
- case options
- when :global
- defaults.merge!(list_name: "global:activity")
- when :posts
- defaults.merge!(list_name: "user:id:#{self.id}:posts")
- when :mentions
- defaults.merge!(list_name: "user:id:#{self.id}:mentions")
+ private
+ def timeline_options(options)
+ defaults = { list_name: "user:id:#{self.id}:activity", start: 0, end: 19 }
+ if options.is_a? Hash
+ defaults.merge!(options)
+ elsif options.is_a? Symbol
+ case options
+ when :global
+ defaults.merge!(list_name: "global:activity")
+ when :posts
+ defaults.merge!(list_name: "user:id:#{self.id}:posts")
+ when :mentions
+ defaults.merge!(list_name: "user:id:#{self.id}:mentions")
+ end
end
end
- end
+ end
end
end
View
4 lib/timeline/helpers.rb
@@ -10,7 +10,7 @@ def decode(object)
return unless object
begin
- ::MultiJson.decode(object)
+ ::MultiJson.load(object)
rescue ::MultiJson::DecodeError => e
raise DecodeException, e
end
@@ -20,4 +20,4 @@ def get_list(options={})
Timeline.redis.lrange options[:list_name], options[:start], options[:end]
end
end
-end
+end
View
6 redis-timeline.gemspec → redis_timeline.gemspec
@@ -5,11 +5,11 @@ require "timeline/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
- s.name = "redis-timeline"
+ s.name = "redis_timeline"
s.version = Timeline::VERSION
s.authors = ["Felix Clack"]
s.email = ["felixclack@gmail.com"]
- s.homepage = "http://felixclack.github.com/timeline"
+ s.homepage = "http://felixclack.github.com/redis-timeline"
s.summary = "Redis backed timeline for your activity feeds."
s.description = ""
@@ -21,6 +21,8 @@ Gem::Specification.new do |s|
s.add_dependency "multi_json"
s.add_dependency "redis"
s.add_dependency "hashie"
+ s.add_dependency "redis-namespace"
s.add_development_dependency "sqlite3"
+ s.add_development_dependency "rspec"
end
View
4 spec/activity_spec.rb
@@ -2,11 +2,11 @@
describe Timeline::Activity do
describe "initialized with json" do
- let(:json) { MultiJson.encode({ id: "1", verb: "new_post"}) }
+ let(:json) { { id: "1", verb: "new_post" } }
it "returns a Hashie-fied object" do
Timeline::Activity.new(json).id.should == "1"
Timeline::Activity.new(json).verb.should == "new_post"
end
end
-end
+end
View
2  spec/spec_helper.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib redis-timeline]))
+require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib redis_timeline]))
dir = File.dirname(File.expand_path(__FILE__))
RSpec.configure do |config|
Please sign in to comment.
Something went wrong with that request. Please try again.