bun_bo 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/exe/bun_bo +1 -1
- data/lib/bun_bo/content_generator.rb +21 -0
- data/lib/bun_bo/errors/base_error.rb +4 -0
- data/lib/bun_bo/errors/file_existed.rb +17 -0
- data/lib/bun_bo/{file_not_found.rb → errors/file_not_found.rb} +3 -1
- data/lib/bun_bo/version.rb +1 -1
- data/lib/bun_bo.rb +10 -3
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44a4a1c7a917197bf417c931b912e9d4f306785df1b581e10b5ba262345baf1c
|
4
|
+
data.tar.gz: bcfc15f4786909b3290576210489007afa505e271c55de6e4d21713779706405
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c0dbba19175e90d0d4a51da84ee6cdb44eb1044cb0adf3c315663505bdc1ae34e632e5c5c7249106277c19002f63037393566e95e613799ee2ac7654711c604
|
7
|
+
data.tar.gz: b61e580edf7ef2bf5ccc9ba6435f8f77b2866f094206b831504d5088221d82798a9649caf1f73884c17f6457e66cc161527bb621a6c2498436f6eacf448dd733
|
data/README.md
CHANGED
data/exe/bun_bo
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
class BunBo
|
2
|
+
class ContentGenerator
|
3
|
+
def initialize(root_path)
|
4
|
+
@root_path = root_path
|
5
|
+
end
|
6
|
+
|
7
|
+
def generate
|
8
|
+
if root_path.join('spec', 'rails_helper.rb').exist?
|
9
|
+
"require 'rails_helper'"
|
10
|
+
elsif root_path.join('spec', 'spec_helper.rb').exist?
|
11
|
+
"require 'spec_helper'"
|
12
|
+
else
|
13
|
+
''
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :root_path
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bun_bo/errors/base_error'
|
2
|
+
|
3
|
+
class BunBo
|
4
|
+
class FileExisted < BaseError
|
5
|
+
def initialize(path)
|
6
|
+
@path = path
|
7
|
+
end
|
8
|
+
|
9
|
+
def message
|
10
|
+
"#{path} exists. No modification is applied for this file."
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_reader :path
|
16
|
+
end
|
17
|
+
end
|
data/lib/bun_bo/version.rb
CHANGED
data/lib/bun_bo.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "bun_bo/version"
|
2
|
-
require "bun_bo/file_not_found"
|
2
|
+
require "bun_bo/errors/file_not_found"
|
3
|
+
require "bun_bo/errors/file_existed"
|
4
|
+
require "bun_bo/content_generator"
|
3
5
|
require 'fileutils'
|
4
6
|
|
5
7
|
class BunBo
|
@@ -14,8 +16,13 @@ class BunBo
|
|
14
16
|
test_folder = folder_path.sub(/^(app|lib)/, 'spec')
|
15
17
|
test_path = test_folder.join("#{base_name}_spec").sub_ext(".rb")
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
+
if !test_path.exist?
|
20
|
+
FileUtils.mkdir_p(test_folder)
|
21
|
+
generator = ContentGenerator.new(Pathname.pwd)
|
22
|
+
test_path.write(generator.generate)
|
23
|
+
else
|
24
|
+
raise FileExisted, test_path
|
25
|
+
end
|
19
26
|
else
|
20
27
|
raise FileNotFound
|
21
28
|
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.1.
|
4
|
+
version: 0.1.4
|
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-
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,7 +72,10 @@ files:
|
|
72
72
|
- bun_bo.gemspec
|
73
73
|
- exe/bun_bo
|
74
74
|
- lib/bun_bo.rb
|
75
|
-
- lib/bun_bo/
|
75
|
+
- lib/bun_bo/content_generator.rb
|
76
|
+
- lib/bun_bo/errors/base_error.rb
|
77
|
+
- lib/bun_bo/errors/file_existed.rb
|
78
|
+
- lib/bun_bo/errors/file_not_found.rb
|
76
79
|
- lib/bun_bo/version.rb
|
77
80
|
homepage: https://github.com/hieuk09/bun_bo
|
78
81
|
licenses:
|