learn-open 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/learn_open/opener.rb +12 -6
- data/lib/learn_open/version.rb +1 -1
- data/spec/learn_open/opener_spec.rb +15 -13
- 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: 187cbff6f0a0e54e2c1eeee9df256c855cda0fdc
|
4
|
+
data.tar.gz: 73c0bb51b2d5dd3512d06ad889130987c13a6eb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2b5157421e1cdb8b5a791ee963153ad43ed7fc50c797b90d772bd5e2b1c466b8a8c2e7f35c1e2d7a16e457f100e036112d207b860261c11f44c241dba92663e
|
7
|
+
data.tar.gz: 6c70af6367cab4362834610ccfc3cdbbee44e614fa8a7625ffc75dbc109b97c73197879b6c3a8ce018ec5ee56e8bfcb72a4a282cd339b6aed4917814ab7b5bc7
|
data/lib/learn_open/opener.rb
CHANGED
@@ -39,12 +39,18 @@ module LearnOpen
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def repo_exists?
|
42
|
-
|
43
|
-
if File.exists?(
|
44
|
-
File.
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
cloned_labs = "#{HOME_DIR}/.cloned_labs"
|
43
|
+
if File.exists?(cloned_labs)
|
44
|
+
if File.readlines(cloned_labs).grep(/#{repo_dir}/).any?
|
45
|
+
until File.exists?("#{lessons_dir}/#{repo_dir}")
|
46
|
+
puts "Loading..."
|
47
|
+
puts Dir["#{lessons_dir}/*"].count
|
48
|
+
sleep 1
|
49
|
+
end
|
50
|
+
true
|
51
|
+
else
|
52
|
+
false
|
53
|
+
end
|
48
54
|
else
|
49
55
|
File.exists?("#{lessons_dir}/#{repo_dir}")
|
50
56
|
end
|
data/lib/learn_open/version.rb
CHANGED
@@ -5,32 +5,34 @@ describe LearnOpen::Opener do
|
|
5
5
|
|
6
6
|
context "Verifying repo existance" do
|
7
7
|
let(:opener) { LearnOpen::Opener.new("","","") }
|
8
|
-
|
8
|
+
before do
|
9
|
+
path = File.join(__dir__, "..", "home_dir", "code")
|
10
|
+
FileUtils.rm_rf(path)
|
11
|
+
end
|
12
|
+
|
13
|
+
context "with .cloned_labs file" do
|
9
14
|
before do
|
10
|
-
|
11
|
-
FileUtils.rm(
|
15
|
+
cloned_labs = "#{LearnOpen::Opener::HOME_DIR}/.cloned_labs"
|
16
|
+
FileUtils.rm(cloned_labs) if File.exists?(cloned_labs)
|
12
17
|
end
|
13
|
-
it "returns true if lab is in the .
|
14
|
-
expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
|
18
|
+
it "returns true if lab is in the .cloned_labs file" do
|
19
|
+
expect(opener).to receive(:repo_dir).at_least(:once).and_return("js-rubber-duck-wrangling")
|
15
20
|
|
16
|
-
File.open("#{LearnOpen::Opener::HOME_DIR}/.
|
21
|
+
File.open("#{LearnOpen::Opener::HOME_DIR}/.cloned_labs", "w+") do |f|
|
17
22
|
f.puts("js-rubber-duck-wrangling")
|
18
23
|
end
|
19
24
|
|
25
|
+
FileUtils.mkdir_p("#{opener.lessons_dir}/js-rubber-duck-wrangling")
|
26
|
+
|
20
27
|
expect(opener.repo_exists?).to be_truthy
|
21
28
|
end
|
22
|
-
it "returns false if lab is not in the .
|
29
|
+
it "returns false if lab is not in the .cloned_labs file" do
|
23
30
|
expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
|
24
31
|
expect(opener.repo_exists?).to be_falsy
|
25
32
|
end
|
26
33
|
end
|
27
34
|
|
28
|
-
context "without .
|
29
|
-
before do
|
30
|
-
path = File.join(__dir__, "..", "home_dir", "code")
|
31
|
-
FileUtils.rm_rf(path)
|
32
|
-
end
|
33
|
-
|
35
|
+
context "without .cloned_labs file" do
|
34
36
|
it "returns true if directory for lab exists" do
|
35
37
|
expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
|
36
38
|
FileUtils.mkdir_p("#{opener.lessons_dir}/js-rubber-duck-wrangling")
|