Sha256: 066d64db92b41ff454c9e248b55c06b667ee27a4f9c1d9e148167f86bace7559

Contents?: true

Size: 652 Bytes

Versions: 1

Compression:

Stored size: 652 Bytes

Contents

module Totem
  module Tasks
    class Generator
      def migration(name)
        tstamp =  Time.now.utc.strftime("%Y%m%d%H%M%S")
        fname = "#{tstamp}_#{name}.rb"
        path = File.join(Totem.root, 'db', 'migrate', fname)

        name || raise('You must specify a name')

        puts "Creating migration: #{path}"

        if File.exists?(path)
          puts 'ERROR: File already exists.'
          return
        end

        content = <<-EOS.unindent
          class #{name.camelize} < ActiveRecord::Migration
          end
        EOS

        File.open(path, 'w') { |f| f.write(content) }

        return nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
totem-0.0.1 lib/totem/tasks/generator.rb