Skip to content
Browse files

+ Redis lib only loaded if the Redis backend is used

  • Loading branch information...
1 parent b2ca60a commit a18fcc545aa8c4f24259d40b0543e68f8ca540d9 @floere committed Oct 26, 2011
View
3 server/lib/picky/backends/redis.rb
@@ -9,7 +9,10 @@ class Redis < Backend
attr_reader :client
def initialize options = {}
+ require 'redis'
@client = options[:client] || ::Redis.new(:db => (options[:db] || 15))
+ rescue LoadError => e
+ warn_gem_missing 'redis', 'the Redis client'
end
# Returns an object that on #initial, #load returns an object that responds to:
View
2 server/lib/picky/extensions/object.rb
@@ -16,7 +16,7 @@ def exclaim text
# Puts a text that informs the user of a missing gem.
#
def warn_gem_missing gem_name, message
- warn "#{gem_name} gem missing!\nTo use #{message}, you need to:\n 1. Add the following line to Gemfile:\n gem '#{gem_name}'\n 2. Then, run:\n bundle update\n"
+ warn "#{gem_name} gem missing!\nTo use #{message}, you need to:\n 1. Add the following line to Gemfile:\n gem '#{gem_name}'\n or\n require '#{gem_name}'\n for example on top of your app.rb/application.rb\n 2. Then, run:\n bundle update\n"
end
# Indents each line by <tt>amount=2</tt> spaces.
View
2 server/spec/lib/extensions/object_spec.rb
@@ -24,7 +24,7 @@
describe 'warn_gem_missing' do
it 'should warn right' do
- object.should_receive(:warn).once.with "gnorf gem missing!\nTo use gnarble gnarf, you need to:\n 1. Add the following line to Gemfile:\n gem 'gnorf'\n 2. Then, run:\n bundle update\n"
+ object.should_receive(:warn).once.with "gnorf gem missing!\nTo use gnarble gnarf, you need to:\n 1. Add the following line to Gemfile:\n gem 'gnorf'\n or\n require 'gnorf'\n for example on top of your app.rb/application.rb\n 2. Then, run:\n bundle update\n"
object.warn_gem_missing 'gnorf', 'gnarble gnarf'
end
View
2 server/spec/lib/sources/delicious_spec.rb
@@ -19,7 +19,7 @@
@source.should_receive(:require).any_number_of_times.and_raise LoadError
end
it "warns & exits" do
- @source.should_receive(:warn).once.with "www-delicious gem missing!\nTo use the delicious source, you need to:\n 1. Add the following line to Gemfile:\n gem 'www-delicious'\n 2. Then, run:\n bundle update\n"
+ @source.should_receive(:warn).once.with "www-delicious gem missing!\nTo use the delicious source, you need to:\n 1. Add the following line to Gemfile:\n gem 'www-delicious'\n or\n require 'www-delicious'\n for example on top of your app.rb/application.rb\n 2. Then, run:\n bundle update\n"
@source.should_receive(:exit).once.with 1
@source.check_gem
View
1 server/test_project/app/application.rb
@@ -1,5 +1,6 @@
# encoding: utf-8
#
+require 'redis'
require File.expand_path '../logging', __FILE__
class ChangingItem

0 comments on commit a18fcc5

Please sign in to comment.
Something went wrong with that request. Please try again.