bun_bo 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44a4a1c7a917197bf417c931b912e9d4f306785df1b581e10b5ba262345baf1c
4
- data.tar.gz: bcfc15f4786909b3290576210489007afa505e271c55de6e4d21713779706405
3
+ metadata.gz: 9080163c619f84fe5f13192fdde2572a00a38ecc2b12fe23d17e8d8331e44fe7
4
+ data.tar.gz: fb4a901ba375f12e519ce1fc727c786049170c422f8e5cf06112e75bc1ec75cc
5
5
  SHA512:
6
- metadata.gz: 9c0dbba19175e90d0d4a51da84ee6cdb44eb1044cb0adf3c315663505bdc1ae34e632e5c5c7249106277c19002f63037393566e95e613799ee2ac7654711c604
7
- data.tar.gz: b61e580edf7ef2bf5ccc9ba6435f8f77b2866f094206b831504d5088221d82798a9649caf1f73884c17f6457e66cc161527bb621a6c2498436f6eacf448dd733
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 <file_name>
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
@@ -4,8 +4,5 @@ require "bun_bo"
4
4
 
5
5
  input_path = ARGV.first
6
6
 
7
- begin
8
- BunBo.new.run(input_path)
9
- rescue BunBo::BaseError => e
10
- puts e.message
11
- end
7
+ result = BunBo.new.run(input_path)
8
+ puts result.message
@@ -0,0 +1,7 @@
1
+ class BunBo
2
+ class BaseError
3
+ def success?
4
+ false
5
+ end
6
+ end
7
+ end
@@ -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
@@ -1,4 +1,4 @@
1
- require 'bun_bo/errors/base_error'
1
+ require 'bun_bo/results/base_error'
2
2
 
3
3
  class BunBo
4
4
  class FileExisted < BaseError
@@ -1,4 +1,4 @@
1
- require 'bun_bo/errors/base_error'
1
+ require 'bun_bo/results/base_error'
2
2
 
3
3
  class BunBo
4
4
  class FileNotFound < BaseError
@@ -0,0 +1,19 @@
1
+ class BunBo
2
+ class Success
3
+ def initialize(path)
4
+ @path = path
5
+ end
6
+
7
+ def success?
8
+ true
9
+ end
10
+
11
+ def message
12
+ "#{path} is created successfully."
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :path
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  class BunBo
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/bun_bo.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bun_bo/version"
2
- require "bun_bo/errors/file_not_found"
3
- require "bun_bo/errors/file_existed"
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
- raise FileExisted, test_path
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
- raise FileNotFound
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.1.4
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-22 00:00:00.000000000 Z
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/errors/base_error.rb
77
- - lib/bun_bo/errors/file_existed.rb
78
- - lib/bun_bo/errors/file_not_found.rb
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:
@@ -1,4 +0,0 @@
1
- class BunBo
2
- class BaseError < StandardError
3
- end
4
- end