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 +4 -4
- data/lib/bun_bo.rb +16 -9
- data/lib/bun_bo/results/wrong_extension.rb +17 -0
- data/lib/bun_bo/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d70f547b5f97c59e6bf23c20b624a1e5c47635c53ee97c829191896c3c191b7e
|
4
|
+
data.tar.gz: f2920219986d42d6a988d93c32d742f77dd878645278fc6b8547c0fe5c64d77a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
19
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
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) }
|
data/lib/bun_bo/version.rb
CHANGED
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.
|
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-
|
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:
|