learn-open 1.2.22 → 1.2.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/learn-open +7 -2
- data/lib/learn_open.rb +4 -0
- data/lib/learn_open/adapters/learn_web_adapter.rb +2 -1
- data/lib/learn_open/argument_parser.rb +33 -20
- data/lib/learn_open/environments/base_environment.rb +4 -4
- data/lib/learn_open/environments/ide_environment.rb +3 -3
- data/lib/learn_open/environments/jupyter_container_environment.rb +3 -8
- data/lib/learn_open/environments/linux_environment.rb +1 -1
- data/lib/learn_open/environments/mac_environment.rb +4 -4
- data/lib/learn_open/lessons/base_lesson.rb +2 -0
- data/lib/learn_open/lessons/ios_lesson.rb +2 -2
- data/lib/learn_open/lessons/jupyter_lesson.rb +2 -2
- data/lib/learn_open/lessons/lab_lesson.rb +2 -2
- data/lib/learn_open/lessons/readme_lesson.rb +1 -1
- data/lib/learn_open/opener.rb +6 -4
- data/lib/learn_open/services/lesson_downloader.rb +4 -3
- data/lib/learn_open/version.rb +1 -1
- data/spec/fakes/fake_learn_client.rb +10 -0
- data/spec/learn_open/argument_parser_spec.rb +93 -0
- data/spec/learn_open/environments/ide_environment_spec.rb +21 -5
- data/spec/learn_open/environments/jupyter_container_environment_spec.rb +95 -0
- data/spec/learn_open/opener_spec.rb +95 -44
- data/spec/learn_open/services/lesson_downloader_spec.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a2315b5750af05a40423c2ed0ad7524e4e6c466e7c48d2ff71b6687c264f0b8
|
4
|
+
data.tar.gz: 36664ed4926d4651bf7ca76c23d47139edc86d4a4e4200e01d1d95f0d26218b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3ab4bffda355cb42203733a64a19c55ab788684b8dde17f80a9a10e571cfd2047a0139d87c0e4a9c9180d38e72bed105fd8b33ffca58d7a7699349771ebcee7
|
7
|
+
data.tar.gz: 93e940e9c4164b2ebbb55185e3deb432f9c96ad61fa348284b05e55e495c9aa12ea6fb7758c0ba703fe4cf41c0b6a997735a27dc006102ca085b79e945efdb8b
|
data/bin/learn-open
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'learn_open'
|
4
4
|
|
5
|
-
lesson, editor_specified, next_lesson = LearnOpen::ArgumentParser.new(ARGV).execute
|
5
|
+
lesson, editor_specified, next_lesson, clone_only = LearnOpen::ArgumentParser.new(ARGV).execute
|
6
6
|
|
7
|
-
LearnOpen::Opener.run(
|
7
|
+
LearnOpen::Opener.run(
|
8
|
+
lesson: lesson,
|
9
|
+
editor_specified: editor_specified,
|
10
|
+
get_next_lesson: next_lesson,
|
11
|
+
clone_only: clone_only
|
12
|
+
)
|
data/lib/learn_open.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module LearnOpen
|
2
2
|
module Adapters
|
3
3
|
class LearnWebAdapter
|
4
|
-
attr_reader :client
|
4
|
+
attr_reader :client, :io
|
5
5
|
|
6
6
|
def initialize(options = {})
|
7
7
|
@client = options.fetch(:learn_web_client) {LearnOpen.learn_web_client}
|
8
|
+
@io = options.fetch(:io) {LearnOpen.default_io}
|
8
9
|
end
|
9
10
|
|
10
11
|
def fetch_lesson_data(target_lesson: false, fetch_next_lesson: false)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
1
3
|
module LearnOpen
|
2
4
|
class ArgumentParser
|
3
5
|
attr_reader :args
|
@@ -6,31 +8,42 @@ module LearnOpen
|
|
6
8
|
@args = args
|
7
9
|
end
|
8
10
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
def parse
|
12
|
+
options = {}
|
13
|
+
rest = OptionParser.new do |opts|
|
14
|
+
opts.on("--next", "open next lab") do |n|
|
15
|
+
options[:next] = n
|
16
|
+
end
|
17
|
+
opts.on("--editor=EDITOR", "specify editor") do |e|
|
18
|
+
options[:editor] = e
|
19
|
+
end
|
15
20
|
|
16
|
-
|
17
|
-
|
21
|
+
opts.on("--clone-only", "only download files. No shell") do |co|
|
22
|
+
options[:clone_only] = co
|
23
|
+
end
|
24
|
+
end.parse(args)
|
25
|
+
options[:lesson_name] = rest.first
|
26
|
+
options
|
27
|
+
end
|
18
28
|
|
19
|
-
|
20
|
-
|
21
|
-
|
29
|
+
def learn_config_editor
|
30
|
+
config_path = File.expand_path('~/.learn-config')
|
31
|
+
editor = YAML.load(File.read(config_path))[:editor]
|
32
|
+
editor.split.first
|
33
|
+
end
|
22
34
|
|
23
|
-
|
24
|
-
|
25
|
-
elsif ARGV[0].start_with?('--next')
|
26
|
-
next_lesson = true
|
27
|
-
end
|
35
|
+
def execute
|
36
|
+
cli_args = parse
|
28
37
|
|
29
|
-
|
30
|
-
|
31
|
-
end
|
38
|
+
editor = cli_args[:editor].empty? ? learn_config_editor : cli_args[:editor]
|
39
|
+
cli_args.merge!(editor: editor)
|
32
40
|
|
33
|
-
[
|
41
|
+
[
|
42
|
+
cli_args[:lesson_name],
|
43
|
+
cli_args[:editor],
|
44
|
+
cli_args[:next],
|
45
|
+
cli_args[:clone_only]
|
46
|
+
]
|
34
47
|
end
|
35
48
|
end
|
36
49
|
end
|
@@ -16,21 +16,21 @@ module LearnOpen
|
|
16
16
|
false
|
17
17
|
end
|
18
18
|
|
19
|
-
def open_jupyter_lab(
|
19
|
+
def open_jupyter_lab(_lesson, _location, _editor, _clone_only)
|
20
20
|
:noop
|
21
21
|
end
|
22
22
|
|
23
|
-
def open_lab(lesson, location, editor)
|
23
|
+
def open_lab(lesson, location, editor, clone_only)
|
24
24
|
case lesson
|
25
25
|
when LearnOpen::Lessons::IosLesson
|
26
26
|
io.puts "You need to be on a Mac to work on iOS lessons."
|
27
27
|
else
|
28
28
|
case download_lesson(lesson, location)
|
29
29
|
when :ok, :noop
|
30
|
-
open_editor(lesson, location, editor)
|
30
|
+
open_editor(lesson, location, editor) unless clone_only
|
31
31
|
install_dependencies(lesson, location)
|
32
32
|
notify_of_completion
|
33
|
-
open_shell
|
33
|
+
open_shell unless clone_only
|
34
34
|
when :ssh_unauthenticated
|
35
35
|
io.puts 'Failed to obtain an SSH connection!'
|
36
36
|
else
|
@@ -13,7 +13,7 @@ module LearnOpen
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def open_jupyter_lab(lesson, location, editor)
|
16
|
+
def open_jupyter_lab(lesson, location, editor, _clone_only)
|
17
17
|
when_valid(lesson) do
|
18
18
|
warn_if_necessary(lesson)
|
19
19
|
io.puts "Opening Jupyter Lesson..."
|
@@ -21,7 +21,7 @@ module LearnOpen
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def open_lab(lesson, location, editor)
|
24
|
+
def open_lab(lesson, location, editor, clone_only)
|
25
25
|
when_valid(lesson) do
|
26
26
|
warn_if_necessary(lesson)
|
27
27
|
case lesson
|
@@ -33,7 +33,7 @@ module LearnOpen
|
|
33
33
|
start_file_backup(lesson, location)
|
34
34
|
install_dependencies(lesson, location)
|
35
35
|
notify_of_completion
|
36
|
-
open_shell
|
36
|
+
open_shell unless clone_only
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -5,13 +5,12 @@ module LearnOpen
|
|
5
5
|
true
|
6
6
|
end
|
7
7
|
|
8
|
-
def open_jupyter_lab(lesson, location, editor)
|
8
|
+
def open_jupyter_lab(lesson, location, editor, clone_only)
|
9
9
|
download_lesson(lesson, location)
|
10
|
-
|
11
|
-
start_file_backup(lesson, location)
|
10
|
+
start_file_backup(lesson, location) if lesson.use_student_fork
|
12
11
|
install_jupyter_dependencies(lesson, location)
|
13
12
|
notify_of_completion
|
14
|
-
open_shell
|
13
|
+
open_shell unless clone_only
|
15
14
|
end
|
16
15
|
|
17
16
|
def open_editor(lesson, location, editor)
|
@@ -23,10 +22,6 @@ module LearnOpen
|
|
23
22
|
def install_jupyter_dependencies(lesson, location)
|
24
23
|
LearnOpen::DependencyInstallers::JupyterPipInstall.call(lesson, location, self, options)
|
25
24
|
end
|
26
|
-
|
27
|
-
def open_shell
|
28
|
-
system_adapter.open_login_shell(environment_vars['SHELL'])
|
29
|
-
end
|
30
25
|
end
|
31
26
|
end
|
32
27
|
end
|
@@ -7,7 +7,7 @@ module LearnOpen
|
|
7
7
|
system_adapter.run_command("xdg-open #{lesson.to_url}")
|
8
8
|
end
|
9
9
|
|
10
|
-
def open_jupyter_lab(lesson, location,
|
10
|
+
def open_jupyter_lab(lesson, location, _editor, _clone_only)
|
11
11
|
warn_if_necessary(lesson)
|
12
12
|
io.puts "Opening Jupyter Lesson..."
|
13
13
|
system_adapter.run_command("xdg-open #{lesson.to_url}")
|
@@ -19,20 +19,20 @@ module LearnOpen
|
|
19
19
|
system_adapter.run_command("open -a Safari #{lesson.to_url}")
|
20
20
|
end
|
21
21
|
|
22
|
-
def open_lab(lesson, location, editor)
|
22
|
+
def open_lab(lesson, location, editor, clone_only)
|
23
23
|
warn_if_necessary(lesson)
|
24
24
|
case lesson
|
25
25
|
when LearnOpen::Lessons::IosLesson
|
26
26
|
download_lesson(lesson, location)
|
27
27
|
open_xcode(lesson)
|
28
28
|
notify_of_completion
|
29
|
-
open_shell
|
29
|
+
open_shell unless clone_only
|
30
30
|
else
|
31
31
|
super
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def open_jupyter_lab(lesson, location, editor)
|
35
|
+
def open_jupyter_lab(lesson, location, editor, _clone_only)
|
36
36
|
warn_if_necessary(lesson)
|
37
37
|
io.puts "Opening Jupyter Lesson..."
|
38
38
|
system_adapter.run_command("open -a Safari #{lesson.to_url}")
|
@@ -64,7 +64,7 @@ module LearnOpen
|
|
64
64
|
system_adapter.run_command("open -a 'Google Chrome' #{lesson.to_url}")
|
65
65
|
end
|
66
66
|
|
67
|
-
def open_jupyter_lab(lesson, location,
|
67
|
+
def open_jupyter_lab(lesson, location, _editor, _clone_only)
|
68
68
|
warn_if_necessary(lesson)
|
69
69
|
io.puts "Opening Jupyter Lesson..."
|
70
70
|
system_adapter.run_command("open -a 'Google Chrome' #{lesson.to_url}")
|
@@ -8,6 +8,7 @@ module LearnOpen
|
|
8
8
|
:dot_learn,
|
9
9
|
:git_server,
|
10
10
|
:later_lesson,
|
11
|
+
:use_student_fork,
|
11
12
|
:options,
|
12
13
|
:io,
|
13
14
|
:system_adapter,
|
@@ -25,6 +26,7 @@ module LearnOpen
|
|
25
26
|
@git_server = lesson.git_server
|
26
27
|
@dot_learn = lesson.dot_learn
|
27
28
|
@is_lab = lesson.lab
|
29
|
+
@use_student_fork = lesson.use_student_fork
|
28
30
|
@later_lesson = lesson_data[:later_lesson]
|
29
31
|
@id = lesson_data[:id]
|
30
32
|
|
@@ -6,8 +6,8 @@ module LearnOpen
|
|
6
6
|
(languages & ["swift", "objc"]).any?
|
7
7
|
end
|
8
8
|
|
9
|
-
def open(environment, editor)
|
10
|
-
environment.open_lab(self, location, editor)
|
9
|
+
def open(environment, editor, clone_only)
|
10
|
+
environment.open_lab(self, location, editor, clone_only)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -6,8 +6,8 @@ module LearnOpen
|
|
6
6
|
!!dot_learn[:jupyter_notebook]
|
7
7
|
end
|
8
8
|
|
9
|
-
def open(environment, editor)
|
10
|
-
environment.open_jupyter_lab(self, location, editor)
|
9
|
+
def open(environment, editor, clone_only)
|
10
|
+
environment.open_jupyter_lab(self, location, editor, clone_only)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module LearnOpen
|
2
2
|
module Lessons
|
3
3
|
class LabLesson < BaseLesson
|
4
|
-
def open(environment, editor)
|
5
|
-
environment.open_lab(self, location, editor)
|
4
|
+
def open(environment, editor, clone_only)
|
5
|
+
environment.open_lab(self, location, editor, clone_only)
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
data/lib/learn_open/opener.rb
CHANGED
@@ -3,18 +3,20 @@ module LearnOpen
|
|
3
3
|
attr_reader :editor,
|
4
4
|
:target_lesson,
|
5
5
|
:get_next_lesson,
|
6
|
+
:clone_only,
|
6
7
|
:io,
|
7
8
|
:logger,
|
8
9
|
:options
|
9
10
|
|
10
|
-
def self.run(lesson:, editor_specified:, get_next_lesson:)
|
11
|
-
new(lesson, editor_specified, get_next_lesson).run
|
11
|
+
def self.run(lesson:, editor_specified:, get_next_lesson:, clone_only:)
|
12
|
+
new(lesson, editor_specified, get_next_lesson, clone_only).run
|
12
13
|
end
|
13
14
|
|
14
|
-
def initialize(target_lesson, editor, get_next_lesson, options = {})
|
15
|
+
def initialize(target_lesson, editor, get_next_lesson, clone_only, options = {})
|
15
16
|
@target_lesson = target_lesson
|
16
17
|
@editor = editor
|
17
18
|
@get_next_lesson = get_next_lesson
|
19
|
+
@clone_only = clone_only
|
18
20
|
|
19
21
|
@io = options.fetch(:io, LearnOpen.default_io)
|
20
22
|
@logger = options.fetch(:logger, LearnOpen.logger)
|
@@ -35,7 +37,7 @@ module LearnOpen
|
|
35
37
|
|
36
38
|
lesson = Lessons.classify(lesson_data, options)
|
37
39
|
environment = LearnOpen::Environments.classify(options)
|
38
|
-
lesson.open(environment, editor)
|
40
|
+
lesson.open(environment, editor, clone_only)
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module LearnOpen
|
2
2
|
class LessonDownloader
|
3
|
-
attr_reader :lesson, :location, :environment, :io, :logger, :client, :git_adapter
|
3
|
+
attr_reader :lesson, :location, :environment, :io, :logger, :client, :git_adapter, :git_ssh_connector
|
4
4
|
|
5
5
|
def self.call(lesson, location, environment, options = {})
|
6
6
|
self.new(lesson, location, environment, options).call
|
@@ -14,12 +14,13 @@ module LearnOpen
|
|
14
14
|
@logger = options.fetch(:logger) { LearnOpen.logger }
|
15
15
|
@io = options.fetch(:io) { LearnOpen.default_io }
|
16
16
|
@git_adapter = options.fetch(:git_adapter) { LearnOpen.git_adapter }
|
17
|
+
@git_ssh_connector = options.fetch(:git_ssh_connector) { LearnOpen.git_adapter }
|
17
18
|
end
|
18
19
|
|
19
20
|
def call
|
20
21
|
if !repo_exists?
|
21
22
|
if ensure_git_ssh!
|
22
|
-
fork_repo
|
23
|
+
fork_repo if lesson.use_student_fork
|
23
24
|
clone_repo
|
24
25
|
:ok
|
25
26
|
else
|
@@ -31,7 +32,7 @@ module LearnOpen
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def ensure_git_ssh!
|
34
|
-
|
35
|
+
git_ssh_connector.call(git_server: lesson.git_server, environment: environment)
|
35
36
|
end
|
36
37
|
|
37
38
|
def fork_repo(retries = 3)
|
data/lib/learn_open/version.rb
CHANGED
@@ -16,6 +16,7 @@ class FakeLearnClient
|
|
16
16
|
:lab=>true,
|
17
17
|
:ios_lab=>false,
|
18
18
|
:ruby_lab=>true,
|
19
|
+
:use_student_fork=>true,
|
19
20
|
:assessments=>
|
20
21
|
[{:type=>"fork", :passing=>true, :failing=>false, :started=>true, :message=>"You forked this lab."},
|
21
22
|
{:type=>"local_build", :passing=>false, :failing=>true, :started=>true, :message=>"Build failures."},
|
@@ -35,6 +36,7 @@ class FakeLearnClient
|
|
35
36
|
:lesson_id=>31322,
|
36
37
|
:later_lesson=>false,
|
37
38
|
:git_server=>"github.com",
|
39
|
+
:use_student_fork=>true,
|
38
40
|
:dot_learn=>{
|
39
41
|
:tags=>[
|
40
42
|
"UIView"
|
@@ -50,6 +52,7 @@ class FakeLearnClient
|
|
50
52
|
:lab=>true,
|
51
53
|
:lesson_id=>31322,
|
52
54
|
:later_lesson=>false,
|
55
|
+
:use_student_fork=>true,
|
53
56
|
:git_server=>"github.com",
|
54
57
|
:dot_learn=>{
|
55
58
|
:tags=>[
|
@@ -65,6 +68,7 @@ class FakeLearnClient
|
|
65
68
|
:repo_slug=>"StevenNunez/jupyter_lab",
|
66
69
|
:lab=>true,
|
67
70
|
:lesson_id=>31322,
|
71
|
+
:use_student_fork=>true,
|
68
72
|
:later_lesson=>false,
|
69
73
|
:git_server=>"github.com",
|
70
74
|
:dot_learn=>{
|
@@ -83,6 +87,7 @@ class FakeLearnClient
|
|
83
87
|
:lab=>true,
|
84
88
|
:lesson_id=>31322,
|
85
89
|
:later_lesson=>false,
|
90
|
+
:use_student_fork=>true,
|
86
91
|
:git_server=>"github.com",
|
87
92
|
:dot_learn=>{
|
88
93
|
:tags=>[
|
@@ -99,6 +104,7 @@ class FakeLearnClient
|
|
99
104
|
:lab=>true,
|
100
105
|
:lesson_id=>31322,
|
101
106
|
:later_lesson=>false,
|
107
|
+
:use_student_fork=>true,
|
102
108
|
:git_server=>"github.com",
|
103
109
|
:dot_learn=>{
|
104
110
|
:tags=>[
|
@@ -115,6 +121,7 @@ class FakeLearnClient
|
|
115
121
|
:lab=>true,
|
116
122
|
:lesson_id=>31322,
|
117
123
|
:later_lesson=>false,
|
124
|
+
:use_student_fork=>true,
|
118
125
|
:git_server=>"github.com",
|
119
126
|
:dot_learn=>{
|
120
127
|
:tags=>[
|
@@ -131,6 +138,7 @@ class FakeLearnClient
|
|
131
138
|
:lab=>false,
|
132
139
|
:lesson_id=>31322,
|
133
140
|
:later_lesson=>false,
|
141
|
+
:use_student_fork=>true,
|
134
142
|
:git_server=>"github.com",
|
135
143
|
:dot_learn=>{
|
136
144
|
:tags=>[
|
@@ -148,6 +156,7 @@ class FakeLearnClient
|
|
148
156
|
:lesson_id=>31322,
|
149
157
|
:later_lesson=>true,
|
150
158
|
:git_server=>"github.com",
|
159
|
+
:use_student_fork=>true,
|
151
160
|
:dot_learn=>{
|
152
161
|
:tags=>[
|
153
162
|
"Readable things"
|
@@ -169,6 +178,7 @@ class FakeLearnClient
|
|
169
178
|
:forked_repo=>"StevenNunez/rails-dynamic-request-lab-cb-000",
|
170
179
|
:clone_repo=>"StevenNunez/rails-dynamic-request-lab-cb-000",
|
171
180
|
:git_server=>"github.com",
|
181
|
+
:use_student_fork=>true,
|
172
182
|
:dot_learn=>
|
173
183
|
{
|
174
184
|
:tags=>[
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fakefs/spec_helpers'
|
3
|
+
|
4
|
+
describe LearnOpen::ArgumentParser do
|
5
|
+
include FakeFS::SpecHelpers
|
6
|
+
let(:home_dir) { File.expand_path('~') }
|
7
|
+
|
8
|
+
before do
|
9
|
+
FileUtils.mkdir_p home_dir
|
10
|
+
end
|
11
|
+
|
12
|
+
context "" do
|
13
|
+
it 'reads the .learn-config for the editor' do
|
14
|
+
File.open("#{home_dir}/.learn-config", "w+") do |f|
|
15
|
+
f.puts <<-EOF
|
16
|
+
---
|
17
|
+
:learn_directory: "#{home_dir}/Development/code"
|
18
|
+
:editor: vim
|
19
|
+
EOF
|
20
|
+
end
|
21
|
+
args = ['--editor=']
|
22
|
+
_lesson, editor, _load_next = LearnOpen::ArgumentParser.new(args).execute
|
23
|
+
expect(editor).to eq('vim')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'ignores switches in the editor field' do
|
27
|
+
File.open("#{home_dir}/.learn-config", "w+") do |f|
|
28
|
+
f.puts <<-EOF
|
29
|
+
---
|
30
|
+
:learn_directory: "#{home_dir}/Development/code"
|
31
|
+
:editor: vim -m
|
32
|
+
EOF
|
33
|
+
end
|
34
|
+
args = ['--editor=']
|
35
|
+
_lesson, editor, _load_next = LearnOpen::ArgumentParser.new(args).execute
|
36
|
+
expect(editor).to eq('vim')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'overrides editor is passed in as argument' do
|
40
|
+
File.open("#{home_dir}/.learn-config", "w+") do |f|
|
41
|
+
f.puts <<-EOF
|
42
|
+
---
|
43
|
+
:learn_directory: "#{home_dir}/Development/code"
|
44
|
+
:editor: vim -m
|
45
|
+
EOF
|
46
|
+
end
|
47
|
+
args = ['--editor=atom']
|
48
|
+
_lesson, editor, _load_next = LearnOpen::ArgumentParser.new(args).execute
|
49
|
+
expect(editor).to eq('atom')
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'parses next lab if --next spedified' do
|
53
|
+
File.open("#{home_dir}/.learn-config", "w+") do |f|
|
54
|
+
f.puts <<-EOF
|
55
|
+
---
|
56
|
+
:learn_directory: "#{home_dir}/Development/code"
|
57
|
+
:editor: atom
|
58
|
+
EOF
|
59
|
+
end
|
60
|
+
args = ['--next', '--editor=vim']
|
61
|
+
_lesson, editor, load_next = LearnOpen::ArgumentParser.new(args).execute
|
62
|
+
expect(load_next).to eq(true)
|
63
|
+
expect(editor).to eq('vim')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'parses lab name if provided' do
|
67
|
+
File.open("#{home_dir}/.learn-config", "w+") do |f|
|
68
|
+
f.puts <<-EOF
|
69
|
+
---
|
70
|
+
:learn_directory: "#{home_dir}/Development/code"
|
71
|
+
:editor: emacs
|
72
|
+
EOF
|
73
|
+
end
|
74
|
+
args = ['hashketball', '--editor=vim']
|
75
|
+
lesson, editor, _load_next = LearnOpen::ArgumentParser.new(args).execute
|
76
|
+
expect(lesson).to eq('hashketball')
|
77
|
+
expect(editor).to eq('vim')
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'accepts a --clone-only argument' do
|
81
|
+
File.open("#{home_dir}/.learn-config", "w+") do |f|
|
82
|
+
f.puts <<-EOF
|
83
|
+
---
|
84
|
+
:learn_directory: "#{home_dir}/Development/code"
|
85
|
+
:editor: emacs
|
86
|
+
EOF
|
87
|
+
end
|
88
|
+
args = ['hashketball', '--editor=vim', '--clone-only']
|
89
|
+
_lesson, _editor, _load_next, clone_only = LearnOpen::ArgumentParser.new(args).execute
|
90
|
+
expect(clone_only).to eq(true)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -34,13 +34,13 @@ describe LearnOpen::Environments::IDEEnvironment do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it "opens correct lab" do
|
37
|
-
environment.open_lab(lesson, double, double)
|
37
|
+
environment.open_lab(lesson, double, double, false)
|
38
38
|
custom_commands_log = File.read("#{@home_dir}/.custom_commands.log")
|
39
39
|
expect(custom_commands_log).to eq(%Q{{"command":"open_lab","lab_name":"a-different-lesson"}\n})
|
40
40
|
end
|
41
41
|
|
42
42
|
it "opens correct jupyter lab" do
|
43
|
-
environment.open_jupyter_lab(lesson, double, double)
|
43
|
+
environment.open_jupyter_lab(lesson, double, double, false)
|
44
44
|
custom_commands_log = File.read("#{@home_dir}/.custom_commands.log")
|
45
45
|
expect(custom_commands_log).to eq(%Q{{"command":"open_lab","lab_name":"a-different-lesson"}\n})
|
46
46
|
end
|
@@ -58,20 +58,35 @@ describe LearnOpen::Environments::IDEEnvironment do
|
|
58
58
|
to_url: "valid-lesson-url",
|
59
59
|
to_path: @home_dir,
|
60
60
|
git_server: "github.com",
|
61
|
-
repo_path: "/org/lesson"
|
61
|
+
repo_path: "/org/lesson",
|
62
|
+
use_student_fork: true
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
let(:deployed_source_lesson) do
|
67
|
+
double(
|
68
|
+
name: "valid_lab",
|
69
|
+
later_lesson: false,
|
70
|
+
to_url: "valid-lesson-url",
|
71
|
+
to_path: @home_dir,
|
72
|
+
git_server: "github.com",
|
73
|
+
repo_path: "/org/lesson",
|
74
|
+
use_student_fork: false
|
62
75
|
)
|
63
76
|
end
|
64
77
|
|
65
78
|
let(:env_vars) {{ "LAB_NAME" => "valid_lab", "CREATED_USER" => "bobby", "SHELL" => "/usr/local/fish"}}
|
66
79
|
let(:git_adapter) { double }
|
67
80
|
let(:system_adapter) { double }
|
81
|
+
let(:git_ssh_connector) { double(call: true) }
|
68
82
|
let(:environment) do
|
69
83
|
subject.new({
|
70
84
|
io: io,
|
71
85
|
environment_vars: env_vars,
|
72
86
|
logger: spy,
|
73
87
|
git_adapter: git_adapter,
|
74
|
-
system_adapter: system_adapter
|
88
|
+
system_adapter: system_adapter,
|
89
|
+
git_ssh_connector: git_ssh_connector
|
75
90
|
})
|
76
91
|
end
|
77
92
|
|
@@ -84,6 +99,7 @@ describe LearnOpen::Environments::IDEEnvironment do
|
|
84
99
|
it "opens the lab" do
|
85
100
|
location = double
|
86
101
|
editor = "vim"
|
102
|
+
clone_only = false
|
87
103
|
|
88
104
|
expect(io).to receive(:puts).with("Forking lesson...")
|
89
105
|
expect(io).to receive(:puts).with("Cloning lesson...")
|
@@ -108,7 +124,7 @@ describe LearnOpen::Environments::IDEEnvironment do
|
|
108
124
|
.to receive(:open_login_shell)
|
109
125
|
.with("/usr/local/fish")
|
110
126
|
|
111
|
-
environment.open_lab(lesson, location, editor)
|
127
|
+
environment.open_lab(lesson, location, editor, clone_only)
|
112
128
|
end
|
113
129
|
end
|
114
130
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fakefs/spec_helpers'
|
3
|
+
|
4
|
+
describe LearnOpen::Environments::JupyterContainerEnvironment do
|
5
|
+
include FakeFS::SpecHelpers
|
6
|
+
subject { LearnOpen::Environments::JupyterContainerEnvironment }
|
7
|
+
|
8
|
+
let(:io) { instance_double(LearnOpen::Adapters::IOAdapter) }
|
9
|
+
|
10
|
+
context "valid environments" do
|
11
|
+
before do
|
12
|
+
@home_dir = create_linux_home_dir("bobby")
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:lesson) do
|
16
|
+
double(
|
17
|
+
name: "valid_lab",
|
18
|
+
later_lesson: false,
|
19
|
+
to_url: "valid-lesson-url",
|
20
|
+
to_path: @home_dir,
|
21
|
+
git_server: "github.com",
|
22
|
+
repo_path: "/org/lesson",
|
23
|
+
use_student_fork: true
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:deployed_source_lesson) do
|
28
|
+
double(
|
29
|
+
name: "valid_lab",
|
30
|
+
later_lesson: false,
|
31
|
+
to_url: "valid-lesson-url",
|
32
|
+
to_path: @home_dir,
|
33
|
+
git_server: "github.com",
|
34
|
+
repo_path: "/org/lesson",
|
35
|
+
use_student_fork: false
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:env_vars) {{ "LAB_NAME" => "valid_lab", "CREATED_USER" => "bobby", "SHELL" => "/usr/local/fish"}}
|
40
|
+
let(:git_adapter) { double }
|
41
|
+
let(:system_adapter) { double }
|
42
|
+
let(:git_ssh_connector) { double(call: true) }
|
43
|
+
let(:environment) do
|
44
|
+
subject.new({
|
45
|
+
io: io,
|
46
|
+
environment_vars: env_vars,
|
47
|
+
logger: spy,
|
48
|
+
git_adapter: git_adapter,
|
49
|
+
system_adapter: system_adapter,
|
50
|
+
git_ssh_connector: git_ssh_connector
|
51
|
+
})
|
52
|
+
end
|
53
|
+
|
54
|
+
it "only clones repo when not using student fork" do
|
55
|
+
location = double
|
56
|
+
editor = "vim"
|
57
|
+
clone_only = false
|
58
|
+
|
59
|
+
expect(io).to receive(:puts).with("Cloning lesson...")
|
60
|
+
expect(io).to receive(:puts).with("Done.")
|
61
|
+
expect(git_adapter)
|
62
|
+
.to receive(:clone)
|
63
|
+
.with("git@github.com:/org/lesson.git", "valid_lab", {:path=> location})
|
64
|
+
expect(system_adapter)
|
65
|
+
.to receive(:open_login_shell)
|
66
|
+
.with("/usr/local/fish")
|
67
|
+
|
68
|
+
environment.open_jupyter_lab(deployed_source_lesson, location, editor, clone_only)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "opens the lab" do
|
72
|
+
location = double
|
73
|
+
editor = "vim"
|
74
|
+
clone_only = false
|
75
|
+
|
76
|
+
expect(io).to receive(:puts).with("Forking lesson...")
|
77
|
+
expect(io).to receive(:puts).with("Cloning lesson...")
|
78
|
+
expect(io).to receive(:puts).with("Done.")
|
79
|
+
expect(git_adapter)
|
80
|
+
.to receive(:clone)
|
81
|
+
.with("git@github.com:/org/lesson.git", "valid_lab", {:path=> location})
|
82
|
+
expect(system_adapter)
|
83
|
+
.to receive(:spawn)
|
84
|
+
.with("restore-lab", {:block=>true})
|
85
|
+
expect(system_adapter)
|
86
|
+
.to receive(:watch_dir)
|
87
|
+
.with("/home/bobby", "backup-lab")
|
88
|
+
expect(system_adapter)
|
89
|
+
.to receive(:open_login_shell)
|
90
|
+
.with("/usr/local/fish")
|
91
|
+
|
92
|
+
environment.open_jupyter_lab(lesson, location, editor, clone_only)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -7,13 +7,14 @@ describe LearnOpen::Opener do
|
|
7
7
|
let(:learn_web_client) { FakeLearnClient.new(token: "some-amazing-password") }
|
8
8
|
let(:git_adapter) { FakeGit.new }
|
9
9
|
let(:system_adapter) { class_double(LearnOpen::Adapters::SystemAdapter) }
|
10
|
+
let(:git_ssh_connector) { class_double(LearnOpen::GitSSHConnector) }
|
10
11
|
|
11
12
|
before do
|
12
13
|
create_home_dir
|
13
14
|
create_netrc_file
|
14
15
|
create_learn_config_file
|
15
16
|
|
16
|
-
allow(
|
17
|
+
allow(git_ssh_connector)
|
17
18
|
.to receive(:call)
|
18
19
|
.with(git_server: instance_of(String), environment: anything)
|
19
20
|
.and_return(true)
|
@@ -21,21 +22,27 @@ describe LearnOpen::Opener do
|
|
21
22
|
|
22
23
|
context "Initializer" do
|
23
24
|
it "sets the lesson" do
|
24
|
-
opener = LearnOpen::Opener.new("ttt-2-board-rb-v-000","", false)
|
25
|
+
opener = LearnOpen::Opener.new("ttt-2-board-rb-v-000","", false, false)
|
25
26
|
expect(opener.target_lesson).to eq("ttt-2-board-rb-v-000")
|
26
27
|
end
|
27
28
|
it "sets the editor" do
|
28
|
-
opener = LearnOpen::Opener.new("", "atom", false)
|
29
|
+
opener = LearnOpen::Opener.new("", "atom", false, false)
|
29
30
|
expect(opener.editor).to eq("atom")
|
30
31
|
end
|
31
32
|
it "sets the whether to open the next lesson or not" do
|
32
|
-
opener = LearnOpen::Opener.new("", "", true)
|
33
|
+
opener = LearnOpen::Opener.new("", "", true, false)
|
33
34
|
expect(opener.get_next_lesson).to eq(true)
|
34
35
|
end
|
36
|
+
|
37
|
+
it "sets the clone only options" do
|
38
|
+
opener = LearnOpen::Opener.new("", "", true, true)
|
39
|
+
expect(opener.clone_only).to eq(true)
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
37
43
|
context "running the opener" do
|
38
44
|
it "calls its collaborators" do
|
45
|
+
clone_only = false
|
39
46
|
expect(system_adapter)
|
40
47
|
.to receive(:open_editor)
|
41
48
|
.with("atom", path: ".")
|
@@ -52,19 +59,42 @@ describe LearnOpen::Opener do
|
|
52
59
|
.to receive(:fork_repo)
|
53
60
|
.with(repo_name: "rails-dynamic-request-lab-cb-000")
|
54
61
|
|
55
|
-
expect(
|
62
|
+
expect(git_ssh_connector)
|
56
63
|
.to receive(:call)
|
57
|
-
.with(git_server: instance_of(String), environment: instance_of(LearnOpen::Environments::MacEnvironment))
|
58
64
|
|
59
|
-
opener = LearnOpen::Opener.new(nil, "atom", true,
|
65
|
+
opener = LearnOpen::Opener.new(nil, "atom", true, clone_only,
|
60
66
|
learn_web_client: learn_web_client,
|
61
67
|
git_adapter: git_adapter,
|
62
68
|
environment_vars: {"SHELL" => "/usr/local/bin/fish"},
|
63
69
|
system_adapter: system_adapter,
|
70
|
+
git_ssh_connector: git_ssh_connector,
|
64
71
|
io: spy)
|
65
72
|
opener.run
|
66
73
|
end
|
67
74
|
end
|
75
|
+
|
76
|
+
context "clone_only" do
|
77
|
+
it "It only calls clone/fork code, but doesn't open shell" do
|
78
|
+
clone_only = true
|
79
|
+
|
80
|
+
expect(learn_web_client)
|
81
|
+
.to receive(:fork_repo)
|
82
|
+
.with(repo_name: "rails-dynamic-request-lab-cb-000")
|
83
|
+
|
84
|
+
expect(git_ssh_connector)
|
85
|
+
.to receive(:call)
|
86
|
+
|
87
|
+
opener = LearnOpen::Opener.new(nil, "atom", true, clone_only,
|
88
|
+
learn_web_client: learn_web_client,
|
89
|
+
git_adapter: git_adapter,
|
90
|
+
environment_vars: {"SHELL" => "/usr/local/bin/fish"},
|
91
|
+
system_adapter: system_adapter,
|
92
|
+
git_ssh_connector: git_ssh_connector,
|
93
|
+
io: spy)
|
94
|
+
opener.run
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
68
98
|
context "Opening on specific environments" do
|
69
99
|
before do
|
70
100
|
allow(system_adapter).to receive_messages(
|
@@ -95,11 +125,12 @@ describe LearnOpen::Opener do
|
|
95
125
|
.to receive(:run_command)
|
96
126
|
.with("bundle install")
|
97
127
|
|
98
|
-
opener = LearnOpen::Opener.new("ruby_lab", "atom", false,
|
128
|
+
opener = LearnOpen::Opener.new("ruby_lab", "atom", false, false,
|
99
129
|
learn_web_client: learn_web_client,
|
100
130
|
git_adapter: git_adapter,
|
101
131
|
environment_vars: environment,
|
102
132
|
system_adapter: system_adapter,
|
133
|
+
git_ssh_connector: git_ssh_connector,
|
103
134
|
io: spy)
|
104
135
|
opener.run
|
105
136
|
end
|
@@ -114,11 +145,12 @@ describe LearnOpen::Opener do
|
|
114
145
|
allow(system_adapter).to receive_messages([:spawn, :watch_dir])
|
115
146
|
|
116
147
|
home_dir = create_linux_home_dir("bobby")
|
117
|
-
opener = LearnOpen::Opener.new(nil, "atom", true,
|
148
|
+
opener = LearnOpen::Opener.new(nil, "atom", true, false,
|
118
149
|
learn_web_client: learn_web_client,
|
119
150
|
git_adapter: git_adapter,
|
120
151
|
environment_vars: environment,
|
121
152
|
system_adapter: system_adapter,
|
153
|
+
git_ssh_connector: git_ssh_connector,
|
122
154
|
io: spy)
|
123
155
|
opener.run
|
124
156
|
expect(File.exist?("#{home_dir}/.custom_commands.log")).to eq(false)
|
@@ -142,11 +174,12 @@ describe LearnOpen::Opener do
|
|
142
174
|
.with("Opening new window")
|
143
175
|
|
144
176
|
create_linux_home_dir("bobby")
|
145
|
-
opener = LearnOpen::Opener.new("later_lesson", "atom", true,
|
177
|
+
opener = LearnOpen::Opener.new("later_lesson", "atom", true, false,
|
146
178
|
learn_web_client: learn_web_client,
|
147
179
|
git_adapter: git_adapter,
|
148
180
|
environment_vars: environment,
|
149
181
|
system_adapter: system_adapter,
|
182
|
+
git_ssh_connector: git_ssh_connector,
|
150
183
|
io: io)
|
151
184
|
opener.run
|
152
185
|
end
|
@@ -180,11 +213,12 @@ describe LearnOpen::Opener do
|
|
180
213
|
.with("Opening readme...")
|
181
214
|
|
182
215
|
create_linux_home_dir("bobby")
|
183
|
-
opener = LearnOpen::Opener.new("later_lesson", "atom", true,
|
216
|
+
opener = LearnOpen::Opener.new("later_lesson", "atom", true, false,
|
184
217
|
learn_web_client: learn_web_client,
|
185
218
|
git_adapter: git_adapter,
|
186
219
|
environment_vars: environment,
|
187
220
|
system_adapter: system_adapter,
|
221
|
+
git_ssh_connector: git_ssh_connector,
|
188
222
|
io: io)
|
189
223
|
opener.run
|
190
224
|
end
|
@@ -199,11 +233,12 @@ describe LearnOpen::Opener do
|
|
199
233
|
allow(system_adapter).to receive_messages([:spawn, :watch_dir])
|
200
234
|
|
201
235
|
home_dir = create_linux_home_dir("bobby")
|
202
|
-
opener = LearnOpen::Opener.new(nil, "atom", true,
|
236
|
+
opener = LearnOpen::Opener.new(nil, "atom", true, false,
|
203
237
|
learn_web_client: learn_web_client,
|
204
238
|
git_adapter: git_adapter,
|
205
239
|
environment_vars: environment,
|
206
240
|
system_adapter: system_adapter,
|
241
|
+
git_ssh_connector: git_ssh_connector,
|
207
242
|
io: spy)
|
208
243
|
opener.run
|
209
244
|
custom_commands_log = File.read("#{home_dir}/.custom_commands.log")
|
@@ -219,11 +254,12 @@ describe LearnOpen::Opener do
|
|
219
254
|
allow(system_adapter).to receive_messages([:spawn, :watch_dir])
|
220
255
|
|
221
256
|
home_dir = create_linux_home_dir("bobby")
|
222
|
-
opener = LearnOpen::Opener.new(nil, "atom", true,
|
257
|
+
opener = LearnOpen::Opener.new(nil, "atom", true, false,
|
223
258
|
learn_web_client: learn_web_client,
|
224
259
|
git_adapter: git_adapter,
|
225
260
|
environment_vars: environment,
|
226
261
|
system_adapter: system_adapter,
|
262
|
+
git_ssh_connector: git_ssh_connector,
|
227
263
|
io: spy)
|
228
264
|
opener.run
|
229
265
|
expect(File.exist?("#{home_dir}/.custom_commands.log")).to eq(false)
|
@@ -253,11 +289,12 @@ describe LearnOpen::Opener do
|
|
253
289
|
.to receive(:run_command)
|
254
290
|
.with("yarn install --no-lockfile")
|
255
291
|
|
256
|
-
opener = LearnOpen::Opener.new("node_lab", "atom", false,
|
292
|
+
opener = LearnOpen::Opener.new("node_lab", "atom", false, false,
|
257
293
|
learn_web_client: learn_web_client,
|
258
294
|
git_adapter: git_adapter,
|
259
295
|
environment_vars: environment,
|
260
296
|
system_adapter: system_adapter,
|
297
|
+
git_ssh_connector: git_ssh_connector,
|
261
298
|
io: spy)
|
262
299
|
opener.run
|
263
300
|
end
|
@@ -280,7 +317,7 @@ describe LearnOpen::Opener do
|
|
280
317
|
|
281
318
|
io = StringIO.new
|
282
319
|
|
283
|
-
opener = LearnOpen::Opener.new("ruby_lab", "atom", false,
|
320
|
+
opener = LearnOpen::Opener.new("ruby_lab", "atom", false, false,
|
284
321
|
learn_web_client: learn_web_client,
|
285
322
|
git_adapter: git_adapter,
|
286
323
|
environment_vars: environment,
|
@@ -310,11 +347,12 @@ Failed to obtain an SSH connection!
|
|
310
347
|
|
311
348
|
io = StringIO.new
|
312
349
|
|
313
|
-
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false,
|
350
|
+
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false, false,
|
314
351
|
learn_web_client: learn_web_client,
|
315
352
|
git_adapter: git_adapter,
|
316
353
|
environment_vars: environment,
|
317
354
|
system_adapter: system_adapter,
|
355
|
+
git_ssh_connector: git_ssh_connector,
|
318
356
|
io: io)
|
319
357
|
opener.run
|
320
358
|
io.rewind
|
@@ -322,7 +360,6 @@ Failed to obtain an SSH connection!
|
|
322
360
|
Looking for lesson...
|
323
361
|
Forking lesson...
|
324
362
|
Cloning lesson...
|
325
|
-
Opening lesson...
|
326
363
|
Installing pip dependencies...
|
327
364
|
Done.
|
328
365
|
EOF
|
@@ -343,11 +380,12 @@ Done.
|
|
343
380
|
)
|
344
381
|
|
345
382
|
|
346
|
-
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false,
|
383
|
+
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false, false,
|
347
384
|
learn_web_client: learn_web_client,
|
348
385
|
git_adapter: git_adapter,
|
349
386
|
environment_vars: environment,
|
350
387
|
system_adapter: system_adapter,
|
388
|
+
git_ssh_connector: git_ssh_connector,
|
351
389
|
io: spy)
|
352
390
|
opener.run
|
353
391
|
expect(File.read("#{home_dir}/.learn-open-tmp")).to eq("Done.")
|
@@ -366,9 +404,6 @@ Done.
|
|
366
404
|
.with("git@github.com:StevenNunez/jupyter_lab.git", "jupyter_lab", {:path=>"/home/bobby/Development/code"})
|
367
405
|
.and_call_original
|
368
406
|
|
369
|
-
expect(system_adapter)
|
370
|
-
.to receive(:open_editor)
|
371
|
-
.with("atom", path: ".")
|
372
407
|
expect(system_adapter)
|
373
408
|
.to receive(:spawn)
|
374
409
|
.with("restore-lab", block: true)
|
@@ -378,18 +413,16 @@ Done.
|
|
378
413
|
expect(system_adapter)
|
379
414
|
.to receive(:open_login_shell)
|
380
415
|
.with("/usr/local/bin/fish")
|
381
|
-
expect(system_adapter)
|
382
|
-
.to receive(:change_context_directory)
|
383
|
-
.with("/home/bobby/Development/code/jupyter_lab")
|
384
416
|
expect(system_adapter)
|
385
417
|
.to receive(:run_command)
|
386
418
|
.with("/opt/conda/bin/python -m pip install -r requirements.txt")
|
387
419
|
|
388
|
-
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false,
|
420
|
+
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false, false,
|
389
421
|
learn_web_client: learn_web_client,
|
390
422
|
git_adapter: git_adapter,
|
391
423
|
environment_vars: environment,
|
392
424
|
system_adapter: system_adapter,
|
425
|
+
git_ssh_connector: git_ssh_connector,
|
393
426
|
io: spy)
|
394
427
|
opener.run
|
395
428
|
end
|
@@ -398,11 +431,12 @@ Done.
|
|
398
431
|
environment = {"CREATED_USER" => "bobby", "IDE_CONTAINER" => "true", "LAB_NAME" => "jupyter_lab"}
|
399
432
|
io = StringIO.new
|
400
433
|
home_dir = create_linux_home_dir("bobby")
|
401
|
-
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false,
|
434
|
+
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false, false,
|
402
435
|
learn_web_client: learn_web_client,
|
403
436
|
git_adapter: git_adapter,
|
404
437
|
environment_vars: environment,
|
405
438
|
system_adapter: system_adapter,
|
439
|
+
git_ssh_connector: git_ssh_connector,
|
406
440
|
io: io)
|
407
441
|
opener.run
|
408
442
|
io.rewind
|
@@ -419,11 +453,12 @@ EOF
|
|
419
453
|
.to receive(:run_command)
|
420
454
|
.with("open -a Safari https://learn.co/lessons/31322")
|
421
455
|
io = StringIO.new
|
422
|
-
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false,
|
456
|
+
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false, false,
|
423
457
|
learn_web_client: learn_web_client,
|
424
458
|
git_adapter: git_adapter,
|
425
459
|
system_adapter: system_adapter,
|
426
460
|
io: io,
|
461
|
+
git_ssh_connector: git_ssh_connector,
|
427
462
|
platform: "darwin")
|
428
463
|
opener.run
|
429
464
|
io.rewind
|
@@ -440,11 +475,12 @@ EOF
|
|
440
475
|
.with("open -a 'Google Chrome' https://learn.co/lessons/31322")
|
441
476
|
|
442
477
|
io = StringIO.new
|
443
|
-
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false,
|
478
|
+
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false, false,
|
444
479
|
learn_web_client: learn_web_client,
|
445
480
|
git_adapter: git_adapter,
|
446
481
|
system_adapter: system_adapter,
|
447
482
|
io: io,
|
483
|
+
git_ssh_connector: git_ssh_connector,
|
448
484
|
platform: "darwin")
|
449
485
|
opener.run
|
450
486
|
io.rewind
|
@@ -459,11 +495,12 @@ EOF
|
|
459
495
|
.to receive(:run_command)
|
460
496
|
.with("xdg-open https://learn.co/lessons/31322")
|
461
497
|
io = StringIO.new
|
462
|
-
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false,
|
498
|
+
opener = LearnOpen::Opener.new("jupyter_lab", "atom", false, false,
|
463
499
|
learn_web_client: learn_web_client,
|
464
500
|
git_adapter: git_adapter,
|
465
501
|
system_adapter: system_adapter,
|
466
502
|
io: io,
|
503
|
+
git_ssh_connector: git_ssh_connector,
|
467
504
|
platform: "linux")
|
468
505
|
opener.run
|
469
506
|
io.rewind
|
@@ -476,7 +513,7 @@ EOF
|
|
476
513
|
context "Readme" do
|
477
514
|
it "does not open readme if on unsupported environment" do
|
478
515
|
io = StringIO.new
|
479
|
-
opener = LearnOpen::Opener.new("readme", "atom", false,
|
516
|
+
opener = LearnOpen::Opener.new("readme", "atom", false, false,
|
480
517
|
learn_web_client: learn_web_client,
|
481
518
|
git_adapter: git_adapter,
|
482
519
|
environment_vars: {},
|
@@ -496,11 +533,12 @@ EOF
|
|
496
533
|
environment = {"CREATED_USER" => "bobby", "IDE_CONTAINER" => "true", "LAB_NAME" => "readme"}
|
497
534
|
io = StringIO.new
|
498
535
|
home_dir = create_linux_home_dir("bobby")
|
499
|
-
opener = LearnOpen::Opener.new("readme", "atom", false,
|
536
|
+
opener = LearnOpen::Opener.new("readme", "atom", false, false,
|
500
537
|
learn_web_client: learn_web_client,
|
501
538
|
git_adapter: git_adapter,
|
502
539
|
environment_vars: environment,
|
503
540
|
system_adapter: system_adapter,
|
541
|
+
git_ssh_connector: git_ssh_connector,
|
504
542
|
io: io)
|
505
543
|
opener.run
|
506
544
|
|
@@ -519,12 +557,13 @@ EOF
|
|
519
557
|
.to receive(:run_command)
|
520
558
|
.with("open -a Safari https://learn.co/lessons/31322")
|
521
559
|
|
522
|
-
opener = LearnOpen::Opener.new("readme", "atom", false,
|
560
|
+
opener = LearnOpen::Opener.new("readme", "atom", false, false,
|
523
561
|
learn_web_client: learn_web_client,
|
524
562
|
git_adapter: git_adapter,
|
525
563
|
environment_vars: {},
|
526
564
|
system_adapter: system_adapter,
|
527
565
|
io: io,
|
566
|
+
git_ssh_connector: git_ssh_connector,
|
528
567
|
platform: "darwin")
|
529
568
|
opener.run
|
530
569
|
|
@@ -544,12 +583,13 @@ EOF
|
|
544
583
|
.with("open -a 'Google Chrome' https://learn.co/lessons/31322")
|
545
584
|
|
546
585
|
|
547
|
-
opener = LearnOpen::Opener.new("readme", "atom", false,
|
586
|
+
opener = LearnOpen::Opener.new("readme", "atom", false, false,
|
548
587
|
learn_web_client: learn_web_client,
|
549
588
|
git_adapter: git_adapter,
|
550
589
|
environment_vars: {},
|
551
590
|
system_adapter: system_adapter,
|
552
591
|
io: io,
|
592
|
+
git_ssh_connector: git_ssh_connector,
|
553
593
|
platform: "darwin")
|
554
594
|
opener.run
|
555
595
|
|
@@ -569,11 +609,12 @@ EOF
|
|
569
609
|
.with("xdg-open https://learn.co/lessons/31322")
|
570
610
|
|
571
611
|
|
572
|
-
opener = LearnOpen::Opener.new("readme", "atom", false,
|
612
|
+
opener = LearnOpen::Opener.new("readme", "atom", false, false,
|
573
613
|
learn_web_client: learn_web_client,
|
574
614
|
git_adapter: git_adapter,
|
575
615
|
environment_vars: {},
|
576
616
|
system_adapter: system_adapter,
|
617
|
+
git_ssh_connector: git_ssh_connector,
|
577
618
|
io: io,
|
578
619
|
platform: "linux")
|
579
620
|
opener.run
|
@@ -590,11 +631,12 @@ EOF
|
|
590
631
|
it "fails to open on Linux" do
|
591
632
|
io = StringIO.new
|
592
633
|
|
593
|
-
opener = LearnOpen::Opener.new("ios_lab", "atom", false,
|
634
|
+
opener = LearnOpen::Opener.new("ios_lab", "atom", false, false,
|
594
635
|
learn_web_client: learn_web_client,
|
595
636
|
git_adapter: git_adapter,
|
596
637
|
environment_vars: {"SHELL" => "/usr/local/bin/fish"},
|
597
638
|
system_adapter: system_adapter,
|
639
|
+
git_ssh_connector: git_ssh_connector,
|
598
640
|
io: io,
|
599
641
|
platform: "linux")
|
600
642
|
opener.run
|
@@ -617,11 +659,12 @@ EOF
|
|
617
659
|
create_linux_home_dir("bobby")
|
618
660
|
io = StringIO.new
|
619
661
|
|
620
|
-
opener = LearnOpen::Opener.new("ios_lab", "atom", false,
|
662
|
+
opener = LearnOpen::Opener.new("ios_lab", "atom", false, false,
|
621
663
|
learn_web_client: learn_web_client,
|
622
664
|
git_adapter: git_adapter,
|
623
665
|
environment_vars: environment,
|
624
666
|
system_adapter: system_adapter,
|
667
|
+
git_ssh_connector: git_ssh_connector,
|
625
668
|
io: io,
|
626
669
|
platform: "linux")
|
627
670
|
opener.run
|
@@ -646,12 +689,13 @@ EOF
|
|
646
689
|
.with("cd /home/bobby/Development/code/ios_lab && open *.xcodeproj")
|
647
690
|
|
648
691
|
|
649
|
-
opener = LearnOpen::Opener.new("ios_lab", "atom", false,
|
692
|
+
opener = LearnOpen::Opener.new("ios_lab", "atom", false, false,
|
650
693
|
learn_web_client: learn_web_client,
|
651
694
|
git_adapter: git_adapter,
|
652
695
|
environment_vars: {"SHELL" => "/usr/local/bin/fish"},
|
653
696
|
system_adapter: system_adapter,
|
654
697
|
io: io,
|
698
|
+
git_ssh_connector: git_ssh_connector,
|
655
699
|
platform: "darwin")
|
656
700
|
opener.run
|
657
701
|
|
@@ -669,12 +713,13 @@ EOF
|
|
669
713
|
.with("cd /home/bobby/Development/code/ios_with_workspace_lab && open *.xcworkspace")
|
670
714
|
|
671
715
|
|
672
|
-
opener = LearnOpen::Opener.new("ios_with_workspace_lab", "atom", false,
|
716
|
+
opener = LearnOpen::Opener.new("ios_with_workspace_lab", "atom", false, false,
|
673
717
|
learn_web_client: learn_web_client,
|
674
718
|
git_adapter: git_adapter,
|
675
719
|
environment_vars: {"SHELL" => "/usr/local/bin/fish"},
|
676
720
|
system_adapter: system_adapter,
|
677
721
|
io: io,
|
722
|
+
git_ssh_connector: git_ssh_connector,
|
678
723
|
platform: "darwin")
|
679
724
|
opener.run
|
680
725
|
|
@@ -693,11 +738,12 @@ EOF
|
|
693
738
|
expect(system_adapter)
|
694
739
|
.to receive(:run_command)
|
695
740
|
.with("bundle install")
|
696
|
-
opener = LearnOpen::Opener.new("ruby_lab", "atom", false,
|
741
|
+
opener = LearnOpen::Opener.new("ruby_lab", "atom", false, false,
|
697
742
|
learn_web_client: learn_web_client,
|
698
743
|
git_adapter: git_adapter,
|
699
744
|
environment_vars: {"SHELL" => "/usr/local/bin/fish"},
|
700
745
|
system_adapter: system_adapter,
|
746
|
+
git_ssh_connector: git_ssh_connector,
|
701
747
|
io: spy)
|
702
748
|
opener.run
|
703
749
|
end
|
@@ -712,11 +758,12 @@ EOF
|
|
712
758
|
)
|
713
759
|
|
714
760
|
io = StringIO.new
|
715
|
-
opener = LearnOpen::Opener.new("ruby_lab", "atom", false,
|
761
|
+
opener = LearnOpen::Opener.new("ruby_lab", "atom", false, false,
|
716
762
|
learn_web_client: learn_web_client,
|
717
763
|
git_adapter: git_adapter,
|
718
764
|
environment_vars: {"SHELL" => "/usr/local/bin/fish"},
|
719
765
|
system_adapter: system_adapter,
|
766
|
+
git_ssh_connector: git_ssh_connector,
|
720
767
|
io: io)
|
721
768
|
opener.run
|
722
769
|
io.rewind
|
@@ -746,11 +793,12 @@ EOF
|
|
746
793
|
expect(system_adapter)
|
747
794
|
.to receive(:run_command)
|
748
795
|
.with("python -m pip install -r requirements.txt")
|
749
|
-
opener = LearnOpen::Opener.new("python_lab", "atom", false,
|
796
|
+
opener = LearnOpen::Opener.new("python_lab", "atom", false, false,
|
750
797
|
learn_web_client: learn_web_client,
|
751
798
|
git_adapter: git_adapter,
|
752
799
|
environment_vars: {"SHELL" => "/usr/local/bin/fish"},
|
753
800
|
system_adapter: system_adapter,
|
801
|
+
git_ssh_connector: git_ssh_connector,
|
754
802
|
io: spy)
|
755
803
|
opener.run
|
756
804
|
end
|
@@ -764,11 +812,12 @@ EOF
|
|
764
812
|
)
|
765
813
|
|
766
814
|
io = StringIO.new
|
767
|
-
opener = LearnOpen::Opener.new("python_lab", "atom", false,
|
815
|
+
opener = LearnOpen::Opener.new("python_lab", "atom", false, false,
|
768
816
|
learn_web_client: learn_web_client,
|
769
817
|
git_adapter: git_adapter,
|
770
818
|
environment_vars: {"SHELL" => "/usr/local/bin/fish"},
|
771
819
|
system_adapter: system_adapter,
|
820
|
+
git_ssh_connector: git_ssh_connector,
|
772
821
|
io: io)
|
773
822
|
opener.run
|
774
823
|
io.rewind
|
@@ -798,11 +847,12 @@ EOF
|
|
798
847
|
expect(system_adapter)
|
799
848
|
.to receive(:run_command)
|
800
849
|
.with("npm install")
|
801
|
-
opener = LearnOpen::Opener.new("node_lab", "atom", false,
|
850
|
+
opener = LearnOpen::Opener.new("node_lab", "atom", false, false,
|
802
851
|
learn_web_client: learn_web_client,
|
803
852
|
git_adapter: git_adapter,
|
804
853
|
environment_vars: {"SHELL" => "/usr/local/bin/fish"},
|
805
854
|
system_adapter: system_adapter,
|
855
|
+
git_ssh_connector: git_ssh_connector,
|
806
856
|
io: spy)
|
807
857
|
opener.run
|
808
858
|
end
|
@@ -816,11 +866,12 @@ EOF
|
|
816
866
|
)
|
817
867
|
|
818
868
|
io = StringIO.new
|
819
|
-
opener = LearnOpen::Opener.new("node_lab", "atom", false,
|
869
|
+
opener = LearnOpen::Opener.new("node_lab", "atom", false, false,
|
820
870
|
learn_web_client: learn_web_client,
|
821
871
|
git_adapter: git_adapter,
|
822
872
|
environment_vars: {"SHELL" => "/usr/local/bin/fish"},
|
823
873
|
system_adapter: system_adapter,
|
874
|
+
git_ssh_connector: git_ssh_connector,
|
824
875
|
io: io)
|
825
876
|
opener.run
|
826
877
|
io.rewind
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LearnOpen::LessonDownloader do
|
4
|
-
let(:lesson) { double }
|
4
|
+
let(:lesson) { double(use_student_fork: true) }
|
5
5
|
let(:location) { double }
|
6
6
|
let(:environment) { double }
|
7
7
|
let(:downloader) { LearnOpen::LessonDownloader.new(lesson, location, environment) }
|
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.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flatiron School
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -215,7 +215,9 @@ files:
|
|
215
215
|
- spec/fakes/fake_learn_client.rb
|
216
216
|
- spec/fixtures/learn-config
|
217
217
|
- spec/learn_open/adapters/ssh_adapter_spec.rb
|
218
|
+
- spec/learn_open/argument_parser_spec.rb
|
218
219
|
- spec/learn_open/environments/ide_environment_spec.rb
|
220
|
+
- spec/learn_open/environments/jupyter_container_environment_spec.rb
|
219
221
|
- spec/learn_open/opener_spec.rb
|
220
222
|
- spec/learn_open/services/git_ssh_connector_spec.rb
|
221
223
|
- spec/learn_open/services/lesson_downloader_spec.rb
|
@@ -241,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
243
|
version: '0'
|
242
244
|
requirements: []
|
243
245
|
rubyforge_project:
|
244
|
-
rubygems_version: 2.7.
|
246
|
+
rubygems_version: 2.7.7
|
245
247
|
signing_key:
|
246
248
|
specification_version: 4
|
247
249
|
summary: Open Learn lessons locally
|
@@ -250,7 +252,9 @@ test_files:
|
|
250
252
|
- spec/fakes/fake_learn_client.rb
|
251
253
|
- spec/fixtures/learn-config
|
252
254
|
- spec/learn_open/adapters/ssh_adapter_spec.rb
|
255
|
+
- spec/learn_open/argument_parser_spec.rb
|
253
256
|
- spec/learn_open/environments/ide_environment_spec.rb
|
257
|
+
- spec/learn_open/environments/jupyter_container_environment_spec.rb
|
254
258
|
- spec/learn_open/opener_spec.rb
|
255
259
|
- spec/learn_open/services/git_ssh_connector_spec.rb
|
256
260
|
- spec/learn_open/services/lesson_downloader_spec.rb
|