bun_bo 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -1
- data/exe/bun_bo +2 -5
- data/lib/bun_bo/results/base_error.rb +7 -0
- data/lib/bun_bo/results/directory_result.rb +19 -0
- data/lib/bun_bo/{errors → results}/file_existed.rb +1 -1
- data/lib/bun_bo/{errors → results}/file_not_found.rb +1 -1
- data/lib/bun_bo/results/success.rb +19 -0
- data/lib/bun_bo/version.rb +1 -1
- data/lib/bun_bo.rb +10 -4
- metadata +7 -5
- data/lib/bun_bo/errors/base_error.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9080163c619f84fe5f13192fdde2572a00a38ecc2b12fe23d17e8d8331e44fe7
|
4
|
+
data.tar.gz: fb4a901ba375f12e519ce1fc727c786049170c422f8e5cf06112e75bc1ec75cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e885e3b219426418b24b741a0f5a9eb72cb5e9c23c679b12451b76fcda6d76b95b6fa6ecc3c80518cbbe31f43c5a827464144fd41230d402fb5eca93e4506dfa
|
7
|
+
data.tar.gz: d33ab82e6659319cd14415238e262be2115c6847976a83df1b66e0acf67f83b0a1dbd10d6fccee3f793fd2d5edc8b5a1fb261391e4f60933a0b6efcd6ad0bd4f
|
data/README.md
CHANGED
@@ -4,6 +4,7 @@ This is a simple test generator for ruby code. The gem currently is a
|
|
4
4
|
work-in-progress. The functionality it intends to deliver:
|
5
5
|
|
6
6
|
- [x] Create new test file from existing ruby file
|
7
|
+
- [x] Create new test files for all ruby files in a folder
|
7
8
|
- [ ] Populate test file with `describe` block for class/module
|
8
9
|
- [ ] Populate test file with `describe` block for each method
|
9
10
|
- [ ] Support both minitest and rspec
|
@@ -18,8 +19,10 @@ $ gem install bun_bo
|
|
18
19
|
|
19
20
|
## Usage
|
20
21
|
|
22
|
+
### For single file
|
23
|
+
|
21
24
|
```shell
|
22
|
-
bun_bo <
|
25
|
+
bun_bo <file_path>
|
23
26
|
```
|
24
27
|
|
25
28
|
Example:
|
@@ -30,6 +33,36 @@ bun_bo lib/bun_bo.rb
|
|
30
33
|
|
31
34
|
The above command will create a new test file in `spec/bun_bo_spec.rb`.
|
32
35
|
|
36
|
+
### For folder
|
37
|
+
|
38
|
+
```shell
|
39
|
+
bun_bo <folder_path>
|
40
|
+
```
|
41
|
+
|
42
|
+
Example:
|
43
|
+
|
44
|
+
You have a directory tree like this:
|
45
|
+
|
46
|
+
```
|
47
|
+
lib
|
48
|
+
|___ folder
|
49
|
+
|___ file_1.rb
|
50
|
+
|___ file_2.rb
|
51
|
+
```
|
52
|
+
|
53
|
+
```shell
|
54
|
+
bun_bo lib/folder
|
55
|
+
```
|
56
|
+
|
57
|
+
The above command will create the below new test files:
|
58
|
+
|
59
|
+
```
|
60
|
+
spec
|
61
|
+
|___ folder
|
62
|
+
|___ file_1_spec.rb
|
63
|
+
|___ file_2_spec.rb
|
64
|
+
```
|
65
|
+
|
33
66
|
## Development
|
34
67
|
|
35
68
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/exe/bun_bo
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
class BunBo
|
2
|
+
class DirectoryResult
|
3
|
+
def initialize(results)
|
4
|
+
@results = results
|
5
|
+
end
|
6
|
+
|
7
|
+
def success?
|
8
|
+
results.all?(&:success?)
|
9
|
+
end
|
10
|
+
|
11
|
+
def message
|
12
|
+
results.map(&:message).join("\n")
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_reader :results
|
18
|
+
end
|
19
|
+
end
|
data/lib/bun_bo/version.rb
CHANGED
data/lib/bun_bo.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "bun_bo/version"
|
2
|
-
require "bun_bo/
|
3
|
-
require "bun_bo/
|
2
|
+
require "bun_bo/results/directory_result"
|
3
|
+
require "bun_bo/results/file_not_found"
|
4
|
+
require "bun_bo/results/file_existed"
|
5
|
+
require "bun_bo/results/success"
|
4
6
|
require "bun_bo/content_generator"
|
5
7
|
require 'fileutils'
|
6
8
|
|
@@ -20,11 +22,15 @@ class BunBo
|
|
20
22
|
FileUtils.mkdir_p(test_folder)
|
21
23
|
generator = ContentGenerator.new(Pathname.pwd)
|
22
24
|
test_path.write(generator.generate)
|
25
|
+
Success.new(test_path)
|
23
26
|
else
|
24
|
-
|
27
|
+
FileExisted.new(test_path)
|
25
28
|
end
|
29
|
+
elsif input_path.directory?
|
30
|
+
result = input_path.each_child.map { |child| run(child) }
|
31
|
+
BunBo::DirectoryResult.new(result)
|
26
32
|
else
|
27
|
-
|
33
|
+
FileNotFound.new
|
28
34
|
end
|
29
35
|
end
|
30
36
|
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.
|
4
|
+
version: 0.2.0
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,9 +73,11 @@ files:
|
|
73
73
|
- exe/bun_bo
|
74
74
|
- lib/bun_bo.rb
|
75
75
|
- lib/bun_bo/content_generator.rb
|
76
|
-
- lib/bun_bo/
|
77
|
-
- lib/bun_bo/
|
78
|
-
- lib/bun_bo/
|
76
|
+
- lib/bun_bo/results/base_error.rb
|
77
|
+
- lib/bun_bo/results/directory_result.rb
|
78
|
+
- lib/bun_bo/results/file_existed.rb
|
79
|
+
- lib/bun_bo/results/file_not_found.rb
|
80
|
+
- lib/bun_bo/results/success.rb
|
79
81
|
- lib/bun_bo/version.rb
|
80
82
|
homepage: https://github.com/hieuk09/bun_bo
|
81
83
|
licenses:
|