Class: BunBo
- Inherits:
-
Object
- Object
- BunBo
- Defined in:
- lib/bun_bo.rb,
lib/bun_bo/version.rb,
lib/bun_bo/content_generator.rb,
lib/bun_bo/errors/base_error.rb,
lib/bun_bo/errors/file_existed.rb,
lib/bun_bo/errors/file_not_found.rb
Defined Under Namespace
Classes: BaseError, ContentGenerator, FileExisted, FileNotFound
Constant Summary collapse
- VERSION =
"0.1.4"
Instance Method Summary collapse
Instance Method Details
#run(input_path) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bun_bo.rb', line 8 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 |