Sha256: d616e0f0c323d04113c440ad0df446c1e5491d4ac5b1129c1994fc21db596268
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
#!/usr/bin/env ruby require 'rubygems' require 'thor' require 'thor/group' class New < Thor::Group include Thor::Actions # Define arguments and options argument :name class_option :ar, :default => false def copy_tree directory('project', "#{name}/") empty_directory("#{name}/log") empty_directory("#{name}/tmp") if ar copy_file("database.yml", "#{name}/config/database.yml") empty_directory("#{name}/db/migrate") end end def chmod_example_bin chmod "#{name}/bin/example", 0755 chmod "#{name}/bin/console", 0755 end private def self.source_root File.join(File.dirname(__FILE__), %w{.. generator }) end def base_name File.basename(name) end def ar options[:ar] end end class Migration < Thor::Group include Thor::Actions argument :name def copy_migration require 'active_support' require 'active_support/inflector' unless ''.respond_to?(:underscore) template("migration.rb.tt", "./db/migrate/#{migration_name}_#{name.underscore}.rb") end def self.source_root File.join(File.dirname(__FILE__), %w{.. generator }) end private def migration_name Time.now.utc.strftime("%Y%m%d%H%M%S") end end class RubyApp < Thor register New, :new, "new", "create new project [NAME]" register Migration, :migration, "migration", "generate migration [NAME] for app with AR" end RubyApp.start
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ruby-app-0.1.9 | bin/ruby-app |
ruby-app-0.1.8 | bin/ruby-app |
ruby-app-0.1.7 | bin/ruby-app |
ruby-app-0.1.6 | bin/ruby-app |