Sha256: 99f97621ef22560c393028ab2a6f3808cdb964fb056be47f56e4c7d54a899720

Contents?: true

Size: 992 Bytes

Versions: 4

Compression:

Stored size: 992 Bytes

Contents

require 'plans/command'

module Plans
  class New < Command

    def do(doc_type)
      plans_path = plans_pathname(@options[:'plans-path'])
      check_plans_pathname_exists plans_path

      doc_path = plans_path + doc_type
      check_doc_path_exists(doc_path, plans_path, doc_type)

      # Set the Thor::Actions destination root to the current working directory.
      self.destination_root = '.'
      # copy the template directory, but don't include the reference word docs.
      directory(doc_path, "./#{doc_type}", :exclude_pattern => /docx/)
    end

    def check_doc_path_exists(doc_path, plans_path, doc_type)
      unless doc_path.exist?
        say "Cannot create DOC_TYPE #{doc_type} because this template does not exist.", :red
        say 'Try `plans list` to see the available DOC_TYPEs or'
        say 'check the templates in the .plans directory here:'
        say "  #{plans_path}"
        raise_error("DOC_TYPE #{doc_type} does not exist.")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
plans-0.4.1 lib/plans/new.rb
plans-0.3.0 lib/plans/new.rb
plans-0.2.0 lib/plans/new.rb
plans-0.1.0 lib/plans/new.rb