green_eggs_and_spam 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.gitignore +4 -1
  2. data/README.md +91 -24
  3. data/Rakefile +30 -2
  4. data/green_eggs_and_spam.gemspec +5 -1
  5. data/lib/green_eggs_and_spam/action_controller.rb +10 -4
  6. data/lib/green_eggs_and_spam/active_record.rb +28 -0
  7. data/lib/green_eggs_and_spam/anti_spam_validator.rb +11 -0
  8. data/lib/green_eggs_and_spam/form_helper.rb +7 -8
  9. data/lib/green_eggs_and_spam/options.rb +45 -0
  10. data/lib/green_eggs_and_spam/version.rb +1 -1
  11. data/lib/green_eggs_and_spam.rb +31 -3
  12. data/test/dummy/Rakefile +7 -0
  13. data/test/dummy/app/controllers/application_controller.rb +3 -0
  14. data/test/dummy/app/controllers/comments_controller.rb +18 -0
  15. data/test/dummy/app/controllers/eggs_controller.rb +24 -0
  16. data/test/dummy/app/helpers/application_helper.rb +2 -0
  17. data/test/dummy/app/models/egg.rb +7 -0
  18. data/test/dummy/app/views/comments/new.html.erb +14 -0
  19. data/test/dummy/app/views/eggs/index.html.erb +14 -0
  20. data/test/dummy/app/views/eggs/new.html.erb +21 -0
  21. data/test/dummy/app/views/layouts/application.html.erb +59 -0
  22. data/test/dummy/config/application.rb +45 -0
  23. data/test/dummy/config/boot.rb +10 -0
  24. data/test/dummy/config/database.yml +22 -0
  25. data/test/dummy/config/environment.rb +5 -0
  26. data/test/dummy/config/environments/development.rb +26 -0
  27. data/test/dummy/config/environments/production.rb +49 -0
  28. data/test/dummy/config/environments/test.rb +35 -0
  29. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  30. data/test/dummy/config/initializers/inflections.rb +10 -0
  31. data/test/dummy/config/initializers/mime_types.rb +5 -0
  32. data/test/dummy/config/initializers/secret_token.rb +7 -0
  33. data/test/dummy/config/initializers/session_store.rb +8 -0
  34. data/test/dummy/config/locales/en.yml +5 -0
  35. data/test/dummy/config/routes.rb +5 -0
  36. data/test/dummy/config.ru +4 -0
  37. data/test/dummy/db/migrate/20110223073415_create_eggs.rb +11 -0
  38. data/test/dummy/db/schema.rb +19 -0
  39. data/test/dummy/public/404.html +26 -0
  40. data/test/dummy/public/422.html +26 -0
  41. data/test/dummy/public/500.html +26 -0
  42. data/test/dummy/public/favicon.ico +0 -0
  43. data/test/dummy/public/images/antispam/1.png +0 -0
  44. data/test/dummy/public/images/antispam/2.png +0 -0
  45. data/test/dummy/public/images/antispam/3.png +0 -0
  46. data/test/dummy/script/rails +6 -0
  47. data/test/helper.rb +23 -0
  48. data/test/integration/navigation_test.rb +7 -0
  49. data/test/support/integration_case.rb +5 -0
  50. data/test/test_green_eggs_and_ham.rb +53 -0
  51. data/test/test_options.rb +37 -0
  52. metadata +126 -6
  53. data/lib/green_eggs_and_spam/anti_spam.rb +0 -29
data/.gitignore CHANGED
@@ -2,4 +2,7 @@
2
2
  .bundle
3
3
  .DS_Store
4
4
  Gemfile.lock
5
- pkg/*
5
+ pkg/*
6
+ test/dummy/db/*.sqlite3
7
+ test/dummy/log/
8
+ test/dummy/tmp/
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Green Eggs and Spam
2
2
  ===================
3
3
 
4
- A simple way to filter spam in your rails forms. Green eggs and spam presents the user with a simple question: **What color is this image?**
4
+ A simple way to filter spam in your rails forms. Green eggs and spam presents users with a simple question: **What color is this image?**
5
5
 
6
6
  You'll supply the images and a key of which one's which. The gem will handle the rest.
7
7
 
@@ -18,49 +18,89 @@ Install the gem just like you would any other:
18
18
 
19
19
  # or with bundler
20
20
 
21
- gem 'green_eggs_and_spam', '>= 0.1.0'
21
+ gem 'green_eggs_and_spam', '>= 0.1.1'
22
22
 
23
23
 
24
- Create a handful of color coded images and name them `1.png`, `2.png`, etc. Tell Green Eggs and Spam which ones which with an initializer:
24
+ Create a handful of color coded images and name them something other than their color or design. `1.png`, `banana.png` or `firetruck.png` for example. Tell GreenEggsandSpam which ones which with an initializer:
25
25
 
26
26
  # config/initializers/green_eggs_and_spam.rb
27
27
 
28
- GreenEggsAndSpam::AntiSpam.key_index = { "1" => "blue", "2" => "green", "3" => "red" }
28
+ GreenEggsAndSpam.options[:key_index] = { "1" => "blue", "banana" => "yellow", "firetruck" => "red" }
29
29
 
30
30
 
31
- In your controller:
32
31
 
33
- class CommentsController < ApplicationController
32
+ Include the helper form:
33
+
34
+ = form_for @comment, :url => comment_path do |f|
35
+ %p
36
+ = f.label :comment
37
+ = f.text_field :comment
38
+
39
+ // Here's what your interested in:
40
+ %p
41
+ = anti_spam_form, "What color is this piece of bacon?" # the first optional argument is your custom question, the second are the form options
42
+
43
+ = f.submit 'send'
44
+
45
+
46
+
47
+ Chances are your form is interacting with a model. If that's the case, start by adding the validator to your model like so:
48
+
49
+ class Egg < ActiveRecord::Base
50
+ validates_anti_spam
51
+ end
34
52
 
53
+
54
+
55
+ Next, setup your controller with the 'magic' `has_anti_spam` method. This will prepare the controller and give you access to the helper methods.
56
+
57
+ class EggsController < ApplicationController
58
+
35
59
  has_anti_spam
36
60
 
61
+ ...
62
+
63
+ # merge the antispam params into your model's params before validation
37
64
  def create
38
- ... # your code
39
-
40
- # add an error unless the anti spam question was answered correctly
41
- @comment.errors[:base] << "Spam Detected! Please make sure you've properly answered the anti spam question." unless anti_spam_valid?
65
+ @egg = Egg.new(params[:egg].merge(:antispam => params[:antispam]))
42
66
 
43
- ... # the rest of your action
67
+ # validate as usual
68
+ if @egg.valid? && @egg.save
69
+ # do something
70
+ end
44
71
  end
45
72
 
46
73
  end
74
+
75
+
76
+
77
+ ### That's it!
78
+
79
+
80
+ But what if my form isn't validating a model? No big deal, just use the `anti_spam_valid?` helper method.
47
81
 
82
+ class CommentsController < ApplicationController
83
+
84
+ has_anti_spam
85
+
86
+ ...
87
+
88
+ # merge the antispam params into your model's params before validation
89
+ def create
90
+ # validate with the anti spam helper method
91
+ if anti_spam_valid?
92
+ # do something
93
+ end
94
+ end
95
+
96
+ end
48
97
 
49
- In your form:
50
98
 
51
- = form_for @comment, :url => comment_path do |f|
52
- %p
53
- = f.label :comment
54
- = f.text_field :comment
55
-
56
- // Here's what your interested in:
57
- %p
58
- = anti_spam_form, "What color is this piece of bacon?" # the optional argument is your custom question
59
-
60
- = f.submit 'send'
61
-
62
99
 
63
- Customization:
100
+
101
+
102
+ Customization
103
+ -------------
64
104
 
65
105
  So you're using `.gif`'s or you don't want the images stored in `/images/antispam`. Here's some available options for the form helper.
66
106
 
@@ -75,8 +115,35 @@ So you're using `.gif`'s or you don't want the images stored in `/images/antispa
75
115
  # usage
76
116
  anti_spam_form, "Your custom color question?", { :extension => 'png', :path => '/images' }
77
117
 
118
+ # or set globally in your initializer
119
+
120
+ GreenEggsAndSpam.options[:form_options] = { :extension => 'png', :path => '/images' }
121
+
122
+
123
+
124
+ Demo
125
+ ----
78
126
 
127
+ If you'd like to see GreenEggsAndSpam in action, there is a demo app located in `test/dummy`.
79
128
 
129
+ git://github.com/citrus/green_eggs_and_spam.git
130
+ cd green_eggs_and_spam
131
+ bundle install
132
+ cd test/dummy
133
+ rake db:migrate
134
+ rails s
135
+
136
+
137
+ Testing
138
+ -------
139
+
140
+ Shoulda tests can be run using `rake test` or just `rake`.
141
+
142
+ git://github.com/citrus/green_eggs_and_spam.git
143
+ cd green_eggs_and_spam
144
+ rake
145
+
146
+
80
147
  License
81
148
  -------
82
149
 
data/Rakefile CHANGED
@@ -1,2 +1,30 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'rake'
10
+ require 'rake/rdoctask'
11
+ require 'rake/testtask'
12
+
13
+ Bundler::GemHelper.install_tasks
14
+
15
+ Rake::TestTask.new(:test) do |t|
16
+ t.libs << 'lib'
17
+ t.libs << 'test'
18
+ #t.pattern = 'test/**/*_test.rb'
19
+ t.verbose = true
20
+ end
21
+
22
+ task :default => :test
23
+
24
+ Rake::RDocTask.new(:rdoc) do |rdoc|
25
+ rdoc.rdoc_dir = 'rdoc'
26
+ rdoc.title = 'SpreeMail'
27
+ rdoc.options << '--line-numbers' << '--inline-source'
28
+ rdoc.rdoc_files.include('README.rdoc')
29
+ rdoc.rdoc_files.include('lib/**/*.rb')
30
+ end
@@ -20,4 +20,8 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
  s.add_dependency("rails", ">= 3.0.0")
23
- end
23
+
24
+ s.add_development_dependency("capybara", ">= 0.4.0")
25
+ s.add_development_dependency("shoulda", ">= 2.11.3")
26
+ s.add_development_dependency("sqlite3", ">= 1.3.3")
27
+ end
@@ -2,27 +2,33 @@ module GreenEggsAndSpam
2
2
 
3
3
  module ActionController
4
4
 
5
+ # Adds the `has_anti_spam` method into ActionController::Base
5
6
  def self.included(base)
6
7
  base.extend GreenEggsAndSpam::ActionController::ClassMethods
7
8
  end
8
9
 
9
10
  module ClassMethods
11
+
12
+ # Installs GreenEggsAndSpam's functionality into the supplied controller
10
13
  def has_anti_spam
11
14
  self.send(:include, GreenEggsAndSpam::ActionController::InstanceMethods)
12
15
  self.class_eval do
13
16
  helper GreenEggsAndSpam::AntiSpamFormHelper
14
- before_filter :setup_anti_spam, :only => [:index,:new, :create]
17
+ before_filter :setup_anti_spam, :only => [:index,:new,:create]
15
18
  private
16
- def setup_anti_spam
17
- @antispam_key = GreenEggsAndSpam::AntiSpam.random_key
19
+ # Sets the antispam key to a random one
20
+ def setup_anti_spam
21
+ @antispam_key = GreenEggsAndSpam.random_key
18
22
  end
19
23
  end
20
24
  end
21
25
  end
22
26
 
23
27
  module InstanceMethods
