learn-open 1.2.26 → 1.2.27
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/adapters/system_adapter.rb +0 -4
- data/lib/learn_open/environments/base_environment.rb +0 -10
- data/lib/learn_open/environments/ide_environment.rb +0 -3
- data/lib/learn_open/environments/linux_environment.rb +0 -2
- data/lib/learn_open/environments/mac_environment.rb +0 -5
- data/lib/learn_open/services/file_backup_starter.rb +4 -1
- data/lib/learn_open/version.rb +1 -1
- data/spec/learn_open/environments/ide_environment_spec.rb +2 -2
- data/spec/learn_open/environments/jupyter_container_environment_spec.rb +2 -2
- data/spec/learn_open/opener_spec.rb +11 -77
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eed604cd38477a398c08a0f865919e776f63db144f9e447af7af398c6b12f0f5
|
4
|
+
data.tar.gz: 80de4e7cc2e539d87e866eb7ab1c87fee136787d68387edd67fb092fdcaa377e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 364185f316c52cbf5f92e83806ec846a5a59ef701774c03613a4efd421fe80b3aef4d382dd22d9f36c4e57dbbdcdb9dddc0c21a2d422c45c930c1fcf9ea5b0b5
|
7
|
+
data.tar.gz: 14e9684582c1afe07b72e509280979e4e9c20dbe8d6d12bb368646ab391163ea137a67362345f6c0d67d8fb68bf81bb93f763d20fd4867b6f0dc353fb276262e
|
@@ -11,10 +11,6 @@ module LearnOpen
|
|
11
11
|
exec("#{shell} -l")
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.watch_dir(dir, action)
|
15
|
-
spawn("while inotifywait -qre create,delete,move,close_write --exclude \"#{excluded_dirs}\" #{dir}; do #{action}; done")
|
16
|
-
end
|
17
|
-
|
18
14
|
def self.spawn(command, block: false)
|
19
15
|
pid = Process.spawn(command, [:out, :err] => File::NULL)
|
20
16
|
Process.waitpid(pid) if block
|
@@ -65,16 +65,6 @@ module LearnOpen
|
|
65
65
|
logger.log("Done.")
|
66
66
|
io.puts "Done."
|
67
67
|
end
|
68
|
-
|
69
|
-
def warn_if_necessary(lesson)
|
70
|
-
return unless lesson.later_lesson
|
71
|
-
|
72
|
-
io.puts 'WARNING: You are attempting to open a lesson that is beyond your current lesson.'
|
73
|
-
io.print 'Are you sure you want to continue? [Y/n]: '
|
74
|
-
|
75
|
-
warn_response = io.gets.chomp.downcase
|
76
|
-
exit if !['yes', 'y'].include?(warn_response)
|
77
|
-
end
|
78
68
|
end
|
79
69
|
end
|
80
70
|
end
|
@@ -7,7 +7,6 @@ module LearnOpen
|
|
7
7
|
|
8
8
|
def open_readme(lesson)
|
9
9
|
when_valid(lesson) do
|
10
|
-
warn_if_necessary(lesson)
|
11
10
|
io.puts "Opening readme..."
|
12
11
|
run_custom_command(:browser_open, {url: lesson.to_url})
|
13
12
|
end
|
@@ -15,7 +14,6 @@ module LearnOpen
|
|
15
14
|
|
16
15
|
def open_jupyter_lab(lesson, location, editor, _clone_only)
|
17
16
|
when_valid(lesson) do
|
18
|
-
warn_if_necessary(lesson)
|
19
17
|
io.puts "Opening Jupyter Lesson..."
|
20
18
|
run_custom_command(:browser_open, {url: lesson.to_url})
|
21
19
|
end
|
@@ -23,7 +21,6 @@ module LearnOpen
|
|
23
21
|
|
24
22
|
def open_lab(lesson, location, editor, clone_only)
|
25
23
|
when_valid(lesson) do
|
26
|
-
warn_if_necessary(lesson)
|
27
24
|
case lesson
|
28
25
|
when LearnOpen::Lessons::IosLesson
|
29
26
|
super
|
@@ -2,13 +2,11 @@ module LearnOpen
|
|
2
2
|
module Environments
|
3
3
|
class LinuxEnvironment < BaseEnvironment
|
4
4
|
def open_readme(lesson)
|
5
|
-
warn_if_necessary(lesson)
|
6
5
|
io.puts "Opening readme..."
|
7
6
|
system_adapter.run_command("xdg-open #{lesson.to_url}")
|
8
7
|
end
|
9
8
|
|
10
9
|
def open_jupyter_lab(lesson, location, _editor, _clone_only)
|
11
|
-
warn_if_necessary(lesson)
|
12
10
|
io.puts "Opening Jupyter Lesson..."
|
13
11
|
system_adapter.run_command("xdg-open #{lesson.to_url}")
|
14
12
|
end
|
@@ -14,13 +14,11 @@ module LearnOpen
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def open_readme(lesson)
|
17
|
-
warn_if_necessary(lesson)
|
18
17
|
io.puts "Opening readme..."
|
19
18
|
system_adapter.run_command("open -a Safari #{lesson.to_url}")
|
20
19
|
end
|
21
20
|
|
22
21
|
def open_lab(lesson, location, editor, clone_only)
|
23
|
-
warn_if_necessary(lesson)
|
24
22
|
case lesson
|
25
23
|
when LearnOpen::Lessons::IosLesson
|
26
24
|
download_lesson(lesson, location)
|
@@ -33,7 +31,6 @@ module LearnOpen
|
|
33
31
|
end
|
34
32
|
|
35
33
|
def open_jupyter_lab(lesson, location, editor, _clone_only)
|
36
|
-
warn_if_necessary(lesson)
|
37
34
|
io.puts "Opening Jupyter Lesson..."
|
38
35
|
system_adapter.run_command("open -a Safari #{lesson.to_url}")
|
39
36
|
end
|
@@ -59,13 +56,11 @@ module LearnOpen
|
|
59
56
|
|
60
57
|
class MacWithChromeEnvironment < MacEnvironment
|
61
58
|
def open_readme(lesson)
|
62
|
-
warn_if_necessary(lesson)
|
63
59
|
io.puts "Opening readme..."
|
64
60
|
system_adapter.run_command("open -a 'Google Chrome' #{lesson.to_url}")
|
65
61
|
end
|
66
62
|
|
67
63
|
def open_jupyter_lab(lesson, location, _editor, _clone_only)
|
68
|
-
warn_if_necessary(lesson)
|
69
64
|
io.puts "Opening Jupyter Lesson..."
|
70
65
|
system_adapter.run_command("open -a 'Google Chrome' #{lesson.to_url}")
|
71
66
|
end
|
@@ -1,5 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module LearnOpen
|
2
3
|
class FileBackupStarter
|
4
|
+
BACKUP_LAB_PROCESS = "tail -f ~/inotify.log | while read change do; backup-lab; done"
|
5
|
+
|
3
6
|
attr_reader :lesson, :location, :system_adapter
|
4
7
|
|
5
8
|
def self.call(lesson, location, options)
|
@@ -14,7 +17,7 @@ module LearnOpen
|
|
14
17
|
|
15
18
|
def call
|
16
19
|
system_adapter.spawn("restore-lab", block: true)
|
17
|
-
system_adapter.
|
20
|
+
system_adapter.spawn(BACKUP_LAB_PROCESS)
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
data/lib/learn_open/version.rb
CHANGED
@@ -118,8 +118,8 @@ describe LearnOpen::Environments::IDEEnvironment do
|
|
118
118
|
.to receive(:spawn)
|
119
119
|
.with("restore-lab", {:block=>true})
|
120
120
|
expect(system_adapter)
|
121
|
-
.to receive(:
|
122
|
-
.with(
|
121
|
+
.to receive(:spawn)
|
122
|
+
.with(LearnOpen::FileBackupStarter::BACKUP_LAB_PROCESS)
|
123
123
|
expect(system_adapter)
|
124
124
|
.to receive(:open_login_shell)
|
125
125
|
.with("/usr/local/fish")
|
@@ -83,8 +83,8 @@ describe LearnOpen::Environments::JupyterContainerEnvironment do
|
|
83
83
|
.to receive(:spawn)
|
84
84
|
.with("restore-lab", {:block=>true})
|
85
85
|
expect(system_adapter)
|
86
|
-
.to receive(:
|
87
|
-
.with(
|
86
|
+
.to receive(:spawn)
|
87
|
+
.with(LearnOpen::FileBackupStarter::BACKUP_LAB_PROCESS)
|
88
88
|
expect(system_adapter)
|
89
89
|
.to receive(:open_login_shell)
|
90
90
|
.with("/usr/local/fish")
|
@@ -119,8 +119,8 @@ describe LearnOpen::Opener do
|
|
119
119
|
.to receive(:spawn)
|
120
120
|
.with('restore-lab', block: true)
|
121
121
|
expect(system_adapter)
|
122
|
-
.to receive(:
|
123
|
-
.with(
|
122
|
+
.to receive(:spawn)
|
123
|
+
.with(LearnOpen::FileBackupStarter::BACKUP_LAB_PROCESS)
|
124
124
|
expect(system_adapter)
|
125
125
|
.to receive(:run_command)
|
126
126
|
.with("bundle install")
|
@@ -142,7 +142,7 @@ describe LearnOpen::Opener do
|
|
142
142
|
"IDE_CONTAINER" => "true",
|
143
143
|
"IDE_VERSION" => "3"
|
144
144
|
}
|
145
|
-
allow(system_adapter).to receive_messages([:spawn, :
|
145
|
+
allow(system_adapter).to receive_messages([:spawn, :spawn])
|
146
146
|
|
147
147
|
home_dir = create_linux_home_dir("bobby")
|
148
148
|
opener = LearnOpen::Opener.new(nil, "atom", true, false,
|
@@ -156,72 +156,6 @@ describe LearnOpen::Opener do
|
|
156
156
|
expect(File.exist?("#{home_dir}/.custom_commands.log")).to eq(false)
|
157
157
|
end
|
158
158
|
|
159
|
-
it "does not prompt if they want to skip lesson if the container is for a different lab" do
|
160
|
-
environment = {
|
161
|
-
"SHELL" => "/usr/local/bin/fish",
|
162
|
-
"LAB_NAME" => "Something wild",
|
163
|
-
"CREATED_USER" => "bobby",
|
164
|
-
"IDE_CONTAINER" => "true",
|
165
|
-
"IDE_VERSION" => "3"
|
166
|
-
}
|
167
|
-
io = instance_double(LearnOpen::Adapters::IOAdapter)
|
168
|
-
expect(io)
|
169
|
-
.to receive(:puts)
|
170
|
-
.with("Looking for lesson...")
|
171
|
-
|
172
|
-
expect(io)
|
173
|
-
.to receive(:puts)
|
174
|
-
.with("Opening new window")
|
175
|
-
|
176
|
-
create_linux_home_dir("bobby")
|
177
|
-
opener = LearnOpen::Opener.new("later_lesson", "atom", true, false,
|
178
|
-
learn_web_client: learn_web_client,
|
179
|
-
git_adapter: git_adapter,
|
180
|
-
environment_vars: environment,
|
181
|
-
system_adapter: system_adapter,
|
182
|
-
git_ssh_connector: git_ssh_connector,
|
183
|
-
io: io)
|
184
|
-
opener.run
|
185
|
-
end
|
186
|
-
it "prompts if they want to skip lesson" do
|
187
|
-
environment = {
|
188
|
-
"SHELL" => "/usr/local/bin/fish",
|
189
|
-
"LAB_NAME" => "later_lesson",
|
190
|
-
"CREATED_USER" => "bobby",
|
191
|
-
"IDE_CONTAINER" => "true",
|
192
|
-
"IDE_VERSION" => "3"
|
193
|
-
}
|
194
|
-
io = instance_double(LearnOpen::Adapters::IOAdapter)
|
195
|
-
expect(io)
|
196
|
-
.to receive(:puts)
|
197
|
-
.with("Looking for lesson...")
|
198
|
-
|
199
|
-
expect(io)
|
200
|
-
.to receive(:puts)
|
201
|
-
.with("WARNING: You are attempting to open a lesson that is beyond your current lesson.")
|
202
|
-
|
203
|
-
expect(io)
|
204
|
-
.to receive(:print)
|
205
|
-
.with("Are you sure you want to continue? [Y/n]: ")
|
206
|
-
|
207
|
-
expect(io)
|
208
|
-
.to receive(:gets)
|
209
|
-
.and_return("yes")
|
210
|
-
|
211
|
-
expect(io)
|
212
|
-
.to receive(:puts)
|
213
|
-
.with("Opening readme...")
|
214
|
-
|
215
|
-
create_linux_home_dir("bobby")
|
216
|
-
opener = LearnOpen::Opener.new("later_lesson", "atom", true, false,
|
217
|
-
learn_web_client: learn_web_client,
|
218
|
-
git_adapter: git_adapter,
|
219
|
-
environment_vars: environment,
|
220
|
-
system_adapter: system_adapter,
|
221
|
-
git_ssh_connector: git_ssh_connector,
|
222
|
-
io: io)
|
223
|
-
opener.run
|
224
|
-
end
|
225
159
|
it "writes to custom_commands_log if lab name doesn't match env" do
|
226
160
|
environment = {
|
227
161
|
"SHELL" => "/usr/local/bin/fish",
|
@@ -230,7 +164,7 @@ describe LearnOpen::Opener do
|
|
230
164
|
"IDE_CONTAINER" => "true",
|
231
165
|
"IDE_VERSION" => "3"
|
232
166
|
}
|
233
|
-
allow(system_adapter).to receive_messages([:spawn, :
|
167
|
+
allow(system_adapter).to receive_messages([:spawn, :spawn])
|
234
168
|
|
235
169
|
home_dir = create_linux_home_dir("bobby")
|
236
170
|
opener = LearnOpen::Opener.new(nil, "atom", true, false,
|
@@ -251,7 +185,7 @@ describe LearnOpen::Opener do
|
|
251
185
|
"LAB_NAME" => "Something wild",
|
252
186
|
"CREATED_USER" => "bobby"
|
253
187
|
}
|
254
|
-
allow(system_adapter).to receive_messages([:spawn, :
|
188
|
+
allow(system_adapter).to receive_messages([:spawn, :spawn])
|
255
189
|
|
256
190
|
home_dir = create_linux_home_dir("bobby")
|
257
191
|
opener = LearnOpen::Opener.new(nil, "atom", true, false,
|
@@ -272,7 +206,7 @@ describe LearnOpen::Opener do
|
|
272
206
|
"CREATED_USER" => "bobby",
|
273
207
|
"IDE_CONTAINER" => "true",
|
274
208
|
}
|
275
|
-
allow(system_adapter).to receive_messages([:spawn, :
|
209
|
+
allow(system_adapter).to receive_messages([:spawn, :spawn])
|
276
210
|
expect(system_adapter)
|
277
211
|
.to receive(:open_editor)
|
278
212
|
.with("atom", path: ".")
|
@@ -309,7 +243,7 @@ describe LearnOpen::Opener do
|
|
309
243
|
allow(system_adapter).to receive_messages(
|
310
244
|
open_editor: :noop,
|
311
245
|
spawn: :noop,
|
312
|
-
|
246
|
+
spawn: :noop,
|
313
247
|
open_login_shell: :noop,
|
314
248
|
change_context_directory: :noop,
|
315
249
|
run_command: :noop,
|
@@ -339,7 +273,7 @@ Failed to obtain an SSH connection!
|
|
339
273
|
allow(system_adapter).to receive_messages(
|
340
274
|
open_editor: :noop,
|
341
275
|
spawn: :noop,
|
342
|
-
|
276
|
+
spawn: :noop,
|
343
277
|
open_login_shell: :noop,
|
344
278
|
change_context_directory: :noop,
|
345
279
|
run_command: :noop,
|
@@ -373,7 +307,7 @@ Done.
|
|
373
307
|
allow(system_adapter).to receive_messages(
|
374
308
|
open_editor: :noop,
|
375
309
|
spawn: :noop,
|
376
|
-
|
310
|
+
spawn: :noop,
|
377
311
|
open_login_shell: :noop,
|
378
312
|
change_context_directory: :noop,
|
379
313
|
run_command: :noop,
|
@@ -408,8 +342,8 @@ Done.
|
|
408
342
|
.to receive(:spawn)
|
409
343
|
.with("restore-lab", block: true)
|
410
344
|
expect(system_adapter)
|
411
|
-
.to receive(:
|
412
|
-
.with(
|
345
|
+
.to receive(:spawn)
|
346
|
+
.with(LearnOpen::FileBackupStarter::BACKUP_LAB_PROCESS)
|
413
347
|
expect(system_adapter)
|
414
348
|
.to receive(:open_login_shell)
|
415
349
|
.with("/usr/local/bin/fish")
|
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.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flatiron School
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|