Sha256: 9b6c9e98ac93b050cf191c6c5bc456c5ba0f0f60da6fdcda70e28c208e263268

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

require "bun_bo/version"
require "bun_bo/errors/file_not_found"
require "bun_bo/errors/file_existed"
require "bun_bo/content_generator"
require 'fileutils'

class BunBo
  def run(input_path)
    input_path = Pathname.new(input_path)

    if input_path.file?
      folder_path, file_name = input_path.split
      extension = file_name.extname
      base_name = file_name.basename(extension)

      test_folder = folder_path.sub(/^(app|lib)/, 'spec')
      test_path = test_folder.join("#{base_name}_spec").sub_ext(".rb")

      if !test_path.exist?
        FileUtils.mkdir_p(test_folder)
        generator = ContentGenerator.new(Pathname.pwd)
        test_path.write(generator.generate)
      else
        raise FileExisted, test_path
      end
    else
      raise FileNotFound
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bun_bo-0.1.4 lib/bun_bo.rb