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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce919d50ea888137cb8a19f22c046b2494ad631195316ec929fe4b728263ed8d
4
- data.tar.gz: 23fd7e27dadf7d54ce16dbe803abb613332feeeb8703421fdb2ddfd22831b227
3
+ metadata.gz: 44a4a1c7a917197bf417c931b912e9d4f306785df1b581e10b5ba262345baf1c
4
+ data.tar.gz: bcfc15f4786909b3290576210489007afa505e271c55de6e4d21713779706405
5
5
  SHA512:
6
- metadata.gz: 311e703e4e68f6f7b37c6bf2ed57adb9d2068745251d65bbcda85da5acee2e6302a6e730f7a8d09867b35bcb2f47a5fd9eb85806f18c5e247c9b26b0ce139927
7
- data.tar.gz: 69b0cb30793c1752acfbbb9b5ec3ee9d784f241adcb3fd809b32a619d4c664ad6971ab50671ad9a9cbe919c620591d39d1225565ccf3e7f998760262d02ccd4e
6
+ metadata.gz: 9c0dbba19175e90d0d4a51da84ee6cdb44eb1044cb0adf3c315663505bdc1ae34e632e5c5c7249106277c19002f63037393566e95e613799ee2ac7654711c604
7
+ data.tar.gz: b61e580edf7ef2bf5ccc9ba6435f8f77b2866f094206b831504d5088221d82798a9649caf1f73884c17f6457e66cc161527bb621a6c2498436f6eacf448dd733
data/README.md CHANGED
@@ -28,7 +28,7 @@ Example:
28
28
  bun_bo lib/bun_bo.rb
29
29
  ```
30
30
 
31
- The above command will create a new test file in `spec/lib/bun_bo_spec.rb`
31
+ The above command will create a new test file in `spec/bun_bo_spec.rb`.
32
32
 
33
33
  ## Development
34
34
 
data/exe/bun_bo CHANGED
@@ -6,6 +6,6 @@ input_path = ARGV.first
6
6
 
7
7
  begin
8
8
  BunBo.new.run(input_path)
9
- rescue BunBo::FileNotFound => e
9
+ rescue BunBo::BaseError => e
10
10
  puts e.message
11
11
  end
@@ -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,4 @@
1
+ class BunBo
2
+ class BaseError < StandardError
3
+ end
4
+ 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
@@ -1,5 +1,7 @@
1
+ require 'bun_bo/errors/base_error'
2
+
1
3
  class BunBo
2
- class FileNotFound < StandardError
4
+ class FileNotFound < BaseError
3
5
  def message
4
6
  "File does not exists"
5
7
  end
@@ -1,3 +1,3 @@
1
1
  class BunBo
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
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
- FileUtils.mkdir_p(test_folder)
18
- test_path.write('')
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.3
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-20 00:00:00.000000000 Z
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/file_not_found.rb
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: