Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added generators

  • Loading branch information...
commit 17e97befbf83b69e3c7ee23cbac3d776cf04f4a7 1 parent c6b9dd7
@kristianmandrup authored
View
18 README.rdoc
@@ -20,6 +20,24 @@ Then use it in your controller, here in the RedemptionsController
Enjoy!
+== Rails 3 Generators
+
+Flasher now includes a few generators to get started
+
+=== Install
+
+$ rails g flasher:install
+
+Generator to create controller flash locale folder with locale files.
+
+=== Generate flash locales
+
+$ rails g flasher:locale controller --locales locale1 locale2
+
+Example:
+
+$ rails g flasher:locale redemptions --locales da fr
+
== Contributing to flasher
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
View
14 lib/generators/flasher/install/install_generator.rb
@@ -0,0 +1,14 @@
+module Flasher
+ module Generators
+ class InstallGenerator < ::Rails::Generators::Base
+ def generate_flash_dir
+ empty_directory 'config/locales/flash'
+ say "Create folders for controllers here and then your flash locale files in them."
+ end
+
+ def source_path
+ source_paths.first
+ end
+ end
+ end
+end
View
20 lib/generators/flasher/locales/locales_generator.rb
@@ -0,0 +1,20 @@
+module Flasher
+ module Generators
+ class LocalesGenerator < ::Rails::Generators::Name
+ attr_accessor :locale
+
+ class_option :locales, :type => :array, :default => [], :desc => "Locales to generate"
+
+ def generate_locales
+ locales.each do |locale|
+ @locale = locale
+ template "locale.erb" , "app/config/flash/#{name}/#{locale}.yml"
+ end
+ end
+
+ def source_path
+ source_paths.first
+ end
+ end
+ end
+end
View
5 lib/generators/flasher/locales/templates/locale.erb
@@ -0,0 +1,5 @@
+<%= locale %>:
+ flash:
+ <%= name %>:
+ # message1:
+
Please sign in to comment.
Something went wrong with that request. Please try again.