redis-aid 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,8 +3,8 @@ class Redis
3
3
 
4
4
  module Version
5
5
  MAJOR = 0
6
- MINOR = 0
7
- PATCH = 3
6
+ MINOR = 1
7
+ PATCH = 0
8
8
  STRING = [MAJOR, MINOR, PATCH].join('.')
9
9
  end # Version
10
10
 
@@ -0,0 +1,22 @@
1
+ require 'rails/generators/base'
2
+
3
+ class Redis
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+
7
+ def self.source_root
8
+ @_redis_source_root ||= File.expand_path(File.join("../templates"), __FILE__)
9
+ end
10
+
11
+ class_option :host, :type => :string, :required => false, :default => 'localhost', :desc => "Name of the Redis host use"
12
+
13
+ def create_files
14
+ options[:host] ||= 'localhost'
15
+ template 'redis.yml.tt', "config/redis.yml"
16
+ say "Please ensure Gemfile contains: gem 'redis', '>= 2.0'"
17
+ say "For production environment Redis configuration, set environment variables as indicated in config/redis.yml"
18
+ end
19
+
20
+ end # Install
21
+ end # Generators
22
+ end # Redis
@@ -0,0 +1,18 @@
1
+ defaults: &defaults
2
+ host: <%= options[:host] %>
3
+ port: 6379
4
+
5
+ development:
6
+ <<: *defaults
7
+ db: 1
8
+
9
+ test:
10
+ <<: *defaults
11
+ db: 2
12
+
13
+ production:
14
+ <<: *defaults
15
+ host: <%%= ENV['REDIS_HOST'] %>
16
+ port: <%%= ENV['REDIS_PORT'] %>
17
+ db: <%%= ENV['REDIS_DB'] %>
18
+ password: <%%= ENV['REDIS_PASSWORD'] %>
@@ -0,0 +1,22 @@
1
+ require 'rails'
2
+ require 'redis/aid'
3
+
4
+ class Redis
5
+ class Railtie < Rails::Railtie
6
+
7
+ initializer "redis_aid.configure_rails_initialization" do |app|
8
+ app.class.send :include, Redis::Aid
9
+ redis_config_file = Rails.root.join('config/redis.yml')
10
+
11
+ if File.exists?(redis_config_file)
12
+ redis_config = HashWithIndifferentAccess.new(YAML.load_file(redis_config_file))
13
+ Redis::Aid.redis = Redis.new(redis_config[Rails.env]) if redis_config[Rails.env]
14
+ end
15
+ end
16
+
17
+ generators do
18
+ require "redis/generators/install/install_generator.rb"
19
+ end
20
+
21
+ end # Railtie
22
+ end # Redis
@@ -15,8 +15,9 @@ Gem::Specification.new do |s|
15
15
  s.require_paths = %w[lib]
16
16
  s.extra_rdoc_files = %w[LICENSE README.rdoc]
17
17
 
18
- s.add_runtime_dependency 'redis', [">= 2.0"]
19
- s.add_runtime_dependency 'nest', [">= 0"]
20
- s.add_development_dependency 'rspec', ["~> 2.0"]
21
- s.add_development_dependency 'mocha', [">= 0.9"]
18
+ s.add_runtime_dependency 'redis', [">= 2.0"]
19
+ s.add_runtime_dependency 'nest', [">= 0"]
20
+ s.add_development_dependency 'rspec', ["~> 2.0"]
21
+ s.add_development_dependency 'mocha', [">= 0.9"]
22
+ s.add_development_dependency 'genspec', ["~> 0.1.1"]
22
23
  end
@@ -0,0 +1,22 @@
1
+ #require File.expand_path("../../spec_helper", __FILE__)
2
+ #require "redis/generators/install/install_generator"
3
+
4
+ #describe Redis::Generators::InstallGenerator do
5
+ # context "with no args" do
6
+ # it "should generate a redis configuration file with default host" do
7
+ # subject.should generate("config/redis.yml") { |content|
8
+ # content.should match(/host\: localhost/)
9
+ # }
10
+ # end
11
+ # end
12
+ #
13
+ # context "with a host" do
14
+ # with_args 'host.com'
15
+ #
16
+ # it "should generate a redis configuration file with given host" do
17
+ # subject.should generate("config/redis.yml") { |content|
18
+ # content.should match(/host\: host\.com/)
19
+ # }
20
+ # end
21
+ # end
22
+ #end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-aid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 3
10
- version: 0.0.3
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Kowalik
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-17 00:00:00 +01:00
18
+ date: 2011-01-13 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -77,6 +77,22 @@ dependencies:
77
77
  version: "0.9"
78
78
  type: :development
79
79
  version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: genspec
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ hash: 25
89
+ segments:
90
+ - 0
91
+ - 1
92
+ - 1
93
+ version: 0.1.1
94
+ type: :development
95
+ version_requirements: *id005
80
96
  description: Small lib which helps with extending your classes or modules with redis (and nest) goodies.
81
97
  email:
82
98
  - chris@nu7hat.ch
@@ -95,7 +111,11 @@ files:
95
111
  - lib/redis-aid.rb
96
112
  - lib/redis/aid.rb
97
113
  - lib/redis/aid/version.rb
114
+ - lib/redis/generators/install/install_generator.rb
115
+ - lib/redis/generators/install/templates/redis.yml.tt
116
+ - lib/redis/railtie.rb
98
117
  - redis-aid.gemspec
118
+ - spec/generators/install_generator_spec.rb
99
119
  - spec/redis_aid_spec.rb
100
120
  - spec/spec_helper.rb
101
121
  has_rdoc: true