28
+
29
+ # Validates the supplied antispam params
24
30
  def anti_spam_valid?
25
- GreenEggsAndSpam::AntiSpam.valid?(params)
31
+ GreenEggsAndSpam.validates?(params[:antispam])
26
32
  end
27
33
  end
28
34
 
@@ -0,0 +1,28 @@
1
+ require 'green_eggs_and_spam/anti_spam_validator'
2
+
3
+ module GreenEggsAndSpam
4
+
5
+ module ActiveRecord
6
+
7
+ # Adds the `validates_anti_spam` method into ActiveRecord::Base
8
+ def self.included(base)
9
+ base.extend GreenEggsAndSpam::ActiveRecord::ClassMethods
10
+ end
11
+
12
+ module ClassMethods
13
+
14
+ # Installs GreenEggsAndSpam's validation functionality into the supplied model
15
+ def validates_anti_spam
16
+ self.class_eval do
17
+ attr_accessor :antispam
18
+ validates_with GreenEggsAndSpam::AntiSpamValidator
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
26
+ end
27
+
28
+ ActiveRecord::Base.send(:include, GreenEggsAndSpam::ActiveRecord) if defined?(ActiveRecord)
@@ -0,0 +1,11 @@
1
+ module GreenEggsAndSpam
2
+
3
+ class AntiSpamValidator < ActiveModel::Validator
4
+
5
+ def validate(record)
6
+ record.errors[:base] << GreenEggsAndSpam.options[:error_message] unless GreenEggsAndSpam.validates?(record.antispam)
7
+ end
8
+
9
+ end
10
+
11
+ end
@@ -1,18 +1,17 @@
1
1
  module GreenEggsAndSpam
2
2
 
3
3
  module AntiSpamFormHelper
4
-
4
+
5
+ # Builds a label tag, text field and hidden field for use in a rails form
5
6
  def anti_spam_form(question="What color is this image?", options={})
6
7
  key = @antispam_key || 0
7
- options = { :alt => 'AntiSpam Image', :class => 'antispam-image', :path => '/images/antispam', :extension => 'jpg' }.merge(options)
8
- choices = GreenEggsAndSpam::AntiSpam.key_index.values.to_a
8
+ options = GreenEggsAndSpam.options[:form_options].merge(options)
9
+ choices = GreenEggsAndSpam.key_index.values.to_a
9
10
  choices[choices.length - 1] = "or #{choices.last}"
10
11
  [
11
- label_tag(:antispam, question, :class => 'antispam-label'),
12
- tag(:br),
13
- text_field_tag(:antispam, '', :class => 'antispam-field text required', :title => choices.join(", ")),
14
- hidden_field_tag(:antispam_key, key),
15
- tag(:br, :class => 'clear'),
12
+ label_tag('antispam[answer]', question, :class => 'antispam-label'),
13
+ text_field_tag('antispam[answer]', '', :class => 'antispam-field text required', :title => choices.join(", ")),
14
+ hidden_field_tag('antispam[key]', key, :class => 'hidden'),
16
15
  image_tag(File.join(options[:path], "#{key}.#{options[:extension]}"), :alt => options[:alt], :class => options[:class])
17
16
  ].join("\n").html_safe
18
17
  end
