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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8eefb801c37c1a63235d568a07042a6991a276b
4
- data.tar.gz: a71612e54d72db7c25ec6f71d99d37e5432dac73
3
+ metadata.gz: f71edf24bcdfc6d39ee8206c8ce1a2a5f666794f
4
+ data.tar.gz: 6c5defd9ef8d38ecd71c96f58c456baaa6e0a44d
5
5
  SHA512:
6
- metadata.gz: 806ca91e2f01aa4240d1dc42374705e78a7caa00ed9c95ff0b905debd0db7e427e3959bb4ed68290279c35903eaf794ede8592bdb807cc629c69a5bf65f06860
7
- data.tar.gz: 39ad9ac85c6257441b7821236fc1f78e547f75b70f6fb64ac6bdcac0e815fa67cfd8309e7cd5d1eabfcdfcbea249f0fd81f5b3711b4b0ae1f1e27ce712a62f24
6
+ metadata.gz: ee19d9ab4a82fdb889cffc99445d235aa0148daf84d02a3a7d3db3a13caec99104a5b6bce623486913e9d7819951f9caca128563481dd7e1df9855154248143f
7
+ data.tar.gz: 2ee07524eb58e33c98424a409aa132734be207debbf483f034fd3bf58e6c2e65dfd5a043556cb2fd47b7df3839c01cd5d4d176e80db553331aa6d354c89a37ee
@@ -29,30 +29,15 @@ module LearnOpen
29
29
  if lesson_is_readme?
30
30
  open_readme
31
31
  else
32
- fork_repo
33
- clone_repo
34
- bundle_install
35
- npm_install
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
- cloned_labs = "#{HOME_DIR}/.cloned_labs"
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("cd #{lessons_dir}/#{repo_dir} && #{editor} .")
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("cd #{lessons_dir}/#{repo_dir} && bundle install > /dev/null 2>&1")
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("cd #{lessons_dir}/#{repo_dir} && yarn install --no-lockfile")
337
+ system("yarn install --no-lockfile")
356
338
  else
357
- system("cd #{lessons_dir}/#{repo_dir} && npm install")
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
@@ -1,3 +1,3 @@
1
1
  module LearnOpen
2
- VERSION = '1.2.5'
2
+ VERSION = '1.2.6'
3
3
  end
@@ -10,65 +10,16 @@ describe LearnOpen::Opener do
10
10
  FileUtils.rm_rf(path)
11
11
  end
12
12
 
13
- context "with .cloned_labs file" do
14
- after do
15
- cloned_labs = "#{LearnOpen::Opener::HOME_DIR}/.cloned_labs"
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
- syncing_started = "#{LearnOpen::Opener::HOME_DIR}/.syncing_started"
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
- context "without .cloned_labs file" do
61
- it "returns true if directory for lab exists" do
62
- expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
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.5
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-03-06 00:00:00.000000000 Z
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.8
126
+ rubygems_version: 2.6.10
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Open Learn lessons locally