Sha256: 564d8e9e81bb078795ec13bc2263c3f5d1f54c024fc2814011549f729bff5728

Contents?: true

Size: 728 Bytes

Versions: 29

Compression:

Stored size: 728 Bytes

Contents

require 'active_support'
require 'active_support/core_ext'
require 'thor'
require 'eucalypt/helpers'

module Eucalypt
  module Generators
    class Model < Thor::Group
      include Thor::Actions
      include Eucalypt::Helpers

      def self.source_root
        File.join File.dirname(__dir__), 'templates'
      end

      def generate(spec: true, columns: [], table: true, name:)
        model = Inflect.new(:model, name)
        config = {class_name: model.class_name}
        template("model.tt", model.file_path, config)
        template("model_spec.tt", model.spec_path, config) if spec
        Eucalypt::CLI.start(['migration', 'create', 'table', Inflect.resources(name), *columns]) if table
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
eucalypt-0.9.0 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.8.0 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.7.2 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.7.1 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.7.0 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.6.2 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.6.1 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.6.0 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.5.4 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.5.3 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.5.2 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.5.1 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.5.0 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.4.2 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.4.1 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.4.0 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.3.5 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.3.4 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.3.3 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
eucalypt-0.3.2 lib/eucalypt/generate/namespaces/generate-model/generators/model.rb