learn-open 1.2.5 → 1.2.6
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 +30 -27
- data/lib/learn_open/version.rb +1 -1
- data/spec/learn_open/opener_spec.rb +7 -56
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f71edf24bcdfc6d39ee8206c8ce1a2a5f666794f
|
4
|
+
data.tar.gz: 6c5defd9ef8d38ecd71c96f58c456baaa6e0a44d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee19d9ab4a82fdb889cffc99445d235aa0148daf84d02a3a7d3db3a13caec99104a5b6bce623486913e9d7819951f9caca128563481dd7e1df9855154248143f
|
7
|
+
data.tar.gz: 2ee07524eb58e33c98424a409aa132734be207debbf483f034fd3bf58e6c2e65dfd5a043556cb2fd47b7df3839c01cd5d4d176e80db553331aa6d354c89a37ee
|
data/lib/learn_open/opener.rb
CHANGED
@@ -29,30 +29,15 @@ module LearnOpen
|
|
29
29
|
if lesson_is_readme?
|
30
30
|
open_readme
|
31
31
|
else
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
open_with_editor
|
37
|
-
cd_to_lesson
|
32
|
+
git_tasks
|
33
|
+
file_tasks
|
34
|
+
dependency_tasks
|
35
|
+
completion_tasks
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
41
39
|
def repo_exists?
|
42
|
-
|
43
|
-
if File.exists?(cloned_labs)
|
44
|
-
puts "Loading..."
|
45
|
-
syncing_done = "#{HOME_DIR}/.syncing_started"
|
46
|
-
sleep 1 until File.exists?(syncing_done)
|
47
|
-
if File.readlines(cloned_labs).grep(/#{repo_dir}/).any?
|
48
|
-
sleep 1 until File.exists?("#{lessons_dir}/#{repo_dir}")
|
49
|
-
true
|
50
|
-
else
|
51
|
-
false
|
52
|
-
end
|
53
|
-
else
|
54
|
-
File.exists?("#{lessons_dir}/#{repo_dir}")
|
55
|
-
end
|
40
|
+
File.exists?("#{lessons_dir}/#{repo_dir}/.git")
|
56
41
|
end
|
57
42
|
|
58
43
|
private
|
@@ -270,7 +255,7 @@ module LearnOpen
|
|
270
255
|
if ios_lesson?
|
271
256
|
open_ios_lesson
|
272
257
|
elsif editor
|
273
|
-
system("
|
258
|
+
system("#{editor} .")
|
274
259
|
end
|
275
260
|
end
|
276
261
|
|
@@ -335,15 +320,12 @@ module LearnOpen
|
|
335
320
|
def cd_to_lesson
|
336
321
|
puts "Opening lesson..."
|
337
322
|
Dir.chdir("#{lessons_dir}/#{repo_dir}")
|
338
|
-
cleanup_tmp_file
|
339
|
-
puts "Done."
|
340
|
-
exec("#{ENV['SHELL']} -l")
|
341
323
|
end
|
342
324
|
|
343
325
|
def bundle_install
|
344
326
|
if !ios_lesson? && File.exists?("#{lessons_dir}/#{repo_dir}/Gemfile")
|
345
327
|
puts "Bundling..."
|
346
|
-
system("
|
328
|
+
system("bundle install > /dev/null 2>&1")
|
347
329
|
end
|
348
330
|
end
|
349
331
|
|
@@ -352,9 +334,9 @@ module LearnOpen
|
|
352
334
|
puts 'Installing dependencies...'
|
353
335
|
|
354
336
|
if ide_environment?
|
355
|
-
system("
|
337
|
+
system("yarn install --no-lockfile")
|
356
338
|
else
|
357
|
-
system("
|
339
|
+
system("npm install")
|
358
340
|
end
|
359
341
|
end
|
360
342
|
end
|
@@ -404,5 +386,26 @@ module LearnOpen
|
|
404
386
|
def ide_environment?
|
405
387
|
ENV['IDE_CONTAINER'] == "true"
|
406
388
|
end
|
389
|
+
|
390
|
+
def git_tasks
|
391
|
+
fork_repo
|
392
|
+
clone_repo
|
393
|
+
end
|
394
|
+
|
395
|
+
def file_tasks
|
396
|
+
cd_to_lesson
|
397
|
+
open_with_editor
|
398
|
+
end
|
399
|
+
|
400
|
+
def dependency_tasks
|
401
|
+
bundle_install
|
402
|
+
npm_install
|
403
|
+
end
|
404
|
+
|
405
|
+
def completion_tasks
|
406
|
+
cleanup_tmp_file
|
407
|
+
puts "Done."
|
408
|
+
exec("#{ENV['SHELL']} -l")
|
409
|
+
end
|
407
410
|
end
|
408
411
|
end
|
data/lib/learn_open/version.rb
CHANGED
@@ -10,65 +10,16 @@ describe LearnOpen::Opener do
|
|
10
10
|
FileUtils.rm_rf(path)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
FileUtils.rm(cloned_labs) if File.exists?(cloned_labs)
|
13
|
+
it "returns true if .git directory for lab exists" do
|
14
|
+
expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
|
15
|
+
FileUtils.mkdir_p("#{opener.lessons_dir}/js-rubber-duck-wrangling/.git")
|
17
16
|
|
18
|
-
|
19
|
-
FileUtils.rm(syncing_started) if File.exists?(syncing_started)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "returns true if lab is in the .cloned_labs file" do
|
23
|
-
expect(opener).to receive(:repo_dir).at_least(:once).and_return("js-rubber-duck-wrangling")
|
24
|
-
|
25
|
-
File.open("#{LearnOpen::Opener::HOME_DIR}/.cloned_labs", "w+") do |f|
|
26
|
-
f.puts("js-rubber-duck-wrangling")
|
27
|
-
end
|
28
|
-
|
29
|
-
File.open("#{LearnOpen::Opener::HOME_DIR}/.syncing_started", "w+") do |f|
|
30
|
-
f.puts("done")
|
31
|
-
end
|
32
|
-
|
33
|
-
FileUtils.mkdir_p("#{opener.lessons_dir}/js-rubber-duck-wrangling")
|
34
|
-
|
35
|
-
expect(opener.repo_exists?).to be_truthy
|
36
|
-
end
|
37
|
-
|
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
|
42
|
-
expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
|
43
|
-
expect(opener.repo_exists?).to be_falsy
|
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
|
17
|
+
expect(opener.repo_exists?).to be_truthy
|
58
18
|
end
|
59
19
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
FileUtils.mkdir_p("#{opener.lessons_dir}/js-rubber-duck-wrangling")
|
64
|
-
|
65
|
-
expect(opener.repo_exists?).to be_truthy
|
66
|
-
end
|
67
|
-
|
68
|
-
it "returns false if directory for lab doesn't exists" do
|
69
|
-
expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
|
70
|
-
expect(opener.repo_exists?).to be_falsy
|
71
|
-
end
|
20
|
+
it "returns false if directory for lab doesn't exists" do
|
21
|
+
expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
|
22
|
+
expect(opener.repo_exists?).to be_falsy
|
72
23
|
end
|
73
24
|
end
|
74
25
|
end
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flatiron School
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.6.
|
126
|
+
rubygems_version: 2.6.10
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Open Learn lessons locally
|