Permalink
Browse files

added generators

  • Loading branch information...
1 parent c6b9dd7 commit 17e97befbf83b69e3c7ee23cbac3d776cf04f4a7 @kristianmandrup committed Mar 30, 2012
View
@@ -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.
@@ -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
@@ -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
@@ -0,0 +1,5 @@
+<%= locale %>:
+ flash:
+ <%= name %>:
+ # message1:
+

0 comments on commit 17e97be

Please sign in to comment.