@@ -0,0 +1,45 @@
1
+ module GreenEggsAndSpam
2
+
3
+ class Options < Hash
4
+
5
+ # Initializes the options hash with the defaults
6
+ def initialize
7
+ super
8
+ default!
9
+ end
10
+
11
+ # Clears current options and resets to the defaults
12
+ def default!
13
+ clear.merge!(defaults)
14
+ end
15
+
16
+ # The default options hash
17
+ def defaults
18
+ {
19
+ :key_index => { "1" => "red", "2" => "green", "3" => "blue" },
20
+ :form_options => { :alt => 'AntiSpam Image', :class => 'antispam-image', :path => '/images/antispam', :extension => 'png' },
21
+ :error_message => "Spam Detected! Please make sure you've properly answered the anti spam question."
22
+ }
23
+ end
24
+
25
+ # Sets and option and converts its key to a symbol
26
+ def []=(key, value)
27
+ key = key.to_sym
28
+ case key
29
+ when :key_index
30
+ raise "Invalid Key Index" unless value.is_a?(Hash) && 1 < value.keys.length
31
+ when :form_options
32
+ raise "Invalid Form Options" unless value.is_a?(Hash)
33
+ value = fetch(:form_options).merge(value)
34
+ end
35
+ super(key, value)
36
+ end
37
+
38
+ # Turns the key into a symbol and returns the requested value
39
+ def [](key)
40
+ super(key.to_sym)
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -1,3 +1,3 @@
1
1
  module GreenEggsAndSpam
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,7 +1,35 @@
1
- require 'green_eggs_and_spam/anti_spam'
1
+ require 'green_eggs_and_spam/options'
2
2
  require 'green_eggs_and_spam/action_controller'
3
+ require 'green_eggs_and_spam/active_record'
3
4
  require 'green_eggs_and_spam/form_helper'
4
5
 
5
6
  module GreenEggsAndSpam
