summaryrefslogtreecommitdiff
path: root/lib/generators/nifty.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
commitb80bd744ad873f6fc43018bc4bfb90677de167bd (patch)
tree072c4b0e33d442528555b82c415f5e7a1712b2b0 /lib/generators/nifty.rb
parent3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff)
Start of GS5.
Diffstat (limited to 'lib/generators/nifty.rb')
-rw-r--r--lib/generators/nifty.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/generators/nifty.rb b/lib/generators/nifty.rb
new file mode 100644
index 0000000..1c3d6d7
--- /dev/null
+++ b/lib/generators/nifty.rb
@@ -0,0 +1,28 @@
+require 'rails/generators/base'
+
+module Nifty
+ module Generators
+ class Base < Rails::Generators::Base #:nodoc:
+ def self.source_root
+ @_nifty_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'nifty', generator_name, 'templates'))
+ end
+
+ def self.banner
+ "rails generate nifty:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
+ end
+
+ private
+
+ def add_gem(name, options = {})
+ gemfile_content = File.read(destination_path("Gemfile"))
+ File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
+ gem name, options unless gemfile_content.include? name
+ end
+
+ def print_usage
+ self.class.help(Thor::Base.shell.new)
+ exit
+ end
+ end
+ end
+end