Sha256: 18d852b68fbbcc3c190b6d3cfb5780572f529aedcdb1ec9f01981038a6967a47

Contents?: true

Size: 638 Bytes

Versions: 2

Compression:

Stored size: 638 Bytes

Contents

module Sinatra
  class ModelDestroyer < Sinatra::NameCommand

    def self.command
      "destroy:model"
    end

    def self.help
      "model_name"
    end
    
    def initialize(*args)
      super
      @app_dir = File.expand_path(pwd)
    end

    def call
      path = File.expand_path(File.join(@app_dir, "models", "#{self.underscored}.rb"))
      begin
        rm path, verbose: true
      rescue Errno::ENOENT => e
      end
      path = File.expand_path(File.join(@app_dir, "spec", "models", "#{self.underscored}_spec.rb"))
      begin
        rm path, verbose: true
      rescue Errno::ENOENT => e
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sinatra-template-1.2.0 lib/sinatra/commands/model_destroyer_command.rb
sinatra-template-1.1.0 lib/sinatra/commands/model_destroyer_command.rb