Sha256: 82abae98e875c145507fb08627c87b03a496db8009874c14d8920667b8a7afcb

Contents?: true

Size: 960 Bytes

Versions: 4

Compression:

Stored size: 960 Bytes

Contents

require 'eucalypt/eucalypt-generate/namespaces/generate-controller/generators/controller'
require 'eucalypt/app'
require 'eucalypt/errors'
require 'eucalypt/helpers'

module Eucalypt
  class Generate < Thor
    include Eucalypt::Helpers
    using Colorize
    option :spec, type: :boolean, default: true, desc: "Include a controller spec file"
    option :rest, aliases: '-r', type: :boolean, default: false,  desc: "Generate REST routes for the controller"
    desc "controller [NAME]", "Generates a controller".colorize(:grey)
    def controller(name)
      directory = File.expand_path('.')
      if Eucalypt.app? directory
        controller = Eucalypt::Generators::Controller.new
        controller.destination_root = directory
        controller.generate(
          name: name,
          spec: options[:spec],
          rest: options[:rest],
          policy: false
        )
      else
        Eucalypt::Error.wrong_directory
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eucalypt-0.1.3 lib/eucalypt/eucalypt-generate/namespaces/generate-controller/cli/generate-controller.rb
eucalypt-0.1.2 lib/eucalypt/eucalypt-generate/namespaces/generate-controller/cli/generate-controller.rb
eucalypt-0.1.1 lib/eucalypt/eucalypt-generate/namespaces/generate-controller/cli/generate-controller.rb
eucalypt-0.1.0 lib/eucalypt/eucalypt-generate/namespaces/generate-controller/cli/generate-controller.rb