learn-open 1.2.2 → 1.2.3
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 +4 -5
- data/lib/learn_open/version.rb +1 -1
- data/spec/learn_open/opener_spec.rb +27 -2
- 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: e3956d3ee82551fddb6e65f916bae370b8b90dc7
|
4
|
+
data.tar.gz: ec2a1c366eeec4a0756b20883406b4eca9a1c519
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d2bf84191e5b578e0563d4d92e3db05460fea2d3bff766a39bd0151162508d3310852ac7d1b4b92bc9fca5903fe1957fd38976f10d9d81ffc50be3f36d80fe7
|
7
|
+
data.tar.gz: 277b383633ddf01fd09fee7fa310c1951869a081413c6191e18032661fd6e588475c85ad1e3be779323ca77f4459fb3b1786ca05a85a44e153a5eef60833f3e7
|
data/lib/learn_open/opener.rb
CHANGED
@@ -41,12 +41,11 @@ module LearnOpen
|
|
41
41
|
def repo_exists?
|
42
42
|
cloned_labs = "#{HOME_DIR}/.cloned_labs"
|
43
43
|
if File.exists?(cloned_labs)
|
44
|
+
puts "Loading..."
|
45
|
+
syncing_done = "#{HOME_DIR}/.syncing_started"
|
46
|
+
sleep 1 until File.exists?(syncing_done)
|
44
47
|
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
|
48
|
+
sleep 1 until File.exists?("#{lessons_dir}/#{repo_dir}")
|
50
49
|
true
|
51
50
|
else
|
52
51
|
false
|
data/lib/learn_open/version.rb
CHANGED
@@ -5,16 +5,20 @@ describe LearnOpen::Opener do
|
|
5
5
|
|
6
6
|
context "Verifying repo existance" do
|
7
7
|
let(:opener) { LearnOpen::Opener.new("","","") }
|
8
|
-
|
8
|
+
after do
|
9
9
|
path = File.join(__dir__, "..", "home_dir", "code")
|
10
10
|
FileUtils.rm_rf(path)
|
11
11
|
end
|
12
12
|
|
13
13
|
context "with .cloned_labs file" do
|
14
|
-
|
14
|
+
after do
|
15
15
|
cloned_labs = "#{LearnOpen::Opener::HOME_DIR}/.cloned_labs"
|
16
16
|
FileUtils.rm(cloned_labs) if File.exists?(cloned_labs)
|
17
|
+
|
18
|
+
syncing_started = "#{LearnOpen::Opener::HOME_DIR}/.syncing_started"
|
19
|
+
FileUtils.rm(syncing_started) if File.exists?(syncing_started)
|
17
20
|
end
|
21
|
+
|
18
22
|
it "returns true if lab is in the .cloned_labs file" do
|
19
23
|
expect(opener).to receive(:repo_dir).at_least(:once).and_return("js-rubber-duck-wrangling")
|
20
24
|
|
@@ -22,14 +26,35 @@ describe LearnOpen::Opener do
|
|
22
26
|
f.puts("js-rubber-duck-wrangling")
|
23
27
|
end
|
24
28
|
|
29
|
+
File.open("#{LearnOpen::Opener::HOME_DIR}/.syncing_started", "w+") do |f|
|
30
|
+
f.puts("done")
|
31
|
+
end
|
32
|
+
|
25
33
|
FileUtils.mkdir_p("#{opener.lessons_dir}/js-rubber-duck-wrangling")
|
26
34
|
|
27
35
|
expect(opener.repo_exists?).to be_truthy
|
28
36
|
end
|
37
|
+
|
29
38
|
it "returns false if lab is not in the .cloned_labs file" do
|
39
|
+
File.open("#{LearnOpen::Opener::HOME_DIR}/.syncing_started", "w+") do |f|
|
40
|
+
f.puts("done")
|
41
|
+
end
|
30
42
|
expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
|
31
43
|
expect(opener.repo_exists?).to be_falsy
|
32
44
|
end
|
45
|
+
|
46
|
+
context "before filesyncing starts" do
|
47
|
+
it "waits for .syncing_started " do
|
48
|
+
File.open("#{LearnOpen::Opener::HOME_DIR}/.cloned_labs", "w+") do |f|
|
49
|
+
f.puts("js-rubber-duck-wrangling")
|
50
|
+
end
|
51
|
+
|
52
|
+
FileUtils.mkdir_p("#{opener.lessons_dir}/js-rubber-duck-wrangling")
|
53
|
+
expect do
|
54
|
+
Timeout::timeout(2) { opener.repo_exists? }
|
55
|
+
end.to raise_error(Timeout::Error)
|
56
|
+
end
|
57
|
+
end
|
33
58
|
end
|
34
59
|
|
35
60
|
context "without .cloned_labs file" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: learn-open
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flatiron School
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|