rstub 0.1.0 → 0.1.1
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/lib/rstub.rb +4 -2
- data/rstub.gemspec +1 -1
- data/spec/file_parser_spec.rb +2 -1
- data/spec/fixtures/foo.rb +0 -5
- data/spec/rstub_spec.rb +10 -10
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d031d969fbd0db57f5ec06b0a02d363433312a3
|
|
4
|
+
data.tar.gz: 0bb0fea0e4bfbffc1f0bdd21ca4dc17276d5a9c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1dbe528955a923d9a448a5e17161eaa8d6a12960fa52d6fed879f02398997689eea16da8941452371024563cd55ff047124e19af151f96768e7c13e6d836efd5
|
|
7
|
+
data.tar.gz: 0970f3cf25f9cf6c0cb10e79612aa5214db99f9a950af6e4ebd05911e35dc88d2d7ceef4205b24d13132841c8ef85222d95cc3226a343e578f604cfc79124349
|
data/lib/rstub.rb
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
require 'rstub/file_parser'
|
|
2
|
+
require 'rstub/path_parser'
|
|
3
|
+
|
|
1
4
|
class RStub
|
|
2
5
|
attr_reader :file_parser, :path_parser
|
|
3
6
|
attr_accessor :target, :files, :directories, :target_files
|
|
@@ -7,8 +10,7 @@ class RStub
|
|
|
7
10
|
@path_parser = PathParser.new
|
|
8
11
|
end
|
|
9
12
|
|
|
10
|
-
def start(
|
|
11
|
-
args = raw_args.split(' ')
|
|
13
|
+
def start(args = [])
|
|
12
14
|
raise 'Not enough arguments' if args.size < 2
|
|
13
15
|
parse_args(args)
|
|
14
16
|
make_new_directory_structure
|
data/rstub.gemspec
CHANGED
data/spec/file_parser_spec.rb
CHANGED
|
@@ -9,6 +9,7 @@ describe FileParser do
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
after(:all) do
|
|
12
|
+
File.new('foo.rb', 'w')
|
|
12
13
|
Dir.chdir('../..')
|
|
13
14
|
end
|
|
14
15
|
|
|
@@ -17,7 +18,7 @@ describe FileParser do
|
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
def stub_all
|
|
20
|
-
RStub.new.start('* target')
|
|
21
|
+
RStub.new.start(['*', 'target'])
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def expect_text(text)
|
data/spec/fixtures/foo.rb
CHANGED
data/spec/rstub_spec.rb
CHANGED
|
@@ -15,53 +15,53 @@ describe RStub do
|
|
|
15
15
|
let(:rstub) { RStub.new }
|
|
16
16
|
|
|
17
17
|
it 'creates the correct directory and file' do
|
|
18
|
-
rstub.start('foo.rb target')
|
|
18
|
+
rstub.start(['foo.rb', 'target'])
|
|
19
19
|
expect(Dir.exist?('target')).to be true
|
|
20
20
|
expect(File.exist?('target/foo.rb')).to be true
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it 'raises error with invalid number of arguments' do
|
|
24
24
|
expect{rstub.start}.to raise_error('Not enough arguments')
|
|
25
|
-
expect{rstub.start('foo')}.to raise_error('Not enough arguments')
|
|
25
|
+
expect{rstub.start(['foo'])}.to raise_error('Not enough arguments')
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it 'raises error if the last argument isn\'t a directory' do
|
|
29
|
-
expect{rstub.start('foo.rb baz.rb')}
|
|
29
|
+
expect{rstub.start(['foo.rb', 'baz.rb'])}
|
|
30
30
|
.to raise_error('The last argument needs to be a directory')
|
|
31
|
-
expect{rstub.start('target foo.rb')}
|
|
31
|
+
expect{rstub.start(['target', 'foo.rb'])}
|
|
32
32
|
.to raise_error('The last argument needs to be a directory')
|
|
33
|
-
expect{rstub.start('foo.rb *')}
|
|
33
|
+
expect{rstub.start(['foo.rb', '*'])}
|
|
34
34
|
.to raise_error('The last argument needs to be a directory')
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it 'doesn\'t create files that aren\' already there but were passed in' do
|
|
38
|
-
rstub.start('bar.rb target')
|
|
38
|
+
rstub.start(['bar.rb', 'target'])
|
|
39
39
|
expect(Dir.exist?('target')).to be true
|
|
40
40
|
expect(File.exist?('target/bar.rb')).to be false
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it 'adds multiple files to the directory' do
|
|
44
|
-
rstub.start('foo.rb baz.rb target')
|
|
44
|
+
rstub.start(['foo.rb', 'baz.rb', 'target'])
|
|
45
45
|
expect(Dir.exist?('target')).to be true
|
|
46
46
|
expect(File.exist?('target/foo.rb')).to be true
|
|
47
47
|
expect(File.exist?('target/baz.rb')).to be true
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it 'doesn\'t add nonexistent files even when there are multiple files' do
|
|
51
|
-
rstub.start('foo.rb bar.rb target')
|
|
51
|
+
rstub.start(['foo.rb', 'bar.rb', 'target'])
|
|
52
52
|
expect(Dir.exist?('target')).to be true
|
|
53
53
|
expect(File.exist?('target/foo.rb')).to be true
|
|
54
54
|
expect(File.exist?('target/bar.rb')).to be false
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it 'doesn\'t add nonexistent files even with wildcard' do
|
|
58
|
-
rstub.start('foo/* target')
|
|
58
|
+
rstub.start(['foo/*', 'target'])
|
|
59
59
|
expect(Dir.exist?('target')).to be true
|
|
60
60
|
expect(Dir.exist?('target/foo')).to be false
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it 'all files are added with wildcard' do
|
|
64
|
-
rstub.start('* target')
|
|
64
|
+
rstub.start(['*', 'target'])
|
|
65
65
|
expect(Dir.exist?('target')).to be true
|
|
66
66
|
expect(File.exist?('target/foo.rb')).to be true
|
|
67
67
|
expect(File.exist?('target/baz.rb')).to be true
|