Sha256: fc2ba45e6f9ff66840ed6ff572251be0568e49ffcd11e8c255e8613a6ab82911

Contents?: true

Size: 559 Bytes

Versions: 3

Compression:

Stored size: 559 Bytes

Contents

namespace 'mk' do

  def make_class_template file_name, class_line
    unless File.exists? file_name
      f = File.new file_name, 'w+'
      f << class_line
      f << "\nend"
      f.close
    end
  end

  task :migration, :name do |_, args|
    make_class_template "migrations/#{Time.now.utc.strftime('%Y%m%d%H%M%S')}_#{args[:name]}.rb", "class #{args[:name].camelize} < ActiveRecord::Migration"
  end

  task :model, :name do |_, args|
    make_class_template "models/#{args[:name]}.rb", "class Kit::#{args[:name].camelize} < ActiveRecord::Base"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kit-1.1.0 lib/kit/rake/admin/make.rb
kit-1.0.1 lib/kit/rake/admin/make.rb
kit-1.0.0 lib/kit/rake/admin/make.rb