Permalink
Browse files

rails 3 generator

  • Loading branch information...
=
= committed Sep 22, 2010
1 parent f44e88d commit 2f390a81cd7edbaea5afa0ff8d019586ef3117ca
@@ -1 +0,0 @@
-YT_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/<%= file_name %>_config.yml")
@@ -1,19 +0,0 @@
-class YoutubeModelGenerator < Rails::Generator::NamedBase
- def manifest
- record do |m|
- m.class_collisions class_path, class_name
- m.directory File.join('app/models', class_path)
- m.directory File.join('test/unit', class_path)
- m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
- m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
- m.file 'config.yml', File.join('config', "#{file_name}_config.yml")
- m.template 'initializer.rb', File.join('config/initializers', "#{file_name}_initalizer.rb")
- end
- end
-
- protected
-
- def banner
- "Usage: #{$0} youtube_model ModelName"
- end
-end
File renamed without changes.
@@ -0,0 +1 @@
+YT_CONFIG = YAML.load_file("#{RAILS.root}/config/<%= file_name %>_config.yml")
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../test_helper'
+require 'test_helper'
class <%= class_name %>Test < Test::Unit::TestCase
def test_this_plugin
@@ -0,0 +1,16 @@
+class YoutubeModelGenerator < Rails::Generators::NamedBase
+
+ desc "Generate youtube_model files, Usage: rails g youtube_model ModelName"
+
+ source_root File.expand_path('../templates', __FILE__)
+
+ check_class_collision
+
+ def manifest
+ template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
+ template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
+ template 'config.yml', File.join('config', "#{file_name}_config.yml")
+ template 'initializer.rb', File.join('config/initializers', "#{file_name}_initalizer.rb")
+ end
+
+end

0 comments on commit 2f390a8

Please sign in to comment.