Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 9cdfcab311
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 133 lines (116 sloc) 3.522 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
require 'rubygems'
require 'rake'

begin
  require 'jeweler'
  Jeweler::Tasks.new do |gem|
    gem.name = "memodis"
    gem.summary = %Q{redis backed memoization helpers}
    gem.description = %Q{ semi-transparent memoization; backed by redis; }
    gem.email = "levicook@gmail.com"
    gem.homepage = "http://github.com/levicook/memodis"
    gem.authors = ["levicook@gmail.com"]
    gem.add_dependency "redis", ">= 0.1.2"
    gem.add_development_dependency "riot", ">= 0"
    gem.add_development_dependency "reek", ">= 0"
    gem.add_development_dependency "daemon_controller", ">= 0"
    # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
  end
  Jeweler::GemcutterTasks.new
rescue LoadError
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
end

require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
  test.libs << 'lib' << 'test'
  test.pattern = 'test/**/*_test.rb'
  test.verbose = true
end

begin
  require 'rcov/rcovtask'
  Rcov::RcovTask.new do |test|
    test.libs << 'test'
    test.pattern = 'test/**/*_test.rb'
    test.verbose = true
  end
rescue LoadError
  task :rcov do
    abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
  end
end

task :test => :check_dependencies

begin
  require 'reek/adapters/rake_task'
  Reek::RakeTask.new do |t|
    t.fail_on_error = true
    t.verbose = false
    t.source_files = 'lib/**/*.rb'
  end
rescue LoadError
  task :reek do
    abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
  end
end

begin
  require 'roodi'
  require 'roodi_task'
  RoodiTask.new do |t|
    t.verbose = false
  end
rescue LoadError
  task :roodi do
    abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
  end
end

task :default => :test

require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
  rdoc.rdoc_dir = 'rdoc'
  rdoc.title = "memodis #{version}"
  rdoc.rdoc_files.include('README*')
  rdoc.rdoc_files.include('lib/**/*.rb')
end



# redis test environment...

def write_redis_config(confile, port, slaveof=nil)
  pidfile = File.expand_path("test/pid/#{ File.basename(confile, '.*') }.pid")
  logfile = File.expand_path("test/log/#{ File.basename(confile, '.*') }.log")
  open(confile, 'w') do |f|
    f.puts "daemonize yes"
    f.puts "port #{port}"
    f.puts "pidfile #{pidfile}"
    f.puts "bind 127.0.0.1"
    f.puts "timeout 0"
    f.puts "dir ./test"
    f.puts "loglevel notice"
    f.puts "logfile #{logfile}"
    f.puts slaveof unless slaveof.nil?
    f.puts "databases 2"
    f.puts "maxmemory 6291456"
    f.puts "glueoutputbuf yes"
    f.puts "shareobjects no"
    f.puts "shareobjectspoolsize 1024"
  end
end

directory 'test/config'
directory 'test/log'
directory 'test/pid'

(16379..16380).each do |port|
  config_file = "test/config/redis-server:#{port}.conf"
  file config_file => %w(test/config test/log test/pid) do
    write_redis_config(config_file, port)
  end
  namespace :test do
    task :config => config_file
  end
end

(16389..16394).each do |port|
  config_file = "test/config/redis-server:#{port}.conf"
  file config_file => %w(test/config test/log test/pid) do
    master_port = port.even? ? 16379 : 16380
    write_redis_config(config_file, port, "slaveof 127.0.0.1 #{master_port}")
  end
  namespace :test do
    task :config => config_file
  end
end

task :test => 'test:config'
Something went wrong with that request. Please try again.