bun_bo 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9080163c619f84fe5f13192fdde2572a00a38ecc2b12fe23d17e8d8331e44fe7
4
- data.tar.gz: fb4a901ba375f12e519ce1fc727c786049170c422f8e5cf06112e75bc1ec75cc
3
+ metadata.gz: d70f547b5f97c59e6bf23c20b624a1e5c47635c53ee97c829191896c3c191b7e
4
+ data.tar.gz: f2920219986d42d6a988d93c32d742f77dd878645278fc6b8547c0fe5c64d77a
5
5
  SHA512:
6
- metadata.gz: e885e3b219426418b24b741a0f5a9eb72cb5e9c23c679b12451b76fcda6d76b95b6fa6ecc3c80518cbbe31f43c5a827464144fd41230d402fb5eca93e4506dfa
7
- data.tar.gz: d33ab82e6659319cd14415238e262be2115c6847976a83df1b66e0acf67f83b0a1dbd10d6fccee3f793fd2d5edc8b5a1fb261391e4f60933a0b6efcd6ad0bd4f
6
+ metadata.gz: d6f5185fcb85bb5b9c28a733194b9908a9fa8e2f76ab52bdcb579a6645c6b36f1c231ebd551fce0b47ff9380574c37dc5d1d1175ea89186a4cab29dc812f59b0
7
+ data.tar.gz: 98b30689bc7de135ffac377c71b2c55d6cc61fa18f20d15a468b961eab7c90b13150052baf56eeb8359344bec97e17ed7547cce233b47cbfbdb0ac908283be5c
data/lib/bun_bo.rb CHANGED
@@ -2,29 +2,36 @@ require "bun_bo/version"
2
2
  require "bun_bo/results/directory_result"
3
3
  require "bun_bo/results/file_not_found"
4
4
  require "bun_bo/results/file_existed"
5
+ require "bun_bo/results/wrong_extension"
5
6
  require "bun_bo/results/success"
6
7
  require "bun_bo/content_generator"
7
8
  require 'fileutils'
8
9
 
9
10
  class BunBo
11
+ RUBY_EXTENSIONS = %w(.rb .rake)
12
+
10
13
  def run(input_path)
11
14
  input_path = Pathname.new(input_path)
12
15
 
13
16
  if input_path.file?
14
17
  folder_path, file_name = input_path.split
15
18
  extension = file_name.extname
16
- base_name = file_name.basename(extension)
17
19
 
18
- test_folder = folder_path.sub(/^(app|lib)/, 'spec')
19
- test_path = test_folder.join("#{base_name}_spec").sub_ext(".rb")
20
+ if RUBY_EXTENSIONS.include?(extension)
21
+ base_name = file_name.basename(extension)
22
+ test_folder = folder_path.sub(/^(app|lib)/, 'spec')
23
+ test_path = test_folder.join("#{base_name}_spec").sub_ext(".rb")
20
24
 
21
- if !test_path.exist?
22
- FileUtils.mkdir_p(test_folder)
23
- generator = ContentGenerator.new(Pathname.pwd)
24
- test_path.write(generator.generate)
25
- Success.new(test_path)
25
+ if test_path.exist?
26
+ FileExisted.new(test_path)
27
+ else
28
+ FileUtils.mkdir_p(test_folder)
29
+ generator = ContentGenerator.new(Pathname.pwd)
30
+ test_path.write(generator.generate)
31
+ Success.new(test_path)
32
+ end
26
33
  else
27
- FileExisted.new(test_path)
34
+ WrongExtension.new(test_path)
28
35
  end
29
36
  elsif input_path.directory?
30
37
  result = input_path.each_child.map { |child| run(child) }
@@ -0,0 +1,17 @@
1
+ require 'bun_bo/results/base_error'
2
+
3
+ class BunBo
4
+ class WrongExtension < BaseError
5
+ def initialize(path)
6
+ @path = path
7
+ end
8
+
9
+ def message
10
+ "#{path} is not a correct ruby file."
11
+ end
12
+
13
+ private
14
+
15
+ attr_reader :path
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  class BunBo
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bun_bo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hieu Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-30 00:00:00.000000000 Z
11
+ date: 2018-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,6 +78,7 @@ files:
78
78
  - lib/bun_bo/results/file_existed.rb
79
79
  - lib/bun_bo/results/file_not_found.rb
80
80
  - lib/bun_bo/results/success.rb
81
+ - lib/bun_bo/results/wrong_extension.rb
81
82
  - lib/bun_bo/version.rb
82
83
  homepage: https://github.com/hieuk09/bun_bo
83
84
  licenses: