lib/bun_bo.rb in bun_bo-0.1.1 vs lib/bun_bo.rb in bun_bo-0.1.2
- old
+ new
@@ -1,18 +1,21 @@
require "bun_bo/version"
+require 'fileutils'
class BunBo
def run(input_path)
- if File.file?(input_path)
- folder_path, file_name = File.split(input_path)
- extension = File.extname(file_name)
- base_name = File.basename(file_name, extension)
+ input_path = Pathname.new(input_path)
- test_folder = File.join('spec', folder_path)
- test_path = File.join(test_folder, "#{base_name}_spec#{extension}")
+ 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")
+
FileUtils.mkdir_p(test_folder)
- File.write(test_path, '')
+ test_path.write('')
else
puts "File does not exists"
end
end
end