rstub 0.1.2 → 0.1.3
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 +4 -4
- data/Gemfile +1 -1
- data/bin/rstub +1 -2
- data/lib/rstub.rb +10 -3
- data/lib/rstub/path_parser.rb +3 -7
- data/rstub.gemspec +1 -1
- data/spec/path_parser_spec.rb +0 -14
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ecffc042bdc6192d0e134540bf3952861dc70bac
|
|
4
|
+
data.tar.gz: dc688dd4721bd4cbde6f381b058cb55d2e6972d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29c7d8a57f05805d818a1fe56b987cb303de7d9d0cca65829f259694c8944c5268ffa86ff539fcac9fb53231e8631d5cc95fe3f07832ecc959f4ef14cdcd241a
|
|
7
|
+
data.tar.gz: 2f6d0adc62a34381d6d269380c735e4285d90b81c7f01b5bcfbbf419d4573fbf31b2646b98e8a52f97b480e6a9369c9aeb1fe1c6209d7d2ff6a79b26c41b2400
|
data/Gemfile
CHANGED
data/bin/rstub
CHANGED
data/lib/rstub.rb
CHANGED
|
@@ -22,23 +22,30 @@ class RStub
|
|
|
22
22
|
|
|
23
23
|
private
|
|
24
24
|
|
|
25
|
+
def directory?(directory)
|
|
26
|
+
!/^\.?\w+$/.match(directory).nil?
|
|
27
|
+
end
|
|
28
|
+
|
|
25
29
|
# returns a hash with a files key with a value of an array of the files to be
|
|
26
30
|
# stubbed and a directory key with the name of the directory to be made as a
|
|
27
31
|
# string
|
|
28
32
|
def parse_args(args)
|
|
29
33
|
self.target = args.pop
|
|
30
|
-
unless
|
|
34
|
+
unless directory?(target)
|
|
31
35
|
fail ArgumentError, 'The last argument needs to be a directory'
|
|
32
36
|
end
|
|
33
37
|
self.files = args
|
|
34
38
|
end
|
|
35
39
|
|
|
36
40
|
def make_target_directory
|
|
37
|
-
Dir.mkdir(target)
|
|
41
|
+
Dir.mkdir(target) unless Dir.exists? target
|
|
38
42
|
end
|
|
39
43
|
|
|
40
44
|
def make_new_directories
|
|
41
|
-
directories.each
|
|
45
|
+
directories.each do |d|
|
|
46
|
+
new_dir = "#{target}/#{d}"
|
|
47
|
+
Dir.mkdir(new_dir) unless d == target && Dir.exists?(new_dir)
|
|
48
|
+
end
|
|
42
49
|
end
|
|
43
50
|
|
|
44
51
|
def make_new_files
|
data/lib/rstub/path_parser.rb
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
# PathParser parses directory and file paths into a hash with directory and file
|
|
2
2
|
# arrays.
|
|
3
3
|
class PathParser
|
|
4
|
-
def self.directory?(directory)
|
|
5
|
-
!(/^\.?\w+$/ =~ directory).nil?
|
|
6
|
-
end
|
|
7
|
-
|
|
8
4
|
def get_globs(files)
|
|
9
5
|
glob_files = check_globs(files)
|
|
10
6
|
directories = get_directories(glob_files)
|
|
@@ -15,7 +11,7 @@ class PathParser
|
|
|
15
11
|
private
|
|
16
12
|
|
|
17
13
|
def glob?(file)
|
|
18
|
-
|
|
14
|
+
!/\*/.match(file).nil?
|
|
19
15
|
end
|
|
20
16
|
|
|
21
17
|
def check_globs(files)
|
|
@@ -25,7 +21,7 @@ class PathParser
|
|
|
25
21
|
end
|
|
26
22
|
|
|
27
23
|
def in_directory?(file)
|
|
28
|
-
|
|
24
|
+
!%r{\/}.match(file).nil?
|
|
29
25
|
end
|
|
30
26
|
|
|
31
27
|
def extract_directories(file)
|
|
@@ -41,7 +37,7 @@ class PathParser
|
|
|
41
37
|
end
|
|
42
38
|
|
|
43
39
|
def get_directories(files)
|
|
44
|
-
files.select { |file|
|
|
40
|
+
files.select { |file| Dir.exist?(file) }
|
|
45
41
|
.concat(parse_out_directories(files))
|
|
46
42
|
end
|
|
47
43
|
|
data/rstub.gemspec
CHANGED
data/spec/path_parser_spec.rb
CHANGED
|
@@ -7,20 +7,6 @@ describe PathParser do
|
|
|
7
7
|
Dir.chdir('../..')
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
describe '::directory?' do
|
|
11
|
-
it 'no file extension is directory' do
|
|
12
|
-
expect(PathParser.directory?('bar')).to be true
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'file extension is file' do
|
|
16
|
-
expect(PathParser.directory?('foo.rb')).to be false
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'detects hidden directories' do
|
|
20
|
-
expect(PathParser.directory?('.bar')).to be true
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
10
|
describe '#get_globs' do
|
|
25
11
|
let(:path_parser) { PathParser.new }
|
|
26
12
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rstub
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Kim
|
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
85
85
|
version: '0'
|
|
86
86
|
requirements: []
|
|
87
87
|
rubyforge_project:
|
|
88
|
-
rubygems_version: 2.4.
|
|
88
|
+
rubygems_version: 2.4.8
|
|
89
89
|
signing_key:
|
|
90
90
|
specification_version: 4
|
|
91
91
|
summary: A gem to stub out code
|