gh-diff 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gh-diff.rb +2 -0
- data/lib/gh-diff/cli.rb +3 -0
- data/lib/gh-diff/version.rb +1 -1
- data/spec/cli_spec.rb +7 -1
- data/spec/gh-diff_spec.rb +4 -0
- 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: 58a7afc6f9936f07dc10fc7eba22da6cc50b6232
|
4
|
+
data.tar.gz: 98dee8f50d2d2148c302a05cc85fdd03fd8657a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64760cc1db798ee4718a24afa8864904e44f9e5d95bdeed3846d1db7e6f0e951348691302119380b8b43c504265015194877881fa19d8225d7b8fd9159358dbb
|
7
|
+
data.tar.gz: a0c9929f293389dd2a29ecbc3d3b50790c04344bb8e8c402c737227bbd3d2c42448b7030cb5b0e58806fa4d5cda8ea7b5411ffadc2e31dee1f221e331689b035
|
data/lib/gh-diff.rb
CHANGED
@@ -10,6 +10,7 @@ require "togglate"
|
|
10
10
|
|
11
11
|
module GhDiff
|
12
12
|
class RepositoryNameError < StandardError; end
|
13
|
+
class NoDirectoryError < StandardError; end
|
13
14
|
class Diff
|
14
15
|
attr_accessor :repo, :revision, :dir
|
15
16
|
def initialize(repo, revision:'master', dir:nil)
|
@@ -37,6 +38,7 @@ module GhDiff
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def dir_diff(directory, repo:@repo, revision:@revision, dir:@dir)
|
41
|
+
raise NoDirectoryError unless Dir.exist?(directory)
|
40
42
|
local_files = Dir.glob("#{directory}/*").map { |f| File.basename f }
|
41
43
|
remote_path = build_path(dir, directory)
|
42
44
|
remote_files = get_contents(repo, remote_path, revision).map(&:name)
|
data/lib/gh-diff/cli.rb
CHANGED
data/lib/gh-diff/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -126,11 +126,17 @@ describe GhDiff::CLI do
|
|
126
126
|
end
|
127
127
|
|
128
128
|
it "raises an error when repo is empty" do
|
129
|
-
ARGV.replace %w(dir_diff docs
|
129
|
+
ARGV.replace %w(dir_diff docs --repo=)
|
130
130
|
expect { GhDiff::CLI.start }.to raise_error(SystemExit)
|
131
131
|
expect($stdout.string).to match(/Repository should/)
|
132
132
|
end
|
133
133
|
|
134
|
+
it "raises an error when directory not exsit" do
|
135
|
+
ARGV.replace %w(dir_diff docs/hello --repo=jekyll/jekyll --dir=site)
|
136
|
+
expect { GhDiff::CLI.start }.to raise_error(SystemExit)
|
137
|
+
expect($stdout.string).to match(/Directory not found/)
|
138
|
+
end
|
139
|
+
|
134
140
|
context "with save option" do
|
135
141
|
it "saves new files" do
|
136
142
|
VCR.use_cassette('save-dir-diff') do
|
data/spec/gh-diff_spec.rb
CHANGED