6
- # Your code goes here...
7
- end
7
+
8
+ extend self
9
+
10
+ # Returns the options hash
11
+ def options
12
+ @options ||= Options.new
13
+ end
14
+
15
+ # Returns the key index from the options hash
16
+ def key_index
17
+ options[:key_index]
18
+ end
19
+
20
+ # Returns a random key
21
+ def random_key
22
+ key_index.keys.sort_by{rand}.first
23
+ end
24
+
25
+ # Validates a key and answer combo
26
+ def validates?(params)
27
+ key = params[:key].to_s
28
+ val = params[:answer].to_s
29
+ return false if key.empty? || val.empty?
30
+ answer = key_index[key.to_s]
31
+ regex = Regexp.new(answer, 'i')
32
+ return val.match(regex) != nil
33
+ end
34
+
35
+ end
@@ -0,0 +1,7 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,18 @@
1
+ class CommentsController < ApplicationController
2
+
3
+ has_anti_spam
4
+
5
+ def new
6
+ end
7
+
8
+ def create
9
+ if anti_spam_valid?
10
+ flash[:notice] = "Comment sent!"
11
+ redirect_to new_comment_path
12
+ else
13
+ flash[:error] = GreenEggsAndSpam.options[:error_message]
14
+ render :action => 'new'
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,24 @@
1
+ class EggsController < ApplicationController
2
+
3
+ has_anti_spam
4
+
5
+ def index
6
+ @eggs = Egg.all
7
+ end
8
+
9
+ def new
10
+ @egg = Egg.new
11
+ end
12
+
13
+ def create
14
+ @egg = Egg.new(params[:egg].merge(:antispam => params[:antispam]))
15
+ if @egg.save
16
+ flash[:notice] = "Egg successfully created!"
17
+ redirect_to eggs_path
18
+ else
19
+ flash[:error] = "Egg could not be saved."
20
+ render :action => 'new'
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,7 @@
1
+ class Egg < ActiveRecord::Base
2
+
3
+ validates_presence_of :name
4
+
5
+ validates_anti_spam
6
+
7
+ end
@@ -0,0 +1,14 @@
1
+ <h2>Send a Comment</h2>
2
+
3
+ <%= form_tag comments_path do %>
4
+ <p>
5
+ <%= label_tag 'comment' %>
6
+ <%= text_field_tag 'comment', params[:comment] %>
7
+ </p>
8
+ <p>
9
+ <%= anti_spam_form %>
10
+ </p>
11
+ <p>
12
+ <%= submit_tag 'Send' %>
13
+ </p>
14
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <h2>Eggs</h2>
2
+ <h3>Why Eggs? Because they're delicious!</h3>
3
+
4
+ <%= link_to "new egg", new_egg_path %>
5
+
6
+ <ul>
7
+ <% if @eggs.empty? %>
8
+ <li>No eggs have been created!</li>
9
+ <% else %>
10
+ <% @eggs.each do |egg| %>
11
+ <li><%= egg.inspect %></li>
12
+ <% end %></ul>
13
+ <% end %>
14
+ </ul>
@@ -0,0 +1,21 @@
1
+ <h2>New Egg</h2>
2
+
3
+ <% if 0 < @egg.errors.to_a.length %>
4
+ <p class="flash error">
5
+ <b>Errors:</b><br/>
6
+ <%= @egg.errors.to_a.join("<br/>").html_safe %>
7
+ </p>
8
+ <% end %>
9
+
10
+ <%= form_for @egg do |f| %>
11
+ <p>
12
+ <%= f.label :name %>
13
+ <%= f.text_field :name %>
14
+ </p>
15
+ <p>
16
+ <%= anti_spam_form %>
17
+ </p>
18
+ <p>
19
+ <%= f.submit %>
20
+ </p>
21
+ <% end %>
@@ -0,0 +1,59 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= csrf_meta_tag %>
6
+ <style type="text/css">
7
+ body {
8
+ font-family: "HelveticaNeue", Helvetica, Arial, sans-serif;
9
+ color: #080603;
10
+ }
11
+ a {
12
+ text-decoration: none;
13
+ color: #68962c;
14
+ }
15
+ .container {
16
+ width: 500px;
17
+ margin: 0 auto;
18
+ }
19
+ .header {
20
+ border-bottom: 1px solid #ddd;
21
+ }
22
+ .header a {
23
+ display: inline-block;
24
+ padding: 4px 10px;
25
+ background-color: #eee;
26
+ }
27
+
28
+ .flash {
29
+ padding: 10px 0;
30
+ border-bottom: 1px solid #ddd;
31
+ }
32
+ .flash.notice {
33
+ color: #68962c;
34
+ }
35
+ .flash.error {
36
+ color: #c00e0e;
37
+ }
38
+
39
+ </style>
40
+ </head>
41
+ <body>
42
+
43
+ <div class="container">
44
+
45
+ <div class="header">
46
+ <h1 class="title">Green Eggs &amp; Spam Demo</h1>
47
+ <%= link_to "play with eggs", eggs_path %>
48
+ <%= link_to "send a comment", new_comment_path %>
49
+ </div>
50
+
51
+ <%= content_tag(:p, flash[:notice], :class => 'flash notice') if flash[:notice] %>
52
+ <%= content_tag(:p, flash[:error], :class => 'flash error') if flash[:error] %>
53
+
54
+ <%= yield %>
55
+
56
+ </div>
57
+
58
+ </body>
59
+ </html>
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "active_model/railtie"
4
+ require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_view/railtie"
7
+ require "action_mailer/railtie"
8
+
9
+ Bundler.require
10
+ require "green_eggs_and_spam"
11
+
12
+ module Dummy
13
+ class Application < Rails::Application
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+
18
+ # Custom directories with classes and modules you want to be autoloadable.
19
+ # config.autoload_paths += %W(#{config.root}/extras)
20
+
21
+ # Only load the plugins named here, in the order given (default is alphabetical).
22
+ # :all can be used as a placeholder for all plugins not explicitly named.
23
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
24
+
25
+ # Activate observers that should always be running.
26
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
27
+
28
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
29
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
30
+ # config.time_zone = 'Central Time (US & Canada)'
31
+
32
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
33
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34
+ # config.i18n.default_locale = :de
35
+
36
+ # JavaScript files you want as :defaults (application.js is always included).
37
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
38
+
39
+ # Configure the default encoding used in templates for Ruby 1.9.
40
+ config.encoding = "utf-8"
41
+
42
+ # Configure sensitive parameters which will be filtered from the log file.
43
+ config.filter_parameters += [:password]
44
+ end
45
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,22 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: db/production.sqlite3
21
+ pool: 5
22
+ timeout: 5000